| @@ -4,13 +4,14 @@ import { convertObjToURLSearchParams } from "@/app/utils/commonUtil"; | |||||
| import { serverFetchJson } from "@/app/utils/fetchUtil" | import { serverFetchJson } from "@/app/utils/fetchUtil" | ||||
| import { BASE_API_URL } from "@/config/api" | import { BASE_API_URL } from "@/config/api" | ||||
| import { cache } from "react" | import { cache } from "react" | ||||
| import { ScheduleType } from "."; | |||||
| export interface SearchProdSchedule { | export interface SearchProdSchedule { | ||||
| scheduleAt?: string; | scheduleAt?: string; | ||||
| schedulePeriod?: string; | schedulePeriod?: string; | ||||
| schedulePeriodTo?: string; | schedulePeriodTo?: string; | ||||
| totalEstProdCount?: number; | totalEstProdCount?: number; | ||||
| type?: "manual" | "detailed" | "rough"; | |||||
| types?: ScheduleType[]; | |||||
| pageSize?: number; | pageSize?: number; | ||||
| pageNum?: number; | pageNum?: number; | ||||
| } | } | ||||
| @@ -40,4 +41,24 @@ export const fetchProdSchedules = cache(async (data: SearchProdSchedule | null) | |||||
| tags: ["prodSchedules"] | tags: ["prodSchedules"] | ||||
| } | } | ||||
| }) | }) | ||||
| }) | |||||
| export const testRoughSchedule = cache(async () => { | |||||
| return serverFetchJson(`${BASE_API_URL}/productionSchedule/testRoughSchedule`, { | |||||
| method: "GET", | |||||
| headers: { "Content-Type": "application/json" }, | |||||
| next: { | |||||
| tags: ["prodSchedules"] | |||||
| } | |||||
| }) | |||||
| }) | |||||
| export const testDetailSchedule = cache(async () => { | |||||
| return serverFetchJson(`${BASE_API_URL}/productionSchedule/testDetailSchedule`, { | |||||
| method: "GET", | |||||
| headers: { "Content-Type": "application/json" }, | |||||
| next: { | |||||
| tags: ["prodSchedules"] | |||||
| } | |||||
| }) | |||||
| }) | }) | ||||
| @@ -3,9 +3,9 @@ import { BASE_API_URL } from "@/config/api" | |||||
| import { cache } from "react" | import { cache } from "react" | ||||
| import "server-only" | import "server-only" | ||||
| export type ScheduleType = "rough" | "detail"; | |||||
| export type ScheduleType = "all" | "rough" | "detailed" | "manual"; | |||||
| export interface ProdScheduleResult { | |||||
| export interface RoughProdScheduleResult { | |||||
| id: number; | id: number; | ||||
| scheduleAt: number[]; | scheduleAt: number[]; | ||||
| schedulePeriod: number[]; | schedulePeriod: number[]; | ||||
| @@ -13,13 +13,13 @@ export interface ProdScheduleResult { | |||||
| totalEstProdCount: number; | totalEstProdCount: number; | ||||
| totalFGType: number; | totalFGType: number; | ||||
| type: string; | type: string; | ||||
| prodScheduleLinesByFg: ProdScheduleLineResultByFg[]; | |||||
| prodScheduleLinesByFgByDate: { [assignDate: number]: ProdScheduleLineResultByFg[] }; | |||||
| prodScheduleLinesByBom: ProdScheduleLineResultByBom[]; | |||||
| prodScheduleLinesByBomByDate: { [assignDate: number]: ProdScheduleLineResultByBomByDate[] }; | |||||
| prodScheduleLinesByFg: RoughProdScheduleLineResultByFg[]; | |||||
| prodScheduleLinesByFgByDate: { [assignDate: number]: RoughProdScheduleLineResultByFg[] }; | |||||
| prodScheduleLinesByBom: RoughProdScheduleLineResultByBom[]; | |||||
| prodScheduleLinesByBomByDate: { [assignDate: number]: RoughProdScheduleLineResultByBomByDate[] }; | |||||
| } | } | ||||
| export interface ProdScheduleLineResultByFg { | |||||
| export interface RoughProdScheduleLineResultByFg { | |||||
| id: number; | id: number; | ||||
| code: string; | code: string; | ||||
| name: string; | name: string; | ||||
| @@ -30,10 +30,10 @@ export interface ProdScheduleLineResultByFg { | |||||
| estCloseBal: number; | estCloseBal: number; | ||||
| priority: number; | priority: number; | ||||
| assignDate: number; | assignDate: number; | ||||
| bomMaterials: ProdScheduleLineBomMaterialResult[]; | |||||
| bomMaterials: RoughProdScheduleLineBomMaterialResult[]; | |||||
| } | } | ||||
| export interface ProdScheduleLineBomMaterialResult { | |||||
| export interface RoughProdScheduleLineBomMaterialResult { | |||||
| id: number; | id: number; | ||||
| code: string; | code: string; | ||||
| name: string; | name: string; | ||||
| @@ -43,7 +43,7 @@ export interface ProdScheduleLineBomMaterialResult { | |||||
| uomName: string; | uomName: string; | ||||
| } | } | ||||
| export interface ProdScheduleLineResultByBom { | |||||
| export interface RoughProdScheduleLineResultByBom { | |||||
| id: number, | id: number, | ||||
| code: string, | code: string, | ||||
| name: string, | name: string, | ||||
| @@ -60,7 +60,7 @@ export interface ProdScheduleLineResultByBom { | |||||
| uomName: string, | uomName: string, | ||||
| } | } | ||||
| export interface ProdScheduleLineResultByBomByDate { | |||||
| export interface RoughProdScheduleLineResultByBomByDate { | |||||
| id: number, | id: number, | ||||
| code: string, | code: string, | ||||
| name: string, | name: string, | ||||
| @@ -72,7 +72,7 @@ export interface ProdScheduleLineResultByBomByDate { | |||||
| } | } | ||||
| export const fetchProdScheduleDetail = cache(async (id: number) => { | export const fetchProdScheduleDetail = cache(async (id: number) => { | ||||
| return serverFetchJson<ProdScheduleResult>(`${BASE_API_URL}/productionSchedule/detail/${id}`, { | |||||
| return serverFetchJson<RoughProdScheduleResult>(`${BASE_API_URL}/productionSchedule/detail/${id}`, { | |||||
| method: "GET", | method: "GET", | ||||
| headers: { "Content-Type": "application/json" }, | headers: { "Content-Type": "application/json" }, | ||||
| next: { | next: { | ||||
| @@ -18,7 +18,7 @@ import { InputDataGridProps, TableRow } from "../InputDataGrid/InputDataGrid"; | |||||
| import { TypeEnum } from "@/app/utils/typeEnum"; | import { TypeEnum } from "@/app/utils/typeEnum"; | ||||
| import { NumberInputProps } from "@/components/CreateItem/NumberInputProps"; | import { NumberInputProps } from "@/components/CreateItem/NumberInputProps"; | ||||
| import { arrayToDateString, integerFormatter } from "@/app/utils/formatUtil"; | import { arrayToDateString, integerFormatter } from "@/app/utils/formatUtil"; | ||||
| import { ProdScheduleResult } from "@/app/api/scheduling"; | |||||
| import { RoughProdScheduleResult } from "@/app/api/scheduling"; | |||||
| import { DatePicker, LocalizationProvider } from "@mui/x-date-pickers"; | import { DatePicker, LocalizationProvider } from "@mui/x-date-pickers"; | ||||
| import { AdapterDayjs } from "@mui/x-date-pickers/AdapterDayjs"; | import { AdapterDayjs } from "@mui/x-date-pickers/AdapterDayjs"; | ||||
| @@ -38,12 +38,12 @@ const DetailInfoCard: React.FC<Props> = ({ isEditing }) => { | |||||
| getValues, | getValues, | ||||
| watch, | watch, | ||||
| formState: { errors, defaultValues, touchedFields }, | formState: { errors, defaultValues, touchedFields }, | ||||
| } = useFormContext<ProdScheduleResult>(); | |||||
| } = useFormContext<RoughProdScheduleResult>(); | |||||
| // const [details, setDetails] = useState(null); | // const [details, setDetails] = useState(null); | ||||
| useEffect(() => { | useEffect(() => { | ||||
| console.log("[debug] record details", getValues) | |||||
| console.log("[debug] record details", getValues()) | |||||
| // setDetails(recordDetails); | // setDetails(recordDetails); | ||||
| }, [getValues]) | }, [getValues]) | ||||
| @@ -15,7 +15,7 @@ type Props = { | |||||
| const RoughScheduleDetailWrapper: React.FC<Props> & SubComponents = async ({ id, type }) => { | const RoughScheduleDetailWrapper: React.FC<Props> & SubComponents = async ({ id, type }) => { | ||||
| const prodSchedule = id ? await fetchProdScheduleDetail(id) : undefined | const prodSchedule = id ? await fetchProdScheduleDetail(id) : undefined | ||||
| return ( | return ( | ||||
| <RoughScheduleDetailView | <RoughScheduleDetailView | ||||
| isEditMode={Boolean(id)} | isEditMode={Boolean(id)} | ||||
| @@ -24,13 +24,13 @@ import ViewByFGDetails from "@/components/RoughScheduleDetail/ViewByFGDetails"; | |||||
| import ViewByBomDetails from "@/components/RoughScheduleDetail/ViewByBomDetails"; | import ViewByBomDetails from "@/components/RoughScheduleDetail/ViewByBomDetails"; | ||||
| import ScheduleTable from "@/components/ScheduleTable"; | import ScheduleTable from "@/components/ScheduleTable"; | ||||
| import { Column } from "@/components/ScheduleTable/ScheduleTable"; | import { Column } from "@/components/ScheduleTable/ScheduleTable"; | ||||
| import { ProdScheduleResult, ScheduleType } from "@/app/api/scheduling"; | |||||
| import { RoughProdScheduleResult, ScheduleType } from "@/app/api/scheduling"; | |||||
| import { arrayToDayjs, dayjsToDateString } from "@/app/utils/formatUtil"; | import { arrayToDayjs, dayjsToDateString } from "@/app/utils/formatUtil"; | ||||
| type Props = { | type Props = { | ||||
| isEditMode: boolean; | isEditMode: boolean; | ||||
| type: ScheduleType; | type: ScheduleType; | ||||
| defaultValues: Partial<ProdScheduleResult> | undefined; | |||||
| defaultValues: Partial<RoughProdScheduleResult> | undefined; | |||||
| // qcChecks: ItemQc[] | // qcChecks: ItemQc[] | ||||
| }; | }; | ||||
| @@ -42,7 +42,6 @@ const RoughScheduleDetailView: React.FC<Props> = ({ | |||||
| // console.log(type) | // console.log(type) | ||||
| const apiRef = useGridApiRef(); | const apiRef = useGridApiRef(); | ||||
| const params = useSearchParams() | const params = useSearchParams() | ||||
| console.log(params.get("id")) | |||||
| const [serverError, setServerError] = useState(""); | const [serverError, setServerError] = useState(""); | ||||
| const [tabIndex, setTabIndex] = useState(0); | const [tabIndex, setTabIndex] = useState(0); | ||||
| const { t } = useTranslation("schedule") | const { t } = useTranslation("schedule") | ||||
| @@ -51,7 +50,7 @@ const RoughScheduleDetailView: React.FC<Props> = ({ | |||||
| //const title = "Demand Forecast Detail" | //const title = "Demand Forecast Detail" | ||||
| // console.log(typeId) | // console.log(typeId) | ||||
| const formProps = useForm<ProdScheduleResult>({ | |||||
| const formProps = useForm<RoughProdScheduleResult>({ | |||||
| defaultValues: defaultValues ? defaultValues : { | defaultValues: defaultValues ? defaultValues : { | ||||
| }, | }, | ||||
| }); | }); | ||||
| @@ -88,7 +87,7 @@ const RoughScheduleDetailView: React.FC<Props> = ({ | |||||
| router.replace(`/scheduling/rough`); | router.replace(`/scheduling/rough`); | ||||
| }; | }; | ||||
| const onSubmit = useCallback<SubmitHandler<ProdScheduleResult>>( | |||||
| const onSubmit = useCallback<SubmitHandler<RoughProdScheduleResult>>( | |||||
| async (data, event) => { | async (data, event) => { | ||||
| let hasErrors = false; | let hasErrors = false; | ||||
| console.log(errors) | console.log(errors) | ||||
| @@ -109,7 +108,7 @@ const RoughScheduleDetailView: React.FC<Props> = ({ | |||||
| ); | ); | ||||
| // multiple tabs | // multiple tabs | ||||
| const onSubmitError = useCallback<SubmitErrorHandler<ProdScheduleResult>>( | |||||
| const onSubmitError = useCallback<SubmitErrorHandler<RoughProdScheduleResult>>( | |||||
| (errors) => { }, | (errors) => { }, | ||||
| [] | [] | ||||
| ); | ); | ||||
| @@ -21,7 +21,7 @@ import { RiceBowl } from "@mui/icons-material"; | |||||
| // import EditableSearchResults, { Column } from "@/components/SearchResults/EditableSearchResults"; | // import EditableSearchResults, { Column } from "@/components/SearchResults/EditableSearchResults"; | ||||
| import { decimalFormatter } from "@/app/utils/formatUtil"; | import { decimalFormatter } from "@/app/utils/formatUtil"; | ||||
| import { GridRenderCellParams } from "@mui/x-data-grid"; | import { GridRenderCellParams } from "@mui/x-data-grid"; | ||||
| import { ProdScheduleLineResultByBom, ProdScheduleLineResultByBomByDate, ProdScheduleResult, ScheduleType } from "@/app/api/scheduling"; | |||||
| import { RoughProdScheduleLineResultByBom, RoughProdScheduleLineResultByBomByDate, RoughProdScheduleResult, ScheduleType } from "@/app/api/scheduling"; | |||||
| import ScheduleTable from "@/components/ScheduleTable"; | import ScheduleTable from "@/components/ScheduleTable"; | ||||
| import { Column } from "@/components/ScheduleTable/ScheduleTable"; | import { Column } from "@/components/ScheduleTable/ScheduleTable"; | ||||
| @@ -63,7 +63,7 @@ const ViewByBomDetails: React.FC<Props> = ({ apiRef, isEdit, type, dayPeriod }) | |||||
| control, | control, | ||||
| getValues, | getValues, | ||||
| formState: { errors, defaultValues, touchedFields }, | formState: { errors, defaultValues, touchedFields }, | ||||
| } = useFormContext<ProdScheduleResult>(); | |||||
| } = useFormContext<RoughProdScheduleResult>(); | |||||
| // const apiRef = useGridApiRef(); | // const apiRef = useGridApiRef(); | ||||
| const { fields } = useFieldArray({ | const { fields } = useFieldArray({ | ||||
| @@ -165,7 +165,7 @@ const ViewByBomDetails: React.FC<Props> = ({ apiRef, isEdit, type, dayPeriod }) | |||||
| style: { | style: { | ||||
| textAlign: "right", | textAlign: "right", | ||||
| }, | }, | ||||
| renderCell: (row: ProdScheduleLineResultByBom) => { | |||||
| renderCell: (row: RoughProdScheduleLineResultByBom) => { | |||||
| if (typeof (row.availableQty) == "number") { | if (typeof (row.availableQty) == "number") { | ||||
| return decimalFormatter.format(row.availableQty) | return decimalFormatter.format(row.availableQty) | ||||
| } | } | ||||
| @@ -180,7 +180,7 @@ const ViewByBomDetails: React.FC<Props> = ({ apiRef, isEdit, type, dayPeriod }) | |||||
| style: { | style: { | ||||
| textAlign: "right", | textAlign: "right", | ||||
| }, | }, | ||||
| renderCell: (row: ProdScheduleLineResultByBom) => { | |||||
| renderCell: (row: RoughProdScheduleLineResultByBom) => { | |||||
| if (typeof (row.totalDemandQty) == "number") { | if (typeof (row.totalDemandQty) == "number") { | ||||
| return decimalFormatter.format(row.totalDemandQty) | return decimalFormatter.format(row.totalDemandQty) | ||||
| } | } | ||||
| @@ -194,7 +194,7 @@ const ViewByBomDetails: React.FC<Props> = ({ apiRef, isEdit, type, dayPeriod }) | |||||
| style: { | style: { | ||||
| textAlign: "right", | textAlign: "right", | ||||
| }, | }, | ||||
| renderCell: (row: ProdScheduleLineResultByBom) => { | |||||
| renderCell: (row: RoughProdScheduleLineResultByBom) => { | |||||
| if (typeof (row.demandQty1) == "number") { | if (typeof (row.demandQty1) == "number") { | ||||
| return decimalFormatter.format(row.demandQty1) | return decimalFormatter.format(row.demandQty1) | ||||
| } | } | ||||
| @@ -208,7 +208,7 @@ const ViewByBomDetails: React.FC<Props> = ({ apiRef, isEdit, type, dayPeriod }) | |||||
| style: { | style: { | ||||
| textAlign: "right", | textAlign: "right", | ||||
| }, | }, | ||||
| renderCell: (row: ProdScheduleLineResultByBom) => { | |||||
| renderCell: (row: RoughProdScheduleLineResultByBom) => { | |||||
| if (typeof (row.demandQty2) == "number") { | if (typeof (row.demandQty2) == "number") { | ||||
| return decimalFormatter.format(row.demandQty2) | return decimalFormatter.format(row.demandQty2) | ||||
| } | } | ||||
| @@ -222,7 +222,7 @@ const ViewByBomDetails: React.FC<Props> = ({ apiRef, isEdit, type, dayPeriod }) | |||||
| style: { | style: { | ||||
| textAlign: "right", | textAlign: "right", | ||||
| }, | }, | ||||
| renderCell: (row: ProdScheduleLineResultByBom) => { | |||||
| renderCell: (row: RoughProdScheduleLineResultByBom) => { | |||||
| if (typeof (row.demandQty3) == "number") { | if (typeof (row.demandQty3) == "number") { | ||||
| return decimalFormatter.format(row.demandQty3) | return decimalFormatter.format(row.demandQty3) | ||||
| } | } | ||||
| @@ -236,7 +236,7 @@ const ViewByBomDetails: React.FC<Props> = ({ apiRef, isEdit, type, dayPeriod }) | |||||
| style: { | style: { | ||||
| textAlign: "right", | textAlign: "right", | ||||
| }, | }, | ||||
| renderCell: (row: ProdScheduleLineResultByBom) => { | |||||
| renderCell: (row: RoughProdScheduleLineResultByBom) => { | |||||
| if (typeof (row.demandQty4) == "number") { | if (typeof (row.demandQty4) == "number") { | ||||
| return decimalFormatter.format(row.demandQty4) | return decimalFormatter.format(row.demandQty4) | ||||
| } | } | ||||
| @@ -249,7 +249,7 @@ const ViewByBomDetails: React.FC<Props> = ({ apiRef, isEdit, type, dayPeriod }) | |||||
| style: { | style: { | ||||
| textAlign: "right", | textAlign: "right", | ||||
| }, | }, | ||||
| renderCell: (row: ProdScheduleLineResultByBom) => { | |||||
| renderCell: (row: RoughProdScheduleLineResultByBom) => { | |||||
| if (typeof (row.demandQty5) == "number") { | if (typeof (row.demandQty5) == "number") { | ||||
| return decimalFormatter.format(row.demandQty5) | return decimalFormatter.format(row.demandQty5) | ||||
| } | } | ||||
| @@ -263,7 +263,7 @@ const ViewByBomDetails: React.FC<Props> = ({ apiRef, isEdit, type, dayPeriod }) | |||||
| style: { | style: { | ||||
| textAlign: "right", | textAlign: "right", | ||||
| }, | }, | ||||
| renderCell: (row: ProdScheduleLineResultByBom) => { | |||||
| renderCell: (row: RoughProdScheduleLineResultByBom) => { | |||||
| if (typeof (row.demandQty6) == "number") { | if (typeof (row.demandQty6) == "number") { | ||||
| return decimalFormatter.format(row.demandQty6) | return decimalFormatter.format(row.demandQty6) | ||||
| } | } | ||||
| @@ -277,7 +277,7 @@ const ViewByBomDetails: React.FC<Props> = ({ apiRef, isEdit, type, dayPeriod }) | |||||
| style: { | style: { | ||||
| textAlign: "right", | textAlign: "right", | ||||
| }, | }, | ||||
| renderCell: (row: ProdScheduleLineResultByBom) => { | |||||
| renderCell: (row: RoughProdScheduleLineResultByBom) => { | |||||
| if (typeof (row.demandQty7) == "number") { | if (typeof (row.demandQty7) == "number") { | ||||
| return decimalFormatter.format(row.demandQty7) | return decimalFormatter.format(row.demandQty7) | ||||
| } | } | ||||
| @@ -288,7 +288,7 @@ const ViewByBomDetails: React.FC<Props> = ({ apiRef, isEdit, type, dayPeriod }) | |||||
| [t] | [t] | ||||
| ); | ); | ||||
| const columns = useMemo<Column<ProdScheduleLineResultByBomByDate>[]>( | |||||
| const columns = useMemo<Column<RoughProdScheduleLineResultByBomByDate>[]>( | |||||
| () => [ | () => [ | ||||
| { | { | ||||
| field: "code", | field: "code", | ||||
| @@ -317,7 +317,7 @@ const ViewByBomDetails: React.FC<Props> = ({ apiRef, isEdit, type, dayPeriod }) | |||||
| style: { | style: { | ||||
| textAlign: "right", | textAlign: "right", | ||||
| }, | }, | ||||
| renderCell: (row: ProdScheduleLineResultByBomByDate) => { | |||||
| renderCell: (row: RoughProdScheduleLineResultByBomByDate) => { | |||||
| if (typeof (row.availableQty) == "number") { | if (typeof (row.availableQty) == "number") { | ||||
| return decimalFormatter.format(row.availableQty) | return decimalFormatter.format(row.availableQty) | ||||
| } | } | ||||
| @@ -331,7 +331,7 @@ const ViewByBomDetails: React.FC<Props> = ({ apiRef, isEdit, type, dayPeriod }) | |||||
| style: { | style: { | ||||
| textAlign: "right", | textAlign: "right", | ||||
| }, | }, | ||||
| renderCell: (row: ProdScheduleLineResultByBomByDate) => { | |||||
| renderCell: (row: RoughProdScheduleLineResultByBomByDate) => { | |||||
| if (typeof (row.demandQty) == "number") { | if (typeof (row.demandQty) == "number") { | ||||
| return decimalFormatter.format(row.demandQty) | return decimalFormatter.format(row.demandQty) | ||||
| } | } | ||||
| @@ -342,15 +342,13 @@ const ViewByBomDetails: React.FC<Props> = ({ apiRef, isEdit, type, dayPeriod }) | |||||
| [] | [] | ||||
| ); | ); | ||||
| console.log(getValues("prodScheduleLinesByBom")) | |||||
| return ( | return ( | ||||
| <Grid container spacing={2}> | <Grid container spacing={2}> | ||||
| <Grid item xs={12} key={"all"}> | <Grid item xs={12} key={"all"}> | ||||
| <Typography variant="overline" display="block" marginBlockEnd={1}> | <Typography variant="overline" display="block" marginBlockEnd={1}> | ||||
| {t("Material Demand List (7 Days)")} | {t("Material Demand List (7 Days)")} | ||||
| </Typography> | </Typography> | ||||
| <ScheduleTable<ProdScheduleLineResultByBom> | |||||
| <ScheduleTable<RoughProdScheduleLineResultByBom> | |||||
| // index={7} | // index={7} | ||||
| type={type} | type={type} | ||||
| items={getValues("prodScheduleLinesByBom")} | items={getValues("prodScheduleLinesByBom")} | ||||
| @@ -368,7 +366,7 @@ const ViewByBomDetails: React.FC<Props> = ({ apiRef, isEdit, type, dayPeriod }) | |||||
| <Typography variant="overline" display="block" marginBlockEnd={1}> | <Typography variant="overline" display="block" marginBlockEnd={1}> | ||||
| {`${t("Material Demand Date")}: ${date}`} | {`${t("Material Demand Date")}: ${date}`} | ||||
| </Typography> | </Typography> | ||||
| <ScheduleTable<ProdScheduleLineResultByBomByDate> | |||||
| <ScheduleTable<RoughProdScheduleLineResultByBomByDate> | |||||
| // index={index} | // index={index} | ||||
| type={type} | type={type} | ||||
| items={getValues("prodScheduleLinesByBomByDate")[index + 1]} // Use the corresponding records for the day | items={getValues("prodScheduleLinesByBomByDate")[index + 1]} // Use the corresponding records for the day | ||||
| @@ -21,7 +21,7 @@ import { RiceBowl } from "@mui/icons-material"; | |||||
| import ScheduleTable from "@/components/ScheduleTable"; | import ScheduleTable from "@/components/ScheduleTable"; | ||||
| import { Column } from "@/components/ScheduleTable/ScheduleTable"; | import { Column } from "@/components/ScheduleTable/ScheduleTable"; | ||||
| import { arrayToDayjs, dayjsToDateString, decimalFormatter, integerFormatter } from "@/app/utils/formatUtil"; | import { arrayToDayjs, dayjsToDateString, decimalFormatter, integerFormatter } from "@/app/utils/formatUtil"; | ||||
| import { ProdScheduleLineResultByFg, ProdScheduleResult, ScheduleType } from "@/app/api/scheduling"; | |||||
| import { RoughProdScheduleLineResultByFg, RoughProdScheduleResult, ScheduleType } from "@/app/api/scheduling"; | |||||
| type Props = { | type Props = { | ||||
| apiRef: MutableRefObject<GridApiCommunity> | apiRef: MutableRefObject<GridApiCommunity> | ||||
| @@ -50,7 +50,7 @@ const ViewByFGDetails: React.FC<Props> = ({ apiRef, isEdit, type, dayPeriod }) = | |||||
| control, | control, | ||||
| getValues, | getValues, | ||||
| formState: { errors, defaultValues, touchedFields }, | formState: { errors, defaultValues, touchedFields }, | ||||
| } = useFormContext<ProdScheduleResult>(); | |||||
| } = useFormContext<RoughProdScheduleResult>(); | |||||
| const { fields } = useFieldArray({ | const { fields } = useFieldArray({ | ||||
| control, | control, | ||||
| @@ -125,7 +125,7 @@ const ViewByFGDetails: React.FC<Props> = ({ apiRef, isEdit, type, dayPeriod }) = | |||||
| }); | }); | ||||
| }; | }; | ||||
| const columns = useMemo<Column<ProdScheduleLineResultByFg>[]>( | |||||
| const columns = useMemo<Column<RoughProdScheduleLineResultByFg>[]>( | |||||
| () => [ | () => [ | ||||
| { | { | ||||
| field: "code", | field: "code", | ||||
| @@ -177,7 +177,7 @@ const ViewByFGDetails: React.FC<Props> = ({ apiRef, isEdit, type, dayPeriod }) = | |||||
| [] | [] | ||||
| ); | ); | ||||
| const overallColumns = useMemo<Column<ProdScheduleLineResultByFg>[]>( | |||||
| const overallColumns = useMemo<Column<RoughProdScheduleLineResultByFg>[]>( | |||||
| () => [ | () => [ | ||||
| { | { | ||||
| field: "code", | field: "code", | ||||
| @@ -270,7 +270,7 @@ const ViewByFGDetails: React.FC<Props> = ({ apiRef, isEdit, type, dayPeriod }) = | |||||
| <Typography variant="overline" display="block" marginBlockEnd={1}> | <Typography variant="overline" display="block" marginBlockEnd={1}> | ||||
| {t("FG Demand List (7 Days)")} | {t("FG Demand List (7 Days)")} | ||||
| </Typography> | </Typography> | ||||
| <ScheduleTable<ProdScheduleLineResultByFg> | |||||
| <ScheduleTable<RoughProdScheduleLineResultByFg> | |||||
| // index={7} | // index={7} | ||||
| type={type} | type={type} | ||||
| items={getValues("prodScheduleLinesByFg")} | items={getValues("prodScheduleLinesByFg")} | ||||
| @@ -288,9 +288,9 @@ const ViewByFGDetails: React.FC<Props> = ({ apiRef, isEdit, type, dayPeriod }) = | |||||
| <Typography variant="overline" display="block" marginBlockEnd={1}> | <Typography variant="overline" display="block" marginBlockEnd={1}> | ||||
| {`${t("FG Demand Date")}: ${date}`} | {`${t("FG Demand Date")}: ${date}`} | ||||
| </Typography> | </Typography> | ||||
| <ScheduleTable<ProdScheduleLineResultByFg> | |||||
| <ScheduleTable<RoughProdScheduleLineResultByFg> | |||||
| type={type} | type={type} | ||||
| items={getValues("prodScheduleLinesByFgByDate")[index + 1]} // Use the corresponding records for the day | |||||
| items={getValues("prodScheduleLinesByFgByDate") && Object.entries(getValues("prodScheduleLinesByFgByDate")).length > 0 ? getValues("prodScheduleLinesByFgByDate")[index + 1] : []} // Use the corresponding records for the day | |||||
| columns={columns} | columns={columns} | ||||
| setPagingController={updatePagingController} | setPagingController={updatePagingController} | ||||
| pagingController={pagingController[index]} | pagingController={pagingController[index]} | ||||