1
0
Fork 0
mirror of https://github.com/seanmorley15/AdventureLog.git synced 2025-07-20 13:29:37 +02:00

Add support for end date to adventure

This commit is contained in:
Sean Morley 2024-08-18 12:30:12 -04:00
parent 276ea42138
commit 03e0530e90
9 changed files with 66 additions and 5 deletions

View file

@ -9,7 +9,7 @@
let newCollection: Collection = {
user_id: NaN,
id: NaN,
id: '',
name: '',
description: '',
adventures: [] as Adventure[],
@ -41,6 +41,12 @@
const form = event.target as HTMLFormElement;
const formData = new FormData(form);
// make sure that start_date is before end_date
if (new Date(newCollection.start_date ?? '') > new Date(newCollection.end_date ?? '')) {
addToast('error', 'Start date must be before end date');
return;
}
const response = await fetch(form.action, {
method: form.method,
body: formData