|
|
@@ -99,16 +99,30 @@ function SearchBox<T extends string>({ |
|
|
|
() => |
|
|
|
criteria.reduce<Record<T, string>>( |
|
|
|
(acc, c) => { |
|
|
|
let defaultValue: string | number = "" |
|
|
|
switch (c.type) { |
|
|
|
case "select": |
|
|
|
if (!(c.needAll === false)) { |
|
|
|
defaultValue = "All" |
|
|
|
} else if (c.options.length > 0) { |
|
|
|
defaultValue = c.options[0] |
|
|
|
} |
|
|
|
break; |
|
|
|
case "autocomplete": |
|
|
|
if (!(c.needAll === false)) { |
|
|
|
defaultValue = "All" |
|
|
|
} else if (c.options.length > 0) { |
|
|
|
defaultValue = c.options[0].value |
|
|
|
} |
|
|
|
break; |
|
|
|
case "monthYear": |
|
|
|
defaultValue = dayjs().format("YYYY-MM") |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
return { |
|
|
|
...acc, |
|
|
|
[c.paramName]: |
|
|
|
c.type === "select" || c.type === "autocomplete" |
|
|
|
? !(c.needAll === false) |
|
|
|
? "All" |
|
|
|
: c.options.length > 0 |
|
|
|
? c.type === "autocomplete" ? c.options[0].value : c.options[0] |
|
|
|
: "" |
|
|
|
: "" |
|
|
|
[c.paramName]: defaultValue |
|
|
|
}; |
|
|
|
}, |
|
|
|
{} as Record<T, string> |
|
|
@@ -297,7 +311,7 @@ function SearchBox<T extends string>({ |
|
|
|
</MenuItem> |
|
|
|
); |
|
|
|
}} |
|
|
|
renderInput={(params) => <TextField {...params} variant="outlined" label={c.label}/>} |
|
|
|
renderInput={(params) => <TextField {...params} variant="outlined" label={c.label} />} |
|
|
|
/> |
|
|
|
)} |
|
|
|
{c.type === "autocomplete" && !c.options.some(option => Boolean(option.group)) && ( |
|
|
@@ -356,7 +370,7 @@ function SearchBox<T extends string>({ |
|
|
|
</MenuItem> |
|
|
|
); |
|
|
|
}} |
|
|
|
renderInput={(params) => <TextField {...params} variant="outlined" label={c.label}/>} |
|
|
|
renderInput={(params) => <TextField {...params} variant="outlined" label={c.label} />} |
|
|
|
/> |
|
|
|
)} |
|
|
|
{c.type === "number" && ( |
|
|
|