Merge branch 'main' of https://repos.hackathon.bz.it/2025-summer/team-1
This commit is contained in:
commit
9ec601b263
6 changed files with 24 additions and 32 deletions
|
@ -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"}
|
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)}
|
disabled={!!picked_suggestions.includes(sug.uuid)}
|
||||||
onclick={async () => {
|
onclick={async () => {
|
||||||
sug.upvode += 1
|
|
||||||
await vote(1, sug.uuid)
|
await vote(1, sug.uuid)
|
||||||
}}><ThumbsUp /></button
|
}}><ThumbsUp /></button
|
||||||
>
|
>
|
||||||
|
@ -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"}
|
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)}
|
disabled={!!picked_suggestions.includes(sug.uuid)}
|
||||||
onclick={async () => {
|
onclick={async () => {
|
||||||
sug.upvode += 1
|
|
||||||
await vote(-1, sug.uuid)
|
await vote(-1, sug.uuid)
|
||||||
}}><ThumbsDown /></button
|
}}><ThumbsDown /></button
|
||||||
>
|
>
|
||||||
|
|
|
@ -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"
|
import { parseSong, parseSuggestion, type FetchError, type Song, type Suggestion } from "./types"
|
||||||
|
|
||||||
export const joinRoom = async function (roomId: string, coords: Coordinates): Promise<[FetchError | null, string]> {
|
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}`)
|
let res = await fetch(`/api/join?room=${roomId}&lat=${coords.latitude}&lon=${coords.longitude}&pin=${pin}`)
|
||||||
|
|
||||||
if (res.status != 200) {
|
if (res.status != 200) {
|
||||||
return [{ code: 400, message: "Cannot join the room" }, ""]
|
return [{ code: 400, message: "Cannot join the room" }, ""]
|
||||||
|
|
|
@ -112,5 +112,7 @@
|
||||||
<button class="rounded-md border border-dark-pine-muted p-2 hover:scale-105 active:scale-90 dark:bg-dark-pine-blue" onclick={playNext}>Next</button>
|
<button class="rounded-md border border-dark-pine-muted p-2 hover:scale-105 active:scale-90 dark:bg-dark-pine-blue" onclick={playNext}>Next</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<img class="absolute right-1 bottom-1" src="/api/room/qrcode?room=1000&pin=1234" />
|
||||||
|
<!-- @PERETTO fix here pls -->
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
let sugg, queue, index
|
let sugg, queue, index
|
||||||
;[returnError] = await joinRoom(data.roomId, coords)
|
;[returnError] = await joinRoom(data.roomId, coords, data.pin)
|
||||||
if (returnError) {
|
if (returnError) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,5 +3,6 @@ import type { PageLoad } from "./$types"
|
||||||
export const load: PageLoad = ({ params, url }) => {
|
export const load: PageLoad = ({ params, url }) => {
|
||||||
return {
|
return {
|
||||||
roomId: params.id || "",
|
roomId: params.id || "",
|
||||||
|
pin: url.searchParams.get("pin") || "",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,9 +9,7 @@
|
||||||
|
|
||||||
let name: string = $state()
|
let name: string = $state()
|
||||||
let range: number = $state()
|
let range: number = $state()
|
||||||
|
let pin: number = $state()
|
||||||
const privateStyle = "bg-red-500"
|
|
||||||
const publicStyle = "bg-green-500"
|
|
||||||
|
|
||||||
async function createRoom() {
|
async function createRoom() {
|
||||||
if (creating) {
|
if (creating) {
|
||||||
|
@ -22,16 +20,12 @@
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
let pin
|
|
||||||
if (privateRoom) {
|
|
||||||
pin = Math.floor(Math.random() * 10000)
|
|
||||||
} else {
|
|
||||||
pin = ""
|
|
||||||
}
|
|
||||||
|
|
||||||
creating = true
|
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()
|
const json = await res.json()
|
||||||
|
|
||||||
|
@ -50,8 +44,10 @@
|
||||||
<div class="flex flex-col gap-3 w-1/2">
|
<div class="flex flex-col gap-3 w-1/2">
|
||||||
<input
|
<input
|
||||||
bind:value={name}
|
bind:value={name}
|
||||||
placeholder="Room name"
|
placeholder="Room name (Required)"
|
||||||
class="p-2 text-xl rounded-md border-dark-pine-muted bg-light-pine-overlay hover:bg-dark-pine-base/20 dark:bg-dark-pine-overlay hover:dark:bg-light-pine-base/20 duration-100 outline-none focus:ring-2"
|
class="{name
|
||||||
|
? ''
|
||||||
|
: 'border-2 border-red-500'} p-2 text-xl rounded-md bg-light-pine-overlay hover:bg-dark-pine-base/20 dark:bg-dark-pine-overlay hover:dark:bg-light-pine-base/20 duration-100 outline-none focus:ring-2"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<input
|
<input
|
||||||
|
@ -67,21 +63,16 @@
|
||||||
<span>{coord.latitude},{coord.longitude}</span>
|
<span>{coord.latitude},{coord.longitude}</span>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div class="flex flex-row items-center gap-2">
|
<input
|
||||||
Public Room:
|
bind:value={pin}
|
||||||
<button class="cursor-pointer w-10 h-10 rounded-lg duration-200 flex items-center justify-center {privateRoom ? privateStyle : publicStyle}" onclick={() => (privateRoom = !privateRoom)}>
|
type="number"
|
||||||
{#if privateRoom}
|
max="9999"
|
||||||
<X />
|
placeholder="PIN (none if public)"
|
||||||
{:else}
|
class="p-2 text-xl rounded-md border-dark-pine-muted bg-light-pine-overlay hover:bg-dark-pine-base/20 dark:bg-dark-pine-overlay hover:dark:bg-light-pine-base/20 duration-100 outline-none focus:ring-2"
|
||||||
<Check />
|
/>
|
||||||
{/if}
|
|
||||||
</button>
|
|
||||||
{#if !privateRoom}
|
|
||||||
<p class="text-sm italic">The room is flagged as public, everyone can join</p>
|
|
||||||
{/if}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<button
|
<button
|
||||||
|
type="button"
|
||||||
class="cursor-pointer flex flex-row items-center justify-center gap-3 border border-dark-pine-muted bg-light-pine-overlay hover:bg-dark-pine-base/20 dark:bg-dark-pine-overlay hover:dark:bg-light-pine-base/20 duration-100 rounded-lg h-10 font-bold"
|
class="cursor-pointer flex flex-row items-center justify-center gap-3 border border-dark-pine-muted bg-light-pine-overlay hover:bg-dark-pine-base/20 dark:bg-dark-pine-overlay hover:dark:bg-light-pine-base/20 duration-100 rounded-lg h-10 font-bold"
|
||||||
onclick={createRoom}
|
onclick={createRoom}
|
||||||
>
|
>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue