Skip to content

Commit

Permalink
feat(AppliedTagFilter): show readonly applied filters
Browse files Browse the repository at this point in the history
  • Loading branch information
DenisVorop committed Mar 25, 2024
1 parent 7c04647 commit ca7f026
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/components/AppliedTagFilter/AppliedTagFilter.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { trpc } from '../../utils/trpcClient';
import { AppliedFilter } from '../AppliedFilter/AppliedFilter';
import { TagDropdown } from '../TagDropdown/TagDropdown';

interface AppliedTagsFilterProps {
value?: string[];
label?: string;
readOnly?: boolean;
}

export const AppliedTagFilter = ({ value = [], label, readOnly }: AppliedTagsFilterProps) => {
const { data } = trpc.tag.getByIds.useQuery(value);

return (
<AppliedFilter readOnly={readOnly} label={label}>
<TagDropdown mode="multiple" value={data} readOnly={readOnly} placement="bottom" />
</AppliedFilter>
);
};
4 changes: 4 additions & 0 deletions src/components/FiltersPanel/FiltersPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import { AppliedPriorityFilter } from '../AppliedPriorityFilter/AppliedPriorityF
import { AppliedStateFilter } from '../AppliedStateFilter/AppliedStateFilter';
import { AppliedUsersFilter } from '../AppliedUsersFilter/AppliedUsersFilter';
import { PageUserMenu } from '../PageUserMenu';
import { AppliedTagFilter } from '../AppliedTagFilter/AppliedTagFilter';

import { tr } from './FiltersPanel.i18n';

Expand Down Expand Up @@ -286,6 +287,9 @@ export const FiltersPanel: FC<{
{nullable(Boolean(queryFilterState?.project), () => (
<AppliedGoalParentFilter label={tr('Project')} value={queryFilterState?.project} readOnly />
))}
{nullable(Boolean(queryFilterState?.tag), () => (
<AppliedTagFilter label={tr('Tags')} value={queryFilterState?.tag} readOnly />
))}
<Button
ref={filterTriggerRef}
text={tr('Filter')}
Expand Down
10 changes: 10 additions & 0 deletions trpc/router/tag.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Prisma } from '@prisma/client';
import { z } from 'zod';

import { prisma } from '../../src/utils/prisma';
import { protectedProcedure, router } from '../trpcBackend';
Expand Down Expand Up @@ -50,4 +51,13 @@ export const tag = router({
},
});
}),
getByIds: protectedProcedure.input(z.array(z.string())).query(({ input }) => {
return prisma.tag.findMany({
where: {
id: {
in: input,
},
},
});
}),
});

0 comments on commit ca7f026

Please sign in to comment.