diff --git a/src/app/api/scheduling/actions.ts b/src/app/api/scheduling/actions.ts index 030533e..c511911 100644 --- a/src/app/api/scheduling/actions.ts +++ b/src/app/api/scheduling/actions.ts @@ -85,9 +85,10 @@ export const testRoughSchedule = cache(async () => { ); }); -export const testDetailedSchedule = cache(async () => { +export const testDetailedSchedule = cache(async (date?: string) => { + const queryStr = convertObjToURLSearchParams({genDate: date}) return serverFetchJson( - `${BASE_API_URL}/productionSchedule/testDetailedSchedule`, + `${BASE_API_URL}/productionSchedule/testDetailedSchedule?${queryStr}`, { method: "GET", headers: { "Content-Type": "application/json" }, diff --git a/src/components/DetailedSchedule/DetailedScheduleSearchView.tsx b/src/components/DetailedSchedule/DetailedScheduleSearchView.tsx index 492a13b..7c33eb9 100644 --- a/src/components/DetailedSchedule/DetailedScheduleSearchView.tsx +++ b/src/components/DetailedSchedule/DetailedScheduleSearchView.tsx @@ -11,11 +11,13 @@ import { ProdScheduleResult, SearchProdSchedule, fetchProdSchedules, + testDetailedSchedule, } from "@/app/api/scheduling/actions"; import { defaultPagingController } from "../SearchResults/SearchResults"; import { arrayToDateString, decimalFormatter } from "@/app/utils/formatUtil"; import dayjs from "dayjs"; -import { uniqBy } from "lodash"; +import { orderBy, uniqBy } from "lodash"; +import { Button, Stack } from "@mui/material"; // may need move to "index" or "actions" // type RecordStructure = { @@ -63,12 +65,12 @@ const DSOverview: React.FC = ({ type, defaultInputs }) => { const searchCriteria: Criterion[] = useMemo(() => { const searchCriteria: Criterion[] = [ - { - label: t("Schedule Period"), - label2: t("Schedule Period To"), - paramName: "schedulePeriod", - type: "dateRange", - }, + // { + // label: t("Schedule Period"), + // label2: t("Schedule Period To"), + // paramName: "schedulePeriod", + // type: "dateRange", + // }, { label: t("Production Date"), paramName: "scheduleAt", type: "date" }, { label: t("Product Count"), @@ -110,15 +112,15 @@ const DSOverview: React.FC = ({ type, defaultInputs }) => { onClick: (record) => onDetailClick(record), buttonIcon: , }, - { - name: "schedulePeriod", - label: t("Demand Forecast Period"), - renderCell: (params) => { - return `${arrayToDateString( - params.schedulePeriod, - )} - ${arrayToDateString(params.schedulePeriodTo)}`; - }, - }, + // { + // name: "schedulePeriod", + // label: t("Demand Forecast Period"), + // renderCell: (params) => { + // return `${arrayToDateString( + // params.schedulePeriod, + // )} - ${arrayToDateString(params.schedulePeriodTo)}`; + // }, + // }, { name: "scheduleAt", label: t("Production Date"), @@ -169,8 +171,6 @@ const DSOverview: React.FC = ({ type, defaultInputs }) => { : query.types ) as ScheduleType[]; - console.log(convertedTypes); - console.log(query.types); const params: SearchProdSchedule = { scheduleAt: dayjs(query?.scheduleAt).isValid() ? query?.scheduleAt @@ -200,8 +200,9 @@ const DSOverview: React.FC = ({ type, defaultInputs }) => { break; case "paging": setFilteredSchedules((fs) => + orderBy( uniqBy([...fs, ...response.records], "id"), - ); + ["id"], ["desc"])); break; } } @@ -278,8 +279,30 @@ const DSOverview: React.FC = ({ type, defaultInputs }) => { refetchData(inputs, "reset"); }, []); + const testDetailedScheduleClick = useCallback(async () => { + console.log(inputs.scheduleAt) + const response = await testDetailedSchedule(inputs.scheduleAt) + + if (response) { + refetchData(inputs, "paging"); + } + }, []) + return ( <> + + + { @@ -300,8 +323,8 @@ const DSOverview: React.FC = ({ type, defaultInputs }) => { setPagingController={setPagingController} pagingController={pagingController} totalCount={totalCount} - // isAutoPaging={false} - // hasCollapse={false} + // isAutoPaging={false} + // hasCollapse={false} /> ); diff --git a/src/components/RoughSchedule/RoughSchedileSearchView.tsx b/src/components/RoughSchedule/RoughSchedileSearchView.tsx index 592b31f..8251eba 100644 --- a/src/components/RoughSchedule/RoughSchedileSearchView.tsx +++ b/src/components/RoughSchedule/RoughSchedileSearchView.tsx @@ -23,7 +23,7 @@ import { testRoughSchedule, } from "@/app/api/scheduling/actions"; import { arrayToDateString, decimalFormatter } from "@/app/utils/formatUtil"; -import { isEqual, uniqBy } from "lodash"; +import { isEqual, orderBy, sortBy, uniqBy } from "lodash"; import dayjs from "dayjs"; import { defaultPagingController } from "../SearchResults/SearchResults"; import { ScheduleType } from "@/app/api/scheduling"; @@ -178,7 +178,9 @@ const RSOverview: React.FC = ({ type, defaultInputs }) => { break; case "paging": setFilteredSchedules((fs) => - uniqBy([...fs, ...response.records], "id"), + orderBy( + uniqBy([...fs, ...response.records], "id") + , ["id"], ["desc"]), ); break; }