diff --git a/packages/common/src/search/USAGER_DEADLINES.const.ts b/packages/common/src/search/functions/getUsagerDeadlines.ts similarity index 64% rename from packages/common/src/search/USAGER_DEADLINES.const.ts rename to packages/common/src/search/functions/getUsagerDeadlines.ts index a03ca89fd8..567e2396fe 100644 --- a/packages/common/src/search/USAGER_DEADLINES.const.ts +++ b/packages/common/src/search/functions/getUsagerDeadlines.ts @@ -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), }, }; } diff --git a/packages/common/src/search/functions/index.ts b/packages/common/src/search/functions/index.ts index 2c0ec22051..0b4f872473 100644 --- a/packages/common/src/search/functions/index.ts +++ b/packages/common/src/search/functions/index.ts @@ -1,2 +1,3 @@ -//@index('./*', f => `export * from '${f.path}'`) +//@index('./*.ts', f => `export * from '${f.path}'`) +export * from "./getUsagerDeadlines"; export * from "./normalize-string"; diff --git a/packages/common/src/search/functions/tests/getUsagerDeadlines.spec.ts b/packages/common/src/search/functions/tests/getUsagerDeadlines.spec.ts new file mode 100644 index 0000000000..bc06159d45 --- /dev/null +++ b/packages/common/src/search/functions/tests/getUsagerDeadlines.spec.ts @@ -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"), + }, + }); + }); + }); +}); diff --git a/packages/common/src/search/functions/normalize-string.spec.ts b/packages/common/src/search/functions/tests/normalize-string.spec.ts similarity index 96% rename from packages/common/src/search/functions/normalize-string.spec.ts rename to packages/common/src/search/functions/tests/normalize-string.spec.ts index a633b69284..a16fa58b4c 100644 --- a/packages/common/src/search/functions/normalize-string.spec.ts +++ b/packages/common/src/search/functions/tests/normalize-string.spec.ts @@ -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", () => { diff --git a/packages/common/src/search/index.ts b/packages/common/src/search/index.ts index ec1cffcf66..d8f29205de 100644 --- a/packages/common/src/search/index.ts +++ b/packages/common/src/search/index.ts @@ -4,4 +4,3 @@ export * from "./core"; export * from "./functions"; export * from "./sorter"; export * from "./types"; -export * from "./USAGER_DEADLINES.const"; diff --git a/packages/frontend/src/app/app.component.html b/packages/frontend/src/app/app.component.html index bbbcc888c7..f072faff8c 100644 --- a/packages/frontend/src/app/app.component.html +++ b/packages/frontend/src/app/app.component.html @@ -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" > diff --git a/packages/frontend/src/app/modules/general/components/navbar/navbar.component.html b/packages/frontend/src/app/modules/general/components/navbar/navbar.component.html index 37af4e928f..a68a4c3594 100644 --- a/packages/frontend/src/app/modules/general/components/navbar/navbar.component.html +++ b/packages/frontend/src/app/modules/general/components/navbar/navbar.component.html @@ -39,8 +39,8 @@
diff --git a/packages/portail-admins/src/app/modules/general/components/static-pages/plan-site/LIENS_PARTENAIRES.const.ts b/packages/portail-admins/src/app/modules/general/components/static-pages/plan-site/LIENS_PARTENAIRES.const.ts index 11dfa14697..88870e7ac7 100644 --- a/packages/portail-admins/src/app/modules/general/components/static-pages/plan-site/LIENS_PARTENAIRES.const.ts +++ b/packages/portail-admins/src/app/modules/general/components/static-pages/plan-site/LIENS_PARTENAIRES.const.ts @@ -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/" }, diff --git a/packages/portail-admins/src/assets/images/logo-ministere.jpg b/packages/portail-admins/src/assets/images/logo-ministere.jpg new file mode 100644 index 0000000000..6f21c708e6 Binary files /dev/null and b/packages/portail-admins/src/assets/images/logo-ministere.jpg differ diff --git a/packages/portail-admins/src/assets/images/logo-ministere.svg b/packages/portail-admins/src/assets/images/logo-ministere.svg deleted file mode 100644 index da3462e99e..0000000000 --- a/packages/portail-admins/src/assets/images/logo-ministere.svg +++ /dev/null @@ -1,381 +0,0 @@ - - - \ No newline at end of file diff --git a/packages/portail-usagers/src/app/app.component.html b/packages/portail-usagers/src/app/app.component.html index db8d5f6eae..f532ad3ac3 100644 --- a/packages/portail-usagers/src/app/app.component.html +++ b/packages/portail-usagers/src/app/app.component.html @@ -155,12 +155,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" > diff --git a/packages/portail-usagers/src/app/modules/general/components/_static/plan-site/LIENS_PARTENAIRES.const.ts b/packages/portail-usagers/src/app/modules/general/components/_static/plan-site/LIENS_PARTENAIRES.const.ts index 11dfa14697..88870e7ac7 100644 --- a/packages/portail-usagers/src/app/modules/general/components/_static/plan-site/LIENS_PARTENAIRES.const.ts +++ b/packages/portail-usagers/src/app/modules/general/components/_static/plan-site/LIENS_PARTENAIRES.const.ts @@ -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/" }, diff --git a/packages/portail-usagers/src/assets/images/logo-ministere.jpg b/packages/portail-usagers/src/assets/images/logo-ministere.jpg new file mode 100644 index 0000000000..6f21c708e6 Binary files /dev/null and b/packages/portail-usagers/src/assets/images/logo-ministere.jpg differ diff --git a/packages/portail-usagers/src/assets/images/logo-ministere.svg b/packages/portail-usagers/src/assets/images/logo-ministere.svg deleted file mode 100644 index da3462e99e..0000000000 --- a/packages/portail-usagers/src/assets/images/logo-ministere.svg +++ /dev/null @@ -1,381 +0,0 @@ - - - \ No newline at end of file