mirror of
https://github.com/seanmorley15/AdventureLog.git
synced 2025-07-24 07:19:36 +02:00
add transportation
This commit is contained in:
parent
6155d531ab
commit
54ef1677e8
2 changed files with 67 additions and 22 deletions
|
@ -55,11 +55,11 @@
|
||||||
|
|
||||||
transportationToEdit = result;
|
transportationToEdit = result;
|
||||||
|
|
||||||
addToast('success', 'Adventure edited successfully!');
|
addToast('success', 'Transportation edited successfully!');
|
||||||
dispatch('saveEdit', transportationToEdit);
|
dispatch('saveEdit', transportationToEdit);
|
||||||
close();
|
close();
|
||||||
} else {
|
} else {
|
||||||
addToast('error', 'Error editing adventure');
|
addToast('error', 'Error editing transportaion');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -83,6 +83,31 @@
|
||||||
return groupedAdventures;
|
return groupedAdventures;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function groupTransportationsByDate(
|
||||||
|
transportations: Transportation[],
|
||||||
|
startDate: Date
|
||||||
|
): Record<string, Transportation[]> {
|
||||||
|
const groupedTransportations: Record<string, Transportation[]> = {};
|
||||||
|
|
||||||
|
for (let i = 0; i < numberOfDays; i++) {
|
||||||
|
const currentDate = new Date(startDate);
|
||||||
|
currentDate.setDate(startDate.getDate() + i);
|
||||||
|
const dateString = currentDate.toISOString().split('T')[0];
|
||||||
|
groupedTransportations[dateString] = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
transportations.forEach((transportation) => {
|
||||||
|
if (transportation.date) {
|
||||||
|
const transportationDate = new Date(transportation.date).toISOString().split('T')[0];
|
||||||
|
if (groupedTransportations[transportationDate]) {
|
||||||
|
groupedTransportations[transportationDate].push(transportation);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return groupedTransportations;
|
||||||
|
}
|
||||||
|
|
||||||
function createAdventure(event: CustomEvent<Adventure>) {
|
function createAdventure(event: CustomEvent<Adventure>) {
|
||||||
adventures = [event.detail, ...adventures];
|
adventures = [event.detail, ...adventures];
|
||||||
isShowingCreateModal = false;
|
isShowingCreateModal = false;
|
||||||
|
@ -344,19 +369,21 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{#if collection.transportations && collection.transportations.length > 0}
|
{#if collection.transportations && collection.transportations.length > 0}
|
||||||
<h1 class="text-center font-bold text-4xl mt-4 mb-2">Transportation</h1>
|
<h1 class="text-center font-bold text-4xl mt-4 mb-4">Transportation</h1>
|
||||||
{#each transportations as transportation}
|
<div class="flex flex-wrap gap-4 mr-4 justify-center content-center">
|
||||||
<TransportationCard
|
{#each transportations as transportation}
|
||||||
{transportation}
|
<TransportationCard
|
||||||
on:delete={(event) => {
|
{transportation}
|
||||||
transportations = transportations.filter((t) => t.id != event.detail);
|
on:delete={(event) => {
|
||||||
}}
|
transportations = transportations.filter((t) => t.id != event.detail);
|
||||||
on:edit={(event) => {
|
}}
|
||||||
transportationToEdit = event.detail;
|
on:edit={(event) => {
|
||||||
isTransportationEditModalOpen = true;
|
transportationToEdit = event.detail;
|
||||||
}}
|
isTransportationEditModalOpen = true;
|
||||||
/>
|
}}
|
||||||
{/each}
|
/>
|
||||||
|
{/each}
|
||||||
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{#if collection.start_date && collection.end_date}
|
{#if collection.start_date && collection.end_date}
|
||||||
|
@ -378,13 +405,16 @@
|
||||||
{@const dayAdventures = groupAdventuresByDate(adventures, new Date(collection.start_date))[
|
{@const dayAdventures = groupAdventuresByDate(adventures, new Date(collection.start_date))[
|
||||||
dateString
|
dateString
|
||||||
]}
|
]}
|
||||||
|
{@const dayTransportations = groupTransportationsByDate(
|
||||||
|
transportations,
|
||||||
|
new Date(collection.start_date)
|
||||||
|
)[dateString]}
|
||||||
|
|
||||||
<h2 class="text-center font-semibold text-2xl mb-2 mt-4">
|
<h2 class="text-center font-semibold text-2xl mb-2 mt-4">
|
||||||
Day {i + 1} - {currentDate.toLocaleDateString('en-US', { timeZone: 'UTC' })}
|
Day {i + 1} - {currentDate.toLocaleDateString('en-US', { timeZone: 'UTC' })}
|
||||||
</h2>
|
</h2>
|
||||||
|
<div class="flex flex-wrap gap-4 mr-4 justify-center content-center">
|
||||||
{#if dayAdventures.length > 0}
|
{#if dayAdventures.length > 0}
|
||||||
<div class="flex flex-wrap gap-4 mr-4 justify-center content-center">
|
|
||||||
{#each dayAdventures as adventure}
|
{#each dayAdventures as adventure}
|
||||||
<AdventureCard
|
<AdventureCard
|
||||||
user={data.user}
|
user={data.user}
|
||||||
|
@ -395,10 +425,25 @@
|
||||||
on:typeChange={changeType}
|
on:typeChange={changeType}
|
||||||
/>
|
/>
|
||||||
{/each}
|
{/each}
|
||||||
</div>
|
{:else if dayTransportations.length > 0}
|
||||||
{:else}
|
{#each dayTransportations as transportation}
|
||||||
<p class="text-center text-lg mt-2">No adventures planned for this day.</p>
|
<TransportationCard
|
||||||
{/if}
|
{transportation}
|
||||||
|
on:delete={(event) => {
|
||||||
|
transportations = transportations.filter((t) => t.id != event.detail);
|
||||||
|
}}
|
||||||
|
on:edit={(event) => {
|
||||||
|
transportationToEdit = event.detail;
|
||||||
|
isTransportationEditModalOpen = true;
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
{/each}
|
||||||
|
{:else}
|
||||||
|
<p class="text-center text-lg mt-2">
|
||||||
|
No adventures or transportaions planned for this day.
|
||||||
|
</p>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
{/each}
|
{/each}
|
||||||
<div class="flex items-center justify-center w-10/12">
|
<div class="flex items-center justify-center w-10/12">
|
||||||
<MapLibre
|
<MapLibre
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue