mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 13:32:00 +00:00
feat(FE-149): integrate transfer to laying detail page to API
This commit is contained in:
@@ -8,91 +8,6 @@ import TransferToLayingForm from '@/components/pages/production/transfer-to-layi
|
|||||||
import { TransferToLayingApi } from '@/services/api/production/transfer-to-laying';
|
import { TransferToLayingApi } from '@/services/api/production/transfer-to-laying';
|
||||||
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
|
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
|
||||||
|
|
||||||
import { TransferToLaying } from '@/types/api/production/transfer-to-laying';
|
|
||||||
|
|
||||||
// TODO: delete dummy data
|
|
||||||
const DUMMY_TRANSFER_TO_LAYING_DETAIL: TransferToLaying = {
|
|
||||||
id: 1,
|
|
||||||
transfer_date: '2025-10-14',
|
|
||||||
flock_source: {
|
|
||||||
id: 1,
|
|
||||||
name: 'Flock asal test',
|
|
||||||
},
|
|
||||||
flock_destination: {
|
|
||||||
id: 2,
|
|
||||||
name: 'Flock tujuan destination',
|
|
||||||
},
|
|
||||||
quantity: 10,
|
|
||||||
kandangs: [
|
|
||||||
{
|
|
||||||
kandang: {
|
|
||||||
id: 1,
|
|
||||||
name: 'Kandang test',
|
|
||||||
status: 'ACTIVE',
|
|
||||||
location: {
|
|
||||||
id: 1,
|
|
||||||
name: 'test location',
|
|
||||||
address: 'test address 1',
|
|
||||||
area: { id: 1, name: 'test area 1' },
|
|
||||||
},
|
|
||||||
pic: {
|
|
||||||
id: 1,
|
|
||||||
id_user: 2,
|
|
||||||
email: 'test@gmail.com',
|
|
||||||
name: 'test',
|
|
||||||
},
|
|
||||||
created_user: {
|
|
||||||
id: 1,
|
|
||||||
id_user: 2,
|
|
||||||
email: 'test@gmail.com',
|
|
||||||
name: 'test',
|
|
||||||
},
|
|
||||||
created_at: '14-10-2025',
|
|
||||||
updated_at: '14-10-2025',
|
|
||||||
},
|
|
||||||
quantity: 8,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
kandang: {
|
|
||||||
id: 1,
|
|
||||||
name: 'Kandang test 2',
|
|
||||||
status: 'ACTIVE',
|
|
||||||
location: {
|
|
||||||
id: 1,
|
|
||||||
name: 'test location',
|
|
||||||
address: 'test address 1',
|
|
||||||
area: { id: 1, name: 'test area 1' },
|
|
||||||
},
|
|
||||||
pic: {
|
|
||||||
id: 1,
|
|
||||||
id_user: 2,
|
|
||||||
email: 'test@gmail.com',
|
|
||||||
name: 'test',
|
|
||||||
},
|
|
||||||
created_user: {
|
|
||||||
id: 1,
|
|
||||||
id_user: 2,
|
|
||||||
email: 'test@gmail.com',
|
|
||||||
name: 'test',
|
|
||||||
},
|
|
||||||
created_at: '14-10-2025',
|
|
||||||
updated_at: '14-10-2025',
|
|
||||||
},
|
|
||||||
quantity: 2,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
reason: 'Test alasan',
|
|
||||||
|
|
||||||
created_user: {
|
|
||||||
id: 1,
|
|
||||||
id_user: 2,
|
|
||||||
email: 'test@gmail.com',
|
|
||||||
name: 'test',
|
|
||||||
},
|
|
||||||
created_at: '14-10-2025',
|
|
||||||
updated_at: '14-10-2025',
|
|
||||||
};
|
|
||||||
|
|
||||||
const TransferToLayingDetail = () => {
|
const TransferToLayingDetail = () => {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const searchParams = useSearchParams();
|
const searchParams = useSearchParams();
|
||||||
@@ -114,11 +29,9 @@ const TransferToLayingDetail = () => {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: remove dummy data and integrate with real API
|
|
||||||
if (
|
if (
|
||||||
!isLoadingTransferToLaying &&
|
!isLoadingTransferToLaying &&
|
||||||
(!transferToLaying ||
|
(!transferToLaying || isResponseError(transferToLaying))
|
||||||
(isResponseError(transferToLaying) && !DUMMY_TRANSFER_TO_LAYING_DETAIL))
|
|
||||||
) {
|
) {
|
||||||
router.replace('/404');
|
router.replace('/404');
|
||||||
return;
|
return;
|
||||||
@@ -129,18 +42,13 @@ const TransferToLayingDetail = () => {
|
|||||||
{isLoadingTransferToLaying && (
|
{isLoadingTransferToLaying && (
|
||||||
<span className='loading loading-spinner loading-xl' />
|
<span className='loading loading-spinner loading-xl' />
|
||||||
)}
|
)}
|
||||||
{/* {!isLoadingTransferToLaying && isResponseSuccess(transferToLaying) && (
|
|
||||||
|
{!isLoadingTransferToLaying && isResponseSuccess(transferToLaying) && (
|
||||||
<TransferToLayingForm
|
<TransferToLayingForm
|
||||||
type='detail'
|
type='detail'
|
||||||
initialValues={transferToLaying.data}
|
initialValues={transferToLaying.data}
|
||||||
/>
|
/>
|
||||||
)} */}
|
)}
|
||||||
|
|
||||||
{/* TODO: remove this dummy data and integrate to real API */}
|
|
||||||
<TransferToLayingForm
|
|
||||||
type='detail'
|
|
||||||
initialValues={DUMMY_TRANSFER_TO_LAYING_DETAIL}
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user