Skip to content

Commit

Permalink
bugFix #595 Fixed incorrect order of filter items on the "Матеріали" …
Browse files Browse the repository at this point in the history
…page after selecting the "Теми" filter. (#820)

Co-authored-by: Solomiia Lomnytska <solomiia.lomnytska.pz.2021@lpnu.ua>
  • Loading branch information
SolomiiaLomnytska22 and SolomiiaLomnytska22 authored Sep 20, 2023
1 parent 1d63f3e commit 8811f4a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/views/Profile/AdminTable/AdminFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ export const AdminFilter: React.FC<IMaterialsFilter> = ({
}) => {
const ALL_OPTIONS_IDS = allOptions.map((e) => e.id);

const sortedOptions = [...allOptions].sort((a, b) => {
const labelA = a.label || '';
const labelB = b.label || '';
return labelA.localeCompare(labelB);
});

const classes = useStyles();
const { t } = useTranslation();
const [open, setOpen] = useState(false);
Expand Down Expand Up @@ -109,7 +115,7 @@ export const AdminFilter: React.FC<IMaterialsFilter> = ({
<Checkbox checked={selected?.length === allOptions.length} />
<ListItemText primary={t(langTokens.common.all)} />
</MenuItem>
{allOptions.map((option) => (
{sortedOptions.map((option) => (
<MenuItem key={option.id} value={option.id}>
<Checkbox checked={!!selected?.includes(option.id)} />
<ListItemText primary={option?.label ?? option.name} />
Expand Down

0 comments on commit 8811f4a

Please sign in to comment.