2025-08-01 21:10:03 +02:00
|
|
|
<script lang="ts">
|
2025-08-02 02:12:41 +02:00
|
|
|
import type { Suggestion } from "$lib/types"
|
2025-08-01 22:04:55 +02:00
|
|
|
|
2025-08-02 02:12:41 +02:00
|
|
|
let { suggestions, roomId }: { suggestions: Suggestion[]; roomId: string } = $props()
|
|
|
|
|
|
|
|
async function vote(amount: number, songId: string) {
|
|
|
|
await fetch(`/api/song/voting?room=${roomId}&song=${songId}&increment=${amount}`, { method: "POST" })
|
|
|
|
}
|
2025-08-01 21:10:03 +02:00
|
|
|
</script>
|
2025-08-01 22:04:55 +02:00
|
|
|
|
|
|
|
<div class="flex h-full w-full flex-col items-center gap-2 overflow-y-auto">
|
2025-08-02 02:12:41 +02:00
|
|
|
{#each suggestions as sug}
|
2025-08-01 22:04:55 +02:00
|
|
|
<div class="flex h-[80px] w-full flex-row gap-2 rounded border-2 border-black p-2">
|
|
|
|
<div class="flex w-3/4 flex-row gap-2">
|
2025-08-02 02:12:41 +02:00
|
|
|
<img class="w-[60px] min-w-[60px] rounded" src={`https://lastfm.freetls.fastly.net/i/u/174s/${sug.image_id}.png`} alt="Song cover" />
|
|
|
|
<h1>{sug.title} - {sug.artist}</h1>
|
2025-08-01 22:04:55 +02:00
|
|
|
</div>
|
|
|
|
<div class="flex w-1/4 flex-row items-center justify-center gap-2">
|
|
|
|
<button
|
|
|
|
onclick={() => {
|
2025-08-02 02:12:41 +02:00
|
|
|
vote(1, sug.uuid)
|
|
|
|
}}>+1</button
|
2025-08-01 22:04:55 +02:00
|
|
|
>
|
2025-08-02 02:12:41 +02:00
|
|
|
<p>{sug.upvote}</p>
|
2025-08-01 22:04:55 +02:00
|
|
|
<button
|
|
|
|
onclick={() => {
|
2025-08-02 02:12:41 +02:00
|
|
|
vote(-1, sug.uuid)
|
|
|
|
}}>-1</button
|
2025-08-01 22:04:55 +02:00
|
|
|
>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
{/each}
|
|
|
|
</div>
|