diff --git a/frontend/src/lib/components/DateRangeCollapse.svelte b/frontend/src/lib/components/DateRangeCollapse.svelte
new file mode 100644
index 0000000..d8fc699
--- /dev/null
+++ b/frontend/src/lib/components/DateRangeCollapse.svelte
@@ -0,0 +1,387 @@
+
+
+
+
+
+ {$t('adventures.date_information')}
+
+
+
+
+
+
+
+
{$t('adventures.all_day')}
+
{
+ // clear local dates when toggling all day
+ if (allDay) {
+ localStartDate = localStartDate.split('T')[0];
+ localEndDate = localEndDate.split('T')[0];
+ } else {
+ localStartDate = localStartDate + 'T00:00';
+ localEndDate = localEndDate + 'T23:59';
+ }
+ // Update UTC dates when toggling all day
+ utcStartDate = updateUTCDate({
+ localDate: localStartDate,
+ timezone: selectedTimezone,
+ allDay
+ }).utcDate;
+ utcEndDate = updateUTCDate({
+ localDate: localEndDate,
+ timezone: selectedTimezone,
+ allDay
+ }).utcDate;
+ // Update local dates when toggling all day
+ localStartDate = updateLocalDate({
+ utcDate: utcStartDate,
+ timezone: selectedTimezone
+ }).localDate;
+ localEndDate = updateLocalDate({
+ utcDate: utcEndDate,
+ timezone: selectedTimezone
+ }).localDate;
+ }}
+ />
+
+
+
+
+
+
+ {#if !validateDateRange(localStartDate, localEndDate).valid}
+
+
+
{$t('adventures.invalid_date_range')}
+
+ {/if}
+
+ {#if visits && visits.length > 0}
+
+ {#each visits as visit}
+
+
+ {#if isAllDay(visit.start_date)}
+ All Day
+ {visit.start_date.split('T')[0]} – {visit.end_date.split('T')[0]}
+ {:else}
+ {new Date(visit.start_date).toLocaleString()} – {new Date(
+ visit.end_date
+ ).toLocaleString()}
+ {/if}
+
+
+
+
+ {#if visit.notes}
+
+ "{visit.notes}"
+
+ {/if}
+
+
+
+
+
+
+
+ {/each}
+
+ {/if}
+
+
+ {#if type === 'adventure'}
+
+ {/if}
+
+
+
diff --git a/frontend/src/lib/components/DateRangeDropdown.svelte b/frontend/src/lib/components/DateRangeDropdown.svelte
deleted file mode 100644
index 608d8bd..0000000
--- a/frontend/src/lib/components/DateRangeDropdown.svelte
+++ /dev/null
@@ -1,172 +0,0 @@
-
-
-
-
-
- {$t('adventures.date_information')}
-
-
-
-
-
-
-
-
-
-
-
- {#if !validateDateRange(localStartDate, localEndDate).valid}
-
-
-
{$t('adventures.invalid_date_range')}
-
- {/if}
-
-
-
-
diff --git a/frontend/src/lib/components/LodgingModal.svelte b/frontend/src/lib/components/LodgingModal.svelte
index 9a2975e..cbe05c8 100644
--- a/frontend/src/lib/components/LodgingModal.svelte
+++ b/frontend/src/lib/components/LodgingModal.svelte
@@ -5,6 +5,7 @@
import MarkdownEditor from './MarkdownEditor.svelte';
import type { Collection, Lodging } from '$lib/types';
import LocationDropdown from './LocationDropdown.svelte';
+ import DateRangeCollapse from './DateRangeCollapse.svelte';
const dispatch = createEventDispatcher();
@@ -12,22 +13,10 @@
export let lodgingToEdit: Lodging | null = null;
let modal: HTMLDialogElement;
- let constrainDates: boolean = false;
let lodging: Lodging = { ...initializeLodging(lodgingToEdit) };
let fullStartDate: string = '';
let fullEndDate: string = '';
- // Format date as local datetime
- // Convert an ISO date to a datetime-local value in local time.
- function toLocalDatetime(value: string | null): string {
- if (!value) return '';
- const date = new Date(value);
- // Adjust the time by subtracting the timezone offset.
- date.setMinutes(date.getMinutes() - date.getTimezoneOffset());
- // Return format YYYY-MM-DDTHH:mm
- return date.toISOString().slice(0, 16);
- }
-
type LodgingType = {
value: string;
label: string;
@@ -47,27 +36,27 @@
{ value: 'other', label: 'Other' }
];
- // Initialize hotel with values from hotelToEdit or default values
- function initializeLodging(hotelToEdit: Lodging | null): Lodging {
+ // Initialize hotel with values from lodgingToEdit or default values
+ function initializeLodging(lodgingToEdit: Lodging | null): Lodging {
return {
- id: hotelToEdit?.id || '',
- user_id: hotelToEdit?.user_id || '',
- name: hotelToEdit?.name || '',
- type: hotelToEdit?.type || 'other',
- description: hotelToEdit?.description || '',
- rating: hotelToEdit?.rating || NaN,
- link: hotelToEdit?.link || '',
- check_in: hotelToEdit?.check_in ? toLocalDatetime(hotelToEdit.check_in) : null,
- check_out: hotelToEdit?.check_out ? toLocalDatetime(hotelToEdit.check_out) : null,
- reservation_number: hotelToEdit?.reservation_number || '',
- price: hotelToEdit?.price || null,
- latitude: hotelToEdit?.latitude || null,
- longitude: hotelToEdit?.longitude || null,
- location: hotelToEdit?.location || '',
- is_public: hotelToEdit?.is_public || false,
- collection: hotelToEdit?.collection || collection.id,
- created_at: hotelToEdit?.created_at || '',
- updated_at: hotelToEdit?.updated_at || ''
+ id: lodgingToEdit?.id || '',
+ user_id: lodgingToEdit?.user_id || '',
+ name: lodgingToEdit?.name || '',
+ type: lodgingToEdit?.type || 'other',
+ description: lodgingToEdit?.description || '',
+ rating: lodgingToEdit?.rating || NaN,
+ link: lodgingToEdit?.link || '',
+ check_in: lodgingToEdit?.check_in || null,
+ check_out: lodgingToEdit?.check_out || null,
+ reservation_number: lodgingToEdit?.reservation_number || '',
+ price: lodgingToEdit?.price || null,
+ latitude: lodgingToEdit?.latitude || null,
+ longitude: lodgingToEdit?.longitude || null,
+ location: lodgingToEdit?.location || '',
+ is_public: lodgingToEdit?.is_public || false,
+ collection: lodgingToEdit?.collection || collection.id,
+ created_at: lodgingToEdit?.created_at || '',
+ updated_at: lodgingToEdit?.updated_at || ''
};
}
@@ -104,27 +93,6 @@
async function handleSubmit(event: Event) {
event.preventDefault();
- if (lodging.check_in && !lodging.check_out) {
- const checkInDate = new Date(lodging.check_in);
- checkInDate.setDate(checkInDate.getDate() + 1);
- lodging.check_out = checkInDate.toISOString();
- }
-
- if (lodging.check_in && lodging.check_out && lodging.check_in > lodging.check_out) {
- addToast('error', $t('adventures.start_before_end_error'));
- return;
- }
-
- // Only convert to UTC if the time is still in local format.
- if (lodging.check_in && !lodging.check_in.includes('Z')) {
- // new Date(lodging.check_in) interprets the input as local time.
- lodging.check_in = new Date(lodging.check_in).toISOString();
- }
- if (lodging.check_out && !lodging.check_out.includes('Z')) {
- lodging.check_out = new Date(lodging.check_out).toISOString();
- }
- console.log(lodging.check_in, lodging.check_out);
-
// Create or update lodging...
const url = lodging.id === '' ? '/api/lodging' : `/api/lodging/${lodging.id}`;
const method = lodging.id === '' ? 'POST' : 'PATCH';
@@ -331,85 +299,11 @@