mirror of
https://github.com/ichsankurnia/hats-app.git
synced 2026-12-06 21:56:27 +00:00
initial commit for new hats app
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
'use client'
|
||||
|
||||
import { FC } from 'react';
|
||||
import { usePathname, useRouter, useSearchParams } from 'next/navigation';
|
||||
import dayjs from 'dayjs';
|
||||
import { DatePicker } from 'antd';
|
||||
|
||||
type Props = {};
|
||||
|
||||
const DateRangePicker: FC<Props> = () => {
|
||||
const searchParams = useSearchParams();
|
||||
const router = useRouter()
|
||||
const path = usePathname()
|
||||
|
||||
const startDate = searchParams!.get('start_date') as string || dayjs().subtract(1, 'month')
|
||||
const endDate = searchParams!.get('end_date') as string || dayjs()
|
||||
|
||||
const handleChange = (values: any) => {
|
||||
if (values) {
|
||||
const url = `${path}?start_date=${dayjs(values[0]).format('YYYY-MM-DD')}&end_date=${dayjs(values[1]).format('YYYY-MM-DD')}`
|
||||
router.replace(url)
|
||||
} else {
|
||||
const url = `${path}`
|
||||
router.replace(url)
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<DatePicker.RangePicker size='small' className='p-2 rounded-lg' picker='date' format='MMM DD, YYYY'
|
||||
onChange={handleChange} defaultValue={[dayjs(startDate), dayjs(endDate)]}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
export default DateRangePicker;
|
||||
@@ -0,0 +1,114 @@
|
||||
'use client'
|
||||
import { FC, useState } from 'react';
|
||||
import dayjs from 'dayjs';
|
||||
import { useSession } from 'next-auth/react';
|
||||
import { Icons } from '@/components/Icons';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import DateRangePicker from './DateRangePicker';
|
||||
import { exportTable } from '@/lib/exportExcel';
|
||||
import { type IHistory } from '@/app/(dashboard)/history/components/type';
|
||||
import { type IUser } from '@/app/admin/administration/user/component/type';
|
||||
import { IExcelJSColumnType } from '@/types/types';
|
||||
|
||||
type Props = {
|
||||
data: IHistory[]
|
||||
};
|
||||
|
||||
const ExportComponent: FC<Props> = ({ data }) => {
|
||||
const [isLoading, setIsLoading] = useState(false)
|
||||
|
||||
const { data: session } = useSession()
|
||||
|
||||
const handleExport = async () => {
|
||||
setIsLoading(true)
|
||||
|
||||
const columns: IExcelJSColumnType[] = [
|
||||
{ header: 'No', key: 'number', width: 5, style: { numFmt: '0;[Red]0' } },
|
||||
{ header: 'Presence Date', key: 'presence_date', style: { numFmt: 'dd/mm/yyyy' } },
|
||||
{ header: 'CI-Total', key: 'presence_checkin_count', width: 10, style: { numFmt: '0;[Red]0' } },
|
||||
{ header: 'CI-0', key: 'ci_0', width: 7, style: { numFmt: '0;[Red]0' } },
|
||||
{ header: 'CI-1', key: 'ci_1', width: 7, style: { numFmt: '0;[Red]0' } },
|
||||
{ header: 'CI-2', key: 'ci_2', width: 7, style: { numFmt: '0;[Red]0' } },
|
||||
{ header: 'CI-3', key: 'ci_3', width: 7, style: { numFmt: '0;[Red]0' } },
|
||||
{ header: 'CI-4', key: 'ci_4', width: 7, style: { numFmt: '0;[Red]0' } },
|
||||
{ header: 'CI-5', key: 'ci_5', width: 7, style: { numFmt: '0;[Red]0' } },
|
||||
{ header: 'CI-6', key: 'ci_6', width: 7, style: { numFmt: '0;[Red]0' } },
|
||||
{ header: 'CI-7', key: 'ci_7', width: 7, style: { numFmt: '0;[Red]0' } },
|
||||
{ header: 'CI-8', key: 'ci_8', width: 7, style: { numFmt: '0;[Red]0' } },
|
||||
{ header: 'CI-9', key: 'ci_9', width: 7, style: { numFmt: '0;[Red]0' } },
|
||||
{ header: 'CI-10', key: 'ci_10', width: 7, style: { numFmt: '0;[Red]0' } },
|
||||
{ header: 'CI-11', key: 'ci_11', width: 7, style: { numFmt: '0;[Red]0' } },
|
||||
{ header: 'CI-12', key: 'ci_12', width: 7, style: { numFmt: '0;[Red]0' } },
|
||||
{ header: 'CI-13', key: 'ci_13', width: 7, style: { numFmt: '0;[Red]0' } },
|
||||
{ header: 'CI-14', key: 'ci_14', width: 7, style: { numFmt: '0;[Red]0' } },
|
||||
{ header: 'CI-15', key: 'ci_15', width: 7, style: { numFmt: '0;[Red]0' } },
|
||||
{ header: 'CI-16', key: 'ci_16', width: 7, style: { numFmt: '0;[Red]0' } },
|
||||
{ header: 'CI-17', key: 'ci_17', width: 7, style: { numFmt: '0;[Red]0' } },
|
||||
{ header: 'CI-18', key: 'ci_18', width: 7, style: { numFmt: '0;[Red]0' } },
|
||||
{ header: 'CI-19', key: 'ci_19', width: 7, style: { numFmt: '0;[Red]0' } },
|
||||
{ header: 'CI-20', key: 'ci_20', width: 7, style: { numFmt: '0;[Red]0' } },
|
||||
{ header: 'CI-21', key: 'ci_21', width: 7, style: { numFmt: '0;[Red]0' } },
|
||||
{ header: 'CI-22', key: 'ci_22', width: 7, style: { numFmt: '0;[Red]0' } },
|
||||
{ header: 'CI-23', key: 'ci_23', width: 7, style: { numFmt: '0;[Red]0' } },
|
||||
{ header: 'CO-Total', key: 'presence_checkout_count', width: 10, style: { numFmt: '0;[Red]0' } },
|
||||
{ header: 'CO-0', key: 'co_0', width: 7, style: { numFmt: '0;[Red]0' } },
|
||||
{ header: 'CO-1', key: 'co_1', width: 7, style: { numFmt: '0;[Red]0' } },
|
||||
{ header: 'CO-2', key: 'co_2', width: 7, style: { numFmt: '0;[Red]0' } },
|
||||
{ header: 'CO-3', key: 'co_3', width: 7, style: { numFmt: '0;[Red]0' } },
|
||||
{ header: 'CO-4', key: 'co_4', width: 7, style: { numFmt: '0;[Red]0' } },
|
||||
{ header: 'CO-5', key: 'co_5', width: 7, style: { numFmt: '0;[Red]0' } },
|
||||
{ header: 'CO-6', key: 'co_6', width: 7, style: { numFmt: '0;[Red]0' } },
|
||||
{ header: 'CO-7', key: 'co_7', width: 7, style: { numFmt: '0;[Red]0' } },
|
||||
{ header: 'CO-8', key: 'co_8', width: 7, style: { numFmt: '0;[Red]0' } },
|
||||
{ header: 'CO-9', key: 'co_9', width: 7, style: { numFmt: '0;[Red]0' } },
|
||||
{ header: 'CO-10', key: 'co_10', width: 7, style: { numFmt: '0;[Red]0' } },
|
||||
{ header: 'CO-11', key: 'co_11', width: 7, style: { numFmt: '0;[Red]0' } },
|
||||
{ header: 'CO-12', key: 'co_12', width: 7, style: { numFmt: '0;[Red]0' } },
|
||||
{ header: 'CO-13', key: 'co_13', width: 7, style: { numFmt: '0;[Red]0' } },
|
||||
{ header: 'CO-14', key: 'co_14', width: 7, style: { numFmt: '0;[Red]0' } },
|
||||
{ header: 'CO-15', key: 'co_15', width: 7, style: { numFmt: '0;[Red]0' } },
|
||||
{ header: 'CO-16', key: 'co_16', width: 7, style: { numFmt: '0;[Red]0' } },
|
||||
{ header: 'CO-17', key: 'co_17', width: 7, style: { numFmt: '0;[Red]0' } },
|
||||
{ header: 'CO-18', key: 'co_18', width: 7, style: { numFmt: '0;[Red]0' } },
|
||||
{ header: 'CO-19', key: 'co_19', width: 7, style: { numFmt: '0;[Red]0' } },
|
||||
{ header: 'CO-20', key: 'co_20', width: 7, style: { numFmt: '0;[Red]0' } },
|
||||
{ header: 'CO-21', key: 'co_21', width: 7, style: { numFmt: '0;[Red]0' } },
|
||||
{ header: 'CO-22', key: 'co_22', width: 7, style: { numFmt: '0;[Red]0' } },
|
||||
{ header: 'CO-23', key: 'co_23', width: 7, style: { numFmt: '0;[Red]0' } },
|
||||
]
|
||||
|
||||
const resBlob: any = await exportTable(session?.user.detail as IUser, data, columns, 'Attendance Distribution')
|
||||
if (resBlob) {
|
||||
const url = URL.createObjectURL(resBlob);
|
||||
|
||||
// Create a link and trigger a click event to start the download
|
||||
const a = document.createElement("a");
|
||||
a.style.display = "none";
|
||||
a.href = url;
|
||||
a.download = `Attendance Distribution - ${dayjs().format('YYYYMMDD HH:mm:ssa')}`; // Set the downloaded filename
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
|
||||
// Clean up by removing the temporary link and URL
|
||||
document.body.removeChild(a);
|
||||
URL.revokeObjectURL(url);
|
||||
}
|
||||
setIsLoading(false)
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="flex flex-col sm:flex-row items-center gap-4">
|
||||
<DateRangePicker />
|
||||
<Button className='w-full sm:w-max' disabled={isLoading} onClick={handleExport}>
|
||||
{isLoading && (
|
||||
<Icons.spinner className="mr-1 h-4 w-4 animate-spin" />
|
||||
)}
|
||||
Download
|
||||
</Button>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export default ExportComponent;
|
||||
@@ -0,0 +1,691 @@
|
||||
'use client'
|
||||
|
||||
import { FC, Suspense, lazy, useEffect, useState } from 'react';
|
||||
import { Table } from 'antd';
|
||||
import dayjs from 'dayjs';
|
||||
import { TableProps, type ColumnsType } from 'antd/es/table';
|
||||
import { CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';
|
||||
import LazyLoading from '@/components/loader/LazyLoading';
|
||||
import { type IHistory } from '@/app/(dashboard)/history/components/type';
|
||||
|
||||
const ExportComponent = lazy(() => import('./Export'));
|
||||
|
||||
type Props = {
|
||||
data: IHistory[]
|
||||
};
|
||||
|
||||
const ComponentPage: FC<Props> = ({ data }) => {
|
||||
const [groupData, setGroupData] = useState<any>(null)
|
||||
|
||||
useEffect(() => {
|
||||
if (data) {
|
||||
const groupedData: any = {};
|
||||
|
||||
// Loop through the data and group it by presence_date
|
||||
data.forEach((item) => {
|
||||
const presenceDate = item.presence_date;
|
||||
|
||||
if (!groupedData[presenceDate]) {
|
||||
groupedData[presenceDate] = [];
|
||||
}
|
||||
|
||||
groupedData[presenceDate].push(item);
|
||||
});
|
||||
|
||||
const tableData = Object.entries(groupedData).map(([presenceDate, items]) => ({
|
||||
presence_date: presenceDate,
|
||||
items: items,
|
||||
}));
|
||||
|
||||
const tableDataWithCount = tableData.map((row: any) => {
|
||||
const presence_checkout_count = row.items.reduce((accumulator: any, item: any) => {
|
||||
if (item.presence_checkout !== null) {
|
||||
return accumulator + 1;
|
||||
}
|
||||
return accumulator;
|
||||
}, 0);
|
||||
|
||||
let ci: any = {}
|
||||
for (let i = 0; i <= 23; i++) {
|
||||
ci[`ci_${i}`] = row.items.reduce((accumulator: any, item: any) => {
|
||||
if (Number(dayjs(item.working_hours_start).format('HH')) === i) {
|
||||
return accumulator + 1;
|
||||
}
|
||||
return accumulator;
|
||||
}, 0);
|
||||
}
|
||||
|
||||
let co: any = {}
|
||||
for (let i = 0; i <= 23; i++) {
|
||||
co[`co_${i}`] = row.items.reduce((accumulator: any, item: any) => {
|
||||
if (item.presence_checkout !== null) {
|
||||
if (Number(dayjs(item.presence_checkout.working_hours_end).format('HH')) === i) {
|
||||
return accumulator + 1;
|
||||
}
|
||||
}
|
||||
return accumulator;
|
||||
}, 0);
|
||||
}
|
||||
|
||||
return {
|
||||
...{
|
||||
presence_date: row.presence_date,
|
||||
presence_checkin_count: row.items.length,
|
||||
},
|
||||
presence_checkout_count,
|
||||
...ci,
|
||||
...co
|
||||
};
|
||||
});
|
||||
|
||||
setGroupData(tableDataWithCount)
|
||||
}
|
||||
}, [data])
|
||||
|
||||
|
||||
const Columns: ColumnsType<any> = [
|
||||
{
|
||||
title: 'Date',
|
||||
align: 'center',
|
||||
dataIndex: 'presence_date',
|
||||
sorter: ((a, b) => (dayjs(a.presence_date).isAfter(dayjs(b.presence_date)) ? 1 : -1)),
|
||||
render: (val) => dayjs(val).format('dddd, MMM DD, YYYY')
|
||||
},
|
||||
{
|
||||
title: "Check-In",
|
||||
children: [
|
||||
{
|
||||
title: "Total",
|
||||
dataIndex: "presence_checkin_count",
|
||||
key: 99,
|
||||
},
|
||||
{
|
||||
title: "0",
|
||||
dataIndex: "ci_0",
|
||||
key: 0,
|
||||
// render: (val) => <div className='bg-green-500 text-white w-full h-full'>{val}</div>
|
||||
render(val) {
|
||||
return {
|
||||
props: { style: { background: val > 20 ? '#0e0' : val > 10 ? "#0b0" : val > 0 ? 'green' : "none" } },
|
||||
children: <div>{val}</div>
|
||||
};
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "1",
|
||||
dataIndex: "ci_1",
|
||||
key: 1,
|
||||
render(val) {
|
||||
return {
|
||||
props: { style: { background: val > 20 ? '#0e0' : val > 10 ? "#0b0" : val > 0 ? 'green' : "none" } },
|
||||
children: <div>{val}</div>
|
||||
};
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "2",
|
||||
dataIndex: "ci_2",
|
||||
key: 2,
|
||||
render(val) {
|
||||
return {
|
||||
props: { style: { background: val > 20 ? '#0e0' : val > 10 ? "#0b0" : val > 0 ? 'green' : "none" } },
|
||||
children: <div>{val}</div>
|
||||
};
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "3",
|
||||
dataIndex: "ci_3",
|
||||
key: 3,
|
||||
render(val) {
|
||||
return {
|
||||
props: { style: { background: val > 20 ? '#0e0' : val > 10 ? "#0b0" : val > 0 ? 'green' : "none" } },
|
||||
children: <div>{val}</div>
|
||||
};
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "4",
|
||||
dataIndex: "ci_4",
|
||||
key: 4,
|
||||
render(val) {
|
||||
return {
|
||||
props: { style: { background: val > 20 ? '#0e0' : val > 10 ? "#0b0" : val > 0 ? 'green' : "none" } },
|
||||
children: <div>{val}</div>
|
||||
};
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "5",
|
||||
dataIndex: "ci_5",
|
||||
key: 5,
|
||||
render(val) {
|
||||
return {
|
||||
props: { style: { background: val > 20 ? '#0e0' : val > 10 ? "#0b0" : val > 0 ? 'green' : "none" } },
|
||||
children: <div>{val}</div>
|
||||
};
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "6",
|
||||
dataIndex: "ci_6",
|
||||
key: 6,
|
||||
render(val) {
|
||||
return {
|
||||
props: { style: { background: val > 20 ? '#0e0' : val > 10 ? "#0b0" : val > 0 ? 'green' : "none" } },
|
||||
children: <div>{val}</div>
|
||||
};
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "7",
|
||||
dataIndex: "ci_7",
|
||||
key: 7,
|
||||
render(val) {
|
||||
return {
|
||||
props: { style: { background: val > 20 ? '#0e0' : val > 10 ? "#0b0" : val > 0 ? 'green' : "none" } },
|
||||
children: <div>{val}</div>
|
||||
};
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "8",
|
||||
dataIndex: "ci_8",
|
||||
key: 8,
|
||||
render(val) {
|
||||
return {
|
||||
props: { style: { background: val > 20 ? '#0e0' : val > 10 ? "#0b0" : val > 0 ? 'green' : "none" } },
|
||||
children: <div>{val}</div>
|
||||
};
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "9",
|
||||
dataIndex: "ci_9",
|
||||
key: 9,
|
||||
render(val) {
|
||||
return {
|
||||
props: { style: { background: val > 20 ? '#0e0' : val > 10 ? "#0b0" : val > 0 ? 'green' : "none" } },
|
||||
children: <div>{val}</div>
|
||||
};
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "10",
|
||||
dataIndex: "ci_10",
|
||||
key: 10,
|
||||
render(val) {
|
||||
return {
|
||||
props: { style: { background: val > 20 ? '#0e0' : val > 10 ? "#0b0" : val > 0 ? 'green' : "none" } },
|
||||
children: <div>{val}</div>
|
||||
};
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "11",
|
||||
dataIndex: "ci_11",
|
||||
key: 11,
|
||||
render(val) {
|
||||
return {
|
||||
props: { style: { background: val > 20 ? '#0e0' : val > 10 ? "#0b0" : val > 0 ? 'green' : "none" } },
|
||||
children: <div>{val}</div>
|
||||
};
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "12",
|
||||
dataIndex: "ci_12",
|
||||
key: 12,
|
||||
render(val) {
|
||||
return {
|
||||
props: { style: { background: val > 20 ? '#0e0' : val > 10 ? "#0b0" : val > 0 ? 'green' : "none" } },
|
||||
children: <div>{val}</div>
|
||||
};
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "13",
|
||||
dataIndex: "ci_13",
|
||||
key: 13,
|
||||
render(val) {
|
||||
return {
|
||||
props: { style: { background: val > 20 ? '#0e0' : val > 10 ? "#0b0" : val > 0 ? 'green' : "none" } },
|
||||
children: <div>{val}</div>
|
||||
};
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "14",
|
||||
dataIndex: "ci_14",
|
||||
key: 14,
|
||||
render(val) {
|
||||
return {
|
||||
props: { style: { background: val > 20 ? '#0e0' : val > 10 ? "#0b0" : val > 0 ? 'green' : "none" } },
|
||||
children: <div>{val}</div>
|
||||
};
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "15",
|
||||
dataIndex: "ci_15",
|
||||
key: 15,
|
||||
render(val) {
|
||||
return {
|
||||
props: { style: { background: val > 20 ? '#0e0' : val > 10 ? "#0b0" : val > 0 ? 'green' : "none" } },
|
||||
children: <div>{val}</div>
|
||||
};
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "16",
|
||||
dataIndex: "ci_16",
|
||||
key: 16,
|
||||
render(val) {
|
||||
return {
|
||||
props: { style: { background: val > 20 ? '#0e0' : val > 10 ? "#0b0" : val > 0 ? 'green' : "none" } },
|
||||
children: <div>{val}</div>
|
||||
};
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "17",
|
||||
dataIndex: "ci_17",
|
||||
key: 17,
|
||||
render(val) {
|
||||
return {
|
||||
props: { style: { background: val > 20 ? '#0e0' : val > 10 ? "#0b0" : val > 0 ? 'green' : "none" } },
|
||||
children: <div>{val}</div>
|
||||
};
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "18",
|
||||
dataIndex: "ci_18",
|
||||
key: 18,
|
||||
render(val) {
|
||||
return {
|
||||
props: { style: { background: val > 20 ? '#0e0' : val > 10 ? "#0b0" : val > 0 ? 'green' : "none" } },
|
||||
children: <div>{val}</div>
|
||||
};
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "19",
|
||||
dataIndex: "ci_19",
|
||||
key: 19,
|
||||
render(val) {
|
||||
return {
|
||||
props: { style: { background: val > 20 ? '#0e0' : val > 10 ? "#0b0" : val > 0 ? 'green' : "none" } },
|
||||
children: <div>{val}</div>
|
||||
};
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "20",
|
||||
dataIndex: "ci_20",
|
||||
key: 20,
|
||||
render(val) {
|
||||
return {
|
||||
props: { style: { background: val > 20 ? '#0e0' : val > 10 ? "#0b0" : val > 0 ? 'green' : "none" } },
|
||||
children: <div>{val}</div>
|
||||
};
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "21",
|
||||
dataIndex: "ci_21",
|
||||
key: 21,
|
||||
render(val) {
|
||||
return {
|
||||
props: { style: { background: val > 20 ? '#0e0' : val > 10 ? "#0b0" : val > 0 ? 'green' : "none" } },
|
||||
children: <div>{val}</div>
|
||||
};
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "22",
|
||||
dataIndex: "ci_22",
|
||||
key: 22,
|
||||
render(val) {
|
||||
return {
|
||||
props: { style: { background: val > 20 ? '#0e0' : val > 10 ? "#0b0" : val > 0 ? 'green' : "none" } },
|
||||
children: <div>{val}</div>
|
||||
};
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "23",
|
||||
dataIndex: "ci_23",
|
||||
key: 23,
|
||||
render(val) {
|
||||
return {
|
||||
props: { style: { background: val > 20 ? '#0e0' : val > 10 ? "#0b0" : val > 0 ? 'green' : "none" } },
|
||||
children: <div>{val}</div>
|
||||
};
|
||||
}
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
title: "Check-Out",
|
||||
children: [
|
||||
{
|
||||
title: "Total",
|
||||
dataIndex: "presence_checkout_count",
|
||||
key: 100,
|
||||
},
|
||||
{
|
||||
title: "0",
|
||||
dataIndex: "co_0",
|
||||
key: 0,
|
||||
render(val) {
|
||||
return {
|
||||
props: { style: { background: val > 20 ? '#e00' : val > 10 ? "#b00" : val > 0 ? 'red' : "none" } },
|
||||
children: <div>{val}</div>
|
||||
};
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "1",
|
||||
dataIndex: "co_1",
|
||||
key: 1,
|
||||
render(val) {
|
||||
return {
|
||||
props: { style: { background: val > 20 ? '#e00' : val > 10 ? "#b00" : val > 0 ? 'red' : "none" } },
|
||||
children: <div>{val}</div>
|
||||
};
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "2",
|
||||
dataIndex: "co_2",
|
||||
key: 2,
|
||||
render(val) {
|
||||
return {
|
||||
props: { style: { background: val > 20 ? '#e00' : val > 10 ? "#b00" : val > 0 ? 'red' : "none" } },
|
||||
children: <div>{val}</div>
|
||||
};
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "3",
|
||||
dataIndex: "co_3",
|
||||
key: 3,
|
||||
render(val) {
|
||||
return {
|
||||
props: { style: { background: val > 20 ? '#e00' : val > 10 ? "#b00" : val > 0 ? 'red' : "none" } },
|
||||
children: <div>{val}</div>
|
||||
};
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "4",
|
||||
dataIndex: "co_4",
|
||||
key: 4,
|
||||
render(val) {
|
||||
return {
|
||||
props: { style: { background: val > 20 ? '#e00' : val > 10 ? "#b00" : val > 0 ? 'red' : "none" } },
|
||||
children: <div>{val}</div>
|
||||
};
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "5",
|
||||
dataIndex: "co_5",
|
||||
key: 5,
|
||||
render(val) {
|
||||
return {
|
||||
props: { style: { background: val > 20 ? '#e00' : val > 10 ? "#b00" : val > 0 ? 'red' : "none" } },
|
||||
children: <div>{val}</div>
|
||||
};
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "6",
|
||||
dataIndex: "co_6",
|
||||
key: 6,
|
||||
render(val) {
|
||||
return {
|
||||
props: { style: { background: val > 20 ? '#e00' : val > 10 ? "#b00" : val > 0 ? 'red' : "none" } },
|
||||
children: <div>{val}</div>
|
||||
};
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "7",
|
||||
dataIndex: "co_7",
|
||||
key: 7,
|
||||
render(val) {
|
||||
return {
|
||||
props: { style: { background: val > 20 ? '#e00' : val > 10 ? "#b00" : val > 0 ? 'red' : "none" } },
|
||||
children: <div>{val}</div>
|
||||
};
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "8",
|
||||
dataIndex: "co_8",
|
||||
key: 8,
|
||||
render(val) {
|
||||
return {
|
||||
props: { style: { background: val > 20 ? '#e00' : val > 10 ? "#b00" : val > 0 ? 'red' : "none" } },
|
||||
children: <div>{val}</div>
|
||||
};
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "9",
|
||||
dataIndex: "co_9",
|
||||
key: 9,
|
||||
render(val) {
|
||||
return {
|
||||
props: { style: { background: val > 20 ? '#e00' : val > 10 ? "#b00" : val > 0 ? 'red' : "none" } },
|
||||
children: <div>{val}</div>
|
||||
};
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "10",
|
||||
dataIndex: "co_10",
|
||||
key: 10,
|
||||
render(val) {
|
||||
return {
|
||||
props: { style: { background: val > 20 ? '#e00' : val > 10 ? "#b00" : val > 0 ? 'red' : "none" } },
|
||||
children: <div>{val}</div>
|
||||
};
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "11",
|
||||
dataIndex: "co_11",
|
||||
key: 11,
|
||||
render(val) {
|
||||
return {
|
||||
props: { style: { background: val > 20 ? '#e00' : val > 10 ? "#b00" : val > 0 ? 'red' : "none" } },
|
||||
children: <div>{val}</div>
|
||||
};
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "12",
|
||||
dataIndex: "co_12",
|
||||
key: 12,
|
||||
render(val) {
|
||||
return {
|
||||
props: { style: { background: val > 20 ? '#e00' : val > 10 ? "#b00" : val > 0 ? 'red' : "none" } },
|
||||
children: <div>{val}</div>
|
||||
};
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "13",
|
||||
dataIndex: "co_13",
|
||||
key: 13,
|
||||
render(val) {
|
||||
return {
|
||||
props: { style: { background: val > 20 ? '#e00' : val > 10 ? "#b00" : val > 0 ? 'red' : "none" } },
|
||||
children: <div>{val}</div>
|
||||
};
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "14",
|
||||
dataIndex: "co_14",
|
||||
key: 14,
|
||||
render(val) {
|
||||
return {
|
||||
props: { style: { background: val > 20 ? '#e00' : val > 10 ? "#b00" : val > 0 ? 'red' : "none" } },
|
||||
children: <div>{val}</div>
|
||||
};
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "15",
|
||||
dataIndex: "co_15",
|
||||
key: 15,
|
||||
render(val) {
|
||||
return {
|
||||
props: { style: { background: val > 20 ? '#e00' : val > 10 ? "#b00" : val > 0 ? 'red' : "none" } },
|
||||
children: <div>{val}</div>
|
||||
};
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "16",
|
||||
dataIndex: "co_16",
|
||||
key: 16,
|
||||
render(val) {
|
||||
return {
|
||||
props: { style: { background: val > 20 ? '#e00' : val > 10 ? "#b00" : val > 0 ? 'red' : "none" } },
|
||||
children: <div>{val}</div>
|
||||
};
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "17",
|
||||
dataIndex: "co_17",
|
||||
key: 17,
|
||||
render(val) {
|
||||
return {
|
||||
props: { style: { background: val > 20 ? '#e00' : val > 10 ? "#b00" : val > 0 ? 'red' : "none" } },
|
||||
children: <div>{val}</div>
|
||||
};
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "18",
|
||||
dataIndex: "co_18",
|
||||
key: 18,
|
||||
render(val) {
|
||||
return {
|
||||
props: { style: { background: val > 20 ? '#e00' : val > 10 ? "#b00" : val > 0 ? 'red' : "none" } },
|
||||
children: <div>{val}</div>
|
||||
};
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "19",
|
||||
dataIndex: "co_19",
|
||||
key: 19,
|
||||
render(val) {
|
||||
return {
|
||||
props: { style: { background: val > 20 ? '#e00' : val > 10 ? "#b00" : val > 0 ? 'red' : "none" } },
|
||||
children: <div>{val}</div>
|
||||
};
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "20",
|
||||
dataIndex: "co_20",
|
||||
key: 20,
|
||||
render(val) {
|
||||
return {
|
||||
props: { style: { background: val > 20 ? '#e00' : val > 10 ? "#b00" : val > 0 ? 'red' : "none" } },
|
||||
children: <div>{val}</div>
|
||||
};
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "21",
|
||||
dataIndex: "co_21",
|
||||
key: 21,
|
||||
render(val) {
|
||||
return {
|
||||
props: { style: { background: val > 20 ? '#e00' : val > 10 ? "#b00" : val > 0 ? 'red' : "none" } },
|
||||
children: <div>{val}</div>
|
||||
};
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "22",
|
||||
dataIndex: "co_22",
|
||||
key: 22,
|
||||
render(val) {
|
||||
return {
|
||||
props: { style: { background: val > 20 ? '#e00' : val > 10 ? "#b00" : val > 0 ? 'red' : "none" } },
|
||||
children: <div>{val}</div>
|
||||
};
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "23",
|
||||
dataIndex: "co_23",
|
||||
key: 23,
|
||||
render(val) {
|
||||
return {
|
||||
props: { style: { background: val > 20 ? '#e00' : val > 10 ? "#b00" : val > 0 ? 'red' : "none" } },
|
||||
children: <div>{val}</div>
|
||||
};
|
||||
}
|
||||
},
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
const tableProps: TableProps<IHistory> = {
|
||||
size: 'small',
|
||||
bordered: false,
|
||||
showHeader: true,
|
||||
pagination: {
|
||||
pageSizeOptions: [5, 10, 20, 50],
|
||||
defaultPageSize: 15,
|
||||
showSizeChanger: true,
|
||||
showQuickJumper: true,
|
||||
size: 'default'
|
||||
},
|
||||
scroll: { x: 'max-content' },
|
||||
tableLayout: 'auto',
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<CardHeader className='flex flex-col md:flex-row items-center justify-between space-y-5 sm:space-y-0'>
|
||||
<div>
|
||||
<CardTitle>Attendance Distribution</CardTitle>
|
||||
<CardDescription className='mt-1 sm:block hidden'>Here's a list of all employee attendance distribution!</CardDescription>
|
||||
</div>
|
||||
<Suspense fallback={<LazyLoading />}>
|
||||
<ExportComponent data={groupData} />
|
||||
</Suspense>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<div className='flex flex-col space-y-4'>
|
||||
<Table
|
||||
{...tableProps}
|
||||
onRow={(record, rowIndex) => {
|
||||
return {
|
||||
onClick: event => { console.log(record.face_image); }, // click row
|
||||
};
|
||||
}}
|
||||
rowKey='presence_date'
|
||||
columns={Columns}
|
||||
dataSource={groupData || []}
|
||||
style={{ cursor: "pointer" }}
|
||||
/>
|
||||
</div>
|
||||
</CardContent>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export default ComponentPage;
|
||||
@@ -0,0 +1,10 @@
|
||||
export interface IDailyPresence {
|
||||
id: number,
|
||||
name: string,
|
||||
status: {
|
||||
id: number,
|
||||
code: "A" | 'N' | 'X',
|
||||
name: "ACTIVE" | 'INACTIVE' | 'DELETED'
|
||||
},
|
||||
description: string
|
||||
}
|
||||
Reference in New Issue
Block a user