Move creator into events structure
This commit is contained in:
94
src/routes/private/events/creator/+page.svelte
Normal file
94
src/routes/private/events/creator/+page.svelte
Normal file
@@ -0,0 +1,94 @@
|
||||
<script lang="ts">
|
||||
import StepConnectGoogle from "./steps/StepConnectGoogle.svelte";
|
||||
import StepCraftEmail from "./steps/StepCraftEmail.svelte";
|
||||
import StepCreateEvent from "./steps/StepCreateEvent.svelte";
|
||||
import StepOverview from "./steps/StepOverview.svelte";
|
||||
import StepUploadFiles from "./steps/StepUploadFiles.svelte";
|
||||
|
||||
let { data, form } = $props();
|
||||
|
||||
let event = $state({});
|
||||
let participants = $state([]);
|
||||
let email = $state({'body': '', 'subject': ''});
|
||||
let authorized = $state(false);
|
||||
|
||||
$effect(() => {
|
||||
if (form && form.new_event) {
|
||||
event = form.new_event;
|
||||
}
|
||||
if (form && form.participants) {
|
||||
participants = form.participants;
|
||||
}
|
||||
});
|
||||
|
||||
// Array of step components in order
|
||||
const steps = [
|
||||
StepConnectGoogle,
|
||||
StepCreateEvent,
|
||||
StepUploadFiles,
|
||||
StepCraftEmail,
|
||||
StepOverview
|
||||
];
|
||||
|
||||
let step: number = $state(0);
|
||||
|
||||
// let stepConditions = $derived([
|
||||
// authorized,
|
||||
// !!new_event?.name,
|
||||
// !!participants?.length,
|
||||
// !!subject && !!body
|
||||
// ]);
|
||||
|
||||
// for debugging purpouses
|
||||
let stepConditions = [
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true
|
||||
];
|
||||
|
||||
function nextStep() {
|
||||
if (step < steps.length - 1) step += 1;
|
||||
}
|
||||
function prevStep() {
|
||||
if (step > 0) step -= 1;
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="flex items-center justify-between mb-4 mt-2">
|
||||
<button
|
||||
onclick={prevStep}
|
||||
disabled={step === 0}
|
||||
class="min-w-[100px] py-2 px-4 bg-white border border-gray-300 text-gray-700 rounded hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed transition"
|
||||
>
|
||||
Previous
|
||||
</button>
|
||||
<span class="flex-1 text-center text-gray-600 font-medium">
|
||||
Step {step + 1} of {steps.length}
|
||||
</span>
|
||||
<button
|
||||
onclick={nextStep}
|
||||
disabled={step === steps.length - 1 || !stepConditions[step]}
|
||||
class="min-w-[100px] py-2 px-4 bg-white border border-gray-300 text-gray-700 rounded hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed transition"
|
||||
>
|
||||
Next
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{#if step == 0}
|
||||
<StepConnectGoogle bind:authorized />
|
||||
{:else if step == 1}
|
||||
<StepCreateEvent {event} />
|
||||
{:else if step == 2}
|
||||
<StepUploadFiles {participants} />
|
||||
{:else if step == 3}
|
||||
<StepCraftEmail bind:email />
|
||||
{:else if step == 4}
|
||||
<StepOverview
|
||||
{data}
|
||||
{event}
|
||||
{participants}
|
||||
{email}
|
||||
{stepConditions}
|
||||
/>
|
||||
{/if}
|
||||
Reference in New Issue
Block a user