-
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add calendar route and integrate calendar component in Navbar
- Loading branch information
1 parent
d44cb06
commit 6410580
Showing
5 changed files
with
70 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import type { Adventure } from '$lib/types'; | ||
import type { PageServerLoad } from './$types'; | ||
const PUBLIC_SERVER_URL = process.env['PUBLIC_SERVER_URL']; | ||
const endpoint = PUBLIC_SERVER_URL || 'http://localhost:8000'; | ||
|
||
export const load = (async (event) => { | ||
let sessionId = event.cookies.get('sessionid'); | ||
let visitedFetch = await fetch(`${endpoint}/api/adventures/all/?include_collections=true`, { | ||
headers: { | ||
Cookie: `sessionid=${sessionId}` | ||
} | ||
}); | ||
let adventures = (await visitedFetch.json()) as Adventure[]; | ||
|
||
return { | ||
props: { | ||
adventures | ||
} | ||
}; | ||
}) satisfies PageServerLoad; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<script lang="ts"> | ||
import type { PageData } from './$types'; | ||
// @ts-ignore | ||
import Calendar from '@event-calendar/core'; | ||
// @ts-ignore | ||
import TimeGrid from '@event-calendar/time-grid'; | ||
// @ts-ignore | ||
import DayGrid from '@event-calendar/day-grid'; | ||
export let data: PageData; | ||
let adventures = data.props.adventures; | ||
let dates: Array<{ | ||
id: string; | ||
start: string; | ||
end: string; | ||
title: string; | ||
backgroundColor?: string; | ||
}> = []; | ||
adventures.forEach((adventure) => { | ||
adventure.visits.forEach((visit) => { | ||
dates.push({ | ||
id: adventure.id, | ||
start: visit.start_date, | ||
end: visit.end_date, | ||
title: adventure.name + ' ' + adventure.category?.icon | ||
}); | ||
}); | ||
}); | ||
let plugins = [TimeGrid, DayGrid]; | ||
let options = { | ||
view: 'dayGridMonth', | ||
events: [...dates] | ||
}; | ||
</script> | ||
|
||
<h1 class="text-center text-2xl font-bold">Adventure Calendar</h1> | ||
|
||
<Calendar {plugins} {options} /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters