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-02 08:31:31 +02:00
|
|
|
import { ThumbsUp, ThumbsDown } from "@lucide/svelte"
|
2025-08-01 22:04:55 +02:00
|
|
|
|
2025-08-02 05:16:37 +02:00
|
|
|
let { suggestions = $bindable(), roomId }: { suggestions: Suggestion[]; roomId: string } = $props()
|
2025-08-02 02:12:41 +02:00
|
|
|
|
2025-08-02 04:34:45 +02:00
|
|
|
async function vote(idx: number, amount: number, songId: string) {
|
|
|
|
suggestions[idx].upvote += amount
|
2025-08-02 02:12:41 +02:00
|
|
|
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 04:34:45 +02:00
|
|
|
{#if suggestions.length == 0}
|
|
|
|
<p>No suggestions yet! Try to add a new one using the <b>Add</b> button</p>
|
|
|
|
{/if}
|
|
|
|
|
|
|
|
{#each suggestions as sug, idx}
|
2025-08-02 05:16:37 +02:00
|
|
|
<div class="flex h-[80px] w-full flex-row gap-2 rounded border-2 border-indigo-600 bg-indigo-500 p-2 shadow-md duration-100 hover:bg-indigo-400">
|
2025-08-02 08:31:31 +02:00
|
|
|
<div class="flex w-3/4 flex-row gap-2 items-center">
|
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" />
|
2025-08-02 08:31:31 +02:00
|
|
|
<div class="text-white flex-col w-fit h-fit">
|
|
|
|
<b>{sug.title}</b>
|
2025-08-02 04:34:45 +02:00
|
|
|
<p>{sug.artist}</p>
|
|
|
|
</div>
|
2025-08-01 22:04:55 +02:00
|
|
|
</div>
|
|
|
|
<div class="flex w-1/4 flex-row items-center justify-center gap-2">
|
|
|
|
<button
|
2025-08-02 08:31:31 +02:00
|
|
|
class="text-green-500"
|
2025-08-01 22:04:55 +02:00
|
|
|
onclick={() => {
|
2025-08-02 04:34:45 +02:00
|
|
|
vote(idx, 1, sug.uuid)
|
2025-08-02 08:31:31 +02:00
|
|
|
}}><ThumbsUp /></button
|
2025-08-01 22:04:55 +02:00
|
|
|
>
|
2025-08-02 05:16:37 +02:00
|
|
|
<p class="font-semibold text-white">{sug.upvote}</p>
|
2025-08-01 22:04:55 +02:00
|
|
|
<button
|
2025-08-02 08:31:31 +02:00
|
|
|
class="duration-100 hover:scale-150 text-red-500"
|
2025-08-01 22:04:55 +02:00
|
|
|
onclick={() => {
|
2025-08-02 04:34:45 +02:00
|
|
|
vote(idx, -1, sug.uuid)
|
2025-08-02 08:31:31 +02:00
|
|
|
}}><ThumbsDown /></button
|
2025-08-01 22:04:55 +02:00
|
|
|
>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
{/each}
|
|
|
|
</div>
|