mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-24 15:25:46 +00:00
implement transition recording
This commit is contained in:
@@ -107,6 +107,13 @@ const RowOptionsMenu = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const isRecordingEditable = (recording: Recording) => {
|
const isRecordingEditable = (recording: Recording) => {
|
||||||
|
const isGrowingCategory =
|
||||||
|
recording.project_flock?.project_flock_category === 'GROWING';
|
||||||
|
const isGrowingLockedByLaying = isGrowingCategory && recording.is_laying;
|
||||||
|
if (isGrowingLockedByLaying) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
const currentIsLaying =
|
const currentIsLaying =
|
||||||
recording.project_flock?.project_flock_category === 'LAYING';
|
recording.project_flock?.project_flock_category === 'LAYING';
|
||||||
|
|
||||||
@@ -123,6 +130,20 @@ const RowOptionsMenu = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const getRecordingRestrictionInfo = (recording: Recording) => {
|
const getRecordingRestrictionInfo = (recording: Recording) => {
|
||||||
|
const isGrowingCategory =
|
||||||
|
recording.project_flock?.project_flock_category === 'GROWING';
|
||||||
|
const isGrowingLockedByLaying = isGrowingCategory && recording.is_laying;
|
||||||
|
if (isGrowingLockedByLaying) {
|
||||||
|
return {
|
||||||
|
canEditStock: false,
|
||||||
|
canEditDepletion: false,
|
||||||
|
canEditEgg: false,
|
||||||
|
isLocked: true,
|
||||||
|
lockReason:
|
||||||
|
'Recording Growing tidak dapat diubah karena sudah masuk fase laying dan dipakai pada recording laying',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
const currentIsLaying =
|
const currentIsLaying =
|
||||||
recording.project_flock?.project_flock_category === 'LAYING';
|
recording.project_flock?.project_flock_category === 'LAYING';
|
||||||
|
|
||||||
@@ -800,10 +821,11 @@ const RecordingTable = () => {
|
|||||||
{
|
{
|
||||||
header: 'Kategori',
|
header: 'Kategori',
|
||||||
cell: (props) => {
|
cell: (props) => {
|
||||||
const isLaying = props.row.original.is_laying;
|
|
||||||
const isTransition = props.row.original.is_transition;
|
const isTransition = props.row.original.is_transition;
|
||||||
const category = isLaying ? 'LAYING' : 'GROWING';
|
const category =
|
||||||
const color = isLaying ? 'info' : 'warning';
|
props.row.original.project_flock?.project_flock_category ||
|
||||||
|
'GROWING';
|
||||||
|
const color = category === 'LAYING' ? 'info' : 'warning';
|
||||||
return (
|
return (
|
||||||
<div className='flex flex-col gap-1'>
|
<div className='flex flex-col gap-1'>
|
||||||
<StatusBadge color={color} text={formatTitleCase(category)} />
|
<StatusBadge color={color} text={formatTitleCase(category)} />
|
||||||
|
|||||||
@@ -420,13 +420,15 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const projectFlockKandangLookupUrl = useMemo(() => {
|
const projectFlockKandangLookupUrl = useMemo(() => {
|
||||||
if (!selectedProjectFlock || !selectedKandang) return null;
|
if (!selectedProjectFlock || !selectedKandang || !selectedRecordDate)
|
||||||
|
return null;
|
||||||
const params = new URLSearchParams({
|
const params = new URLSearchParams({
|
||||||
project_flock_id: selectedProjectFlock.value.toString(),
|
project_flock_id: selectedProjectFlock.value.toString(),
|
||||||
kandang_id: selectedKandang.value.toString(),
|
kandang_id: selectedKandang.value.toString(),
|
||||||
|
record_date: selectedRecordDate,
|
||||||
});
|
});
|
||||||
return `${ProjectFlockApi.basePath}/kandangs/lookup?${params.toString()}`;
|
return `${ProjectFlockApi.basePath}/kandangs/lookup?${params.toString()}`;
|
||||||
}, [selectedProjectFlock, selectedKandang]);
|
}, [selectedProjectFlock, selectedKandang, selectedRecordDate]);
|
||||||
|
|
||||||
const { data: projectFlockKandangLookupData } = useSWR(
|
const { data: projectFlockKandangLookupData } = useSWR(
|
||||||
projectFlockKandangLookupUrl,
|
projectFlockKandangLookupUrl,
|
||||||
@@ -548,6 +550,13 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
|
|||||||
const isRecordingEditable = useCallback((recording?: Recording) => {
|
const isRecordingEditable = useCallback((recording?: Recording) => {
|
||||||
if (!recording) return true;
|
if (!recording) return true;
|
||||||
|
|
||||||
|
const isGrowingCategory =
|
||||||
|
recording.project_flock?.project_flock_category === 'GROWING';
|
||||||
|
const isGrowingLockedByLaying = isGrowingCategory && recording.is_laying;
|
||||||
|
if (isGrowingLockedByLaying) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
const currentIsLaying =
|
const currentIsLaying =
|
||||||
recording.project_flock?.project_flock_category === 'LAYING';
|
recording.project_flock?.project_flock_category === 'LAYING';
|
||||||
|
|
||||||
@@ -2066,13 +2075,22 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
|
|||||||
<div>
|
<div>
|
||||||
<span className='text-sm text-gray-600'>Kategori</span>
|
<span className='text-sm text-gray-600'>Kategori</span>
|
||||||
<p className='font-semibold'>
|
<p className='font-semibold'>
|
||||||
|
{(() => {
|
||||||
|
const category =
|
||||||
|
initialValues.project_flock?.project_flock_category ||
|
||||||
|
'GROWING';
|
||||||
|
const color =
|
||||||
|
category === 'LAYING' ? 'info' : 'warning';
|
||||||
|
return (
|
||||||
<Badge
|
<Badge
|
||||||
variant='soft'
|
variant='soft'
|
||||||
color={initialValues.is_laying ? 'info' : 'warning'}
|
color={color}
|
||||||
size='sm'
|
size='sm'
|
||||||
>
|
>
|
||||||
{initialValues.is_laying ? 'LAYING' : 'GROWING'}
|
{category}
|
||||||
</Badge>
|
</Badge>
|
||||||
|
);
|
||||||
|
})()}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
|
|||||||
Reference in New Issue
Block a user