-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
159 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
packages/app/src/api/core-domain/useCases/referent/GetAllDeclarations.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { type DeclarationRaw } from "@api/core-domain/infra/db/DeclarationRaw"; | ||
import { type IDeclarationRepo } from "@api/core-domain/repo/IDeclarationRepo"; | ||
import { AppError, type UseCase } from "@common/shared-domain"; | ||
|
||
export class GetAllDeclarations implements UseCase<never, Array<Partial<DeclarationRaw>>> { | ||
constructor(private readonly declarationRepo: IDeclarationRepo) {} | ||
|
||
public async execute(): Promise<Array<Partial<DeclarationRaw>>> { | ||
try { | ||
return await this.declarationRepo.getAllSirenAndYear(); | ||
|
||
// return declarations.map(declarationMap.toDTO).filter(d => d) as DeclarationDTO[]; | ||
} catch (error: unknown) { | ||
throw new GetAllDeclarationsError("Cannot get all declarations", error as Error); | ||
} | ||
} | ||
} | ||
|
||
export class GetAllDeclarationsError extends AppError {} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 6 additions & 12 deletions
18
packages/app/src/app/(default)/login/MonCompteProLogin.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,16 @@ | ||
"use client"; | ||
|
||
import MonCompteProButton from "@codegouvfr/react-dsfr/MonCompteProButton"; | ||
import { Link } from "@design-system"; | ||
import { signIn } from "next-auth/react"; | ||
|
||
export interface MonCompteProLoginProps { | ||
callbackUrl: string; | ||
} | ||
export const MonCompteProLogin = ({ callbackUrl }: MonCompteProLoginProps) => ( | ||
<> | ||
<MonCompteProButton | ||
onClick={e => { | ||
e.preventDefault(); | ||
signIn("moncomptepro", { redirect: false }); | ||
}} | ||
/> | ||
<Link href="/aide-moncomptepro" target="_blank"> | ||
Consulter l'aide MonComptePro | ||
</Link> | ||
</> | ||
<MonCompteProButton | ||
onClick={e => { | ||
e.preventDefault(); | ||
signIn("moncomptepro", { redirect: false }); | ||
}} | ||
/> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -97,9 +97,21 @@ const LoginPage = async ({ searchParams }: NextServerPageProps<never, "callbackU | |
</p> | ||
<br /> | ||
<p className={"text-dsfr-error"}> | ||
Si vous rencontrez des difficultés pour vous connecter, vous devez contacter le support{" "} | ||
Si vous utilisez une protection contre les spams (ex. MailInBlack), vous devez contacter votre | ||
service informatique pour qu'il autorise les mails en provenance de MonComptePro. | ||
</p> | ||
<br /> | ||
<p className={"text-dsfr-error"}> | ||
Pour tout problème lié à MonComptePro, vous devez contacter le support dédié à cette adresse email{" "} | ||
<Link href={"mailto:[email protected]"} target={"_blank"}> | ||
MonComptePro | ||
[email protected] | ||
</Link> | ||
</p> | ||
<br /> | ||
<p> | ||
Pour consulter l'aide MonComptePro,{" "} | ||
<Link href={"/aide-moncomptepro"} target={"_blank"}> | ||
cliquez ici | ||
</Link> | ||
</p> | ||
</> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { declarationRepo } from "@api/core-domain/repo"; | ||
import { GetAllDeclarations } from "@api/core-domain/useCases/referent/GetAllDeclarations"; | ||
|
||
export async function getAllDeclarations() { | ||
// handle default errors | ||
const useCase = new GetAllDeclarations(declarationRepo); | ||
return await useCase.execute(); | ||
} |
92 changes: 92 additions & 0 deletions
92
packages/app/src/app/(default)/script/clean-invalids-siren/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
import { getAllDeclarations } from "../actions"; | ||
|
||
function validateSIREN(siren: string): boolean { | ||
// Vérifie que la chaîne est composée de 9 chiffres | ||
if (!/^\d{9}$/.test(siren)) { | ||
return false; | ||
} | ||
|
||
// Applique l'algorithme de Luhn | ||
let sum = 0; | ||
for (let i = 0; i < 9; i++) { | ||
let num = parseInt(siren.charAt(i), 10); | ||
|
||
// Multiplie les chiffres en position paire par 2 | ||
if (i % 2 === 1) { | ||
num *= 2; | ||
// Si le résultat est supérieur à 9, soustrait 9 | ||
if (num > 9) { | ||
num -= 9; | ||
} | ||
} | ||
|
||
sum += num; | ||
} | ||
|
||
// Le numéro est valide si la somme est un multiple de 10 | ||
return sum % 10 === 0; | ||
} | ||
|
||
const CleanInvalidsSirenPage = async () => { | ||
try { | ||
const declarations = await getAllDeclarations(); | ||
const invalidDeclarations = []; | ||
for (const declaration of declarations) { | ||
if (!declaration.data?.entreprise.siren) { | ||
//console.log("No siren", declaration.siren); | ||
} | ||
if (!validateSIREN(declaration.data?.entreprise.siren || "")) { | ||
console.log("Invalid siren", declaration.siren); | ||
invalidDeclarations.push({ ...declaration, invalidSiren: declaration.siren }); | ||
break; | ||
} | ||
if (!declaration.data?.entreprise.ues?.entreprises) { | ||
//console.log("No ues", declaration.siren); | ||
} | ||
for (const entreprise of declaration.data?.entreprise.ues?.entreprises || []) { | ||
if (!validateSIREN(entreprise.siren)) { | ||
invalidDeclarations.push({ ...declaration, invalidSiren: entreprise.siren }); | ||
console.log("Invalid ues siren", entreprise.siren); | ||
break; | ||
} | ||
} | ||
} | ||
// const invalids = declarations | ||
// .filter(declaration => new Siren(declaration.data?.entreprise.siren || "")) | ||
// .filter(declaration => { | ||
// if (!declaration.data?.entreprise.ues?.entreprises) { | ||
// return true; | ||
// } | ||
// | ||
// return declaration.data?.entreprise.ues?.entreprises.reduce((hasValidSirens, entreprise) => { | ||
// if (!hasValidSirens) return false; | ||
// try { | ||
// new Siren(entreprise.siren); | ||
// return true; | ||
// } catch (e) { | ||
// console.log("Invalid siren", entreprise.siren, e); | ||
// return false; | ||
// } | ||
// }, true); | ||
// }); | ||
|
||
return ( | ||
<div> | ||
<p>nombre de sirens invalides: {invalidDeclarations.length}</p> | ||
<ul> | ||
{invalidDeclarations.map((declaration, index) => ( | ||
<li key={`invalid-${index}`}> | ||
declaration siren:{declaration.siren}, declaration année: {declaration.year} invalid ues siren:{" "} | ||
{declaration.invalidSiren} | ||
</li> | ||
))} | ||
</ul> | ||
</div> | ||
); | ||
} catch (e) { | ||
console.log(e); | ||
return <p>Error</p>; | ||
} | ||
}; | ||
|
||
export default CleanInvalidsSirenPage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters