mirror of
https://github.com/ichsankurnia/hats-app.git
synced 2026-12-05 10:56:28 +00:00
update
This commit is contained in:
+2
-1
@@ -19,4 +19,5 @@ FIREBASE_APP_ID = "1:422528660020:web:db16e1cba4d357e32f1061"
|
||||
DEVICE_CODE = "40001"
|
||||
NEXT_PUBLIC_HATS_SUPPORT_NAME = "Amalia"
|
||||
NEXT_PUBLIC_HATS_SUPPORT_PHONE = "6285214074002"
|
||||
NEXT_PUBLIC_APP_VERSION = "v1.1.2"
|
||||
NEXT_PUBLIC_APP_VERSION = "v1.1.2"
|
||||
NEXT_PUBLIC_MANAGER_USER_ID = '2'
|
||||
@@ -131,6 +131,7 @@ const Component: FC<Props> = ({ TL_LIST }) => {
|
||||
firstPage.drawImage(sign, { x: 54, y: 240, width: 100, height: 55 })
|
||||
}
|
||||
|
||||
const fileName = `Form Cuti ${profile.fullname} ${dayjs(leavePeriod[0]).format('YYYYMMDD')} - ${dayjs(leavePeriod[1]).format('YYYYMMDD')}`
|
||||
|
||||
await pdfDoc.setTitle(`Form Cuti ${profile.fullname} - ${dayjs().format('YYYYMMDD')}`)
|
||||
await pdfDoc.setSubject('SURAT PERMOHONAN FORM CUTI KARYAWAN')
|
||||
@@ -146,8 +147,7 @@ const Component: FC<Props> = ({ TL_LIST }) => {
|
||||
if (!preview) {
|
||||
const payload = {
|
||||
"nik": profile.nik,
|
||||
"send_to": 9,
|
||||
// "send_to": 1,
|
||||
"send_to": Number(process.env.NEXT_PUBLIC_MANAGER_USER_ID) || 2,
|
||||
"cc": mentionsTo,
|
||||
"category": leaveType,
|
||||
"start_date": dayjs(leavePeriod[0]).format('YYYY-MM-DD'),
|
||||
@@ -164,7 +164,7 @@ const Component: FC<Props> = ({ TL_LIST }) => {
|
||||
const downloadLink = window.document.createElement('a');
|
||||
downloadLink.style.display = "none";
|
||||
downloadLink.href = pdfBase64;
|
||||
downloadLink.download = `Form Cuti ${profile.fullname} - ${dayjs().format('YYYYMMDD')}`;
|
||||
downloadLink.download = fileName;
|
||||
window.document.body.appendChild(downloadLink);
|
||||
downloadLink.click();
|
||||
window.document.body.removeChild(downloadLink);
|
||||
|
||||
@@ -59,8 +59,7 @@ const Component: FC<Props> = ({ TL_LIST }) => {
|
||||
|
||||
const payload = {
|
||||
"nik": session?.user.detail.nik,
|
||||
"send_to": 9,
|
||||
// "send_to": 1,
|
||||
"send_to": Number(process.env.NEXT_PUBLIC_MANAGER_USER_ID) || 2,
|
||||
"cc": formData['cc'],
|
||||
"category": permitType,
|
||||
"start_date": dayjs(formData['start_date'][0]).format('YYYY-MM-DD'),
|
||||
|
||||
@@ -1,43 +1,62 @@
|
||||
'use client'
|
||||
|
||||
import { ChangeEvent, FC, useEffect, useState } from 'react';
|
||||
import { ChangeEvent, FC, Suspense, useCallback, useEffect, useMemo, useState } from 'react';
|
||||
import { Table } from 'antd';
|
||||
import { TableProps } from 'antd/es/table';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { IHistory } from '@/app/(dashboard)/history/components/type';
|
||||
import ColumnsHistory from './Columns';
|
||||
import { CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';
|
||||
import LazyLoading from '@/components/loader/LazyLoading';
|
||||
import ExportComponent from './Export';
|
||||
import useDebounce from '@/hooks/useDebounce';
|
||||
|
||||
type Props = {
|
||||
data: IHistory[]
|
||||
};
|
||||
|
||||
const ComponentPage: FC<Props> = ({ data }) => {
|
||||
const [filterData, setFilterData] = useState<IHistory[]>([])
|
||||
const [currentDataTable, setCurrentDataTable] = useState<IHistory[]>([])
|
||||
const [searchText, setSearchText] = useState<string>('')
|
||||
|
||||
useEffect(() => {
|
||||
if (data) {
|
||||
setFilterData(data)
|
||||
}
|
||||
}, [data])
|
||||
const debouncedSearchText = useDebounce(searchText, 300)
|
||||
|
||||
const searchFilterLogic = useCallback((item: IHistory, text: string) => {
|
||||
const lowerText = text.toLowerCase();
|
||||
// Use optional chaining carefully, and provide fallback empty strings to avoid crashes
|
||||
return (
|
||||
(item.user?.fullname || '').toLowerCase().includes(lowerText) ||
|
||||
(item.working_status || '').toLowerCase().includes(lowerText) ||
|
||||
(item.device?.name || '').toLowerCase().includes(lowerText) ||
|
||||
(item.location_name || '').toLowerCase().includes(lowerText) ||
|
||||
(item.note || '').toLowerCase().includes(lowerText) ||
|
||||
(item.presence_checkout?.location_name || '').toLowerCase().includes(lowerText) ||
|
||||
(item.presence_checkout?.note || '').toLowerCase().includes(lowerText)
|
||||
);
|
||||
}, []);
|
||||
|
||||
const handleSearch = (e: ChangeEvent<HTMLInputElement>) => {
|
||||
const text = e.target.value
|
||||
if (text) {
|
||||
const newData = [...data!].filter(item => (
|
||||
item.user.fullname?.toLowerCase().includes(text.toLowerCase()) ||
|
||||
item.working_status?.toLowerCase().includes(text.toLowerCase()) ||
|
||||
item.device.name?.toLowerCase().includes(text.toLowerCase()) ||
|
||||
item.location_name?.toLowerCase().includes(text.toLowerCase()) ||
|
||||
item.note?.toLowerCase().includes(text.toLowerCase()) ||
|
||||
item.presence_checkout?.location_name?.toLowerCase().includes(text.toLowerCase()) ||
|
||||
item.presence_checkout?.note?.toLowerCase().includes(text.toLowerCase())
|
||||
))
|
||||
setFilterData(newData)
|
||||
} else {
|
||||
setFilterData(data)
|
||||
}
|
||||
setSearchText(e.target.value);
|
||||
}
|
||||
|
||||
const filterData = useMemo(() => {
|
||||
if (!data) return [];
|
||||
if (!debouncedSearchText) return data;
|
||||
|
||||
return data.filter(item => searchFilterLogic(item, debouncedSearchText));
|
||||
}, [data, debouncedSearchText, searchFilterLogic]);
|
||||
|
||||
const exportData = useMemo(() => {
|
||||
const baseExportData = currentDataTable.length > 0 ? currentDataTable : (data || []);
|
||||
|
||||
// We use the raw searchText here or debounced? Usually debounced is better so they don't export mid-type
|
||||
if (debouncedSearchText) {
|
||||
return baseExportData.filter(item => searchFilterLogic(item, debouncedSearchText));
|
||||
}
|
||||
return baseExportData;
|
||||
}, [currentDataTable, data, debouncedSearchText, searchFilterLogic]);
|
||||
|
||||
|
||||
const tableProps: TableProps<IHistory> = {
|
||||
size: 'small',
|
||||
bordered: false,
|
||||
@@ -53,23 +72,33 @@ const ComponentPage: FC<Props> = ({ data }) => {
|
||||
tableLayout: 'auto',
|
||||
};
|
||||
|
||||
// console.log(data)
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className='flex flex-col space-y-4'>
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="flex flex-1 items-center space-x-2">
|
||||
<Input placeholder="Search report..." className="h-8 w-full sm:w-[250px]" onChange={handleSearch} />
|
||||
</div>
|
||||
<CardHeader className='flex flex-col md:flex-row items-center justify-between space-y-5 sm:space-y-0'>
|
||||
<div>
|
||||
<CardTitle>Attendance History</CardTitle>
|
||||
<CardDescription className='mt-1 sm:block hidden'>Here's a list of all employee attendance history!</CardDescription>
|
||||
</div>
|
||||
<Table
|
||||
{...tableProps}
|
||||
rowKey='presence_checkin_code'
|
||||
columns={ColumnsHistory}
|
||||
dataSource={filterData || []}
|
||||
/>
|
||||
</div>
|
||||
<Suspense fallback={<LazyLoading />}>
|
||||
<ExportComponent data={exportData} />
|
||||
</Suspense>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<div className='flex flex-col space-y-4'>
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="flex flex-1 items-center space-x-2">
|
||||
<Input placeholder="Search report..." className="h-8 w-full sm:w-[250px]" onChange={handleSearch} />
|
||||
</div>
|
||||
</div>
|
||||
<Table
|
||||
{...tableProps}
|
||||
rowKey='presence_checkin_code'
|
||||
columns={ColumnsHistory}
|
||||
onChange={(pagination, filters, sorter, extra) => setCurrentDataTable(extra.currentDataSource as IHistory[])}
|
||||
dataSource={filterData || []}
|
||||
/>
|
||||
</div>
|
||||
</CardContent>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
import { type Metadata } from 'next';
|
||||
import { FC, Suspense, lazy } from 'react';
|
||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';
|
||||
import { Card } from '@/components/ui/card';
|
||||
import LazyLoading from '@/components/loader/LazyLoading';
|
||||
import dayjs from 'dayjs';
|
||||
import { fetchDataWithPost } from '@/lib/fetchData';
|
||||
|
||||
const ExportComponent = lazy(() => import('./component/Export'));
|
||||
const ComponentPage = lazy(() => import('./component'));
|
||||
|
||||
|
||||
@@ -27,22 +26,11 @@ const MonthlyPresencePage: FC<Props> = async ({ searchParams }) => {
|
||||
<>
|
||||
<div className="flex flex-col">
|
||||
<Card>
|
||||
<CardHeader className='flex flex-col md:flex-row items-center justify-between space-y-5 sm:space-y-0'>
|
||||
<div>
|
||||
<CardTitle>Attendance History</CardTitle>
|
||||
<CardDescription className='mt-1 sm:block hidden'>Here's a list of all employee attendance history!</CardDescription>
|
||||
</div>
|
||||
<Suspense fallback={<LazyLoading />}>
|
||||
<ExportComponent data={data.history} />
|
||||
</Suspense>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<Suspense fallback={<LazyLoading />}>
|
||||
<ComponentPage
|
||||
data={data.history}
|
||||
/>
|
||||
</Suspense>
|
||||
</CardContent>
|
||||
<Suspense fallback={<div className='flex justify-center items-center w-full h-[40vh]'><LazyLoading /></div>}>
|
||||
<ComponentPage
|
||||
data={data.history}
|
||||
/>
|
||||
</Suspense>
|
||||
</Card>
|
||||
</div>
|
||||
</>
|
||||
|
||||
@@ -78,6 +78,7 @@
|
||||
"@types/react-dom": "^19",
|
||||
"@types/react-lazy-load-image-component": "^1.6.5",
|
||||
"@types/react-signature-canvas": "^1.0.7",
|
||||
"baseline-browser-mapping": "^2.10.0",
|
||||
"eslint": "^9",
|
||||
"eslint-config-next": "^16.0.10",
|
||||
"tailwindcss": "^4",
|
||||
|
||||
Reference in New Issue
Block a user