Just need a checkpoint cos nothings working atm
This commit is contained in:
@@ -27,8 +27,8 @@
|
|||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="flex flex-row items-center justify-between">
|
<div class="flex flex-row items-center space-x-2">
|
||||||
<h1 class="text-3xl">{formatDate(entry.date)}</h1>
|
<h1 class="text-3xl mr-auto">{formatDate(entry.date)}</h1>
|
||||||
|
|
||||||
{#if !edit}
|
{#if !edit}
|
||||||
<button
|
<button
|
||||||
@@ -36,17 +36,22 @@
|
|||||||
onclick={() => (edit = !edit)}>Edit</button
|
onclick={() => (edit = !edit)}>Edit</button
|
||||||
>
|
>
|
||||||
{:else}
|
{:else}
|
||||||
<button class="bg-destructive py-2 px-3 rounded-lg" onclick={deleteEntry}>
|
<button
|
||||||
|
class="bg-destructive py-2 px-3 rounded-lg hover:opacity-60 transition-brightness"
|
||||||
|
onclick={deleteEntry}
|
||||||
|
>
|
||||||
delete
|
delete
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
class="bg-secondary py-2 px-3 rounded-lg"
|
class="bg-primary text-accent py-2 px-3 rounded-lg hover:opacity-60 transition-brightness"
|
||||||
|
>
|
||||||
|
save
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
class="bg-secondary py-2 px-3 rounded-lg hover:opacity-60 transition-brightness"
|
||||||
onclick={() => (edit = false)}
|
onclick={() => (edit = false)}
|
||||||
>
|
>
|
||||||
cancel
|
cancel
|
||||||
</button>
|
</button>
|
||||||
<button class="bg-primary text-accent py-2 px-3 rounded-lg">
|
|
||||||
save
|
|
||||||
</button>
|
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -2,25 +2,32 @@
|
|||||||
import "./layout.css";
|
import "./layout.css";
|
||||||
import favicon from "$lib/assets/favicon.svg";
|
import favicon from "$lib/assets/favicon.svg";
|
||||||
import { ModeWatcher } from "mode-watcher";
|
import { ModeWatcher } from "mode-watcher";
|
||||||
import { today, getLocalTimeZone } from "@internationalized/date";
|
import { CalendarDate, today, getLocalTimeZone } from "@internationalized/date";
|
||||||
|
|
||||||
import Header from "$lib/components/header.svelte";
|
import Header from "$lib/components/header.svelte";
|
||||||
import Calendar from "$lib/components/calendar.svelte";
|
import Calendar from "$lib/components/calendar.svelte";
|
||||||
import EntrySummaryView from "$lib/components/entrySummaryView.svelte";
|
import EntrySummaryView from "$lib/components/entrySummaryView.svelte";
|
||||||
import { onMount } from "svelte";
|
|
||||||
import { goto } from "$app/navigation";
|
import { goto } from "$app/navigation";
|
||||||
|
|
||||||
let { children } = $props();
|
let { children, data } = $props();
|
||||||
let dateValue = $state(today(getLocalTimeZone()));
|
let dateValue = $derived(data.date);
|
||||||
let entries = $state([])
|
let entries = $derived(data.entries)
|
||||||
|
|
||||||
onMount(async () => {
|
// async function fetchForMonth(d: CalendarDate) {
|
||||||
const res = await fetch(
|
// const res = await fetch(
|
||||||
`/api/entry?month=${dateValue.year}-${dateValue.month}`,
|
// `/api/entry?month=${d.year}-${dateValue.month}`,
|
||||||
);
|
// );
|
||||||
|
|
||||||
entries = await res.json()
|
// return await res.json()
|
||||||
});
|
// }
|
||||||
|
|
||||||
|
// onMount(async () => {
|
||||||
|
// const res = await fetch(
|
||||||
|
// `/api/entry?month=${dateValue.year}-${dateValue.month}`,
|
||||||
|
// );
|
||||||
|
|
||||||
|
// entries = await res.json()
|
||||||
|
// });
|
||||||
|
|
||||||
$effect(() => {
|
$effect(() => {
|
||||||
goto(`/${dateValue}`)
|
goto(`/${dateValue}`)
|
||||||
@@ -37,7 +44,6 @@
|
|||||||
<Header />
|
<Header />
|
||||||
|
|
||||||
{#key dateValue}
|
{#key dateValue}
|
||||||
<!-- <Editor {dateValue} /> -->
|
|
||||||
{@render children()}
|
{@render children()}
|
||||||
{/key}
|
{/key}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
13
src/routes/+layout.ts
Normal file
13
src/routes/+layout.ts
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
import { today, getLocalTimeZone } from "@internationalized/date";
|
||||||
|
|
||||||
|
export async function load({ params, fetch }) {
|
||||||
|
const dateValue = today(getLocalTimeZone());
|
||||||
|
|
||||||
|
const res = await fetch(`/api/entry?month=${dateValue.year}-${dateValue.month}`)
|
||||||
|
const entries = await res.json()
|
||||||
|
|
||||||
|
return {
|
||||||
|
entries: entries,
|
||||||
|
date: dateValue
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
export const load = async ({ fetch, params }) => {
|
|
||||||
const res = await fetch("/api/entry/all");
|
|
||||||
const allEntries = await res.json();
|
|
||||||
|
|
||||||
const today = new Date().toISOString().split('T')[0];
|
|
||||||
const todayEntry = await fetch(`/api/entry?date=${today}`);
|
|
||||||
const todayEntryData = await todayEntry.json();
|
|
||||||
|
|
||||||
return {
|
|
||||||
all: allEntries,
|
|
||||||
today: todayEntryData,
|
|
||||||
};
|
|
||||||
};
|
|
||||||
@@ -1,8 +1,16 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import Editor from "$lib/components/editor.svelte";
|
||||||
|
|
||||||
let {
|
let {
|
||||||
data
|
data
|
||||||
} = $props()
|
} = $props()
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{JSON.stringify(data)}
|
|
||||||
|
{#if data.entry.id}
|
||||||
|
<Editor dateValue={data.date} />
|
||||||
|
{:else}
|
||||||
|
No entry exists for {data.date}
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
|||||||
@@ -2,5 +2,5 @@
|
|||||||
export async function load({ params, fetch }) {
|
export async function load({ params, fetch }) {
|
||||||
const res = await fetch(`/api/entry?date=${params.date}`);
|
const res = await fetch(`/api/entry?date=${params.date}`);
|
||||||
const entries = await res.json();
|
const entries = await res.json();
|
||||||
return { entries };
|
return { entry: entries };
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user