<template>
    <div class="flex items-center justify-between">
        <div class="flex items-center gap-10">
            <Icon @click="router.push('/')" name="gg:arrow-left-o" size="44" class="cursor-pointer text-primary-500"/>
            <h1 class="text-3xl font-bold uppercase text-primary-500">listes des réceptions en attente</h1>
        </div>
    </div>

    <div class="px-[86px]">
        <div class="mt-6 border border-slate-200 mb-16">
            <div class="grid grid-cols-5 gap-4 bg-slate-100 px-4 py-3 text-sm font-semibold uppercase tracking-wide">
                <div>Fournisseur</div>
                <div>Adresse</div>
                <div>Type réception</div>
                <div>Transporteur</div>
                <div>Immatriculation</div>
            </div>
            <div
                v-for="reception in receptionList"
                :key="reception.id"
                class="grid grid-cols-5 gap-4 px-4 py-3 text-sm hover:bg-slate-50 cursor-pointer border-t border-slate-200"
                role="button"
                tabindex="0"
                @click="goToReception(reception.id)"
                @keydown.enter="goToReception(reception.id)"
            >
                <div>{{ reception.supplier?.name }}</div>
                <div>{{ reception.address?.fullAddress }}</div>
                <div>{{ reception.receptionType?.label }}</div>
                <div>{{ reception.carrier?.name }}</div>
                <div>{{ reception.licensePlate }}</div>
            </div>
        </div>
    </div>
</template>

<script setup lang="ts">
import type {ReceptionData} from "~/services/dto/reception-data";
import {getReceptionList} from "~/services/reception";

const receptionList = ref<ReceptionData[]>()
const router = useRouter()

const goToReception = (id: number) => {
        router.push(`/reception/${id}`)
}

onMounted(async () => {
    receptionList.value = await getReceptionList(false)
})
</script>
