Skip to content

Commit 0a6a401

Browse files
authored
Merge pull request #187 from seanmorley15/development
Fix collection link
2 parents 8ea0724 + 5aef1eb commit 0a6a401

File tree

3 files changed

+16
-14
lines changed

3 files changed

+16
-14
lines changed

frontend/src/lib/components/AdventureLink.svelte

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,25 @@
1010
1111
let adventures: Adventure[] = [];
1212
13+
let isLoading: boolean = true;
14+
1315
export let user: User | null;
1416
1517
onMount(async () => {
1618
modal = document.getElementById('my_modal_1') as HTMLDialogElement;
1719
if (modal) {
1820
modal.showModal();
1921
}
20-
let formData = new FormData();
21-
formData.append('include_collections', 'false');
22-
let res = await fetch(`/adventures?/all`, {
23-
method: 'POST',
24-
body: formData
22+
let res = await fetch(`/api/adventures/all/?include_collections=false`, {
23+
method: 'GET'
2524
});
2625
27-
const result: ActionResult = deserialize(await res.text());
28-
console.log(result);
26+
const newAdventures = await res.json();
2927
30-
if (result.type === 'success' && result.data) {
31-
adventures = result.data.adventures as Adventure[];
28+
if (res.ok && adventures) {
29+
adventures = newAdventures;
3230
}
31+
isLoading = false;
3332
});
3433
3534
function close() {
@@ -53,11 +52,16 @@
5352
<!-- svelte-ignore a11y-no-noninteractive-tabindex -->
5453
<div class="modal-box w-11/12 max-w-5xl" role="dialog" on:keydown={handleKeydown} tabindex="0">
5554
<h1 class="text-center font-bold text-4xl mb-6">My Adventures</h1>
55+
{#if isLoading}
56+
<div class="flex justify-center items-center w-full mt-16">
57+
<span class="loading loading-spinner w-24 h-24"></span>
58+
</div>
59+
{/if}
5660
<div class="flex flex-wrap gap-4 mr-4 justify-center content-center">
5761
{#each adventures as adventure}
5862
<AdventureCard user={user ?? null} type="link" {adventure} on:link={add} />
5963
{/each}
60-
{#if adventures.length === 0}
64+
{#if adventures.length === 0 && !isLoading}
6165
<p class="text-center text-lg">
6266
No adventures found that can be linked to this collection.
6367
</p>

frontend/src/routes/adventures/[id]/+page.server.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,15 +146,13 @@ export const actions: Actions = {
146146
};
147147
}
148148

149-
let trip_id_number: number = parseInt(trip_id as string);
150-
151149
let res = await fetch(`${serverEndpoint}/api/adventures/${event.params.id}/`, {
152150
method: 'PATCH',
153151
headers: {
154152
Cookie: `${event.cookies.get('auth')}`,
155153
'Content-Type': 'application/json'
156154
},
157-
body: JSON.stringify({ collection: trip_id_number })
155+
body: JSON.stringify({ collection: trip_id })
158156
});
159157
let res2 = await res.json();
160158
console.log(res2);

frontend/src/routes/adventures/[id]/+page.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@
171171
<span class="text-sm text-muted-foreground">{adventure.location}</span>
172172
</div>
173173
{/if}
174-
{#if adventure.activity_types}
174+
{#if adventure.activity_types && adventure.activity_types?.length > 0}
175175
<div class="flex items-center gap-2">
176176
<svg
177177
xmlns="http://www.w3.org/2000/svg"

0 commit comments

Comments
 (0)