mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 13:32:00 +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';
|
||||
|
||||
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 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 =====
|
||||
const createRecordingHandler = useCallback(
|
||||
async (
|
||||
@@ -2460,7 +2470,9 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
|
||||
}}
|
||||
>
|
||||
<Icon icon='material-symbols:egg' width={24} height={24} />
|
||||
Lanjut ke Grading
|
||||
{hasGradingData(initialValues)
|
||||
? 'Edit Grading'
|
||||
: 'Lanjut ke Grading'}
|
||||
</Button>
|
||||
)}
|
||||
|
||||
|
||||
+4
@@ -55,6 +55,10 @@ export type RecordingEgg = {
|
||||
qty: number;
|
||||
created_by: User;
|
||||
product_warehouse: ProductWarehouse;
|
||||
gradings?: {
|
||||
grade: string;
|
||||
qty: number;
|
||||
}[];
|
||||
};
|
||||
|
||||
export type GradingEgg = {
|
||||
|
||||
Reference in New Issue
Block a user