From 413aa69ac505ec567f94f979fa19b4d3e51433b9 Mon Sep 17 00:00:00 2001
From: Sean Morley
Date: Mon, 7 Oct 2024 19:25:49 -0400
Subject: [PATCH] Hide end_date when start and end dates are the same
---
frontend/src/lib/components/AdventureModal.svelte | 6 ++++--
frontend/src/routes/adventures/[id]/+page.svelte | 4 +++-
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/frontend/src/lib/components/AdventureModal.svelte b/frontend/src/lib/components/AdventureModal.svelte
index 3f39b3e..33795d6 100644
--- a/frontend/src/lib/components/AdventureModal.svelte
+++ b/frontend/src/lib/components/AdventureModal.svelte
@@ -221,7 +221,9 @@
let new_end_date: string = '';
let new_notes: string = '';
function addNewVisit() {
- // check if start date is before end date
+ if (new_start_date && !new_end_date) {
+ new_end_date = new_start_date;
+ }
if (new_start_date > new_end_date) {
addToast('error', 'Start date must be before end date');
return;
@@ -736,7 +738,7 @@ it would also work to just use on:click on the MapLibre component itself. -->
timeZone: 'UTC'
})}
- {#if visit.end_date}
+ {#if visit.end_date && visit.end_date !== visit.start_date}
{new Date(visit.end_date).toLocaleDateString(undefined, {
timeZone: 'UTC'
diff --git a/frontend/src/routes/adventures/[id]/+page.svelte b/frontend/src/routes/adventures/[id]/+page.svelte
index 8f8b6fe..70b8075 100644
--- a/frontend/src/routes/adventures/[id]/+page.svelte
+++ b/frontend/src/routes/adventures/[id]/+page.svelte
@@ -339,7 +339,9 @@
timeZone: 'UTC'
})
: ''}
- {visit.end_date && visit.end_date !== ''
+ {visit.end_date &&
+ visit.end_date !== '' &&
+ visit.end_date !== visit.start_date
? ' - ' +
new Date(visit.end_date).toLocaleDateString(undefined, {
timeZone: 'UTC'