<script setup>
import BasicTable from '@/Components/BasicTable.vue';
import SectionTitle from '@/Components/SectionTitle.vue';
import AppLayout from '@/Layouts/AppLayout.vue';
import { LinkOptions as C_LINK, TableColumn as C_TD, TableRow as C_TR} from '@/Shared/AppObjects';

const props = defineProps({
    chart: Object,
    clients: Array
});

const tableClientHeader = [
    C_TD.make('Nu.', 'header'),
    C_TD.make('Name', 'header')
];

let tableClientBody = [];

props.clients.forEach((p) => {
    const cols = [
        C_TD.make(Number(p.nu), 'body', {}, C_LINK.make('client.show', {'uuid': p.uuid})),
        C_TD.make(p.full_name, 'body')
    ];

    tableClientBody.push(C_TR.make(cols))
});

</script>

<template>
    <AppLayout title="Dashboard">
        <template #header>
            <h2 class="font-semibold text-xl text-gray-800 leading-tight">
                Dashboard
            </h2>
        </template>
        <div class="pt-12">
            <div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
                <div class="bg-white overflow-hidden shadow-xl sm:rounded-lg p-2">
                    <apexchart :width="chart.width" :height="chart.height" :type="chart.type" :options="chart.options" :series="chart.series"></apexchart>
                </div>
            </div>
        </div>
        <div class="py-12">
            <div class="max-w-7xl mx-auto sm:px-6 lg:px-8 grid grid-cols-2 gap-6">
                <div class="bg-white overflow-hidden shadow-xl sm:rounded-lg">
                    <SectionTitle class="p-4">
                        <template #title>
                            Terrain
                        </template>
                        <template #description>
                            List of new contracts for terrain work  
                        </template>
                    </SectionTitle>
                    <BasicTable :table-head="tableClientHeader" :table-body="tableClientBody"></BasicTable>
                </div>
                <div class="bg-white overflow-hidden shadow-xl sm:rounded-lg">
                    <SectionTitle class="p-4">
                        <template #title>
                            Persons
                        </template>
                        <template #description>
                            List of new persons
                        </template>
                    </SectionTitle>
                    <BasicTable :table-head="tableClientHeader" :table-body="tableClientBody"></BasicTable>
                </div>
            </div>
        </div>
    </AppLayout>
</template>
