1
0
Fork 0
mirror of https://github.com/seanmorley15/AdventureLog.git synced 2025-07-22 14:29:36 +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

@ -34,6 +34,7 @@
name: adventureToEdit?.name || '',
type: adventureToEdit?.type || 'visited',
date: adventureToEdit?.date || null,
end_date: adventureToEdit?.end_date || null,
link: adventureToEdit?.link || null,
description: adventureToEdit?.description || null,
activity_types: adventureToEdit?.activity_types || [],
@ -286,6 +287,14 @@
async function handleSubmit(event: Event) {
event.preventDefault();
if (adventure.date && adventure.end_date) {
if (new Date(adventure.date) > new Date(adventure.end_date)) {
addToast('error', 'Start date must be before end date');
return;
}
}
console.log(adventure);
if (adventure.id === '') {
let res = await fetch('/api/adventures', {
@ -374,7 +383,7 @@
</div>
<div>
<label for="date">Date</label><br />
<label for="date">Date (or start date)</label><br />
<input
type="date"
id="date"
@ -385,6 +394,18 @@
class="input input-bordered w-full"
/>
</div>
<div>
<label for="end_date">End Date</label><br />
<input
type="date"
id="end_date"
name="end_date"
min={startDate || ''}
max={endDate || ''}
bind:value={adventure.end_date}
class="input input-bordered w-full"
/>
</div>
<div>
<!-- link -->
<div>