| @@ -266,6 +266,10 @@ const PoDetail: React.FC<Props> = ({ po, warehouse, printerCombo }) => { | |||||
| if (result) { | if (result) { | ||||
| console.log("%c Fetched PO:", "color:orange", result); | console.log("%c Fetched PO:", "color:orange", result); | ||||
| setPurchaseOrder(result); | setPurchaseOrder(result); | ||||
| dnFormProps.reset({ | |||||
| dnNo: "", | |||||
| receiptDate: dayjsToDateString(dayjs()), | |||||
| }); | |||||
| setRows(result.pol || []); | setRows(result.pol || []); | ||||
| if (result.pol && result.pol.length > 0) { | if (result.pol && result.pol.length > 0) { | ||||
| if (result.id === selectedPoId && selectedRow?.id) { | if (result.id === selectedPoId && selectedRow?.id) { | ||||
| @@ -66,9 +66,15 @@ const PoSearch: React.FC<Props> = ({ | |||||
| { label: t(`completed`), value: `completed` }, | { label: t(`completed`), value: `completed` }, | ||||
| ], | ], | ||||
| }, | }, | ||||
| { label: t("ETA"), label2: t("ETA To"), paramName: "estimatedArrivalDate", type: "dateRange", | |||||
| preFilledValue: dayjsToDateString(dayjs(), "input") }, | |||||
| { label: t("ETA"), | |||||
| label2: t("ETA To"), | |||||
| paramName: "estimatedArrivalDate", | |||||
| type: "dateRange", | |||||
| preFilledValue: { | |||||
| from: dayjsToDateString(dayjs(), "input"), | |||||
| to: dayjsToDateString(dayjs(), "input"), | |||||
| }, | |||||
| }, | |||||
| ]; | ]; | ||||
| return searchCriteria; | return searchCriteria; | ||||
| }, [t]); | }, [t]); | ||||
| @@ -378,6 +378,7 @@ const handleRelease = useCallback(() => { | |||||
| {t("Release")} | {t("Release")} | ||||
| </Button> | </Button> | ||||
| )} | )} | ||||
| </Stack> | </Stack> | ||||
| </CardContent> | </CardContent> | ||||
| </Card> | </Card> | ||||
| @@ -39,7 +39,7 @@ interface BaseCriterion<T extends string> { | |||||
| paramName2?: T; | paramName2?: T; | ||||
| // options?: T[] | string[]; | // options?: T[] | string[]; | ||||
| defaultValue?: string; | defaultValue?: string; | ||||
| preFilledValue?: string; | |||||
| preFilledValue?: string | { from?: string; to?: string }; | |||||
| filterObj?: T; | filterObj?: T; | ||||
| handleSelectionChange?: (selectedOptions: T[]) => void; | handleSelectionChange?: (selectedOptions: T[]) => void; | ||||
| } | } | ||||
| @@ -158,14 +158,22 @@ function SearchBox<T extends string>({ | |||||
| const preFilledInputs = useMemo(() => { | const preFilledInputs = useMemo(() => { | ||||
| const preFilledCriteria = criteria.reduce<Record<T | `${T}To`, string>>( | const preFilledCriteria = criteria.reduce<Record<T | `${T}To`, string>>( | ||||
| (acc, c) => { | (acc, c) => { | ||||
| if (c.preFilledValue !== undefined) { | |||||
| return { | |||||
| ...acc, | |||||
| [c.paramName]: c.preFilledValue, | |||||
| }; | |||||
| } else return acc; | |||||
| if (c.type === "dateRange" || c.type === "datetimeRange") { | |||||
| if (typeof c.preFilledValue === "object" && c.preFilledValue !== null) { | |||||
| return { | |||||
| ...acc, | |||||
| ...(c.preFilledValue.from ? { [c.paramName]: c.preFilledValue.from } : {}), | |||||
| ...(c.preFilledValue.to ? { [`${c.paramName}To`]: c.preFilledValue.to } : {}), | |||||
| }; | |||||
| } | |||||
| } | |||||
| if (typeof c.preFilledValue === "string") { | |||||
| return { ...acc, [c.paramName]: c.preFilledValue }; | |||||
| } | |||||
| return acc; | |||||
| }, | }, | ||||
| {} as Record<T | `${T}To`, string>,); | |||||
| {} as Record<T | `${T}To`, string>, | |||||
| ); | |||||
| return {...defaultInputs, ...preFilledCriteria} | return {...defaultInputs, ...preFilledCriteria} | ||||
| }, [defaultInputs]) | }, [defaultInputs]) | ||||
| @@ -221,12 +221,14 @@ function SearchResults<T extends ResultWithId>({ | |||||
| event, | event, | ||||
| ) => { | ) => { | ||||
| console.log(event); | console.log(event); | ||||
| setRowsPerPage(+event.target.value); | |||||
| const newSize = +event.target.value; | |||||
| setRowsPerPage(newSize); | |||||
| setPage(0); | setPage(0); | ||||
| if (setPagingController) { | if (setPagingController) { | ||||
| setPagingController({ | setPagingController({ | ||||
| ...(pagingController ?? defaultPagingController), | ...(pagingController ?? defaultPagingController), | ||||
| pageNum: 1, | pageNum: 1, | ||||
| pageSize: newSize, | |||||
| }); | }); | ||||
| } | } | ||||
| }; | }; | ||||