Skip to content

Commit

Permalink
fix(Goal): support estimate diff in email notification, #1358
Browse files Browse the repository at this point in the history
  • Loading branch information
awinogradov committed Jul 25, 2023
1 parent af8a464 commit c28f287
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions trpc/router/goal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import {
updateCriteriaState,
} from '../../src/schema/criteria';
import type { FieldDiff } from '../../src/types/common';
import { createLocaleDate } from '../../src/utils/dateTime';

import { addCalculatedProjectFields } from './project';

Expand Down Expand Up @@ -535,18 +536,26 @@ export const goal = router({

const correctEstimate = await findOrCreateEstimate(input.estimate, ctx.session.user.activityId, actualGoal.id);
const previousEstimate = actualGoal.estimate.length
? String(actualGoal.estimate[actualGoal.estimate.length - 1].estimateId)
: '';
if (correctEstimate && String(correctEstimate.id) !== previousEstimate) {
? actualGoal.estimate[actualGoal.estimate.length - 1]
: null;
const previousEstimateId = previousEstimate ? String(previousEstimate.estimateId) : '';
if (correctEstimate && String(correctEstimate.id) !== previousEstimateId) {
history.push({
subject: 'estimate',
action: 'change',
previousValue: previousEstimate,
previousValue: previousEstimateId,
nextValue: String(correctEstimate.id),
});

// TODO: estimate diff
// updatedFields.estimate = [];
// FIXME: https://github.com/taskany-inc/issues/issues/1359
updatedFields.estimate = [
previousEstimate?.estimate.date
? createLocaleDate(new Date(previousEstimate?.estimate.date), { locale: 'en' })
: [previousEstimate?.estimate.q, previousEstimate?.estimate.y].join('/'),
correctEstimate.date
? createLocaleDate(new Date(correctEstimate.date), { locale: 'en' })
: [correctEstimate.q, correctEstimate.y].join('/'),
];
}

try {
Expand Down

0 comments on commit c28f287

Please sign in to comment.