Skip to content

Commit

Permalink
feat(Goal): sort by updatedAt by default
Browse files Browse the repository at this point in the history
  • Loading branch information
awinogradov committed May 25, 2023
1 parent 3f13c2c commit fbfd6a6
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/components/GoalListItem/GoalListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ interface GoalListItemProps {
tags?: Array<Tag | undefined>;
state?: State;
createdAt: Date;
updatedAt: Date;
owner?: ActivityByIdReturnType;
comments?: number;
hasForks?: boolean;
Expand Down Expand Up @@ -130,7 +131,7 @@ export const GoalListItem: React.FC<GoalListItemProps> = React.memo(
shortId,
owner,
issuer,
createdAt,
updatedAt,
tags,
title,
comments,
Expand Down Expand Up @@ -171,7 +172,7 @@ export const GoalListItem: React.FC<GoalListItemProps> = React.memo(
</StyledTags>

<StyledSubTitle size="s">
#{shortId} <RelativeTime date={createdAt} kind="created" />
#{shortId} <RelativeTime date={updatedAt} kind="updated" />
{` ${tr('by')} ${issuer?.user?.name}`}
</StyledSubTitle>
</StyledName>
Expand Down
1 change: 1 addition & 0 deletions src/components/GoalsGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export const GoalsGroup: React.FC<GoalGroupProps> = React.memo(
{goals.map((g) => (
<GoalListItem
createdAt={g.createdAt}
updatedAt={g.updatedAt}
id={g.id}
shortId={g._shortId}
state={g.state!}
Expand Down
2 changes: 1 addition & 1 deletion trpc/queries/goals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export const goalsFilter = (
...extra,
},
orderBy: {
createdAt: 'asc',
updatedAt: 'desc',
},
};
};
Expand Down
6 changes: 4 additions & 2 deletions trpc/router/goal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,8 @@ export const goal = router({
tagsToDisconnect = actualGoal.tags?.filter((t) => !input.tags?.some((tag) => tag.id === t.id)) || [];
}

console.log(input.tags);

try {
return prisma.goal.update({
where: { id: actualGoal.id },
Expand All @@ -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,
Expand Down

0 comments on commit fbfd6a6

Please sign in to comment.