mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-23 23:05:46 +00:00
51 lines
1.3 KiB
TypeScript
51 lines
1.3 KiB
TypeScript
'use client';
|
|
|
|
import { useRouter, useSearchParams } from 'next/navigation';
|
|
import useSWR from 'swr';
|
|
|
|
import ClosingDetail from '@/components/pages/closing/ClosingDetail';
|
|
|
|
import { ClosingApi } from '@/services/api/closing';
|
|
import { isResponseError, isResponseSuccess } 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: number) => ClosingApi.getGeneralInfo(id)
|
|
);
|
|
|
|
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 flex flex-row justify-center'>
|
|
{isLoadingClosing && (
|
|
<span className='loading loading-spinner loading-xl' />
|
|
)}
|
|
|
|
{!isLoadingClosing && isResponseSuccess(closing) && (
|
|
<ClosingDetail id={Number(closingId)} initialValue={closing.data} />
|
|
)}
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default ClosingDetailPage;
|