diff --git a/ui/src/lib/components/CheckedLabel.svelte b/ui/src/lib/components/CheckedLabel.svelte new file mode 100644 index 0000000..ab3ee77 --- /dev/null +++ b/ui/src/lib/components/CheckedLabel.svelte @@ -0,0 +1,19 @@ + + + + {#if checked} + + + + {:else} + + + + {/if} + {@render children()} + \ No newline at end of file diff --git a/ui/src/lib/components/Navbar.svelte b/ui/src/lib/components/Navbar.svelte index a3f2da8..13d791f 100644 --- a/ui/src/lib/components/Navbar.svelte +++ b/ui/src/lib/components/Navbar.svelte @@ -1,7 +1,8 @@ + +
+ {#if achievementUnlocked()} + achievement + {:else} + achievement + {/if} +
+ {achievement.name} +
+ {#each achievement.goals as goal, i} +
+ {goal.description} +
+ {/each} +
+ + + +
+
\ No newline at end of file diff --git a/ui/src/lib/components/achievements/AchievementDisplay.svelte b/ui/src/lib/components/achievements/AchievementDisplay.svelte new file mode 100644 index 0000000..74dab60 --- /dev/null +++ b/ui/src/lib/components/achievements/AchievementDisplay.svelte @@ -0,0 +1,39 @@ + + +{#if $query.isSuccess} +
+
+ +
+ {#each $query.data as service} + + {/each} +
+ + {#if admin} + + {/if} +{/if} + diff --git a/ui/src/lib/components/achievements/AchievementEditModal.svelte b/ui/src/lib/components/achievements/AchievementEditModal.svelte new file mode 100644 index 0000000..fb5615d --- /dev/null +++ b/ui/src/lib/components/achievements/AchievementEditModal.svelte @@ -0,0 +1,74 @@ + +
+ + + + + +
+
+ +
+

Edit Service

+
+ // Middle Content +
+ +
+ + +
+
+
+
+
+
+
+ diff --git a/ui/src/lib/components/achievements/AchievementServiceGroup.svelte b/ui/src/lib/components/achievements/AchievementServiceGroup.svelte new file mode 100644 index 0000000..5a7d989 --- /dev/null +++ b/ui/src/lib/components/achievements/AchievementServiceGroup.svelte @@ -0,0 +1,72 @@ + + +{#if $query.isSuccess} +
+
keyClickHandler(ev, toggle)} + tabindex="0" + > + + {toTitleCase(service.name)} + {#if editAllowed} + + {/if} + + + + +
+ + {#if isOpen} +
+ {#each $query.data as achievement } + + {/each} +
+ {/if} +
+{/if} diff --git a/ui/src/lib/components/icons/AchievementIcon.svelte b/ui/src/lib/components/icons/AchievementIcon.svelte new file mode 100644 index 0000000..8d3056a --- /dev/null +++ b/ui/src/lib/components/icons/AchievementIcon.svelte @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ui/src/lib/components/icons/ArrowNoBaseIcon.svelte b/ui/src/lib/components/icons/ArrowNoBaseIcon.svelte new file mode 100644 index 0000000..81e7f95 --- /dev/null +++ b/ui/src/lib/components/icons/ArrowNoBaseIcon.svelte @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/ui/src/lib/components/icons/CheckIcon.svelte b/ui/src/lib/components/icons/CheckIcon.svelte new file mode 100644 index 0000000..5f6c943 --- /dev/null +++ b/ui/src/lib/components/icons/CheckIcon.svelte @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/ui/src/lib/components/icons/CrossIcon.svelte b/ui/src/lib/components/icons/CrossIcon.svelte new file mode 100644 index 0000000..37700b1 --- /dev/null +++ b/ui/src/lib/components/icons/CrossIcon.svelte @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/ui/src/lib/globalFunctions-Types.ts b/ui/src/lib/globalFunctions-Types.ts index f3f63d7..7555c6d 100644 --- a/ui/src/lib/globalFunctions-Types.ts +++ b/ui/src/lib/globalFunctions-Types.ts @@ -15,6 +15,24 @@ export type ProfileData = { export type CurrentUser = { id: number; username: string; + admin: boolean; +}; + +export type AchievementService = { + id: number; + name: string; +}; + +export type Achievement = { + id: number; + name: string; + goals: Goal[]; +}; + +export type Goal = { + id: number; + description: string; + sequence: number; }; export function toTitleCase(str: string) { @@ -60,3 +78,15 @@ export async function submitAbout(userId: number, about: string): Promise { + return fetch(`${BACKEND_URL}/api/services`, { + credentials: 'include' + }).then((r) => r.json()); +} + +export async function getAchievementsFromService(serviceId: number): Promise { + return fetch(`${BACKEND_URL}/api/services/${serviceId}/achievements`, { + credentials: 'include' + }).then((r) => r.json()); +} diff --git a/ui/src/routes/+page.svelte b/ui/src/routes/+page.svelte index 00651f5..67064bb 100644 --- a/ui/src/routes/+page.svelte +++ b/ui/src/routes/+page.svelte @@ -12,7 +12,7 @@ } ); -
+
{#if $query.isSuccess} diff --git a/ui/src/routes/achievements/+page.svelte b/ui/src/routes/achievements/+page.svelte new file mode 100644 index 0000000..2b6948c --- /dev/null +++ b/ui/src/routes/achievements/+page.svelte @@ -0,0 +1,34 @@ + +
+ + {#if $query.isSuccess} + +
+ {:else if $query.isLoading} +

+ Hold on, we're checking if you're logged in... +

+ {:else} +

+ Something went wrong, couldn't reach backend +

+ {/if} +
+
+
+
+
+
diff --git a/ui/src/routes/profile/[username]/+page.svelte b/ui/src/routes/profile/[username]/+page.svelte index a5f7591..e6ee0a9 100644 --- a/ui/src/routes/profile/[username]/+page.svelte +++ b/ui/src/routes/profile/[username]/+page.svelte @@ -17,7 +17,7 @@ -
+
{#if $query.isSuccess}