Skip to content

Commit

Permalink
feat(FiltersPanel): autocomplete for Priority
Browse files Browse the repository at this point in the history
  • Loading branch information
asabotovich committed Jul 5, 2023
1 parent b250ffe commit 837ed92
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 33 deletions.
1 change: 0 additions & 1 deletion src/components/DashboardPage/DashboardPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
13 changes: 1 addition & 12 deletions src/components/FiltersPanel/FiltersPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -46,7 +45,6 @@ export const FiltersPanel: FC<{
queryString?: string;

preset?: FilterById;
priorities?: React.ComponentProps<typeof PriorityFilter>['priorities'];
estimates?: React.ComponentProps<typeof EstimateFilter>['estimates'];
presets?: React.ComponentProps<typeof PresetDropdown>['presets'];

Expand Down Expand Up @@ -75,7 +73,6 @@ export const FiltersPanel: FC<{
preset,
estimates = [],
presets = [],
priorities = [],
onPriorityChange,
onStateChange,
onIssuerChange,
Expand Down Expand Up @@ -171,14 +168,7 @@ export const FiltersPanel: FC<{
onChange={onStateChange}
/>

{Boolean(priorities.length) && (
<PriorityFilter
text={tr('Priority')}
value={queryState.priority}
priorities={priorities}
onChange={onPriorityChange}
/>
)}
<PriorityFilter text={tr('Priority')} value={queryState.priority} onChange={onPriorityChange} />

<ProjectFilter
text={tr('Project')}
Expand Down Expand Up @@ -266,7 +256,6 @@ export const FiltersPanel: FC<{
</FiltersPanelContainer>
<FiltersPanelApplied
queryState={queryState}
priority={priorities as Priority[]}
states={states}
issuers={issuers}
owners={owners}
Expand Down
5 changes: 1 addition & 4 deletions src/components/FiltersPanelApplied/FiltersPanelApplied.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { gray7 } from '@taskany/colors';

import { QueryState } from '../../hooks/useUrlFilterParams';
import { getPriorityText } from '../PriorityText/PriorityText';
import { PriorityFilter } from '../PriorityFilter';
import { StateFilter } from '../StateFilter';
import { UserFilter } from '../UserFilter/UserFilter';
import { ProjectFilter } from '../ProjectFilter';
Expand All @@ -16,7 +15,6 @@ import { tr } from './FiltersPanelApplied.i18n';

interface FiltersPanelAppliedProps {
queryState: QueryState;
priority?: React.ComponentProps<typeof PriorityFilter>['priorities'];
states?: React.ComponentProps<typeof StateFilter>['states'];
issuers?: React.ComponentProps<typeof UserFilter>['users'];
owners?: React.ComponentProps<typeof UserFilter>['users'];
Expand All @@ -37,7 +35,6 @@ const arrToMap = <T extends Array<{ id: string }>>(arr: T): { [key: string]: T[n

export const FiltersPanelApplied: React.FC<FiltersPanelAppliedProps> = ({
queryState,
priority,
states,
issuers,
owners,
Expand All @@ -61,7 +58,7 @@ export const FiltersPanelApplied: React.FC<FiltersPanelAppliedProps> = ({

const appliedMap: Record<string, string[]> = {};

if (queryState.priority.length && priority?.length) {
if (queryState.priority.length) {
appliedMap[tr('Priority')] = queryState.priority.map((p) => getPriorityText(p)).filter(Boolean);
}

Expand Down
1 change: 0 additions & 1 deletion src/components/GoalsPage/GoalsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
23 changes: 9 additions & 14 deletions src/components/PriorityFilter.tsx
Original file line number Diff line number Diff line change
@@ -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 <FiltersDropdown text={text} value={value} items={items} onChange={onChange} />;
}> = ({ text, value, onChange }) => {
return <FiltersDropdown text={text} value={value} items={priorities} onChange={onChange} />;
};
1 change: 0 additions & 1 deletion src/components/ProjectPage/ProjectPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down

0 comments on commit 837ed92

Please sign in to comment.