from typing import TypedDict

from folkugat_web.model import playlists as model

PlaylistRowTuple = tuple[int, int, int, int | None]


class PlaylistRowDict(TypedDict):
    id: int | None
    session_id: int
    set_id: int
    tema_id: int | None


def playlist_entry_to_row(tema_in_set: model.PlaylistEntry) -> PlaylistRowDict:
    return {
        'id': tema_in_set.id,
        'session_id': tema_in_set.session_id,
        'set_id': tema_in_set.set_id,
        'tema_id': tema_in_set.tema_id,
    }


def row_to_playlist_entry(row: PlaylistRowTuple) -> model.PlaylistEntry:
    return model.PlaylistEntry(
        id=row[0],
        session_id=row[1],
        set_id=row[2],
        tema_id=row[3],
    )
