mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 13:32:00 +00:00
feat(FE-326,327): add layout and closing detail page with sales report integration
This commit is contained in:
@@ -0,0 +1,11 @@
|
|||||||
|
import SuspenseHelper from '@/components/helper/SuspenseHelper';
|
||||||
|
|
||||||
|
const Layout = ({
|
||||||
|
children,
|
||||||
|
}: Readonly<{
|
||||||
|
children: React.ReactNode;
|
||||||
|
}>) => {
|
||||||
|
return <SuspenseHelper>{children}</SuspenseHelper>;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Layout;
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
'use client';
|
||||||
|
|
||||||
|
import { useRouter, useSearchParams } from 'next/navigation';
|
||||||
|
import useSWR from 'swr';
|
||||||
|
import SalesReportTable from '@/components/pages/closing/sale/SalesReportTable';
|
||||||
|
import { ClosingApi } from '@/services/api/closing';
|
||||||
|
import { isResponseSuccess, isResponseError } from '@/lib/api-helper';
|
||||||
|
|
||||||
|
const ClosingDetailPage = () => {
|
||||||
|
const router = useRouter();
|
||||||
|
const searchParams = useSearchParams();
|
||||||
|
|
||||||
|
const closingId = searchParams.get('closingId');
|
||||||
|
|
||||||
|
const { data: closing, isLoading: isLoadingClosing } = useSWR(
|
||||||
|
closingId,
|
||||||
|
(id: string) => {
|
||||||
|
const numericId = parseInt(id, 10);
|
||||||
|
if (isNaN(numericId) || numericId <= 0) {
|
||||||
|
throw new Error('Invalid closing ID');
|
||||||
|
}
|
||||||
|
return ClosingApi.getPenjualan(numericId);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!closingId) {
|
||||||
|
router.back();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className='w-full flex flex-row justify-center items-center p-4'>
|
||||||
|
<span className='loading loading-spinner loading-xl' />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isLoadingClosing && (!closing || isResponseError(closing))) {
|
||||||
|
// router.replace('/404');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className='w-full p-4'>
|
||||||
|
{isLoadingClosing && (
|
||||||
|
<div className='w-full flex flex-row justify-center items-center'>
|
||||||
|
<span className='loading loading-spinner loading-xl' />
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{!isLoadingClosing && isResponseSuccess(closing) && (
|
||||||
|
<SalesReportTable type='detail' initialValues={closing.data} />
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ClosingDetailPage;
|
||||||
Reference in New Issue
Block a user