From 837ed92b6617a8a4e3b9616e6ae13b35d4c79d0c Mon Sep 17 00:00:00 2001 From: Anton Date: Tue, 4 Jul 2023 18:32:06 +0300 Subject: [PATCH] feat(FiltersPanel): autocomplete for Priority --- .../DashboardPage/DashboardPage.tsx | 1 - src/components/FiltersPanel/FiltersPanel.tsx | 13 +---------- .../FiltersPanelApplied.tsx | 5 +--- src/components/GoalsPage/GoalsPage.tsx | 1 - src/components/PriorityFilter.tsx | 23 ++++++++----------- src/components/ProjectPage/ProjectPage.tsx | 1 - 6 files changed, 11 insertions(+), 33 deletions(-) diff --git a/src/components/DashboardPage/DashboardPage.tsx b/src/components/DashboardPage/DashboardPage.tsx index 9329392c3..c0edff9bb 100644 --- a/src/components/DashboardPage/DashboardPage.tsx +++ b/src/components/DashboardPage/DashboardPage.tsx @@ -185,7 +185,6 @@ export const DashboardPage = ({ user, ssrTime }: ExternalPageProps) => { counter={goals?.length} queryState={queryState} queryString={queryString} - priorities={meta?.priority} preset={currentPreset} presets={userFilters.data} estimates={meta?.estimates} diff --git a/src/components/FiltersPanel/FiltersPanel.tsx b/src/components/FiltersPanel/FiltersPanel.tsx index 7c9281026..63887e7ea 100644 --- a/src/components/FiltersPanel/FiltersPanel.tsx +++ b/src/components/FiltersPanel/FiltersPanel.tsx @@ -23,7 +23,6 @@ import { UserFilter } from '../UserFilter/UserFilter'; import { PriorityFilter } from '../PriorityFilter'; import { StateFilter } from '../StateFilter'; import { FiltersPanelApplied } from '../FiltersPanelApplied/FiltersPanelApplied'; -import { Priority } from '../../types/priority'; import { FilterById } from '../../../trpc/inferredTypes'; import { trpc } from '../../utils/trpcClient'; import { SortFilter } from '../SortFilter/SortFilter'; @@ -46,7 +45,6 @@ export const FiltersPanel: FC<{ queryString?: string; preset?: FilterById; - priorities?: React.ComponentProps['priorities']; estimates?: React.ComponentProps['estimates']; presets?: React.ComponentProps['presets']; @@ -75,7 +73,6 @@ export const FiltersPanel: FC<{ preset, estimates = [], presets = [], - priorities = [], onPriorityChange, onStateChange, onIssuerChange, @@ -171,14 +168,7 @@ export const FiltersPanel: FC<{ onChange={onStateChange} /> - {Boolean(priorities.length) && ( - - )} + ['priorities']; states?: React.ComponentProps['states']; issuers?: React.ComponentProps['users']; owners?: React.ComponentProps['users']; @@ -37,7 +35,6 @@ const arrToMap = >(arr: T): { [key: string]: T[n export const FiltersPanelApplied: React.FC = ({ queryState, - priority, states, issuers, owners, @@ -61,7 +58,7 @@ export const FiltersPanelApplied: React.FC = ({ const appliedMap: Record = {}; - if (queryState.priority.length && priority?.length) { + if (queryState.priority.length) { appliedMap[tr('Priority')] = queryState.priority.map((p) => getPriorityText(p)).filter(Boolean); } diff --git a/src/components/GoalsPage/GoalsPage.tsx b/src/components/GoalsPage/GoalsPage.tsx index 5b9a38f33..c1b3c846c 100644 --- a/src/components/GoalsPage/GoalsPage.tsx +++ b/src/components/GoalsPage/GoalsPage.tsx @@ -179,7 +179,6 @@ export const GoalsPage = ({ user, ssrTime }: ExternalPageProps) => { counter={goalsOnScreen?.length} queryState={queryState} queryString={queryString} - priorities={meta?.priority} preset={currentPreset} presets={userFilters.data} estimates={meta?.estimates} diff --git a/src/components/PriorityFilter.tsx b/src/components/PriorityFilter.tsx index be161c4d3..0cb05a438 100644 --- a/src/components/PriorityFilter.tsx +++ b/src/components/PriorityFilter.tsx @@ -1,24 +1,19 @@ -import { FC, useMemo } from 'react'; +import { FC } from 'react'; import { FiltersDropdown } from '@taskany/bricks'; -import { Priority } from '../types/priority'; +import { Priority, priorityVariants } from '../types/priority'; import { getPriorityText } from './PriorityText/PriorityText'; +const priorities = Object.keys(priorityVariants).map((p) => ({ + id: p, + data: getPriorityText(p as Priority), +})); + export const PriorityFilter: FC<{ text: string; value: string[]; - priorities: string[]; onChange: (value: string[]) => void; -}> = ({ text, value, priorities, onChange }) => { - const items = useMemo( - () => - priorities.map((p) => ({ - id: p, - data: getPriorityText(p as Priority), - })), - [priorities], - ); - - return ; +}> = ({ text, value, onChange }) => { + return ; }; diff --git a/src/components/ProjectPage/ProjectPage.tsx b/src/components/ProjectPage/ProjectPage.tsx index 24adbc06b..411acab7c 100644 --- a/src/components/ProjectPage/ProjectPage.tsx +++ b/src/components/ProjectPage/ProjectPage.tsx @@ -193,7 +193,6 @@ export const ProjectPage = ({ user, ssrTime, params: { id } }: ExternalPageProps counter={projectDeepInfo?.goals?.length} queryState={queryState} queryString={queryString} - priorities={projectDeepInfo?.meta?.priority} preset={currentPreset} presets={userFilters.data} estimates={projectDeepInfo?.meta?.estimates}