<script lang="ts">
    import { jobOffers, modules, team } from "../../store"
    import Worldcard from "../widgets/Worldcard/worldcard.svelte"
    import Boxlist from "../widgets/boxlist.svelte"
    import ExtendableBox from "../widgets/extendableBox.svelte"
    import IconCycleBox from "../widgets/iconCycleBox.svelte"
    import IconCycleCircle from "../widgets/iconCycleCircle.svelte"
    import PageLinkBlocks from "../widgets/pageLinkBlocks.svelte"
    import Persons from "../widgets/persons.svelte"

    export let col: { contentType: "moduleImport"; moduleImport: string }
    export let pageId: string

    let module = $modules[col.moduleImport] || {}
    $: module = $modules[col.moduleImport] || {}
    $: console.log(
        "peron",
        $team,
        Object.values($team).filter((p) => p.personType == "employee")
    )
</script>

{#if module.type == "iconCycleCircle"}
    <IconCycleCircle iconCycleCircle="{module.iconCycleCircle}" pageId="{pageId}" />
{:else if module.type == "iconCycleSquare"}
    <IconCycleBox iconCycleSquare="{module.iconCycleSquare}" pageId="{pageId}" />
{:else if module.type == "worldCard"}
    <Worldcard worldCard="{module.worldCard}" pageId="{pageId}" />
{:else if module.type == "chefTeam"}
    <Persons persons="{Object.values($team).filter((p) => p.personType == 'chef')}" pageId="{pageId}" />
{:else if module.type == "employeeTeam"}
    <Boxlist persons="{Object.values($team).filter((p) => p.personType == 'employee')}" />
{:else if module.type == "jobOffer"}
    <ExtendableBox pages="{Object.values($jobOffers)}" />
{:else if module.type == "jobOfferLink"}
    <PageLinkBlocks pages="{Object.values($jobOffers)}" pageReference="{module.jobOfferPage}" />
{/if}
