team-1/frontend/src/routes/admin/[id]/+page.svelte

44 lines
1.1 KiB
Svelte
Raw Normal View History

2025-08-02 00:52:13 +02:00
<script lang="ts">
import QueueSlider from "$lib/components/QueueSlider.svelte"
2025-08-02 03:54:26 +02:00
import { type Song } from "$lib/types"
import { onMount } from "svelte"
import type { FetchError } from "$lib/types"
import { getQueueSongs, triggerPlayNext } from "$lib/utils.js"
2025-08-02 00:52:13 +02:00
2025-08-02 03:54:26 +02:00
let { data } = $props()
let queueSongs = $state<Song[]>([])
let playingIndex = $state<number>()
let returnError = $state<FetchError | null>()
onMount(async () => {
let songs, index
;[returnError, songs, index] = await getQueueSongs(data.roomId)
queueSongs = songs
playingIndex = index
})
$effect(() => {
$inspect(queueSongs)
})
async function playNext() {
let songs, index
;[returnError, songs, index] = await triggerPlayNext(data.roomId)
if (returnError) return
if (songs.length != 0) queueSongs = songs
playingIndex = index
}
2025-08-02 00:52:13 +02:00
</script>
2025-08-02 03:54:26 +02:00
{returnError}
2025-08-02 00:52:13 +02:00
<div class="flex w-full flex-col items-center justify-center p-4 lg:p-10">
2025-08-02 03:54:26 +02:00
<QueueSlider {queueSongs} {playingIndex} />
<button onclick={playNext}>Next</button>
2025-08-02 00:52:13 +02:00
</div>