Skip to content

Commit

Permalink
fix: opmc (#2320)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonat75 authored Jul 16, 2024
1 parent 28be68e commit 9a48ff2
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -355,9 +355,10 @@ export const isEditable = (declaration?: DeclarationOpmcDTO) =>

type Props = {
declaration: DeclarationOpmcDTO;
isStaff: boolean;
};

export const ObjectifsMesuresForm = ({ declaration }: Props) => {
export const ObjectifsMesuresForm = ({ declaration, isStaff }: Props) => {
const router = useRouter();
const { setMessage } = useMessageProvider();

Expand Down Expand Up @@ -414,7 +415,7 @@ export const ObjectifsMesuresForm = ({ declaration }: Props) => {
assert(siren, "Le siren est obligatoire");
assert(year, "L'année est obligatoire");

const isReadonly = !isEditable(declaration);
const isReadonly = !isEditable(declaration) && !isStaff;

const onSubmit = async (opmc: UpdateOpMcDTO) => {
const result = await updateDeclarationOpmc({ opmc, siren, year });
Expand All @@ -429,11 +430,15 @@ export const ObjectifsMesuresForm = ({ declaration }: Props) => {
return (
<FormProvider {...methods}>
{isReadonly && (
<Alert
severity="warning"
title="Vos objectifs de progression et mesures de correction ne sont plus modifiables."
description="Vos objectifs de progression et mesures de correction ne sont plus modifiables car le délai est écoulé."
/>
<>
<Alert
severity="info"
as="h2"
title="Cette déclaration a été validée et transmise."
description="Elle n'est plus modifiable car le délai d'un an est écoulé"
className={fr.cx("fr-mb-4w")}
/>
</>
)}

<form onSubmit={handleSubmit(onSubmit)}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { type NextServerPageProps } from "@common/utils/next";
import { SkeletonForm } from "@components/utils/skeleton/SkeletonForm";
import { CenteredContainer } from "@design-system";
import { MessageProvider } from "@design-system/client";
import { notFound } from "next/navigation";
import { notFound, redirect } from "next/navigation";
import { getServerSession, type Session } from "next-auth";

import { getDeclarationOpmc } from "../../actions";
Expand All @@ -22,6 +22,8 @@ const canEditSiren = (user?: Session["user"]) => (siren?: string) => {

const ObjectifsMesuresPage = async ({ params: { siren, year: strYear } }: NextServerPageProps<"siren" | "year">) => {
const year = Number(strYear);
const session = await getServerSession(authConfig);
if (!session) redirect("/login");

let declaration: DeclarationOpmcDTO | null = null;
try {
Expand Down Expand Up @@ -73,7 +75,6 @@ const ObjectifsMesuresPage = async ({ params: { siren, year: strYear } }: NextSe
}

const index = declaration["resultat-global"]?.index;
const session = await getServerSession(authConfig);
const declarationDate = declaration["declaration-existante"].date;
const canEdit = canEditSiren(session?.user)(siren);

Expand All @@ -92,7 +93,7 @@ const ObjectifsMesuresPage = async ({ params: { siren, year: strYear } }: NextSe

return (
<MessageProvider>
<ObjectifsMesuresForm declaration={declaration} />
<ObjectifsMesuresForm declaration={declaration} isStaff={session.user.staff} />
</MessageProvider>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,8 @@ export const TileCompanyIndex = (dto: SearchDeclarationResultDTO) => {
</li>
<li>
Écart taux d'augmentations :{" "}
{company[row.year].workforce?.range !== CompanyWorkforceRange.Enum.FROM_251_TO_999 ? (
{company[row.year].workforce?.range !== CompanyWorkforceRange.Enum.FROM_251_TO_999 &&
company[row.year].workforce?.range !== CompanyWorkforceRange.Enum.FROM_1000_TO_MORE ? (
<>
<Text inline variant="bold" text={`${row.salaryRaisesAndPromotionsScore ?? "NC"}`} />
{row.notComputableReasonSalaryRaisesAndPromotions && (
Expand Down

0 comments on commit 9a48ff2

Please sign in to comment.