diff --git a/src/routes/private/events/+page.svelte b/src/routes/private/events/+page.svelte index 155002e..47dc1f6 100644 --- a/src/routes/private/events/+page.svelte +++ b/src/routes/private/events/+page.svelte @@ -1,16 +1,26 @@ @@ -28,15 +38,10 @@ {/each} {:else} {#each events as event} - -
- {event.name} - {event.date} -
-
+ + {/each} + {#each archived_events as event} + {/each} {/if} diff --git a/src/routes/private/events/SingleEvent.svelte b/src/routes/private/events/SingleEvent.svelte new file mode 100644 index 0000000..ef08e73 --- /dev/null +++ b/src/routes/private/events/SingleEvent.svelte @@ -0,0 +1,19 @@ + + + +
+ + {#if archived} + + {/if} + {name} + + {date} +
+
\ No newline at end of file diff --git a/src/routes/private/events/archived/+page.svelte b/src/routes/private/events/archived/+page.svelte new file mode 100644 index 0000000..e309c53 --- /dev/null +++ b/src/routes/private/events/archived/+page.svelte @@ -0,0 +1,75 @@ + + +

Archived Event Overview

+ +
+
+ {#if loading} +
+
+ {:else} + {event_data?.name} + {event_data?.date} + {/if} +
+
+ +
+
+ + + + {#if loading} +
+ {:else} + Total participants ({event_data?.total_participants}) + {/if} +
+
+
+ + + + {#if loading} +
+ {:else} + Scanned participants ({event_data?.scanned_participants}) + {/if} +
+
diff --git a/src/routes/private/events/creator/+page.svelte b/src/routes/private/events/creator/+page.svelte index fd4af95..0b2e1f0 100644 --- a/src/routes/private/events/creator/+page.svelte +++ b/src/routes/private/events/creator/+page.svelte @@ -1,94 +1,129 @@ -
- - - Step {step + 1} of {steps.length} - - +
+ {#if isAddingParticipants} +

Add Participants to "{event.name}"

+ {/if}
{#if step == 0} - + {:else if step == 1} - + {:else if step == 2} - + {:else if step == 3} - + {:else if step == 4} - + {/if} + +
+ +
+
+ + + Step {step + 1} of {steps.length} + + +
+
diff --git a/src/routes/private/events/creator/finish/+page.svelte b/src/routes/private/events/creator/finish/+page.svelte index c940fab..93dc831 100644 --- a/src/routes/private/events/creator/finish/+page.svelte +++ b/src/routes/private/events/creator/finish/+page.svelte @@ -29,9 +29,18 @@ all_data = JSON.parse(sessionStorage.getItem(session_storage_id) || '{}'); try { - event_status = StepStatus.Loading; - const createdEvent = await createEventInSupabase(all_data.event); - event_status = StepStatus.Success; + let createdEvent; + + if (all_data.isAddingParticipants && all_data.existingEventId) { + // Skip event creation for existing events + event_status = StepStatus.Success; + createdEvent = { id: all_data.existingEventId, ...all_data.event }; + } else { + // Create new event + event_status = StepStatus.Loading; + createdEvent = await createEventInSupabase(all_data.event); + event_status = StepStatus.Success; + } participants_status = StepStatus.Loading; createdParticipants = await createParticipantsInSupabase(all_data.participants, createdEvent); @@ -141,13 +150,17 @@
-

Creating event

+

+ {all_data.isAddingParticipants ? 'Using existing event' : 'Creating event'} +

{#if event_status === StepStatus.Waiting} Waiting... {:else if event_status === StepStatus.Loading} Creating event... {:else if event_status === StepStatus.Success} - Event created successfully. + + {all_data.isAddingParticipants ? 'Using existing event.' : 'Event created successfully.'} + {:else if event_status === StepStatus.Failure} Failed to create event. {/if} @@ -155,21 +168,22 @@
-

Creating database entries

+

Creating QR codes for participants

{#if participants_status === StepStatus.Waiting} Waiting... {:else if participants_status === StepStatus.Loading} Creating entries... {:else if participants_status === StepStatus.Success} - Database entries created successfully. + QR codes created successfully. {:else if participants_status === StepStatus.Failure} - Failed to create database entries. + Failed to create QR codes. {/if}
-

Sending emails

+

Sending emails

+

After pressing send, you must not exit this window until the mail are all sent!

{#if email_status === StepStatus.Waiting}
Waiting... @@ -179,7 +193,7 @@ class="ml-4 px-6 py-2 rounded font-semibold transition disabled:opacity-50 disabled:cursor-not-allowed {event_status === StepStatus.Success && participants_status === StepStatus.Success ? 'bg-blue-600 hover:bg-blue-700 text-white' : 'bg-gray-400 text-white'}" > - Launch Mail Campaign + Send all emails
{:else} diff --git a/src/routes/private/events/creator/steps/StepCraftEmail.svelte b/src/routes/private/events/creator/steps/StepCraftEmail.svelte index bd914c0..32c878c 100644 --- a/src/routes/private/events/creator/steps/StepCraftEmail.svelte +++ b/src/routes/private/events/creator/steps/StepCraftEmail.svelte @@ -57,10 +57,13 @@ > Edit email -
-
    -
  1. {email.subject}
  2. -
  3. {email.body}
  4. -
+
+

Email Preview

+
+ {email.subject} +
+
+ {email.body} +
{/if} \ No newline at end of file diff --git a/src/routes/private/events/creator/steps/StepCreateEvent.svelte b/src/routes/private/events/creator/steps/StepCreateEvent.svelte index 8730dd7..5c96e46 100644 --- a/src/routes/private/events/creator/steps/StepCreateEvent.svelte +++ b/src/routes/private/events/creator/steps/StepCreateEvent.svelte @@ -1,8 +1,8 @@ @@ -59,28 +61,22 @@ {/if} {#if !showForm} - -{/if} - -{#if !showForm} -
- {#if loading} - Loading... - {:else if Object.keys(event).length > 0} -
    -
  1. {event.name}
  2. -
  3. {event.date}
  4. -
+ {#if !readonly} + + {/if} +
+

Event Preview

+ {#if Object.keys(event).length > 0} +
    +
  • {event.name}
  • +
  • {event.date}
  • +
{:else} No event created yet... {/if} diff --git a/src/routes/private/events/creator/steps/StepOverview.svelte b/src/routes/private/events/creator/steps/StepOverview.svelte index cd77d45..836d1bd 100644 --- a/src/routes/private/events/creator/steps/StepOverview.svelte +++ b/src/routes/private/events/creator/steps/StepOverview.svelte @@ -1,7 +1,7 @@ {#if showForm} + {#if errors.length > 0} +
+
    + {#each errors as err} +
  • {err}
  • + {/each} +
+
+ {/if}
- {#if loading} - Loading... - {:else if participants.length === 0} - No participants yet... - {:else} -
    - {#each participants as p, i} -
  • -
    -
    {p.name} {p.surname}
    -
    {p.email}
    -
    -
  • - {/each} -
- {/if} +
+
+

Participants ({participants.length})

+ {#if participants.length > 0} + {#if participants.some((p) => !p.email_valid)} + Some emails appear invalid + {:else} + All emails appear valid + {/if} + {/if} +
+ +
    + {#each participants as p} +
  • + {#if p.email_valid} + + + + {:else} + + + + + + {/if} + {p.name} {p.surname} + + {p.email} +
  • + {/each} +
{/if} diff --git a/src/routes/private/events/event/+page.svelte b/src/routes/private/events/event/+page.svelte index aa6223e..c7432b4 100644 --- a/src/routes/private/events/event/+page.svelte +++ b/src/routes/private/events/event/+page.svelte @@ -37,13 +37,25 @@

Event Overview

-
+
+
+ {#if loading} +
+
+ {:else} + {event_data?.name} + {event_data?.date} + {/if} +
{#if loading} -
-
- {:else} - {event_data?.name} - {event_data?.date} +
+ {:else if event_data} + + Add Participants + {/if}
@@ -60,7 +72,7 @@ {#if loading} -
+
{:else} Scanned ({scannedCount}) {/if} @@ -79,7 +91,7 @@ {#if loading} -
+
{:else} Not scanned ({notScannedCount}) {/if} @@ -89,7 +101,7 @@

{#if loading} -
+
{:else} Participants ({participants.length}) {/if} @@ -97,7 +109,7 @@
    {#if loading}
  • -
    +
  • {:else} {#each participants as p} diff --git a/src/service-worker.ts b/src/service-worker.ts new file mode 100644 index 0000000..935445d --- /dev/null +++ b/src/service-worker.ts @@ -0,0 +1,80 @@ +/// +import { build, files, version } from '$service-worker'; + +// Create a unique cache name for this deployment +const CACHE = `cache-${version}`; + +const ASSETS = [ + ...build, // the app itself + ...files // everything in `static` +]; + +self.addEventListener('install', (event) => { + // Create a new cache and add all files to it + async function addFilesToCache() { + const cache = await caches.open(CACHE); + await cache.addAll(ASSETS); + } + + event.waitUntil(addFilesToCache()); +}); + +self.addEventListener('activate', (event) => { + // Remove previous cached data from disk + async function deleteOldCaches() { + for (const key of await caches.keys()) { + if (key !== CACHE) await caches.delete(key); + } + } + + event.waitUntil(deleteOldCaches()); +}); + +self.addEventListener('fetch', (event) => { + // ignore POST requests etc + if (event.request.method !== 'GET') return; + + async function respond() { + const url = new URL(event.request.url); + const cache = await caches.open(CACHE); + + // `build`/`files` can always be served from the cache + if (ASSETS.includes(url.pathname)) { + const response = await cache.match(url.pathname); + + if (response) { + return response; + } + } + + // for everything else, try the network first, but + // fall back to the cache if we're offline + try { + const response = await fetch(event.request); + + // if we're offline, fetch can return a value that is not a Response + // instead of throwing - and we can't pass this non-Response to respondWith + if (!(response instanceof Response)) { + throw new Error('invalid response from fetch'); + } + + if (response.status === 200) { + cache.put(event.request, response.clone()); + } + + return response; + } catch (err) { + const response = await cache.match(event.request); + + if (response) { + return response; + } + + // if there's no cache, then just error out + // as there is nothing we can do to respond to this request + throw err; + } + } + + event.respondWith(respond()); +}); \ No newline at end of file