feat: add YearControls component and update YearNav for localized year links
This commit is contained in:
@@ -12,7 +12,7 @@
|
|||||||
<div class="flex items-center gap-2">
|
<div class="flex items-center gap-2">
|
||||||
<Button variant="secondary" href="/">Prezenty tego roku</Button>
|
<Button variant="secondary" href="/">Prezenty tego roku</Button>
|
||||||
{#each years as year}
|
{#each years as year}
|
||||||
<Button href={`/year/${year.year}`} variant="secondary">
|
<Button href={`/rok/${year.year}`} variant="secondary">
|
||||||
{year.year}
|
{year.year}
|
||||||
</Button>
|
</Button>
|
||||||
{/each}
|
{/each}
|
||||||
|
|||||||
22
src/lib/components/organisms/YearControls.svelte
Normal file
22
src/lib/components/organisms/YearControls.svelte
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
<script>
|
||||||
|
import { refreshAll } from '$app/navigation';
|
||||||
|
import { DB } from '$lib/integrations/db';
|
||||||
|
import ActionCard from '../molecules/ActionCard.svelte';
|
||||||
|
import PersonModal from '../molecules/PersonModal.svelte';
|
||||||
|
|
||||||
|
let isOpen = $state(false);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div class="my-8 grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4">
|
||||||
|
<ActionCard title="Dodaj nową osobę" onClick={() => (isOpen = true)} />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<PersonModal
|
||||||
|
{isOpen}
|
||||||
|
onClose={() => (isOpen = false)}
|
||||||
|
title="Dodaj nową osobę"
|
||||||
|
onSave={async (data) => {
|
||||||
|
await DB.createPerson(data);
|
||||||
|
refreshAll();
|
||||||
|
}}
|
||||||
|
/>
|
||||||
15
src/routes/rok/[year]/+page.server.ts
Normal file
15
src/routes/rok/[year]/+page.server.ts
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
import { orchestrateLoaders } from '$lib/loaders';
|
||||||
|
import { LoaderYear } from '$lib/loaders/LoaderYear';
|
||||||
|
import { LoaderYears } from '$lib/loaders/LoaderYear';
|
||||||
|
|
||||||
|
export const load = async ({ params }: { params: { year: string } }) => {
|
||||||
|
const [yearData, yearsData] = await orchestrateLoaders([
|
||||||
|
LoaderYear(Number(params.year)),
|
||||||
|
LoaderYears()
|
||||||
|
]);
|
||||||
|
|
||||||
|
return {
|
||||||
|
year: yearData,
|
||||||
|
years: yearsData
|
||||||
|
};
|
||||||
|
};
|
||||||
11
src/routes/rok/[year]/+page.svelte
Normal file
11
src/routes/rok/[year]/+page.svelte
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<script>
|
||||||
|
import YearNav from '$lib/components/molecules/YearNav.svelte';
|
||||||
|
import YearControls from '$lib/components/organisms/YearControls.svelte';
|
||||||
|
import YearOverview from '$lib/components/organisms/YearOverview.svelte';
|
||||||
|
|
||||||
|
let { data } = $props();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<YearOverview data={data.year} />
|
||||||
|
<YearNav years={data.years} />
|
||||||
|
<YearControls />
|
||||||
Reference in New Issue
Block a user