Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(general): update ministery's logo #3611

Merged
merged 1 commit into from
Dec 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,35 +1,42 @@
import { subMonths, addMonths, subYears, addWeeks } from "date-fns";
import { TimingsConfig, Timings } from "./types/Timings.type";
import {
subMonths,
addMonths,
subYears,
addWeeks,
endOfDay,
subDays,
} from "date-fns";
import { TimingsConfig, Timings } from "../types/Timings.type";

export function getUsagerDeadlines(refDate: Date = new Date()): TimingsConfig {
return {
PREVIOUS_TWO_MONTHS: {
label: "Depuis plus de 2 mois",
value: subMonths(refDate, 2),
value: subDays(endOfDay(subMonths(refDate, 2)), 1),
},
PREVIOUS_THREE_MONTHS: {
label: "Depuis plus de 3 mois",
value: subMonths(refDate, 3),
value: subDays(endOfDay(subMonths(refDate, 3)), 1),
},
PREVIOUS_TWO_YEARS: {
label: "Depuis plus de 2 ans",
value: subYears(refDate, 2),
value: subDays(endOfDay(subYears(refDate, 2)), 1),
},
PREVIOUS_YEAR: {
label: "Depuis plus d'un an",
value: subYears(refDate, 1),
value: subDays(endOfDay(subYears(refDate, 1)), 1),
},
NEXT_TWO_MONTHS: {
label: "Dans moins de 2 mois",
value: addMonths(refDate, 2),
value: endOfDay(addMonths(refDate, 2)),
},
NEXT_TWO_WEEKS: {
label: "Dans moins de 2 semaines",
value: addWeeks(refDate, 2),
value: endOfDay(addWeeks(refDate, 2)),
},
EXCEEDED: {
label: "Échéance dépassée",
value: refDate,
value: endOfDay(refDate),
},
};
}
Expand Down
3 changes: 2 additions & 1 deletion packages/common/src/search/functions/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
//@index('./*', f => `export * from '${f.path}'`)
//@index('./*.ts', f => `export * from '${f.path}'`)
export * from "./getUsagerDeadlines";
export * from "./normalize-string";
104 changes: 104 additions & 0 deletions packages/common/src/search/functions/tests/getUsagerDeadlines.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
import { Timings } from "../../types";
import { extractDeadlines, getUsagerDeadlines } from "../getUsagerDeadlines";

describe("Check deadlines", () => {
beforeEach(() => {
jest.useFakeTimers();
jest.setSystemTime(new Date("2024-12-30T22:59:59.999Z"));
});

afterEach(() => {
jest.useRealTimers();
});
describe("getUsagerDeadlines", () => {
it("should return all deadlines correctly with a reference date", () => {
const result = getUsagerDeadlines();

expect(result).toEqual({
PREVIOUS_TWO_MONTHS: {
label: "Depuis plus de 2 mois",
value: new Date("2024-10-29T22:59:59.999Z"),
},
PREVIOUS_THREE_MONTHS: {
label: "Depuis plus de 3 mois",
value: new Date("2024-09-29T21:59:59.999Z"), // Attention: changement d'heure !
},
PREVIOUS_TWO_YEARS: {
label: "Depuis plus de 2 ans",
value: new Date("2022-12-29T22:59:59.999Z"),
},
PREVIOUS_YEAR: {
label: "Depuis plus d'un an",
value: new Date("2023-12-29T22:59:59.999Z"),
},
NEXT_TWO_MONTHS: {
label: "Dans moins de 2 mois",
value: new Date("2025-02-28T22:59:59.999Z"),
},
NEXT_TWO_WEEKS: {
label: "Dans moins de 2 semaines",
value: new Date("2025-01-13T22:59:59.999Z"),
},
EXCEEDED: {
label: "Échéance dépassée",
value: new Date("2024-12-30T22:59:59.999Z"),
},
});
});

it("should use current date when no reference date is provided", () => {
const result = getUsagerDeadlines();
expect(result.EXCEEDED.value).toEqual(
new Date("2024-12-30T22:59:59.999Z")
);
});
});

describe("extractDeadlines", () => {
it("should extract specified deadlines correctly", () => {
const keys: Timings[] = ["PREVIOUS_TWO_MONTHS", "NEXT_TWO_WEEKS"];
const result = extractDeadlines(keys);

expect(result).toEqual({
PREVIOUS_TWO_MONTHS: {
label: "Depuis plus de 2 mois",
value: new Date("2024-10-29T22:59:59.999Z"),
},
NEXT_TWO_WEEKS: {
label: "Dans moins de 2 semaines",
value: new Date("2025-01-13T22:59:59.999Z"),
},
});
});

it("should return empty object when no keys provided", () => {
const result = extractDeadlines([], new Date("2024-01-15T22:59:59.999Z"));
expect(result).toEqual({});
});

it("should use current date when no reference date provided", () => {
const keys: Timings[] = ["EXCEEDED"];
const result = extractDeadlines(keys);

expect(result.EXCEEDED.value).toEqual(
new Date("2024-12-30T22:59:59.999Z")
);
});

it("should extract multiple deadlines correctly", () => {
const keys: Timings[] = ["PREVIOUS_TWO_MONTHS", "NEXT_TWO_MONTHS"];
const result = extractDeadlines(keys);

expect(result).toEqual({
PREVIOUS_TWO_MONTHS: {
label: "Depuis plus de 2 mois",
value: new Date("2024-10-29T22:59:59.999Z"),
},
NEXT_TWO_MONTHS: {
label: "Dans moins de 2 mois",
value: new Date("2025-02-28T22:59:59.999Z"),
},
});
});
});
});
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { normalizeString } from "./normalize-string";
import { normalizeString } from "../normalize-string";

// Tests de tous les cas possibles
describe("normalizeString", () => {
Expand Down
1 change: 0 additions & 1 deletion packages/common/src/search/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ export * from "./core";
export * from "./functions";
export * from "./sorter";
export * from "./types";
export * from "./USAGER_DEADLINES.const";
6 changes: 3 additions & 3 deletions packages/frontend/src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -199,12 +199,12 @@
href="https://solidarites.gouv.fr/"
target="_blank"
rel="noopener noreferrer"
title="Ministère du Travail, de la Santé et des Solidarités"
title="Ministère du Travail, de la Santé, des Solidarités et des familles"
>
<img
rel="noopener noreferrer"
src="/assets/images/logo-ministere.svg"
alt="Ministère du Travail, de la Santé et des Solidarités"
src="/assets/images/logo-ministere.jpg"
alt="Ministère du Travail, de la Santé, des Solidarités et des familles"
/>
</a>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
<div class="d-flex align-items-center">
<img
class="home-header-image"
src="/assets/images/logo-ministere.svg"
alt="Ministère du Travail, de la Santé et des Solidarités"
src="/assets/images/logo-ministere.jpg"
alt="Ministère du Travail, de la Santé, des Solidarités et des familles"
/>
<a
class="navbar-brand ms-4"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const LIENS_PARTENAIRES = [
path: "https://www.gouvernement.fr/delegation-interministerielle-a-l-hebergement-et-a-l-acces-au-logement",
},
{
label: "Ministère du Travail, de la Santé et des Solidarités",
label: "Ministère du Travail, de la Santé, des Solidarités et des familles",
path: "https://solidarites.gouv.fr/",
},
{ label: "UNCCAS", path: "https://www.unccas.org/" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@ function check({
return false;
}

// Convertit les dates en format YYYY-MM-DD
const today = new Date().toISOString().split("T")[0];
const dateFin = new Date(usager.decision.dateFin).toISOString().split("T")[0];
const today = new Date();
const dateFin = new Date(usager.decision.dateFin);

if (echeance === "EXCEEDED") {
return dateFin < today;
}
const deadline = USAGER_DEADLINES[echeance].value.toISOString().split("T")[0];

const deadline = USAGER_DEADLINES[echeance].value;

if (echeance.startsWith("NEXT_")) {
return dateFin >= today && dateFin <= deadline;
return dateFin >= today && dateFin < deadline;
}

if (echeance.startsWith("PREVIOUS_")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@ import { UsagerLight } from "../../../../../../../_common/model";
import { usagerPassageChecker } from "./usagerPassageChecker.service";

describe("usagerPassageChecker ", () => {
beforeEach(() => {
jest.useFakeTimers();
jest.setSystemTime(new Date("2024-12-30T12:00:00.000Z"));
});

afterEach(() => {
jest.useRealTimers();
});

describe("TWO_MONTHS ", () => {
it("usagerPassageChecker: should return true, last interaction > TWO_MONTHS", () => {
expect(
Expand All @@ -27,13 +36,28 @@ describe("usagerPassageChecker ", () => {
statut: "INSTRUCTION",
},
lastInteraction: {
dateInteraction: subMonths(new Date(), 1),
dateInteraction: new Date("2024-10-30T12:00:00.000Z"),
},
} as UsagerLight,
lastInteractionDate: "PREVIOUS_TWO_MONTHS",
})
).toBeFalsy();

expect(
usagerPassageChecker.check({
usager: {
decision: {
statut: "INSTRUCTION",
},
lastInteraction: {
dateInteraction: new Date("2024-10-29T12:00:00.000Z"),
},
} as UsagerLight,
lastInteractionDate: "PREVIOUS_TWO_MONTHS",
})
).toBeTruthy();
});

it("usagerPassageChecker: should return false, last interaction < TWO_MONTHS", () => {
expect(
usagerPassageChecker.check({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,10 @@ function check({
}

if (lastInteractionDate && USAGER_DEADLINES[lastInteractionDate]) {
const deadlineTime = USAGER_DEADLINES[lastInteractionDate].value.getTime();
const interactionTime = new Date(
usager.lastInteraction.dateInteraction
).getTime();
const deadlineTime = USAGER_DEADLINES[lastInteractionDate].value;

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

return true;
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions packages/portail-admins/src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,12 @@
href="https://solidarites.gouv.fr/"
target="_blank"
rel="noopener noreferrer"
title="Ministère du Travail, de la Santé et des Solidarités"
title="Ministère du Travail, de la Santé, des Solidarités et des familles"
>
<img
rel="noopener noreferrer"
src="/assets/images/logo-ministere.svg"
alt="Ministère du Travail, de la Santé et des Solidarités"
src="/assets/images/logo-ministere.jpg"
alt="Ministère du Travail, de la Santé, des Solidarités et des familles"
/>
</a>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const LIENS_PARTENAIRES = [
path: "https://www.gouvernement.fr/delegation-interministerielle-a-l-hebergement-et-a-l-acces-au-logement",
},
{
label: "Ministère du Travail, de la Santé et des Solidarités",
label: "Ministère du Travail, de la Santé, des Solidarités et des familles",
path: "https://solidarites.gouv.fr/",
},
{ label: "UNCCAS", path: "https://www.unccas.org/" },
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading