Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: opmc #2320

Merged
merged 1 commit into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading