From fbfd6a6e43339cb7158ba9e50355a7b3837cd51b Mon Sep 17 00:00:00 2001 From: Tony Vi Date: Tue, 23 May 2023 23:36:15 +0300 Subject: [PATCH] feat(Goal): sort by updatedAt by default --- src/components/GoalListItem/GoalListItem.tsx | 5 +++-- src/components/GoalsGroup.tsx | 1 + trpc/queries/goals.ts | 2 +- trpc/router/goal.ts | 6 ++++-- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/components/GoalListItem/GoalListItem.tsx b/src/components/GoalListItem/GoalListItem.tsx index 23619eed2..7a61ea919 100644 --- a/src/components/GoalListItem/GoalListItem.tsx +++ b/src/components/GoalListItem/GoalListItem.tsx @@ -24,6 +24,7 @@ interface GoalListItemProps { tags?: Array; state?: State; createdAt: Date; + updatedAt: Date; owner?: ActivityByIdReturnType; comments?: number; hasForks?: boolean; @@ -130,7 +131,7 @@ export const GoalListItem: React.FC = React.memo( shortId, owner, issuer, - createdAt, + updatedAt, tags, title, comments, @@ -171,7 +172,7 @@ export const GoalListItem: React.FC = React.memo( - #{shortId} + #{shortId} {` ${tr('by')} ${issuer?.user?.name}`} diff --git a/src/components/GoalsGroup.tsx b/src/components/GoalsGroup.tsx index 2d0d64a25..dbbae67b8 100644 --- a/src/components/GoalsGroup.tsx +++ b/src/components/GoalsGroup.tsx @@ -61,6 +61,7 @@ export const GoalsGroup: React.FC = React.memo( {goals.map((g) => ( !input.tags?.some((tag) => tag.id === t.id)) || []; } + console.log(input.tags); + try { return prisma.goal.update({ where: { id: actualGoal.id }, @@ -309,13 +311,13 @@ export const goal = router({ : undefined, tags: input.tags?.length ? { - connect: input.tags, + connect: input.tags.map((t) => ({ id: t.id })), disconnect: tagsToDisconnect, } : undefined, participants: input.participants?.length ? { - connect: input.participants, + connect: input.participants.map((p) => ({ id: p.id })), disconnect: participantsToDisconnect, } : undefined,