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
-
-
- - {email.subject}
- - {email.body}
-
+
+
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..7d69dc5 100644
--- a/src/routes/private/events/creator/steps/StepCreateEvent.svelte
+++ b/src/routes/private/events/creator/steps/StepCreateEvent.svelte
@@ -66,21 +66,13 @@
>
Edit the event
-{/if}
-
-{#if !showForm}
-
- {#if loading}
-
Loading...
- {:else if Object.keys(event).length > 0}
-
- - {event.name}
- - {event.date}
-
+
+
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/StepUploadParticipants.svelte b/src/routes/private/events/creator/steps/StepUploadParticipants.svelte
index 70e9e4f..ac8cf52 100644
--- a/src/routes/private/events/creator/steps/StepUploadParticipants.svelte
+++ b/src/routes/private/events/creator/steps/StepUploadParticipants.svelte
@@ -2,19 +2,20 @@
import Papa from 'papaparse';
let { participants = $bindable() } = $props();
- let loading = $state(false);
let showForm = $derived(participants.length === 0);
+ let errors = $state([]);
+
+ function isValidEmail(email: string): boolean {
+ return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email);
+ }
async function handleSubmit(e: Event) {
e.preventDefault();
- loading = true;
+ errors = [];
const form = e.target as HTMLFormElement;
const fileInput = form.elements.namedItem('participants') as HTMLInputElement;
const file = fileInput?.files?.[0];
- if (!file) {
- loading = false;
- return;
- }
+ if (!file) return;
const csvText = await file.text();
const { data: parsedRows } = Papa.parse
(csvText, {
skipEmptyLines: true,
@@ -24,13 +25,36 @@
if (parsedRows.length > 0) {
parsedRows.shift();
}
- participants = parsedRows.map((row: string[]) => ({
- name: row[0],
- surname: row[1],
- email: row[2]
- }));
+ const validated = [];
+ parsedRows.forEach((row, idx) => {
+ if (!row || row.length < 3) {
+ errors.push(`Row ${idx + 2} is missing columns.`);
+ return;
+ }
+ const [name, surname, email] = row;
+ if (!name || !surname || !email) {
+ errors.push(`Row ${idx + 2} has missing values.`);
+ return;
+ }
+ validated.push({
+ name,
+ surname,
+ email,
+ email_valid: isValidEmail(email)
+ });
+ });
+ if (errors.length > 0) {
+ return; // Do not proceed if there are errors
+ }
+ if (validated.length === 0) {
+ participants = [];
+ return;
+ }
+ participants = validated.sort((a, b) => {
+ if (a.email_valid === b.email_valid) return 0;
+ return a.email_valid ? 1 : -1;
+ });
showForm = false;
- loading = false;
}
function showEditForm() {
@@ -39,6 +63,15 @@
{#if showForm}
+ {#if errors.length > 0}
+
+
+ {#each errors as err}
+ - {err}
+ {/each}
+
+
+ {/if}