mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-22 22:35:45 +00:00
refactor(FE-316): Centralize uniformity types and add typings
This commit is contained in:
@@ -125,12 +125,14 @@ const UniformityDetailsPreview = ({
|
||||
const tableData = useMemo(() => {
|
||||
if (!uniformity_details) return [];
|
||||
|
||||
return uniformity_details.map((detail, index) => ({
|
||||
id: `body-weight-${index + 1}`,
|
||||
number: index + 1,
|
||||
weight: detail.weight,
|
||||
status: detail.range.toLowerCase() as 'ideal' | 'outside',
|
||||
}));
|
||||
return uniformity_details.map(
|
||||
(detail: UniformityDetailItem, index: number) => ({
|
||||
id: `body-weight-${index + 1}`,
|
||||
number: index + 1,
|
||||
weight: detail.weight,
|
||||
status: detail.range.toLowerCase() as 'ideal' | 'outside',
|
||||
})
|
||||
);
|
||||
}, [uniformity_details]);
|
||||
|
||||
const columnsUniformity: ColumnDef<BodyWeightData>[] = useMemo(
|
||||
|
||||
@@ -79,6 +79,14 @@ export const UniformityFormSchema: Yup.ObjectSchema<UniformityFormSchemaType> =
|
||||
|
||||
export type UniformityFormValues = Yup.InferType<typeof UniformityFormSchema>;
|
||||
|
||||
export type UniformityFormData = {
|
||||
date: string;
|
||||
week: number;
|
||||
project_flock_kandang_id: number;
|
||||
file: File | null;
|
||||
fileName: string;
|
||||
};
|
||||
|
||||
export const getUniformityFormInitialValues = (
|
||||
initialValues?: Uniformity
|
||||
): UniformityFormValues => {
|
||||
|
||||
@@ -10,7 +10,10 @@ import { useUiStore } from '@/stores/ui/ui.store';
|
||||
import { useUniformityStore } from '@/stores/uniformity/uniformity.store';
|
||||
import RequirePermission from '@/components/helper/RequirePermission';
|
||||
import Table from '@/components/Table';
|
||||
import { BodyWeightData } from '@/types/api/uniformity/uniformity';
|
||||
import {
|
||||
BodyWeightData,
|
||||
UniformityDetailItem,
|
||||
} from '@/types/api/uniformity/uniformity';
|
||||
|
||||
const UniformityPreviewForm = () => {
|
||||
const setExpandedDrawerOpen = useUiStore((s) => s.setExpandedDrawerOpen);
|
||||
@@ -34,11 +37,13 @@ const UniformityPreviewForm = () => {
|
||||
const tableData = useMemo(() => {
|
||||
if (!verifyUniformityResult) return [];
|
||||
|
||||
return verifyUniformityResult.uniformity_details.map((detail, index) => ({
|
||||
id: `weight-${index}`,
|
||||
number: index + 1,
|
||||
weight: detail.weight,
|
||||
}));
|
||||
return verifyUniformityResult.uniformity_details.map(
|
||||
(detail: UniformityDetailItem, index: number) => ({
|
||||
id: `weight-${index}`,
|
||||
number: index + 1,
|
||||
weight: detail.weight,
|
||||
})
|
||||
);
|
||||
}, [verifyUniformityResult]);
|
||||
|
||||
const columns: ColumnDef<BodyWeightData>[] = useMemo(
|
||||
|
||||
@@ -22,7 +22,10 @@ import {
|
||||
getWeightStatusText,
|
||||
} from '@/components/pages/uniformity/uniformity-utils';
|
||||
import { DetailOptionType } from '@/types/api/uniformity/uniformity';
|
||||
import { BodyWeightData } from '@/types/api/uniformity/uniformity';
|
||||
import {
|
||||
BodyWeightData,
|
||||
UniformityDetailItem,
|
||||
} from '@/types/api/uniformity/uniformity';
|
||||
|
||||
const UniformityResultForm = () => {
|
||||
const router = useRouter();
|
||||
@@ -169,12 +172,14 @@ const UniformityResultForm = () => {
|
||||
const tableData = useMemo(() => {
|
||||
if (!verifyUniformityResult) return [];
|
||||
|
||||
return verifyUniformityResult.uniformity_details.map((detail, index) => ({
|
||||
id: `body-weight-${index + 1}`,
|
||||
number: index + 1,
|
||||
weight: detail.weight,
|
||||
status: detail.range.toLowerCase() as 'ideal' | 'outside',
|
||||
}));
|
||||
return verifyUniformityResult.uniformity_details.map(
|
||||
(detail: UniformityDetailItem, index: number) => ({
|
||||
id: `body-weight-${index + 1}`,
|
||||
number: index + 1,
|
||||
weight: detail.weight,
|
||||
status: detail.range.toLowerCase() as 'ideal' | 'outside',
|
||||
})
|
||||
);
|
||||
}, [verifyUniformityResult]);
|
||||
|
||||
const columnsUniformity: ColumnDef<BodyWeightData>[] = useMemo(
|
||||
|
||||
Reference in New Issue
Block a user