diff --git a/src/lib/components/wishlists/ItemCard/ApprovalButtons.svelte b/src/lib/components/wishlists/ItemCard/ApprovalButtons.svelte index 25ad482..a0ae4fe 100644 --- a/src/lib/components/wishlists/ItemCard/ApprovalButtons.svelte +++ b/src/lib/components/wishlists/ItemCard/ApprovalButtons.svelte @@ -1,6 +1,4 @@
@@ -23,7 +17,9 @@ Deny {:else if user?.username === item.user?.username || user?.username === item.addedBy?.username} - + diff --git a/src/lib/components/wishlists/ItemCard/ItemCard.svelte b/src/lib/components/wishlists/ItemCard/ItemCard.svelte index 7fd668d..8abab4a 100644 --- a/src/lib/components/wishlists/ItemCard/ItemCard.svelte +++ b/src/lib/components/wishlists/ItemCard/ItemCard.svelte @@ -27,9 +27,10 @@ import { ItemAPI } from "$lib/api/items"; import ApprovalButtons from "./ApprovalButtons.svelte"; import ClaimButtons from "./ClaimButtons.svelte"; - import { invalidateAll } from "$app/navigation"; + import { goto, invalidateAll } from "$app/navigation"; import type { ItemVoidFunction } from "./ReorderButtons.svelte"; import ReorderButtons from "./ReorderButtons.svelte"; + import { page } from "$app/stores"; export let item: FullItem; export let user: (PartialUser & { id: string }) | undefined = undefined; @@ -116,6 +117,9 @@ const handleDelete = async () => modalStore.trigger(confirmDeleteModal); const handleApproval = async (approve = true) => modalStore.trigger(approvalModal(approve)); + const handleEdit = () => { + goto(`/wishlists/${item.user?.username}/edit/${item.id}?ref=${$page.url}`); + }; const handleClaim = async (unclaim = false) => { if (user?.id) { @@ -175,7 +179,8 @@ handleClaim, handleDelete, handlePurchased, - handleApproval + handleApproval, + handleEdit } }; @@ -251,6 +256,7 @@ on:approve={() => handleApproval(true)} on:deny={() => handleApproval(false)} on:delete={handleDelete} + on:edit={handleEdit} /> {/if} diff --git a/src/lib/components/wishlists/ItemDrawer.svelte b/src/lib/components/wishlists/ItemDrawer.svelte index 11f0ed6..db4c548 100644 --- a/src/lib/components/wishlists/ItemDrawer.svelte +++ b/src/lib/components/wishlists/ItemDrawer.svelte @@ -14,6 +14,22 @@ const handleDelete: VoidFunction = $drawerStore.meta.handleDelete; const handlePurchased: (v: boolean) => void = $drawerStore.meta.handlePurchased; const handleApproval: (v: boolean) => void = $drawerStore.meta.handleApproval; + const handleEdit: () => void = $drawerStore.meta.handleEdit; + + const onEdit = () => { + drawerStore.close(); + handleEdit(); + }; + + let imageUrl: string; + if (item.imageUrl) { + try { + new URL(item.imageUrl); + imageUrl = item.imageUrl; + } catch { + imageUrl = `/api/assets/${item.imageUrl}`; + } + }
@@ -24,8 +40,8 @@ {item.name}
- {#if item.imageUrl} - product + {#if imageUrl} + product {/if}
@@ -59,7 +75,7 @@ on:approve={() => handleApproval(true)} on:deny={() => handleApproval(false)} on:delete={handleDelete} - on:edit={() => getDrawerStore().close()} + on:edit={onEdit} />