Skip to content
Open
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
8 changes: 4 additions & 4 deletions src/app/(user)/cdp/[study]/mri/figures.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export function ImageElt({
image: StaticImageData;
}) {
return (
<figure className="text-center">
<figure className="text-center h-fit">
<Image src={image} alt={'Image de ' + value} />
<figcaption className="text-center text-sm mt-2 mb-[-5px]">{label}</figcaption>
<p className="text-center font-bold text-mri-headers m-0">{value}</p>
Expand All @@ -29,14 +29,14 @@ export function ImageElt({
}

export function getDomain(domain: Domain) {
return { label: 'DOMAIN', value: DOMAINS[domain].display, image: DOMAINS[domain].image.next };
return { label: 'DOMAINE', value: DOMAINS[domain].display, image: DOMAINS[domain].image.next };
}

export function getPay(wageLowerBound: number, wageUpperBound: number, pay_level: Level) {
export function getWage(wageLowerBound: number, wageUpperBound: number, wageLevel: Level) {
const label = 'RÉTRIBUTION';
const value = `${wageLowerBound}€ - ${wageUpperBound}€`;

switch (pay_level) {
switch (wageLevel) {
case 'Low':
return { label, value, image: PayLow };
case 'Medium':
Expand Down
4 changes: 2 additions & 2 deletions src/app/(user)/cdp/[study]/mri/render.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
TWITTER_URL,
} from '@/settings/links';

import { getDifficulty, getDomain, getPay, ImageElt } from './figures';
import { getDifficulty, getDomain, getWage, ImageElt } from './figures';
import { AdminDisplay, MriFormType } from './form/schema';

interface RenderMRIProps {
Expand Down Expand Up @@ -64,7 +64,7 @@ export function RenderMRI({ mri, admins }: RenderMRIProps) {
<div className="flex flex-col @sm:flex-row">
<ImageElt {...getDomain(mri.mainDomain)} />
<ImageElt
{...getPay(mri.wageLowerBound, mri.wageUpperBound, mri.wageLevel)}
{...getWage(mri.wageLowerBound, mri.wageUpperBound, mri.wageLevel)}
/>
<ImageElt {...getDifficulty(mri.difficulty)} />
</div>
Expand Down
63 changes: 41 additions & 22 deletions src/app/(user)/suivi/mri-validation/mri-validator.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use client';

import { Prisma } from '@prisma/client';
import { Mri, Prisma } from '@prisma/client';
import { formatDistanceToNow } from 'date-fns';
import { fr } from 'date-fns/locale';
import Image from 'next/image';
Expand All @@ -20,7 +20,7 @@ import useSWR, { useSWRConfig } from 'swr';

import BirdLogo from '@/../public/mri/bird.png';

import { getDifficulty, getDomain, getPay, ImageElt } from '@/app/(user)/cdp/[study]/mri/figures';
import { getDifficulty, getDomain, getWage, ImageElt } from '@/app/(user)/cdp/[study]/mri/figures';
import { Box, BoxContent, BoxHeader } from '@/components/boxes/boxes';
import { useViewer } from '@/components/hooks/use-viewer';
import { Button } from '@/components/ui/button';
Expand Down Expand Up @@ -72,6 +72,32 @@ type MriIssue = {
severity: MriIssueSeverity;
};

function detectMriIssues(mri: Mri): MriIssue[] {
const detectedIssues: MriIssue[] = [];

for (const [key, value] of Object.entries(mri)) {
if ((value == null || value == '') && key != 'validationActions') {
detectedIssues.push({
message: `Absence de ${key}`,
severity: key == 'title' ? MriIssueSeverity.High : MriIssueSeverity.Low,
});
}
}

if (
mri.wageLowerBound !== null &&
mri.wageUpperBound !== null &&
mri.wageLowerBound! > mri.wageUpperBound!
) {
detectedIssues.push({
message: "Fourchette de rétribution à l'envers",
severity: MriIssueSeverity.Low,
});
}

return detectedIssues;
}

export function MRIValidator({ mriId }: { mriId: string }) {
const {
data: mri,
Expand Down Expand Up @@ -105,25 +131,7 @@ export function MRIValidator({ mriId }: { mriId: string }) {
const timeLapsTextLoading = isLoading || mri === undefined || mri === null;
const descriptionTextLoading = isLoading || mri === undefined || mri === null;

const populateIssue = (prop: string | null, message: string, severity: MriIssueSeverity) =>
prop == null || prop == '' ? [{ message, severity }] : [];

const detectedIssues: MriIssue[] =
mri !== undefined
? [
...populateIssue(mri.title, 'Absence de titre', MriIssueSeverity.High),
...populateIssue(
mri.descriptionText,
'Absence de description',
MriIssueSeverity.Low
),
...populateIssue(
mri.requiredSkillsText,
'Absence de compétences recherchées',
MriIssueSeverity.Low
),
]
: [];
const detectedIssues = mri ? detectMriIssues(mri) : [];

const h4cn = 'text-2xl font-bold my-1 text-mri-headers';

Expand Down Expand Up @@ -298,7 +306,7 @@ export function MRIValidator({ mriId }: { mriId: string }) {
<Skeleton />
)}
<ImageElt
{...getPay(
{...getWage(
mri?.wageLowerBound ?? 0,
mri?.wageUpperBound ?? 0,
mri?.wageLevel ?? 'Medium'
Expand Down Expand Up @@ -345,6 +353,17 @@ export function MRIValidator({ mriId }: { mriId: string }) {
</section>
<hr className="my-6 border-mri-separator" />
<div className="flex flex-col items-center">
{mri?.gformUrl && (
<Button asChild className="w-fit mb-6 bg-je-red font-semibold">
<Link
href={mri.gformUrl}
target="_blank"
className="p-4 rounded"
>
Je réponds au formulaire
</Link>
</Button>
)}
<Button asChild className="w-fit mb-6 bg-je-red font-semibold">
<Link href="#" className="p-4 rounded">
Je postule !
Expand Down
Loading
Loading