Skip to content

Commit

Permalink
fix(GoalHistory): check prev and next estimate before push
Browse files Browse the repository at this point in the history
  • Loading branch information
awinogradov committed Jun 21, 2023
1 parent ca34b45 commit 2dbf15d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions trpc/router/goal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -452,14 +452,14 @@ export const goal = router({
}

const correctEstimate = await findOrCreateEstimate(input.estimate, ctx.session.user.activityId, actualGoal.id);

if (correctEstimate) {
const previousEstimate = actualGoal.estimate.length
? String(actualGoal.estimate[actualGoal.estimate.length - 1].estimateId)
: '';
if (correctEstimate && String(correctEstimate.id) !== previousEstimate) {
history.push({
subject: 'estimate',
action: 'change',
previousValue: actualGoal.estimate.length
? String(actualGoal.estimate[actualGoal.estimate.length - 1].estimateId)
: '',
previousValue: previousEstimate,
nextValue: String(correctEstimate.id),
});
}
Expand Down

0 comments on commit 2dbf15d

Please sign in to comment.