diff --git a/client/src/lib/Schedule.svelte b/client/src/lib/Schedule.svelte
index afd3dc9..a85d281 100644
--- a/client/src/lib/Schedule.svelte
+++ b/client/src/lib/Schedule.svelte
@@ -1,40 +1,13 @@
-
-
{new Date(date).toDateString()}
+
{new Date(date).toLocaleDateString(undefined, {
+ weekday: "short",
+ month: "short",
+ day: "numeric"
+ })}
-
Raw Data
- {#if $queryResult.data}
-
-
{JSON.stringify($queryResult.data, null, 2)}
-
+ {#if import.meta.env.ENV != "prod"}
+
Development
+
Raw Data
+ {#if $queryResult.data}
+
+
{JSON.stringify($queryResult.data, null, 2)}
+
+ {/if}
{/if}
diff --git a/client/src/lib/ScheduleItem.svelte b/client/src/lib/ScheduleItem.svelte
new file mode 100644
index 0000000..37fd678
--- /dev/null
+++ b/client/src/lib/ScheduleItem.svelte
@@ -0,0 +1,42 @@
+
+
+
+
+ {item.name}
+ {#each item.tags as tag}
+ {tag.name}
+ {/each}
+
+
+ {#if $deleteMutation.isLoading}
+
+ {:else}
+
+ {/if}
+
+ Delete
+
+
diff --git a/client/src/lib/ScheduleItemForm.svelte b/client/src/lib/ScheduleItemForm.svelte
new file mode 100644
index 0000000..5605914
--- /dev/null
+++ b/client/src/lib/ScheduleItemForm.svelte
@@ -0,0 +1,71 @@
+
+
+
diff --git a/client/src/lib/api.ts b/client/src/lib/api.ts
index 6385368..21262cd 100644
--- a/client/src/lib/api.ts
+++ b/client/src/lib/api.ts
@@ -1,14 +1,14 @@
const SCHEDULE_DAYS = 14;
const API_URL = import.meta.env.PROD ? "/api" : import.meta.env.VITE_API_URL;
-type ScheduleTag = {
+export type ScheduleTag = {
id: number,
createdAt: string,
updatedAt: string,
name: string
}
-type ScheduleItem = {
+export type ScheduleItem = {
id: number,
createdAt: string,
updatedAt: string,
@@ -19,7 +19,7 @@ type ScheduleItem = {
tags: ScheduleTag[]
};
-type Schedule = { [date: string]: ScheduleItem[] };
+export type Schedule = { [date: string]: ScheduleItem[] };
export async function getSchedule(): Promise
{
const res = await fetch(`${API_URL}/schedule?days=${SCHEDULE_DAYS}`);
@@ -31,7 +31,7 @@ export async function getSchedule(): Promise {
}
}
-export async function createScheduleItem(data: { name: string, duration: string, date: string, tags: string[] }) {
+export async function createScheduleItem(data: { name: string, date: string, tags: string[] }) {
const res = await fetch(`${API_URL}/items`, {
method: "POST",
headers: {
@@ -61,3 +61,10 @@ export async function deleteScheduleItem(id: number) {
throw new Error(`Invalid response code ${res?.status}`);
}
}
+
+export function prettyJoin(list: string[]) {
+ if (list.length === 1) return list[0];
+ const firsts = list.slice(0, list.length - 1);
+ const last = list[list.length - 1];
+ return `${firsts.join(", ")} and ${last}`;
+}
diff --git a/main.go b/main.go
index d0bd970..bedcd37 100644
--- a/main.go
+++ b/main.go
@@ -126,7 +126,7 @@ func main() {
}
if input.Duration == nil {
- return c.Status(fiber.StatusBadRequest).SendString("Duration is required")
+ input.Duration = &Duration{Duration: time.Hour}
}
if input.Date == nil {