diff --git a/frontend/src/lib/components/SuggestionList.svelte b/frontend/src/lib/components/SuggestionList.svelte index 193b33c..6c667a3 100644 --- a/frontend/src/lib/components/SuggestionList.svelte +++ b/frontend/src/lib/components/SuggestionList.svelte @@ -47,7 +47,6 @@ class={!picked_suggestions.includes(sug.uuid) ? "text-light-pine-green duration-100 hover:scale-150 dark:text-dark-pine-green" : "text-light-pine-muted dark:text-dark-pine-muted"} disabled={!!picked_suggestions.includes(sug.uuid)} onclick={async () => { - sug.upvode += 1 await vote(1, sug.uuid) }}> @@ -56,7 +55,6 @@ class={!picked_suggestions.includes(sug.uuid) ? "text-light-pine-red duration-100 hover:scale-150 dark:text-dark-pine-red" : "text-light-pine-muted dark:text-dark-pine-muted"} disabled={!!picked_suggestions.includes(sug.uuid)} onclick={async () => { - sug.upvode += 1 await vote(-1, sug.uuid) }}> diff --git a/frontend/src/lib/utils.ts b/frontend/src/lib/utils.ts index 6450247..470da85 100644 --- a/frontend/src/lib/utils.ts +++ b/frontend/src/lib/utils.ts @@ -1,8 +1,8 @@ -import { get_coords, type Coordinates } from "./gps" +import { type Coordinates } from "./gps" import { parseSong, parseSuggestion, type FetchError, type Song, type Suggestion } from "./types" -export const joinRoom = async function (roomId: string, coords: Coordinates): Promise<[FetchError | null, string]> { - let res = await fetch(`/api/join?room=${roomId}&lat=${coords.latitude}&lon=${coords.longitude}`) +export const joinRoom = async function (roomId: string, coords: Coordinates, pin: string): Promise<[FetchError | null, string]> { + let res = await fetch(`/api/join?room=${roomId}&lat=${coords.latitude}&lon=${coords.longitude}&pin=${pin}`) if (res.status != 200) { return [{ code: 400, message: "Cannot join the room" }, ""] diff --git a/frontend/src/routes/admin/[id]/+page.svelte b/frontend/src/routes/admin/[id]/+page.svelte index 07d6f0e..02f5f08 100644 --- a/frontend/src/routes/admin/[id]/+page.svelte +++ b/frontend/src/routes/admin/[id]/+page.svelte @@ -112,5 +112,7 @@ + + {/if} diff --git a/frontend/src/routes/room/[id]/+page.svelte b/frontend/src/routes/room/[id]/+page.svelte index 76984f3..84d8d67 100644 --- a/frontend/src/routes/room/[id]/+page.svelte +++ b/frontend/src/routes/room/[id]/+page.svelte @@ -31,7 +31,7 @@ } let sugg, queue, index - ;[returnError] = await joinRoom(data.roomId, coords) + ;[returnError] = await joinRoom(data.roomId, coords, data.pin) if (returnError) { return } diff --git a/frontend/src/routes/room/[id]/+page.ts b/frontend/src/routes/room/[id]/+page.ts index 1f9f77d..f3bea98 100644 --- a/frontend/src/routes/room/[id]/+page.ts +++ b/frontend/src/routes/room/[id]/+page.ts @@ -3,5 +3,6 @@ import type { PageLoad } from "./$types" export const load: PageLoad = ({ params, url }) => { return { roomId: params.id || "", + pin: url.searchParams.get("pin") || "", } } diff --git a/frontend/src/routes/room/create/+page.svelte b/frontend/src/routes/room/create/+page.svelte index c69b19e..d0009f3 100644 --- a/frontend/src/routes/room/create/+page.svelte +++ b/frontend/src/routes/room/create/+page.svelte @@ -9,9 +9,7 @@ let name: string = $state() let range: number = $state() - - const privateStyle = "bg-red-500" - const publicStyle = "bg-green-500" + let pin: number = $state() async function createRoom() { if (creating) { @@ -22,16 +20,12 @@ return } - let pin - if (privateRoom) { - pin = Math.floor(Math.random() * 10000) - } else { - pin = "" - } - creating = true - const res = await fetch(`/api/room/new?name=${encodeURIComponent(name)}&coords=${coord.latitude},${coord.longitude}&range=${encodeURIComponent(range ?? "100")}&pin=${pin}`, { method: "POST" }) + const res = await fetch( + `/api/room/new?name=${encodeURIComponent(name)}&coords=${coord.latitude},${coord.longitude}&range=${encodeURIComponent(range ?? "100")}&pin=${encodeURIComponent(pin ?? "")}`, + { method: "POST" } + ) const json = await res.json() @@ -50,8 +44,10 @@
{coord.latitude},{coord.longitude}

-
- Public Room: - - {#if !privateRoom} -

The room is flagged as public, everyone can join

- {/if} -
+