Refactor filter rendering in DocSearchView component

Updated the rendering logic for filters to use a switch statement, allowing for flexible handling of different filter types. The layout remains unchanged, but the logic for rendering each filter type has been enhanced for future extensibility.
This commit is contained in:
2025-07-04 10:39:18 +02:00
parent 05c7b49bbc
commit b06595e8d8

View File

@@ -84,8 +84,19 @@ export function DocSearchView({ posts }: Props) {
</Box> </Box>
<> <>
{filters.map((filter, index) => {filters.map((filter, index) => {
( let filterComp;
switch (filter.type) {
case 'VARCHAR':
case 'BOOLEAN':
case 'INTEGER':
case 'DECIMAL':
case 'DATE':
default:
filterComp = (<TextField id="filled-basic" label={filter.label ?? filter.type} variant="filled" />)
break;
}
return (
<Box <Box
sx={{ sx={{
mb: 5, mb: 5,
@@ -94,9 +105,10 @@ export function DocSearchView({ posts }: Props) {
justifyContent: 'space-between', justifyContent: 'space-between',
}} }}
> >
<TextField id="filled-basic" label={filter.label ?? filter.type} variant="filled" /> {filterComp}
</Box> </Box>
) )
}
)} )}
</> </>