<script lang="ts">
import type { AniListAuthorisation } from "$lib/Data/AniList/identity";
import Skeleton from "$lib/Loading/Skeleton.svelte";
import locale from "$stores/locale";
import ListTitle from "../ListTitle.svelte";
import AnimeList from "$lib/List/Anime/DueAnimeList.svelte";
import { onMount } from "svelte";
import stateBin from "$stores/stateBin";

export let userIdentity: { id: number };
export let user: AniListAuthorisation;

onMount(() => {
	$stateBin.dueAnimeListOpen ??= true;
});
</script>

<details bind:open={$stateBin.dueAnimeListOpen} class="list list-due">
  {#if userIdentity.id !== -2}
    <AnimeList {user} />
  {:else}
    <ListTitle title={$locale().lists.due.episodes} />

    <Skeleton card={false} count={5} height="0.9rem" list />
  {/if}
</details>
