Skip to content

Commit

Permalink
Fix "Can't add phadders to phaddergroups" (#529)
Browse files Browse the repository at this point in the history
  • Loading branch information
RufusKoggRojder authored Oct 22, 2024
1 parent f332d8c commit 9d1f05f
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/lib/components/EntitySearch.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
isSearching = true;
timeout = setTimeout(getEntities(searchValue), 300);
};
export let year: number | undefined = undefined;
let timeout: ReturnType<typeof setTimeout> | undefined = undefined;
Expand All @@ -31,6 +32,9 @@
const url = new URL($page.url.origin + endpoint);
url.searchParams.append("search", searchValue);
if (year) {
url.searchParams.append("year", year.toString());
}
const data = await fetch(url, {
method: "GET",
})
Expand Down
2 changes: 2 additions & 0 deletions src/lib/components/MemberSearch.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
export let onSelect: ((member: Member) => void) | undefined;
export let handleSearch: (searchValue: string) => void;
export let endpoint = "/api/members";
export let year: number | undefined = undefined;
const getOption = (option: unknown) => option as Member;
</script>
Expand All @@ -19,6 +20,7 @@
bind:onSelect
bind:handleSearch
{...$$restProps}
{year}
>
<slot />
<div slot="entity" let:option>
Expand Down
2 changes: 2 additions & 0 deletions src/lib/components/forms/MemberSearchInput.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
let isSearching: boolean;
let handleSearch: (search: string) => void;
export let endpoint: string | undefined = undefined;
export let year: number | undefined = undefined;
</script>

<MemberSearch
Expand All @@ -20,6 +21,7 @@
onSelect={(selectedMember) => {
member = selectedMember;
}}
{year}
>
<div class="relative flex h-full flex-col gap-2">
{#if member}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import type { Member } from "@prisma/client";
import MemberSearchInput from "$lib/components/forms/MemberSearchInput.svelte";
export let year: number | undefined = undefined;
export let phadder = false;
export let groupId: string;
let member: Member | undefined = undefined;
Expand All @@ -26,6 +27,7 @@
bind:member
class="flex-1"
endpoint={phadder ? "/api/members/phadders" : undefined}
{year}
/>
<button type="submit" disabled={!member} class="btn btn-primary">+</button>
<input type="hidden" name="groupId" value={groupId} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
</ul>
</div>
</ScrollIndicatedBox>
<AddPersonInput groupId={group.id} phadder />
<AddPersonInput groupId={group.id} phadder year={group.year} />
</div>
{/if}
</div>

0 comments on commit 9d1f05f

Please sign in to comment.