diff --git a/src/routes/private/creator/+page.svelte b/src/routes/private/creator/+page.svelte
index 259fc29..4c1f3b1 100644
--- a/src/routes/private/creator/+page.svelte
+++ b/src/routes/private/creator/+page.svelte
@@ -11,9 +11,9 @@
let participants = $state([]);
let subject = $state('');
let body = $state('');
+ let authorized = $state(false);
- // Update events and participants from the form data
- $effect( () => {
+ $effect(() => {
if (form && form.new_event) {
new_event = form.new_event;
}
@@ -31,10 +31,15 @@
StepOverview
];
- // State variable for current step
- let step = $state(0);
+ let step: number = $state(0);
+
+ let stepConditions = $derived([
+ authorized,
+ !!new_event?.name,
+ !!participants?.length,
+ !!subject && !!body
+ ]);
- // Helper to go to next/previous step (optional)
function nextStep() {
if (step < steps.length - 1) step += 1;
}
@@ -56,16 +61,15 @@
-
{#if step == 0}
-
+
{:else if step == 1}
{:else if step == 2}
@@ -73,5 +77,11 @@
{:else if step == 3}
{:else if step == 4}
-
+
{/if}
diff --git a/src/routes/private/creator/steps/StepConnectGoogle.svelte b/src/routes/private/creator/steps/StepConnectGoogle.svelte
index fddc9f7..77d8f99 100644
--- a/src/routes/private/creator/steps/StepConnectGoogle.svelte
+++ b/src/routes/private/creator/steps/StepConnectGoogle.svelte
@@ -2,8 +2,9 @@
import { onMount } from 'svelte';
import { goto } from '$app/navigation';
+ export let authorized = false;
+
let refreshToken = '';
- let authorized = false;
let loading = true;
let to = '';
@@ -32,22 +33,6 @@
/* ⇢ redirects straight to Google via server 302 */
const connect = () => goto('/private/api/gmail?action=auth');
- async function sendEmail() {
- const r = await fetch('/private/api/gmail', {
- method: 'POST',
- headers: { 'Content-Type': 'application/json' },
- body: JSON.stringify({
- action: 'send',
- to,
- subject,
- text: body,
- refreshToken
- })
- });
- r.ok ? alert('Sent!') : alert(await r.text());
- to = subject = body = '';
- }
-
async function disconnect() {
if (!confirm('Disconnect Google account?')) return;
await fetch('/private/api/gmail', {
diff --git a/src/routes/private/creator/steps/StepOverview.svelte b/src/routes/private/creator/steps/StepOverview.svelte
index 34cb497..2f68806 100644
--- a/src/routes/private/creator/steps/StepOverview.svelte
+++ b/src/routes/private/creator/steps/StepOverview.svelte
@@ -1,5 +1,5 @@
@@ -41,22 +41,22 @@
class="mt-4 w-full rounded bg-blue-600 px-4 py-3 font-bold text-white
transition-colors duration-200 hover:bg-blue-700
disabled:cursor-not-allowed disabled:bg-gray-300 disabled:text-gray-500"
- disabled={!new_event?.name || !participants?.length || !subject || !body}
+ disabled={!stepConditions.every(Boolean)}
>
Generate QR codes and send
- {#if !new_event?.name}
+ {#if !stepConditions[0]}
Please provide an event name before proceeding.
{/if}
- {#if !participants?.length}
+ {#if !stepConditions[1]}
Please add at least one participant before proceeding.
{/if}
- {#if !subject}
+ {#if !stepConditions[2]}
Please provide an email subject before proceeding.
{/if}
- {#if !body}
+ {#if !stepConditions[3]}
Please provide an email body before proceeding.
{/if}