Skip to content

Commit

Permalink
chore: fix public year
Browse files Browse the repository at this point in the history
  • Loading branch information
jonat75 committed Jan 14, 2025
1 parent cf5f804 commit 5019b8b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
COUNTRIES_COG_TO_ISO,
COUNTY_TO_REGION,
inseeCodeToCounty,
PUBLIC_YEARS,
YEARS,
} from "@common/dict";
import { zodFr } from "@common/utils/zod";
import { SkeletonForm } from "@components/utils/skeleton/SkeletonForm";
Expand Down Expand Up @@ -219,8 +219,8 @@ export const CommencerForm = ({ monCompteProHost }: { monCompteProHost: string }
const confirmReset = () => {
if (confirm("Les données ne sont pas sauvegardées, êtes-vous sûr de vouloir réinitialiser le formulaire ?")) {
setValue("siren", "");
if (PUBLIC_YEARS[0]) {
setValue("annéeIndicateurs", PUBLIC_YEARS[0]);
if (YEARS[0]) {
setValue("annéeIndicateurs", YEARS[0]);
}

resetFormData();
Expand Down Expand Up @@ -251,11 +251,11 @@ export const CommencerForm = ({ monCompteProHost }: { monCompteProHost: string }
{year}
</option>
)).reverse()
: PUBLIC_YEARS.map(year => (
: YEARS.map(year => (
<option value={year} key={`year-select-${year}`}>
{year}
</option>
))}
)).reverse()}
</Select>

{user.staff ? (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Input from "@codegouvfr/react-dsfr/Input";
import Select from "@codegouvfr/react-dsfr/Select";
import { createSteps } from "@common/core-domain/dtos/CreateRepresentationEquilibreeDTO";
import { isCompanyClosed } from "@common/core-domain/helpers/entreprise";
import { PUBLIC_YEARS, REPEQ_ADMIN_YEARS } from "@common/dict";
import { REPEQ_ADMIN_YEARS, YEARS } from "@common/dict";
import { BackNextButtonsGroup, FormLayout, Icon, Link } from "@design-system";
import { getCompany } from "@globalActions/company";
import { CompanyErrorCodes } from "@globalActions/companyErrorCodes";
Expand Down Expand Up @@ -150,11 +150,11 @@ export const CommencerForm = ({ session, monCompteProHost }: { monCompteProHost:
{year}
</option>
)).reverse()
: PUBLIC_YEARS.map(year => (
: YEARS.map(year => (
<option value={year} key={`year-select-${year}`}>
{year}
</option>
))}
)).reverse()}
</Select>
{session.user.staff ? (
<Input
Expand Down
6 changes: 3 additions & 3 deletions packages/app/src/app/(default)/stats/content.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { fr } from "@codegouvfr/react-dsfr";
import Alert from "@codegouvfr/react-dsfr/Alert";
import { CURRENT_YEAR } from "@common/dict";
import { PUBLIC_CURRENT_YEAR } from "@common/dict";
import { CenteredContainer, Grid, GridCol } from "@design-system";

import { getPublicStats } from "./actions";
Expand Down Expand Up @@ -40,7 +40,7 @@ export const StatsContent = async () => {
return (
<>
<h2 className={fr.cx("fr-mt-8w", "fr-mb-1w")}>
Index Egapro {CURRENT_YEAR + 1} au titre des données {CURRENT_YEAR}
Index Egapro {PUBLIC_CURRENT_YEAR + 1} au titre des données {PUBLIC_CURRENT_YEAR}
</h2>
<p>Entreprises et unités économiques et sociales (UES) d'au moins 50 salariés</p>
<Grid haveGutters className={fr.cx("fr-mt-4w")}>
Expand Down Expand Up @@ -121,7 +121,7 @@ export const StatsContent = async () => {
</GridCol>
</Grid>
<h2 className={fr.cx("fr-mt-8w", "fr-mb-1w")}>
Représentation équilibrée {CURRENT_YEAR + 1} au titre des données {CURRENT_YEAR}
Représentation équilibrée {PUBLIC_CURRENT_YEAR + 1} au titre des données {PUBLIC_CURRENT_YEAR}
</h2>
<p>Entreprises d'au moins 1000 salariés pour le troisième exercice consécutif.</p>
<Grid haveGutters className="fr-mt-2w">
Expand Down
4 changes: 3 additions & 1 deletion packages/app/src/common/dict.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import { type SimpleObject, type UnknownMapping } from "./utils/types";
// this is first year of egapro existance from where we can search declarations
export const FIRST_YEAR = 2018 as const;

export const FIRST_DECLARATION_YEAR = 2021 as const;

// this is oldest year of possible index declaration
export const FIRST_PUBLIC_YEAR = 2021 as const;
export const FIRST_YEAR_REPEQ = 2021 as const;
Expand All @@ -22,7 +24,7 @@ export const CURRENT_YEAR = 2024 as const;
/** Need to be set */
export const PUBLIC_CURRENT_YEAR = 2023;

export const YEARS = times(CURRENT_YEAR - FIRST_YEAR + 1, idx => FIRST_YEAR + idx);
export const YEARS = times(CURRENT_YEAR - FIRST_DECLARATION_YEAR + 1, idx => FIRST_DECLARATION_YEAR + idx);
export const ADMIN_YEARS = times(CURRENT_YEAR - FIRST_YEAR + 1, idx => FIRST_YEAR + idx);
export const REPEQ_ADMIN_YEARS = times(CURRENT_YEAR - FIRST_YEAR_REPEQ + 1, idx => FIRST_YEAR_REPEQ + idx);
export const PUBLIC_YEARS = new Array(PUBLIC_CURRENT_YEAR - FIRST_PUBLIC_YEAR + 1)
Expand Down

0 comments on commit 5019b8b

Please sign in to comment.