mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-24 23:35:45 +00:00
feat(FE-170,175): add grading data handling in RecordingForm and update types
This commit is contained in:
@@ -48,7 +48,7 @@ import {
|
|||||||
} from './RecordingForm.schema';
|
} from './RecordingForm.schema';
|
||||||
|
|
||||||
import { isResponseSuccess, isResponseError } from '@/lib/api-helper';
|
import { isResponseSuccess, isResponseError } from '@/lib/api-helper';
|
||||||
import { cn, formatDate } from '@/lib/helper';
|
import { formatDate } from '@/lib/helper';
|
||||||
import toast from 'react-hot-toast';
|
import toast from 'react-hot-toast';
|
||||||
import StepItem from '@/components/steps/StepItem';
|
import StepItem from '@/components/steps/StepItem';
|
||||||
|
|
||||||
@@ -102,6 +102,16 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
|
|||||||
);
|
);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
const hasGradingData = useCallback((recording?: Recording) => {
|
||||||
|
if (!recording || !recording.eggs) return false;
|
||||||
|
return recording.eggs.some(
|
||||||
|
(egg) =>
|
||||||
|
egg.gradings &&
|
||||||
|
egg.gradings.length > 0 &&
|
||||||
|
egg.gradings.some((grading) => grading.qty > 0)
|
||||||
|
);
|
||||||
|
}, []);
|
||||||
|
|
||||||
// ===== FORM HANDLERS =====
|
// ===== FORM HANDLERS =====
|
||||||
const createRecordingHandler = useCallback(
|
const createRecordingHandler = useCallback(
|
||||||
async (
|
async (
|
||||||
@@ -2460,7 +2470,9 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Icon icon='material-symbols:egg' width={24} height={24} />
|
<Icon icon='material-symbols:egg' width={24} height={24} />
|
||||||
Lanjut ke Grading
|
{hasGradingData(initialValues)
|
||||||
|
? 'Edit Grading'
|
||||||
|
: 'Lanjut ke Grading'}
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
|||||||
+4
@@ -55,6 +55,10 @@ export type RecordingEgg = {
|
|||||||
qty: number;
|
qty: number;
|
||||||
created_by: User;
|
created_by: User;
|
||||||
product_warehouse: ProductWarehouse;
|
product_warehouse: ProductWarehouse;
|
||||||
|
gradings?: {
|
||||||
|
grade: string;
|
||||||
|
qty: number;
|
||||||
|
}[];
|
||||||
};
|
};
|
||||||
|
|
||||||
export type GradingEgg = {
|
export type GradingEgg = {
|
||||||
|
|||||||
Reference in New Issue
Block a user