mirror of
https://github.com/seanmorley15/AdventureLog.git
synced 2025-07-18 20:39:36 +02:00
Fix collection link
This commit is contained in:
parent
cd55437f91
commit
5aef1eb8bd
3 changed files with 16 additions and 14 deletions
|
@ -10,6 +10,8 @@
|
|||
|
||||
let adventures: Adventure[] = [];
|
||||
|
||||
let isLoading: boolean = true;
|
||||
|
||||
export let user: User | null;
|
||||
|
||||
onMount(async () => {
|
||||
|
@ -17,19 +19,16 @@
|
|||
if (modal) {
|
||||
modal.showModal();
|
||||
}
|
||||
let formData = new FormData();
|
||||
formData.append('include_collections', 'false');
|
||||
let res = await fetch(`/adventures?/all`, {
|
||||
method: 'POST',
|
||||
body: formData
|
||||
let res = await fetch(`/api/adventures/all/?include_collections=false`, {
|
||||
method: 'GET'
|
||||
});
|
||||
|
||||
const result: ActionResult = deserialize(await res.text());
|
||||
console.log(result);
|
||||
const newAdventures = await res.json();
|
||||
|
||||
if (result.type === 'success' && result.data) {
|
||||
adventures = result.data.adventures as Adventure[];
|
||||
if (res.ok && adventures) {
|
||||
adventures = newAdventures;
|
||||
}
|
||||
isLoading = false;
|
||||
});
|
||||
|
||||
function close() {
|
||||
|
@ -53,11 +52,16 @@
|
|||
<!-- svelte-ignore a11y-no-noninteractive-tabindex -->
|
||||
<div class="modal-box w-11/12 max-w-5xl" role="dialog" on:keydown={handleKeydown} tabindex="0">
|
||||
<h1 class="text-center font-bold text-4xl mb-6">My Adventures</h1>
|
||||
{#if isLoading}
|
||||
<div class="flex justify-center items-center w-full mt-16">
|
||||
<span class="loading loading-spinner w-24 h-24"></span>
|
||||
</div>
|
||||
{/if}
|
||||
<div class="flex flex-wrap gap-4 mr-4 justify-center content-center">
|
||||
{#each adventures as adventure}
|
||||
<AdventureCard user={user ?? null} type="link" {adventure} on:link={add} />
|
||||
{/each}
|
||||
{#if adventures.length === 0}
|
||||
{#if adventures.length === 0 && !isLoading}
|
||||
<p class="text-center text-lg">
|
||||
No adventures found that can be linked to this collection.
|
||||
</p>
|
||||
|
|
|
@ -146,15 +146,13 @@ export const actions: Actions = {
|
|||
};
|
||||
}
|
||||
|
||||
let trip_id_number: number = parseInt(trip_id as string);
|
||||
|
||||
let res = await fetch(`${serverEndpoint}/api/adventures/${event.params.id}/`, {
|
||||
method: 'PATCH',
|
||||
headers: {
|
||||
Cookie: `${event.cookies.get('auth')}`,
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({ collection: trip_id_number })
|
||||
body: JSON.stringify({ collection: trip_id })
|
||||
});
|
||||
let res2 = await res.json();
|
||||
console.log(res2);
|
||||
|
|
|
@ -171,7 +171,7 @@
|
|||
<span class="text-sm text-muted-foreground">{adventure.location}</span>
|
||||
</div>
|
||||
{/if}
|
||||
{#if adventure.activity_types}
|
||||
{#if adventure.activity_types && adventure.activity_types?.length > 0}
|
||||
<div class="flex items-center gap-2">
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue