2
0
forked from jmug/cactoide

fix: rvsp delet models

This commit is contained in:
Levente Orban
2025-10-26 17:41:44 +01:00
parent 93b0bac48a
commit 5809cb49ee
6 changed files with 45 additions and 53 deletions

View File

@@ -1,9 +1,8 @@
import { database } from '$lib/database/db';
import { events, rsvps, inviteTokens } from '$lib/database/schema';
import { eq, asc, and } from 'drizzle-orm';
import { events, rsvps } from '$lib/database/schema';
import { eq, asc } from 'drizzle-orm';
import { error, fail } from '@sveltejs/kit';
import type { PageServerLoad, Actions } from './$types';
import { isTokenValid } from '$lib/inviteTokenHelpers.js';
export const load: PageServerLoad = async ({ params, cookies }) => {
const eventId = params.id;

View File

@@ -18,7 +18,7 @@
let newAttendeeName = '';
let isAddingRSVP = false;
let error = '';
let success = '';
let success = ''; // TODO: change to boolean and refactor with 482-506
let addGuests = false;
let numberOfGuests = 1;
let showCalendarModal = false;
@@ -50,19 +50,20 @@
success = '';
}
// TODO: ERROR
// //WHEN DELETING RSVP: THE MODAL MESSAGE IS "RSVP removed successfully."
const handleFormSuccess = () => {
if (form?.type === 'add') {
success = 'RSVP added successfully!';
} else {
success = 'RSVP removed successfully.';
}
// Handle form success from server
$: if (form?.success) {
success = 'RSVP added successfully!';
error = '';
newAttendeeName = '';
addGuests = false;
numberOfGuests = 1;
// show and auto-hide success toast for add action
toastType = 'add';
toastType = form?.type || 'add';
if (browser) {
if (successHideTimer) clearTimeout(successHideTimer);
successHideTimer = window.setTimeout(() => {
@@ -70,7 +71,10 @@
toastType = null;
}, 3000);
}
}
};
// Handle form success from server
$: if (form?.success) handleFormSuccess();
// Derive toast type from local or server form
$: typeToShow = toastType ?? form?.type;