Refactor event form to use separate date/time inputs with validation
All checks were successful
Build And Push Image / docker (push) Successful in 1m26s
All checks were successful
Build And Push Image / docker (push) Successful in 1m26s
- Split combined datetime pickers into separate date and time fields - Add validation for past dates and time consistency - Implement error message display with dismissible alerts - Add watchers to combine date/time values into ISO strings - Set minimum date constraints to prevent past date selection - Add delete endpoint for events
This commit is contained in:
@@ -352,6 +352,47 @@ export const useEvents = () => {
|
||||
cache.clear();
|
||||
};
|
||||
|
||||
/**
|
||||
* Delete an event (board/admin only)
|
||||
*/
|
||||
const deleteEvent = async (eventId: string) => {
|
||||
loading.value = true;
|
||||
error.value = null;
|
||||
|
||||
try {
|
||||
const response = await $fetch<{ success: boolean; message: string; deleted: any }>(`/api/events/${eventId}`, {
|
||||
method: 'DELETE'
|
||||
});
|
||||
|
||||
if (response.success) {
|
||||
// Remove event from local state
|
||||
const eventIndex = events.value.findIndex(e =>
|
||||
e.event_id === eventId ||
|
||||
e.id === eventId ||
|
||||
(e as any).Id === eventId
|
||||
);
|
||||
|
||||
if (eventIndex !== -1) {
|
||||
events.value.splice(eventIndex, 1);
|
||||
}
|
||||
|
||||
// Clear cache and refresh
|
||||
clearCache();
|
||||
await fetchEvents({ force: true });
|
||||
|
||||
return response;
|
||||
} else {
|
||||
throw new Error(response.message || 'Failed to delete event');
|
||||
}
|
||||
} catch (err: any) {
|
||||
error.value = err.message || 'Failed to delete event';
|
||||
console.error('Error deleting event:', err);
|
||||
throw err;
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Refresh events data
|
||||
*/
|
||||
@@ -385,7 +426,9 @@ export const useEvents = () => {
|
||||
// Methods
|
||||
fetchEvents,
|
||||
createEvent,
|
||||
deleteEvent,
|
||||
rsvpToEvent,
|
||||
cancelRSVP,
|
||||
updateAttendance,
|
||||
getCalendarEvents,
|
||||
getUpcomingEvents,
|
||||
|
||||
Reference in New Issue
Block a user