Skip to content
This repository has been archived by the owner on Nov 14, 2024. It is now read-only.

Commit

Permalink
la clé odlep devient opdp
Browse files Browse the repository at this point in the history
  • Loading branch information
anis committed Sep 16, 2024
1 parent 31457d3 commit 688d8fd
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 34 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable no-restricted-syntax */
/* eslint-disable sql/no-unsafe-query */

import { CaminoDate, daysBetween } from 'camino-common/src/date.js'
Expand Down Expand Up @@ -35,7 +34,7 @@ export const up = async (knex: Knex): Promise<void> => {
}

const contenu = {
odlep: {
opdp: {
duree: daysBetween(ouverture.date, cloture.date),
},
}
Expand Down
8 changes: 4 additions & 4 deletions packages/common/src/etape.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ test('getStatutId', () => {
typeId: ETAPES_TYPES.enquetePublique,
date: caminoDateValidator.parse('2020-07-14'),
statutId: ETAPES_STATUTS.ACCEPTE,
contenu: { odlep: { duree: { value: 15, etapeHeritee: null, heritee: false } } },
contenu: { opdp: { duree: { value: 15, etapeHeritee: null, heritee: false } } },
},
caminoDateValidator.parse('2020-07-14')
)
Expand All @@ -79,7 +79,7 @@ test('getStatutId', () => {
typeId: ETAPES_TYPES.enquetePublique,
date: caminoDateValidator.parse('2020-07-14'),
statutId: ETAPES_STATUTS.ACCEPTE,
contenu: { odlep: { duree: { value: 15, etapeHeritee: null, heritee: false } } },
contenu: { opdp: { duree: { value: 15, etapeHeritee: null, heritee: false } } },
},
caminoDateValidator.parse('2020-07-13')
)
Expand All @@ -91,7 +91,7 @@ test('getStatutId', () => {
typeId: ETAPES_TYPES.enquetePublique,
date: caminoDateValidator.parse('2020-07-14'),
statutId: ETAPES_STATUTS.ACCEPTE,
contenu: { odlep: { duree: { value: 15, etapeHeritee: null, heritee: false } } },
contenu: { opdp: { duree: { value: 15, etapeHeritee: null, heritee: false } } },
},
caminoDateValidator.parse('2020-07-29')
)
Expand All @@ -103,7 +103,7 @@ test('getStatutId', () => {
typeId: ETAPES_TYPES.enquetePublique,
date: caminoDateValidator.parse('2020-07-14'),
statutId: ETAPES_STATUTS.ACCEPTE,
contenu: { odlep: { duree: { value: 15, etapeHeritee: null, heritee: false } } },
contenu: { opdp: { duree: { value: 15, etapeHeritee: null, heritee: false } } },
},
caminoDateValidator.parse('2020-07-28')
)
Expand Down
9 changes: 2 additions & 7 deletions packages/common/src/etape.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,18 +176,13 @@ export const etapeNoteValidator = z.object({ valeur: z.string(), is_avertissemen
export type EtapeNote = z.infer<typeof etapeNoteValidator>

export const getStatutId = (etape: Pick<DeepReadonly<FlattenEtape>, 'date' | 'contenu' | 'typeId' | 'statutId'>, currentDate: CaminoDate): EtapeStatutId => {
let contenuKey: 'odlep' | 'opdp'
if (etape.typeId === ETAPES_TYPES.participationDuPublic) {
contenuKey = 'opdp'
} else if (etape.typeId === ETAPES_TYPES.enquetePublique) {
contenuKey = 'odlep'
} else {
if (![ETAPES_TYPES.participationDuPublic, ETAPES_TYPES.enquetePublique].includes(etape.typeId)) {
return etape.statutId
}

if (isBefore(currentDate, etape.date)) {
return ETAPES_STATUTS.PROGRAMME
} else if (isBefore(currentDate, dateAddDays(etape.date, z.number().parse(etape.contenu?.[contenuKey]?.duree.value ?? 0)))) {
} else if (isBefore(currentDate, dateAddDays(etape.date, z.number().parse(etape.contenu?.opdp?.duree.value ?? 0)))) {
return ETAPES_STATUTS.EN_COURS
} else {
return ETAPES_STATUTS.TERMINE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,16 @@ const publication: Section[] = [
},
]

const participationDuPublic: Section[] = [
{
id: 'opdp',
elements: [
{ id: 'lien', nom: 'Lien public externe', type: 'url', optionnel: true, description: '' },
{ id: 'duree', nom: "Durée en jours de l'enquête publique", type: 'number', optionnel: false },
],
},
]

const EtapesTypesSections = {
[ETAPES_TYPES.decisionDeLaMissionAutoriteEnvironnementale_ExamenAuCasParCasDuProjet_]: [
{
Expand Down Expand Up @@ -175,24 +185,8 @@ const EtapesTypesSections = {
[ETAPES_TYPES.decisionAdministrative]: publication,
[ETAPES_TYPES.publicationDeLavisDeDecisionImplicite]: publication,
[ETAPES_TYPES.abrogationDeLaDecision]: publication,
[ETAPES_TYPES.participationDuPublic]: [
{
id: 'opdp',
elements: [
{ id: 'lien', nom: 'Lien public externe', type: 'url', optionnel: true, description: '' },
{ id: 'duree', nom: 'Durée en jours de la participation du public', type: 'number', optionnel: false },
],
},
],
[ETAPES_TYPES.enquetePublique]: [
{
id: 'odlep',
elements: [
{ id: 'lien', nom: 'Lien public externe', type: 'url', optionnel: true, description: '' },
{ id: 'duree', nom: "Durée en jours de l'enquête publique", type: 'number', optionnel: false },
],
},
],
[ETAPES_TYPES.participationDuPublic]: participationDuPublic,
[ETAPES_TYPES.enquetePublique]: participationDuPublic,
} as const satisfies { [key in EtapeTypeId]?: DeepReadonly<Section[]> }

const proprietesDeLaConcession: Section[] = [
Expand Down
18 changes: 16 additions & 2 deletions packages/ui/src/components/demarche/demarche-etape.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ export const DemandeMultipleEntreprisesDocuments: StoryFn = () => (
sections_with_values: [
{ id: 'arm', elements: [{ id: 'mecanise', type: 'radio', value: true, nom: 'Mécanisation', optionnel: false }], nom: 'Arm' },
{
id: 'odlep',
id: 'opdp',
elements: [
{
id: 'lien',
Expand All @@ -339,6 +339,13 @@ export const DemandeMultipleEntreprisesDocuments: StoryFn = () => (
description: '',
value: 'https://beta.gouv.fr',
},
{
id: 'duree',
nom: "Durée en jours de l'enquête publique",
type: 'number',
optionnel: false,
value: 7,
},
],
},
],
Expand Down Expand Up @@ -393,7 +400,7 @@ export const DemandeNoMap: StoryFn = () => (
sections_with_values: [
{ id: 'arm', elements: [{ id: 'mecanise', type: 'radio', value: true, nom: 'Mécanisation', optionnel: false }], nom: 'Arm' },
{
id: 'odlep',
id: 'opdp',
elements: [
{
id: 'lien',
Expand All @@ -403,6 +410,13 @@ export const DemandeNoMap: StoryFn = () => (
description: '',
value: 'https://beta.gouv.fr',
},
{
id: 'duree',
nom: "Durée en jours de l'enquête publique",
type: 'number',
optionnel: false,
value: 7,
},
],
},
],
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/src/components/titre.stories.tsx

Large diffs are not rendered by default.

0 comments on commit 688d8fd

Please sign in to comment.