|
|
@@ -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<Props> = ({ type, defaultInputs }) => { |
|
|
|
|
|
|
|
const searchCriteria: Criterion<SearchParamNames>[] = useMemo(() => { |
|
|
|
const searchCriteria: Criterion<SearchParamNames>[] = [ |
|
|
|
{ |
|
|
|
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<Props> = ({ type, defaultInputs }) => { |
|
|
|
onClick: (record) => onDetailClick(record), |
|
|
|
buttonIcon: <EditNote />, |
|
|
|
}, |
|
|
|
{ |
|
|
|
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<Props> = ({ 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<Props> = ({ type, defaultInputs }) => { |
|
|
|
break; |
|
|
|
case "paging": |
|
|
|
setFilteredSchedules((fs) => |
|
|
|
orderBy( |
|
|
|
uniqBy([...fs, ...response.records], "id"), |
|
|
|
); |
|
|
|
["id"], ["desc"])); |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
@@ -278,8 +279,30 @@ const DSOverview: React.FC<Props> = ({ 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 ( |
|
|
|
<> |
|
|
|
<Stack |
|
|
|
direction="row" |
|
|
|
justifyContent="flex-end" |
|
|
|
flexWrap="wrap" |
|
|
|
rowGap={2} |
|
|
|
> |
|
|
|
<Button |
|
|
|
variant="contained" |
|
|
|
onClick={testDetailedScheduleClick} |
|
|
|
> |
|
|
|
{t("Test Detailed Schedule")} |
|
|
|
</Button> |
|
|
|
</Stack> |
|
|
|
<SearchBox |
|
|
|
criteria={searchCriteria} |
|
|
|
onSearch={(query) => { |
|
|
@@ -300,8 +323,8 @@ const DSOverview: React.FC<Props> = ({ type, defaultInputs }) => { |
|
|
|
setPagingController={setPagingController} |
|
|
|
pagingController={pagingController} |
|
|
|
totalCount={totalCount} |
|
|
|
// isAutoPaging={false} |
|
|
|
// hasCollapse={false} |
|
|
|
// isAutoPaging={false} |
|
|
|
// hasCollapse={false} |
|
|
|
/> |
|
|
|
</> |
|
|
|
); |
|
|
|