mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 13:32:00 +00:00
fix(FE-270): delete relations project flock to flock data master
This commit is contained in:
@@ -1,11 +0,0 @@
|
|||||||
import SuspenseHelper from '@/components/helper/SuspenseHelper';
|
|
||||||
|
|
||||||
const Layout = ({
|
|
||||||
children,
|
|
||||||
}: Readonly<{
|
|
||||||
children: React.ReactNode;
|
|
||||||
}>) => {
|
|
||||||
return <SuspenseHelper>{children}</SuspenseHelper>;
|
|
||||||
};
|
|
||||||
|
|
||||||
export default Layout;
|
|
||||||
@@ -1,343 +0,0 @@
|
|||||||
'use client';
|
|
||||||
|
|
||||||
import Button from '@/components/Button';
|
|
||||||
import Card from '@/components/Card';
|
|
||||||
import Modal, { useModal } from '@/components/Modal';
|
|
||||||
import ConfirmationModal from '@/components/modal/ConfirmationModal';
|
|
||||||
import ChickinForm from '@/components/pages/production/chickin/form/ChickinForm';
|
|
||||||
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
|
|
||||||
import { ChickinApi } from '@/services/api/production/chickin';
|
|
||||||
import { BaseApiResponse } from '@/types/api/api-general';
|
|
||||||
import {
|
|
||||||
Chickin,
|
|
||||||
ChickinApprovalPayload,
|
|
||||||
} from '@/types/api/production/chickin';
|
|
||||||
import { Icon } from '@iconify/react';
|
|
||||||
import { useRouter, useSearchParams } from 'next/navigation';
|
|
||||||
import { useState } from 'react';
|
|
||||||
import toast from 'react-hot-toast';
|
|
||||||
import useSWR from 'swr';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* TODO: Refactor code - pindahin detail ke reuseable component
|
|
||||||
* setelah implement approval and reject
|
|
||||||
*/
|
|
||||||
|
|
||||||
const DetailChickin = () => {
|
|
||||||
const router = useRouter();
|
|
||||||
const searchParams = useSearchParams();
|
|
||||||
const chickinId = searchParams.get('chickinId');
|
|
||||||
const [isApproveLoading, setIsApproveLoading] = useState(false);
|
|
||||||
const [isDeleteLoading, setIsDeleteLoading] = useState(false);
|
|
||||||
|
|
||||||
const confirmModal = useModal();
|
|
||||||
const deleteModal = useModal();
|
|
||||||
const chickinModal = useModal();
|
|
||||||
const {
|
|
||||||
data: chickin,
|
|
||||||
isLoading,
|
|
||||||
mutate: refreshChickin,
|
|
||||||
} = useSWR(chickinId, (id: number) => ChickinApi.getSingle(id));
|
|
||||||
|
|
||||||
const [isApprovedDisabled, setIsApprovedDisabled] = useState(
|
|
||||||
// chickin.data?.approval.step_number == 1 ? false : true
|
|
||||||
true
|
|
||||||
);
|
|
||||||
const [isRejectedDisabled, setIsRejectedDisabled] =
|
|
||||||
useState(!isApprovedDisabled);
|
|
||||||
const [approvalAction, setApprovalAction] = useState<'APPROVED' | 'REJECTED'>(
|
|
||||||
!isApprovedDisabled ? 'APPROVED' : 'REJECTED'
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!chickinId) {
|
|
||||||
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 (!isLoading && (!chickin || isResponseError(chickin))) {
|
|
||||||
router.replace('/404');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isResponseSuccess(chickin)) {
|
|
||||||
return (
|
|
||||||
<div className='w-full flex flex-row justify-center items-center p-4'>
|
|
||||||
<span className='loading loading-spinner loading-xl' />
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const confirmationModalClickHandler = async ({
|
|
||||||
action = 'APPROVED',
|
|
||||||
}: {
|
|
||||||
action: 'APPROVED' | 'REJECTED';
|
|
||||||
}) => {
|
|
||||||
if (chickin?.data.id === undefined) return;
|
|
||||||
setIsApproveLoading(true);
|
|
||||||
const approveChickinRes = await ChickinApi.customRequest<
|
|
||||||
BaseApiResponse<Chickin>,
|
|
||||||
ChickinApprovalPayload
|
|
||||||
>(`/approvals`, {
|
|
||||||
method: 'POST',
|
|
||||||
payload: {
|
|
||||||
action: action,
|
|
||||||
approvable_ids: [chickin.data.id],
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
if (isResponseSuccess(approveChickinRes)) {
|
|
||||||
if (refreshChickin) {
|
|
||||||
await refreshChickin();
|
|
||||||
}
|
|
||||||
toast.success(approveChickinRes.message as string);
|
|
||||||
}
|
|
||||||
if (isResponseError(approveChickinRes)) {
|
|
||||||
toast.error(approveChickinRes?.message as string);
|
|
||||||
}
|
|
||||||
confirmModal.closeModal();
|
|
||||||
setIsApproveLoading(false);
|
|
||||||
};
|
|
||||||
|
|
||||||
const confirmationModalDeleteClickHandler = async () => {
|
|
||||||
setIsDeleteLoading(true);
|
|
||||||
const deleteProjectFlockRes = await ChickinApi.delete(
|
|
||||||
chickin.data?.id as number
|
|
||||||
);
|
|
||||||
|
|
||||||
if (isResponseSuccess(deleteProjectFlockRes)) {
|
|
||||||
toast.success(deleteProjectFlockRes?.message as string);
|
|
||||||
router.push('/production/chickin');
|
|
||||||
}
|
|
||||||
if (isResponseError(deleteProjectFlockRes)) {
|
|
||||||
toast.error(deleteProjectFlockRes?.message as string);
|
|
||||||
}
|
|
||||||
deleteModal.closeModal();
|
|
||||||
setIsDeleteLoading(false);
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<div className='w-full p-4 flex flex-col justify-center gap-4'>
|
|
||||||
{isLoading && <span className='loading loading-spinner loading-xl' />}
|
|
||||||
{!isLoading && isResponseSuccess(chickin) && (
|
|
||||||
<>
|
|
||||||
{/* <div className='w-full flex flex-col sm:flex-row gap-2'>
|
|
||||||
<Button
|
|
||||||
variant='outline'
|
|
||||||
color='success'
|
|
||||||
onClick={(() => {
|
|
||||||
if (chickin?.data.id) {
|
|
||||||
setApprovalAction('APPROVED');
|
|
||||||
confirmModal.openModal();
|
|
||||||
}
|
|
||||||
})}
|
|
||||||
disabled={!chickin?.data.id || isApprovedDisabled}
|
|
||||||
className='w-full sm:w-fit'
|
|
||||||
>
|
|
||||||
<Icon icon='material-symbols:check' width={24} height={24} />
|
|
||||||
Approve
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
variant='outline'
|
|
||||||
color='error'
|
|
||||||
onClick={() => {
|
|
||||||
if (chickin?.data.id) {
|
|
||||||
setApprovalAction('REJECTED');
|
|
||||||
confirmModal.openModal();
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
disabled={!chickin?.data.id || isRejectedDisabled}
|
|
||||||
className='w-full sm:w-fit'
|
|
||||||
>
|
|
||||||
<Icon icon='mdi:times' width={24} height={24} />
|
|
||||||
Reject
|
|
||||||
</Button>
|
|
||||||
</div> */}
|
|
||||||
<Card
|
|
||||||
title='Informasi Umum'
|
|
||||||
variant='bordered'
|
|
||||||
className={{
|
|
||||||
wrapper: 'w-full',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<div className='grid grid-cols-2 gap-4 mt-4'>
|
|
||||||
<div className='flex flex-col gap-2'>
|
|
||||||
<div className='font-semibold text-sm'>Flock</div>
|
|
||||||
<div className='text-sm'>
|
|
||||||
{
|
|
||||||
chickin?.data?.project_flock_kandang?.project_flock?.flock
|
|
||||||
?.name
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className='flex flex-col gap-2'>
|
|
||||||
<div className='font-semibold text-sm'>Area</div>
|
|
||||||
<div className='text-sm'>
|
|
||||||
{
|
|
||||||
chickin.data.project_flock_kandang?.project_flock.area
|
|
||||||
.name
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className='flex flex-col gap-2'>
|
|
||||||
<div className='font-semibold text-sm'>Kategori</div>
|
|
||||||
<div className='text-sm'>
|
|
||||||
{chickin.data.project_flock_kandang?.project_flock.category}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className='flex flex-col gap-2'>
|
|
||||||
<div className='font-semibold text-sm'>Lokasi</div>
|
|
||||||
<div className='text-sm'>
|
|
||||||
{
|
|
||||||
chickin.data.project_flock_kandang?.project_flock.location
|
|
||||||
.name
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className='flex flex-col gap-2'>
|
|
||||||
<div className='font-semibold text-sm'>Periode</div>
|
|
||||||
<div className='text-sm'>
|
|
||||||
{chickin.data.project_flock_kandang?.project_flock.period}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className='flex flex-col gap-2'>
|
|
||||||
<div className='font-semibold text-sm'>Kandang</div>
|
|
||||||
<div className='text-sm'>
|
|
||||||
{chickin.data.project_flock_kandang?.kandang.name}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</Card>
|
|
||||||
<Card
|
|
||||||
title='Detail Chickin'
|
|
||||||
variant='bordered'
|
|
||||||
className={{
|
|
||||||
wrapper: 'w-full',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<div className='grid grid-cols-2 gap-4 mt-4'>
|
|
||||||
<div className='flex flex-col gap-2'>
|
|
||||||
<div className='font-semibold text-sm'>Flock Kandang</div>
|
|
||||||
<div className='text-sm'>
|
|
||||||
{
|
|
||||||
chickin?.data?.project_flock_kandang?.project_flock?.flock
|
|
||||||
?.name
|
|
||||||
}{' '}
|
|
||||||
- {chickin.data.project_flock_kandang?.kandang.name}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className='flex flex-col gap-2'>
|
|
||||||
<div className='font-semibold text-sm'>Tanggal Chickin</div>
|
|
||||||
<div className='text-sm'>
|
|
||||||
{chickin.data.chick_in_date
|
|
||||||
? new Date(chickin.data.chick_in_date).toLocaleDateString(
|
|
||||||
'id-ID'
|
|
||||||
)
|
|
||||||
: '-'}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className='flex flex-col gap-2'>
|
|
||||||
<div className='font-semibold text-sm'>Jumlah (Ekor)</div>
|
|
||||||
<div className='text-sm'>
|
|
||||||
{chickin.data.quantity?.toLocaleString('id-ID')}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className='flex flex-col gap-2'>
|
|
||||||
<div className='font-semibold text-sm'>Catatan</div>
|
|
||||||
<div className='text-sm'>{chickin.data.note}</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</Card>
|
|
||||||
<div className='w-full flex flex-col sm:flex-row gap-2'>
|
|
||||||
<Button
|
|
||||||
color='error'
|
|
||||||
onClick={() => {
|
|
||||||
deleteModal.openModal();
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Icon icon='mdi:times' width={24} height={24} />
|
|
||||||
Delete
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
color='warning'
|
|
||||||
onClick={() => {
|
|
||||||
chickinModal.openModal();
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Icon icon='mdi:pencil-outline' width={24} height={24} />
|
|
||||||
Edit
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<ConfirmationModal
|
|
||||||
ref={deleteModal.ref}
|
|
||||||
type='error'
|
|
||||||
text={`Apakah anda yakin ingin menghapus data Project Flock ini (${chickin?.data?.project_flock_kandang?.project_flock.flock?.name} - ${chickin?.data.project_flock_kandang?.kandang.name})?`}
|
|
||||||
secondaryButton={{
|
|
||||||
text: 'Tidak',
|
|
||||||
}}
|
|
||||||
primaryButton={{
|
|
||||||
text: 'Ya',
|
|
||||||
color: 'error',
|
|
||||||
isLoading: isDeleteLoading,
|
|
||||||
onClick: confirmationModalDeleteClickHandler,
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<Modal ref={chickinModal.ref}>
|
|
||||||
<div className='flex flex-row justify-between items-center'>
|
|
||||||
<h1 className='text-xl font-semibold text-center mb-6'>
|
|
||||||
Chickin Kandang -{' '}
|
|
||||||
{chickin?.data?.project_flock_kandang &&
|
|
||||||
chickin?.data?.project_flock_kandang.kandang?.name}
|
|
||||||
</h1>
|
|
||||||
<Button
|
|
||||||
color='error'
|
|
||||||
variant='link'
|
|
||||||
onClick={chickinModal.closeModal}
|
|
||||||
>
|
|
||||||
<Icon
|
|
||||||
className='text-black'
|
|
||||||
icon='uil:times'
|
|
||||||
width={24}
|
|
||||||
height={24}
|
|
||||||
/>
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
</Modal>
|
|
||||||
|
|
||||||
<ConfirmationModal
|
|
||||||
ref={confirmModal.ref}
|
|
||||||
type={approvalAction == 'APPROVED' ? 'success' : 'error'}
|
|
||||||
text={`Apakah anda yakin ingin ${
|
|
||||||
approvalAction == 'APPROVED' ? 'approve' : 'reject'
|
|
||||||
} chickin berikut? (${
|
|
||||||
chickin?.data?.project_flock_kandang?.project_flock?.flock?.name
|
|
||||||
} - ${chickin?.data.project_flock_kandang?.kandang.name})?`}
|
|
||||||
secondaryButton={{
|
|
||||||
text: 'Tidak',
|
|
||||||
}}
|
|
||||||
primaryButton={{
|
|
||||||
text: 'Ya',
|
|
||||||
color: approvalAction == 'APPROVED' ? 'success' : 'error',
|
|
||||||
isLoading: isApproveLoading,
|
|
||||||
onClick: () => {
|
|
||||||
confirmationModalClickHandler({
|
|
||||||
action: approvalAction,
|
|
||||||
});
|
|
||||||
},
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default DetailChickin;
|
|
||||||
@@ -579,7 +579,7 @@ const ProjectFlockTable = () => {
|
|||||||
<ConfirmationModal
|
<ConfirmationModal
|
||||||
ref={deleteModal.ref}
|
ref={deleteModal.ref}
|
||||||
type='error'
|
type='error'
|
||||||
text={`Apakah anda yakin ingin menghapus data Project Flock ini (${selectedProjectFlock?.flock?.name})?`}
|
text={`Apakah anda yakin ingin menghapus data Project Flock ini (${selectedProjectFlock?.flock_name})?`}
|
||||||
secondaryButton={{
|
secondaryButton={{
|
||||||
text: 'Tidak',
|
text: 'Tidak',
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -285,13 +285,24 @@ const ProjectFlockForm = ({
|
|||||||
|
|
||||||
// Formik InitialValue
|
// Formik InitialValue
|
||||||
const formikInitialValues = useMemo<ProjectFlockFormValues>(() => {
|
const formikInitialValues = useMemo<ProjectFlockFormValues>(() => {
|
||||||
|
const trimFlock =
|
||||||
|
initialValues?.flock_name?.slice(
|
||||||
|
0,
|
||||||
|
initialValues?.flock_name?.lastIndexOf(' ')
|
||||||
|
) ?? '';
|
||||||
return {
|
return {
|
||||||
name: initialValues?.flock_name,
|
flock: initialValues?.flock_name
|
||||||
flock: initialValues?.flock
|
|
||||||
? {
|
? {
|
||||||
value: initialValues?.flock?.id ?? 0,
|
value:
|
||||||
|
optionsFlock.find((flock) => {
|
||||||
|
return flock.label == trimFlock;
|
||||||
|
})?.value ?? 0,
|
||||||
label:
|
label:
|
||||||
initialValues?.flock?.name ?? initialValues?.flock_name ?? '',
|
formType != 'detail'
|
||||||
|
? (optionsFlock.find((flock) => {
|
||||||
|
return flock.label == trimFlock;
|
||||||
|
})?.label ?? '')
|
||||||
|
: initialValues?.flock_name,
|
||||||
}
|
}
|
||||||
: null,
|
: null,
|
||||||
area: initialValues?.area
|
area: initialValues?.area
|
||||||
@@ -318,8 +329,16 @@ const ProjectFlockForm = ({
|
|||||||
label: initialValues.location.name,
|
label: initialValues.location.name,
|
||||||
}
|
}
|
||||||
: null,
|
: null,
|
||||||
flock_id: initialValues?.flock?.id ?? 0,
|
flock_name:
|
||||||
flock_name: initialValues?.flock_name ?? '',
|
optionsFlock.find((flock) => {
|
||||||
|
return (
|
||||||
|
flock.label ==
|
||||||
|
initialValues?.flock_name?.slice(
|
||||||
|
0,
|
||||||
|
initialValues?.flock_name?.lastIndexOf(' ')
|
||||||
|
)
|
||||||
|
);
|
||||||
|
})?.label ?? '',
|
||||||
area_id: initialValues?.area?.id ?? 0,
|
area_id: initialValues?.area?.id ?? 0,
|
||||||
category: initialValues?.category as NonNullable<
|
category: initialValues?.category as NonNullable<
|
||||||
'GROWING' | 'LAYING' | undefined
|
'GROWING' | 'LAYING' | undefined
|
||||||
@@ -331,17 +350,35 @@ const ProjectFlockForm = ({
|
|||||||
| undefined
|
| undefined
|
||||||
)[],
|
)[],
|
||||||
};
|
};
|
||||||
}, [initialValues]);
|
}, [initialValues, optionsFlock]);
|
||||||
|
|
||||||
// Formik
|
// Formik
|
||||||
const formik = useFormik<ProjectFlockFormValues>({
|
const formik = useFormik<ProjectFlockFormValues>({
|
||||||
initialValues: {
|
initialValues: {
|
||||||
name: initialValues?.flock_name,
|
flock: initialValues?.flock_name
|
||||||
flock: initialValues?.flock
|
|
||||||
? {
|
? {
|
||||||
value: initialValues?.flock?.id ?? 0,
|
value:
|
||||||
|
optionsFlock.find((flock) => {
|
||||||
|
return (
|
||||||
|
flock.label ==
|
||||||
|
initialValues?.flock_name?.slice(
|
||||||
|
0,
|
||||||
|
initialValues?.flock_name?.lastIndexOf(' ')
|
||||||
|
)
|
||||||
|
);
|
||||||
|
})?.value ?? 0,
|
||||||
label:
|
label:
|
||||||
initialValues?.flock?.name ?? initialValues?.flock_name ?? '',
|
formType != 'detail'
|
||||||
|
? (optionsFlock.find((flock) => {
|
||||||
|
return (
|
||||||
|
flock.label ==
|
||||||
|
initialValues?.flock_name?.slice(
|
||||||
|
0,
|
||||||
|
initialValues?.flock_name?.lastIndexOf(' ')
|
||||||
|
)
|
||||||
|
);
|
||||||
|
})?.label ?? '')
|
||||||
|
: initialValues?.flock_name,
|
||||||
}
|
}
|
||||||
: null,
|
: null,
|
||||||
area: initialValues?.area
|
area: initialValues?.area
|
||||||
@@ -368,8 +405,18 @@ const ProjectFlockForm = ({
|
|||||||
label: initialValues.location.name,
|
label: initialValues.location.name,
|
||||||
}
|
}
|
||||||
: null,
|
: null,
|
||||||
flock_id: initialValues?.flock?.id ?? 0,
|
flock_name:
|
||||||
flock_name: initialValues?.flock_name ?? '',
|
formType != 'detail'
|
||||||
|
? optionsFlock.find((flock) => {
|
||||||
|
return (
|
||||||
|
flock.label ==
|
||||||
|
initialValues?.flock_name?.slice(
|
||||||
|
0,
|
||||||
|
initialValues?.flock_name?.lastIndexOf(' ')
|
||||||
|
)
|
||||||
|
);
|
||||||
|
})?.label
|
||||||
|
: (initialValues?.flock_name ?? ''),
|
||||||
area_id: initialValues?.area?.id ?? 0,
|
area_id: initialValues?.area?.id ?? 0,
|
||||||
category: initialValues?.category as NonNullable<
|
category: initialValues?.category as NonNullable<
|
||||||
'GROWING' | 'LAYING' | undefined
|
'GROWING' | 'LAYING' | undefined
|
||||||
@@ -390,7 +437,7 @@ const ProjectFlockForm = ({
|
|||||||
onSubmit: async (values) => {
|
onSubmit: async (values) => {
|
||||||
setProjectFlockFormErrorMessage('');
|
setProjectFlockFormErrorMessage('');
|
||||||
const payload: CreateProjectFlockPayload = {
|
const payload: CreateProjectFlockPayload = {
|
||||||
flock_name: values.flock?.label as string,
|
flock_name: values.flock_name as string,
|
||||||
area_id: values.area_id as number,
|
area_id: values.area_id as number,
|
||||||
category: values.category as string,
|
category: values.category as string,
|
||||||
fcr_id: values.fcr_id as number,
|
fcr_id: values.fcr_id as number,
|
||||||
@@ -599,7 +646,6 @@ const ProjectFlockForm = ({
|
|||||||
<div className='card bg-base-100 shadow w-full mb-6'>
|
<div className='card bg-base-100 shadow w-full mb-6'>
|
||||||
<div className='card-body'>
|
<div className='card-body'>
|
||||||
<div className='card-title mb-4'>Informasi Umum</div>
|
<div className='card-title mb-4'>Informasi Umum</div>
|
||||||
{selectedFlock}
|
|
||||||
<div className='grid sm:grid-cols-2 gap-4'>
|
<div className='grid sm:grid-cols-2 gap-4'>
|
||||||
<SelectInput
|
<SelectInput
|
||||||
required
|
required
|
||||||
@@ -621,16 +667,16 @@ const ProjectFlockForm = ({
|
|||||||
value={
|
value={
|
||||||
formik.values.flock_name
|
formik.values.flock_name
|
||||||
? ({
|
? ({
|
||||||
label: selectedFlock,
|
label: formik.values.flock_name,
|
||||||
value: optionsFlock.find((flock) => {
|
value: optionsFlock.find((flock) => {
|
||||||
return flock.label === selectedFlock;
|
return flock.label === formik.values.flock_name;
|
||||||
})?.value,
|
})?.value,
|
||||||
} as OptionType)
|
} as OptionType)
|
||||||
: undefined
|
: undefined
|
||||||
}
|
}
|
||||||
onChange={(val) => {
|
onChange={(val) => {
|
||||||
optionChangeHandler(val, 'flock');
|
optionChangeHandler(val, 'flock');
|
||||||
setSelectedFlock((val as OptionType)?.label as string);
|
setSelectedFlock((val as OptionType)?.label);
|
||||||
formik.setFieldValue(
|
formik.setFieldValue(
|
||||||
'flock_name',
|
'flock_name',
|
||||||
(val as OptionType)?.label
|
(val as OptionType)?.label
|
||||||
@@ -812,7 +858,7 @@ const ProjectFlockForm = ({
|
|||||||
<ConfirmationModal
|
<ConfirmationModal
|
||||||
ref={deleteModal.ref}
|
ref={deleteModal.ref}
|
||||||
type='error'
|
type='error'
|
||||||
text={`Apakah anda yakin ingin menghapus data Project Flock ini (${initialValues?.flock?.name} - ${initialValues?.area?.name})?`}
|
text={`Apakah anda yakin ingin menghapus data Project Flock ini (${initialValues?.flock_name} - ${initialValues?.area?.name})?`}
|
||||||
secondaryButton={{
|
secondaryButton={{
|
||||||
text: 'Tidak',
|
text: 'Tidak',
|
||||||
}}
|
}}
|
||||||
@@ -829,7 +875,7 @@ const ProjectFlockForm = ({
|
|||||||
type={approvalAction == 'APPROVED' ? 'success' : 'error'}
|
type={approvalAction == 'APPROVED' ? 'success' : 'error'}
|
||||||
text={`Apakah anda yakin ingin ${
|
text={`Apakah anda yakin ingin ${
|
||||||
approvalAction == 'APPROVED' ? 'approve' : 'reject'
|
approvalAction == 'APPROVED' ? 'approve' : 'reject'
|
||||||
} Project Flock berikut? (${initialValues?.flock?.name} - ${
|
} Project Flock berikut? (${initialValues?.flock_name} - ${
|
||||||
initialValues?.area?.name
|
initialValues?.area?.name
|
||||||
})?`}
|
})?`}
|
||||||
secondaryButton={{
|
secondaryButton={{
|
||||||
|
|||||||
+1
-3
@@ -9,10 +9,8 @@ export type BaseProjectFlock = {
|
|||||||
id: number;
|
id: number;
|
||||||
name: string;
|
name: string;
|
||||||
flock_name: string;
|
flock_name: string;
|
||||||
|
flock?: Flock; // Deprecated
|
||||||
status: string;
|
status: string;
|
||||||
flock?: Flock;
|
|
||||||
flock_i?: number;
|
|
||||||
flock_name: string;
|
|
||||||
area: Area;
|
area: Area;
|
||||||
area_id: number;
|
area_id: number;
|
||||||
category: string;
|
category: string;
|
||||||
|
|||||||
Reference in New Issue
Block a user