From 60648f312d3e7c68bdde357a59fb22cfaef9664b Mon Sep 17 00:00:00 2001 From: Ichsan Kurniawan Date: Wed, 25 Feb 2026 13:39:59 +0700 Subject: [PATCH] update --- .env.development | 3 +- app/(dashboard)/leave/components/index.tsx | 6 +- .../work-permit/components/index.tsx | 3 +- app/admin/report/history/component/index.tsx | 101 +++++++++++------- app/admin/report/history/page.tsx | 24 ++--- package.json | 1 + 6 files changed, 78 insertions(+), 60 deletions(-) diff --git a/.env.development b/.env.development index b048205..9d5490a 100644 --- a/.env.development +++ b/.env.development @@ -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" \ No newline at end of file +NEXT_PUBLIC_APP_VERSION = "v1.1.2" +NEXT_PUBLIC_MANAGER_USER_ID = '2' \ No newline at end of file diff --git a/app/(dashboard)/leave/components/index.tsx b/app/(dashboard)/leave/components/index.tsx index 3561a35..01ee372 100644 --- a/app/(dashboard)/leave/components/index.tsx +++ b/app/(dashboard)/leave/components/index.tsx @@ -131,6 +131,7 @@ const Component: FC = ({ 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 = ({ 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 = ({ 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); diff --git a/app/(dashboard)/work-permit/components/index.tsx b/app/(dashboard)/work-permit/components/index.tsx index 44d5163..3e37b20 100644 --- a/app/(dashboard)/work-permit/components/index.tsx +++ b/app/(dashboard)/work-permit/components/index.tsx @@ -59,8 +59,7 @@ const Component: FC = ({ 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'), diff --git a/app/admin/report/history/component/index.tsx b/app/admin/report/history/component/index.tsx index 1cd55c2..3b94771 100644 --- a/app/admin/report/history/component/index.tsx +++ b/app/admin/report/history/component/index.tsx @@ -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 = ({ data }) => { - const [filterData, setFilterData] = useState([]) + const [currentDataTable, setCurrentDataTable] = useState([]) + const [searchText, setSearchText] = useState('') - 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) => { - 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 = { size: 'small', bordered: false, @@ -53,23 +72,33 @@ const ComponentPage: FC = ({ data }) => { tableLayout: 'auto', }; - // console.log(data) - return ( <> -
-
-
- -
+ +
+ Attendance History + Here's a list of all employee attendance history!
- - + }> + + + + +
+
+
+ +
+
+
setCurrentDataTable(extra.currentDataSource as IHistory[])} + dataSource={filterData || []} + /> + + ); } diff --git a/app/admin/report/history/page.tsx b/app/admin/report/history/page.tsx index 6869219..9160276 100644 --- a/app/admin/report/history/page.tsx +++ b/app/admin/report/history/page.tsx @@ -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 = async ({ searchParams }) => { <>
- -
- Attendance History - Here's a list of all employee attendance history! -
- }> - - -
- - }> - - - +
}> + + diff --git a/package.json b/package.json index df2d555..495139d 100644 --- a/package.json +++ b/package.json @@ -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",