Skip to content

Commit

Permalink
fix(frontend): fix date of last interaction
Browse files Browse the repository at this point in the history
  • Loading branch information
pYassine committed Dec 31, 2024
1 parent e4b4b40 commit 0587e75
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { subDays, subMonths, subWeeks } from "date-fns";
import { subMonths, subWeeks } from "date-fns";
import { UsagerLight } from "../../../../../../../_common/model";
import { usagerPassageChecker } from "./usagerPassageChecker.service";

Expand Down Expand Up @@ -27,8 +27,6 @@ describe("usagerPassageChecker ", () => {
lastInteractionDate: "PREVIOUS_TWO_MONTHS",
})
).toBeTruthy();
});
it("usagerPassageChecker: should return false, last interaction < TWO_MONTHS", () => {
expect(
usagerPassageChecker.check({
usager: {
Expand All @@ -41,32 +39,32 @@ describe("usagerPassageChecker ", () => {
} as UsagerLight,
lastInteractionDate: "PREVIOUS_TWO_MONTHS",
})
).toBeFalsy();
).toBeTruthy();
});

it("usagerPassageChecker: should return false, last interaction < TWO_MONTHS", () => {
expect(
usagerPassageChecker.check({
usager: {
decision: {
statut: "INSTRUCTION",
},
lastInteraction: {
dateInteraction: new Date("2024-10-29T12:00:00.000Z"),
dateInteraction: new Date("2024-10-31T12:00:00.000Z"),
},
} as UsagerLight,
lastInteractionDate: "PREVIOUS_TWO_MONTHS",
})
).toBeTruthy();
});
).toBeFalsy();

it("usagerPassageChecker: should return false, last interaction < TWO_MONTHS", () => {
expect(
usagerPassageChecker.check({
usager: {
decision: {
statut: "VALIDE",
statut: "INSTRUCTION",
},
lastInteraction: {
dateInteraction: subDays(new Date(), 5),
dateInteraction: new Date("2024-11-28T12:00:00.000Z"),
},
} as UsagerLight,
lastInteractionDate: "PREVIOUS_TWO_MONTHS",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ function check({

if (lastInteractionDate && USAGER_DEADLINES[lastInteractionDate]) {
const deadlineTime = USAGER_DEADLINES[lastInteractionDate].value;

const interactionTime = new Date(usager.lastInteraction.dateInteraction);
return deadlineTime > interactionTime;
}
Expand Down

0 comments on commit 0587e75

Please sign in to comment.