|
|
|
@@ -39,7 +39,7 @@ interface BaseCriterion<T extends string> { |
|
|
|
paramName2?: T; |
|
|
|
// options?: T[] | string[]; |
|
|
|
defaultValue?: string; |
|
|
|
preFilledValue?: string; |
|
|
|
preFilledValue?: string | { from?: string; to?: string }; |
|
|
|
filterObj?: T; |
|
|
|
handleSelectionChange?: (selectedOptions: T[]) => void; |
|
|
|
} |
|
|
|
@@ -158,14 +158,22 @@ function SearchBox<T extends string>({ |
|
|
|
const preFilledInputs = useMemo(() => { |
|
|
|
const preFilledCriteria = criteria.reduce<Record<T | `${T}To`, string>>( |
|
|
|
(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} |
|
|
|
}, [defaultInputs]) |
|
|
|
|
|
|
|
|