Skip to content

Commit

Permalink
slug validation and added a view page
Browse files Browse the repository at this point in the history
  • Loading branch information
WhyAsh5114 committed Dec 27, 2023
1 parent 0b70f81 commit 9d3b296
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
12 changes: 11 additions & 1 deletion src/routes/exerciseSplits/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
<script lang="ts">
export let data;
</script>

<h2>Exercise splits</h2>

<div class="h-px flex flex-col grow overflow-y-auto"></div>
<div class="h-px flex flex-col grow overflow-y-auto gap-1">
{#each data.exerciseSplits as exerciseSplit}
<a class="flex p-2 bg-primary rounded-md" href="/exerciseSplits/view/{exerciseSplit._id}">
<span class="font-semibold">{exerciseSplit.name}</span>
</a>
{/each}
</div>
<a class="btn btn-accent" href="/exerciseSplits/templates">Create new split</a>
2 changes: 1 addition & 1 deletion src/routes/exerciseSplits/+page.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export const load = async ({ fetch }) => {
const response = await fetch("/api/exerciseSplits");
if (response.ok) {
return { exerciseSplits: (await response.json()) as ExerciseSplit[] };
return { exerciseSplits: (await response.json()) as WithSID<ExerciseSplit>[] };
}
return { exerciseSplits: [] };
};
2 changes: 2 additions & 0 deletions src/routes/exerciseSplits/[mode]/+page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ export const load = ({ url, params }) => {
// TODO: Load split to edit into stores and return it
}

if (params.mode !== "new") error(404, "Not found");

const cloneId = url.searchParams.get("cloneId");
if (cloneId) {
// TODO: fetch split to clone from, and return it
Expand Down
Empty file.

0 comments on commit 9d3b296

Please sign in to comment.