Skip to content

Commit

Permalink
fix(fiche-sp): nouveau format de l'url pour les fiches pros (#1265)
Browse files Browse the repository at this point in the history
  • Loading branch information
m-maillot authored Jan 31, 2024
1 parent 3e9c869 commit 03da701
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
11 changes: 9 additions & 2 deletions shared/utils/src/url-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,17 @@ export const generateLegiRef = (
};

export const generateFichesSpRef = (
audience: "associations" | "particuliers" | "professionnels-entreprises",
audience: "Associations" | "Particuliers" | "Professionnels",
ficheSpInitialId: string
) => {
return `https://www.service-public.fr/${audience}/vosdroits/${ficheSpInitialId}`;
switch (audience) {
case "Associations":
return `https://www.service-public.fr/associations/vosdroits/${ficheSpInitialId}`;
case "Particuliers":
return `https://www.service-public.fr/particuliers/vosdroits/${ficheSpInitialId}`;
case "Professionnels":
return `https://entreprendre.service-public.fr/vosdroits/${ficheSpInitialId}`;
}
};

export const generateFichesSpRefLocal = (
Expand Down
9 changes: 2 additions & 7 deletions targets/ingester/src/transform/fichesServicePublic/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type { IndexedAgreement } from "@socialgouv/kali-data-types";
import type { FicheServicePublic } from "../..";
import type { ReferenceResolver } from "../../lib/referenceResolver";
import { parseReferences } from "./parseReference";
import { generateFichesSpRef } from "@shared/utils";

function getChild(element: RawJson, name: string) {
// RawJson children not exist on text node
Expand Down Expand Up @@ -56,13 +57,7 @@ export function format(
| "Particuliers"
| "Professionnels";

const audienceMap = {
Associations: "associations",
Particuliers: "particuliers",
Professionnels: "professionnels-entreprises",
};

const url = `https://www.service-public.fr/${audienceMap[audience]}/vosdroits/${id}`;
const url = generateFichesSpRef(audience, id);

const intro = getText(getChild(publication, "Introduction"));
const texte = getText(getChild(publication, "Texte"));
Expand Down

0 comments on commit 03da701

Please sign in to comment.