From d945209465b6d39f462571ff7f2d8db4ef5f75e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Kr=C4=8Dek?= Date: Sat, 12 Jul 2025 14:40:46 +0200 Subject: [PATCH] Split event view into components --- .../private/events/event/view/+page.svelte | 452 ++---------------- .../event/view/components/EmailResults.svelte | 100 ++++ .../event/view/components/EmailSending.svelte | 94 ++++ .../view/components/EmailTemplate.svelte | 47 ++ .../event/view/components/ErrorMessage.svelte | 11 + .../view/components/EventInformation.svelte | 88 ++++ .../components/GoogleAuthentication.svelte | 26 + .../view/components/ParticipantsTable.svelte | 162 +++++++ 8 files changed, 575 insertions(+), 405 deletions(-) create mode 100644 src/routes/private/events/event/view/components/EmailResults.svelte create mode 100644 src/routes/private/events/event/view/components/EmailSending.svelte create mode 100644 src/routes/private/events/event/view/components/EmailTemplate.svelte create mode 100644 src/routes/private/events/event/view/components/ErrorMessage.svelte create mode 100644 src/routes/private/events/event/view/components/EventInformation.svelte create mode 100644 src/routes/private/events/event/view/components/GoogleAuthentication.svelte create mode 100644 src/routes/private/events/event/view/components/ParticipantsTable.svelte diff --git a/src/routes/private/events/event/view/+page.svelte b/src/routes/private/events/event/view/+page.svelte index 7cf5c17..d9f4413 100644 --- a/src/routes/private/events/event/view/+page.svelte +++ b/src/routes/private/events/event/view/+page.svelte @@ -1,7 +1,15 @@ @@ -249,406 +259,38 @@

Event Overview

- -
- {#if loading} - -
-

Event Information

-
-
- Date: -
-
-
- Created: -
-
-
- Sheet ID: -
-
-
-
- {:else if event} -
-

{event.name}

-
-
- Date: - {formatDate(event.date)} -
-
- Created: - {formatDate(event.created_at)} -
- -
-
- {:else if error} -
-

{error}

-
- {/if} -
+ + - -
-
-

Email Template

-
- - {#if loading} - -
-
- Subject: -
-
- -
- Body: -
-
-
- {:else if event} + + -
-
- Subject: -
-

{event.email_subject}

-
-
-
- Body: -
-

{event.email_body}

-
-
-
- {/if} -
+ - -
-
-

Google Account

-

Required for syncing participants and sending emails

-
- {#if loading} -
- {:else} - { - // Refresh the page or update UI state as needed - error = ''; - }} - onError={(errorMsg) => { - error = errorMsg; - }} - /> - {/if} -
+ - -
-
-

Participants

- -
- - {#if participantsLoading || loading} - -
- {#each Array(5) as _} -
-
-
-
-
-
-
- {/each} -
- {:else if participants.length > 0} -
- - - - - - - - - - - - {#each participants as participant} - - - - - - - - {/each} - -
NameSurnameEmailScannedEmail Sent
{participant.name}{participant.surname}{participant.email} - {#if participant.scanned} -
- - - -
- {:else} -
- - - -
- {/if} -
- {#if participant.email_sent} -
- - - -
- {:else} -
- - - -
- {/if} -
-
- {:else} -
-

- No participants found. Click "Sync Participants" to load from Google Sheets. -

-
- {/if} -
- - -
-
-

Send Emails

- {#if !loading} -
- {participants.filter(p => !p.email_sent).length} uncontacted participants -
- {:else} -
- Loading participants... -
- {/if} -
- - {#if loading} -
- {:else if sendingEmails} -
-
- - - - - Sending {emailProgress.total} emails... Please wait. -
-
- {:else} -
- {#if participants.filter(p => !p.email_sent).length > 0} -
-
- - - - - Warning: Do not close this window while emails are being sent. The process may take several minutes. - -
-
- -
- -
- {:else} -
-
- - - -
-

All participants have been contacted!

-

No pending emails to send.

-
- {/if} -
- {/if} -
- - {#if emailResults} -
-
-

Email Results

-
- {emailResults.summary.success} successful, {emailResults.summary.errors} failed -
-
- -
-
-
-
- Sent: {emailResults.summary.success} -
-
-
- Failed: {emailResults.summary.errors} -
-
-
- Total: {emailResults.summary.total} -
-
-
- - {#if emailResults.results.length > 0} -
- - - - - - - - - - {#each emailResults.results as result} - - - - - - {/each} - -
NameEmailStatus
- {result.participant.name} {result.participant.surname} - {result.participant.email} - {#if result.success} -
- - - - Sent -
- {:else} -
- - - - Failed - {#if result.error} - ({result.error}) - {/if} -
- {/if} -
-
- {/if} -
+ {/if} {#if error} -
-

{error}

-
+ {/if} diff --git a/src/routes/private/events/event/view/components/EmailResults.svelte b/src/routes/private/events/event/view/components/EmailResults.svelte new file mode 100644 index 0000000..1e2c2c7 --- /dev/null +++ b/src/routes/private/events/event/view/components/EmailResults.svelte @@ -0,0 +1,100 @@ + + +{#if emailResults} +
+
+

Email Results

+
+ {emailResults.summary.success} successful, {emailResults.summary.errors} failed +
+
+ +
+
+
+
+ Sent: {emailResults.summary.success} +
+
+
+ Failed: {emailResults.summary.errors} +
+
+
+ Total: {emailResults.summary.total} +
+
+
+ + {#if emailResults.results.length > 0} +
+ + + + + + + + + + {#each emailResults.results as result} + + + + + + {/each} + +
NameEmailStatus
+ {result.participant.name} {result.participant.surname} + {result.participant.email} + {#if result.success} +
+ + + + Sent +
+ {:else} +
+ + + + Failed + {#if result.error} + ({result.error}) + {/if} +
+ {/if} +
+
+ {/if} +
+{/if} diff --git a/src/routes/private/events/event/view/components/EmailSending.svelte b/src/routes/private/events/event/view/components/EmailSending.svelte new file mode 100644 index 0000000..0e27113 --- /dev/null +++ b/src/routes/private/events/event/view/components/EmailSending.svelte @@ -0,0 +1,94 @@ + + +
+
+

Send Emails

+ {#if !loading} +
+ {uncontactedParticipantsCount} uncontacted participants +
+ {:else} +
+ Loading participants... +
+ {/if} +
+ + {#if loading} +
+ {:else if sendingEmails} +
+
+ + + + + Sending {emailProgress.total} emails... Please wait. +
+
+ {:else} +
+ {#if uncontactedParticipantsCount > 0} +
+
+ + + + + Warning: Do not close this window while emails are being sent. The process may take several minutes. + +
+
+ +
+ +
+ {:else} +
+
+ + + +
+

All participants have been contacted!

+

No pending emails to send.

+
+ {/if} +
+ {/if} +
diff --git a/src/routes/private/events/event/view/components/EmailTemplate.svelte b/src/routes/private/events/event/view/components/EmailTemplate.svelte new file mode 100644 index 0000000..2e9718e --- /dev/null +++ b/src/routes/private/events/event/view/components/EmailTemplate.svelte @@ -0,0 +1,47 @@ + + +
+
+

Email Template

+
+ + {#if loading} + +
+
+ Subject: +
+
+ +
+ Body: +
+
+
+ {:else if event} +
+
+ Subject: +
+

{event.email_subject}

+
+
+
+ Body: +
+

{event.email_body}

+
+
+
+ {/if} +
diff --git a/src/routes/private/events/event/view/components/ErrorMessage.svelte b/src/routes/private/events/event/view/components/ErrorMessage.svelte new file mode 100644 index 0000000..e222576 --- /dev/null +++ b/src/routes/private/events/event/view/components/ErrorMessage.svelte @@ -0,0 +1,11 @@ + + +{#if error} +
+

{error}

+
+{/if} diff --git a/src/routes/private/events/event/view/components/EventInformation.svelte b/src/routes/private/events/event/view/components/EventInformation.svelte new file mode 100644 index 0000000..7d99aac --- /dev/null +++ b/src/routes/private/events/event/view/components/EventInformation.svelte @@ -0,0 +1,88 @@ + + +
+ {#if loading} + +
+

Event Information

+
+
+ Date: +
+
+
+ Created: +
+
+
+ Sheet ID: +
+
+
+
+ {:else if event} +
+

{event.name}

+
+
+ Date: + {formatDate(event.date)} +
+
+ Created: + {formatDate(event.created_at)} +
+ +
+
+ {:else if error} +
+

{error}

+
+ {/if} +
diff --git a/src/routes/private/events/event/view/components/GoogleAuthentication.svelte b/src/routes/private/events/event/view/components/GoogleAuthentication.svelte new file mode 100644 index 0000000..4c51af1 --- /dev/null +++ b/src/routes/private/events/event/view/components/GoogleAuthentication.svelte @@ -0,0 +1,26 @@ + + +
+
+

Google Account

+

Required for syncing participants and sending emails

+
+ {#if loading} +
+ {:else} + + {/if} +
diff --git a/src/routes/private/events/event/view/components/ParticipantsTable.svelte b/src/routes/private/events/event/view/components/ParticipantsTable.svelte new file mode 100644 index 0000000..5595401 --- /dev/null +++ b/src/routes/private/events/event/view/components/ParticipantsTable.svelte @@ -0,0 +1,162 @@ + + +
+
+

Participants

+ +
+ + {#if participantsLoading || loading} + +
+ {#each Array(5) as _} +
+
+
+
+
+
+
+ {/each} +
+ {:else if participants.length > 0} +
+ + + + + + + + + + + + {#each participants as participant} + + + + + + + + {/each} + +
NameSurnameEmailScannedEmail Sent
{participant.name}{participant.surname}{participant.email} + {#if participant.scanned} +
+ + + +
+ {:else} +
+ + + +
+ {/if} +
+ {#if participant.email_sent} +
+ + + +
+ {:else} +
+ + + +
+ {/if} +
+
+ {:else} +
+

+ No participants found. Click "Sync Participants" to load from Google Sheets. +

+
+ {/if} +