Skip to content

Commit

Permalink
fix(Field service reports): bug preventing page to open
Browse files Browse the repository at this point in the history
  • Loading branch information
rhahao committed Sep 9, 2024
1 parent 36598f6 commit cdf951d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const MenuSubHeader = ({ children }: PropsWithChildren) => {
const PersonFilter = () => {
const { t } = useAppTranslation();

const { filter, handleChangeFilter, filters } = usePersonFilter();
const { filter, handleChangeFilter, filters, show_group } = usePersonFilter();

return (
<Select value={filter} onChange={(e) => handleChangeFilter(e.target.value)}>
Expand All @@ -49,14 +49,18 @@ const PersonFilter = () => {
</MenuItem>
))}

<MenuSubHeader>{t('tr_fieldServiceGroups')}</MenuSubHeader>
{filters
.find((f) => f.key === 'groups')
.options.map((option) => (
<MenuItem key={option.key} value={option.key}>
<Typography>{option.name}</Typography>
</MenuItem>
))}
{show_group && (
<MenuSubHeader>{t('tr_fieldServiceGroups')}</MenuSubHeader>
)}

{show_group &&
filters
.find((f) => f.key === 'groups')
.options.map((option) => (
<MenuItem key={option.key} value={option.key}>
<Typography>{option.name}</Typography>
</MenuItem>
))}
</Select>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,17 @@ const usePersonFilter = () => {
return result;
}, [t, groups]);

const show_group = useMemo(() => {
return filters.some((record) => record.key === 'groups');
}, [filters]);

const handleChangeFilter = (value: PersonFilterOption) => {
setSelectedPublisher(undefined);

setFilter(value);
};

return { filters, handleChangeFilter, filter };
return { filters, handleChangeFilter, filter, show_group };
};

export default usePersonFilter;

0 comments on commit cdf951d

Please sign in to comment.