fix: prevent removing last filter criteria

This commit is contained in:
kasia.oczkowska
2024-08-01 08:40:54 +01:00
parent c1396b97f0
commit e2dbf1a215

View File

@@ -122,7 +122,7 @@ function FilterConditions(props) {
<React.Fragment> <React.Fragment>
<Stack sx={{ width: '100%' }} direction="column" spacing={2} mt={2}> <Stack sx={{ width: '100%' }} direction="column" spacing={2} mt={2}>
{groups?.map((group, groupIndex) => ( {groups?.map((group, groupIndex) => (
<> <React.Fragment key={groupIndex}>
{groupIndex !== 0 && <Divider />} {groupIndex !== 0 && <Divider />}
<Typography variant="subtitle2" gutterBottom> <Typography variant="subtitle2" gutterBottom>
@@ -200,6 +200,7 @@ function FilterConditions(props) {
edge="start" edge="start"
onClick={() => removeGroupItem(groupIndex, groupItemIndex)} onClick={() => removeGroupItem(groupIndex, groupItemIndex)}
sx={{ width: 61, height: 61 }} sx={{ width: 61, height: 61 }}
disabled={groups.length === 1 && group.and.length === 1}
> >
<RemoveIcon /> <RemoveIcon />
</IconButton> </IconButton>
@@ -227,7 +228,7 @@ function FilterConditions(props) {
</IconButton> </IconButton>
)} )}
</Stack> </Stack>
</> </React.Fragment>
))} ))}
</Stack> </Stack>
</React.Fragment> </React.Fragment>