From bdeeb358f3fb8f1ff6e1384976503f16f734a0e0 Mon Sep 17 00:00:00 2001 From: DenisVorop Date: Thu, 12 Oct 2023 14:46:48 +0300 Subject: [PATCH] fix: added priority model instead of string --- src/components/FiltersPanel/FiltersPanel.tsx | 2 + src/components/GoalActivity.tsx | 5 +-- .../GoalCreateForm/GoalCreateForm.tsx | 7 +++- src/components/GoalEditForm/GoalEditForm.tsx | 2 +- src/components/GoalForm/GoalForm.tsx | 15 ++++--- .../HistoryRecord/HistoryRecord.tsx | 26 +++++++----- src/components/PriorityDropdown.tsx | 19 +++++---- src/components/PriorityFilter.tsx | 40 +++++++++---------- src/schema/goal.ts | 12 +++++- src/types/history.ts | 16 +++++++- src/utils/db.ts | 16 ++++++-- trpc/inferredTypes.ts | 1 + trpc/queries/goals.ts | 17 ++++++-- trpc/router/goal.ts | 11 ++--- trpc/router/index.ts | 2 + trpc/router/priority.ts | 6 +++ 16 files changed, 128 insertions(+), 69 deletions(-) create mode 100644 trpc/router/priority.ts diff --git a/src/components/FiltersPanel/FiltersPanel.tsx b/src/components/FiltersPanel/FiltersPanel.tsx index bfd7eb9d3..873807d33 100644 --- a/src/components/FiltersPanel/FiltersPanel.tsx +++ b/src/components/FiltersPanel/FiltersPanel.tsx @@ -153,6 +153,7 @@ export const FiltersPanel: FC<{ useQueryOptions, ); const { data: states = [] } = trpc.state.all.useQuery(); + const { data: priorities = [] } = trpc.priority.getAll.useQuery(); const setPartialQueryByKey = useCallback((key: K) => { return (value: QueryState[K]) => { @@ -260,6 +261,7 @@ export const FiltersPanel: FC<{ diff --git a/src/components/GoalActivity.tsx b/src/components/GoalActivity.tsx index 5b45cd662..f2a33db31 100644 --- a/src/components/GoalActivity.tsx +++ b/src/components/GoalActivity.tsx @@ -1,7 +1,6 @@ import React, { forwardRef } from 'react'; import { nullable } from '@taskany/bricks'; -import { Priority } from '../types/priority'; import { GoalByIdReturnType } from '../../trpc/inferredTypes'; import { HistoryAction } from '../types/history'; @@ -85,8 +84,8 @@ export const GoalActivity = forwardRef( )} {value.subject === 'priority' && ( )} {value.subject === 'state' && ( diff --git a/src/components/GoalCreateForm/GoalCreateForm.tsx b/src/components/GoalCreateForm/GoalCreateForm.tsx index fd75b7265..3a1cc7016 100644 --- a/src/components/GoalCreateForm/GoalCreateForm.tsx +++ b/src/components/GoalCreateForm/GoalCreateForm.tsx @@ -56,6 +56,9 @@ const GoalCreateForm: React.FC = ({ title, onGoalCreate }) const [createGoalType, setŠ”reateGoalType] = useState(goalCreateFormActionCache || 3); const utils = trpc.useContext(); const { goalCreate } = useGoalResource({}); + // FIXME https://github.com/taskany-inc/issues/issues/1834 + const { data: priorities } = trpc.priority.getAll.useQuery(); + const defaultPriority = priorities?.at(-2); const createOptions = [ { @@ -130,8 +133,8 @@ const GoalCreateForm: React.FC = ({ title, onGoalCreate }) validitySchema={goalCommonSchema} owner={{ id: user?.activityId, user } as ActivityByIdReturnType} parent={currentProjectCache || lastProjectCache || undefined} - priority="Medium" - onSumbit={createGoal} + priority={defaultPriority ?? undefined} + onSubmit={createGoal} title={title} actionButton={ <> diff --git a/src/components/GoalEditForm/GoalEditForm.tsx b/src/components/GoalEditForm/GoalEditForm.tsx index 6f0d3b42a..4d8f34514 100644 --- a/src/components/GoalEditForm/GoalEditForm.tsx +++ b/src/components/GoalEditForm/GoalEditForm.tsx @@ -69,7 +69,7 @@ const GoalEditForm: React.FC = ({ goal, onSubmit }) => { priority={goal.priority ?? undefined} tags={goal.tags} estimate={estimateValue} - onSumbit={updateGoal} + onSubmit={updateGoal} actionButton={ <>