feat: consolidar desenvolvimentos do portal InvestMoz
This commit is contained in:
@@ -0,0 +1,154 @@
|
||||
import { Link } from '@inertiajs/react';
|
||||
import EducationReview from '@/components/education-review';
|
||||
import type { EducationReviewProps } from '@/lib/education-review';
|
||||
import { Management, Pagination } from '../management/shared';
|
||||
import type { Paginated } from '../management/shared';
|
||||
|
||||
type ReviewEntry = {
|
||||
id: string;
|
||||
version: number | null;
|
||||
actor: string | null;
|
||||
occurred_at: string;
|
||||
available: boolean;
|
||||
status: 'reviewed' | 'rejected' | null;
|
||||
reason: string | null;
|
||||
previous_reason: string | null;
|
||||
};
|
||||
export default function Declaration(
|
||||
props: EducationReviewProps & {
|
||||
backUrl: string;
|
||||
references: Record<string, string | null>;
|
||||
history?: Paginated<ReviewEntry>;
|
||||
},
|
||||
) {
|
||||
const row = props.declaration;
|
||||
const labels: Record<string, string> = {
|
||||
occupation: 'Ocupação',
|
||||
skill: 'Competência',
|
||||
location: 'Localização',
|
||||
project: 'Projecto',
|
||||
course: 'Curso',
|
||||
};
|
||||
return (
|
||||
<Management
|
||||
title={
|
||||
props.kind === 'demands'
|
||||
? 'Declaração de procura de trabalhadores'
|
||||
: 'Declaração de vagas formativas'
|
||||
}
|
||||
>
|
||||
<Link className="underline" href={props.backUrl}>
|
||||
Voltar às declarações
|
||||
</Link>
|
||||
<section className="space-y-3 rounded border p-4">
|
||||
<h2 className="text-xl font-semibold break-words">
|
||||
{row.qualification}
|
||||
</h2>
|
||||
<p>
|
||||
{row.quantity}{' '}
|
||||
{props.kind === 'demands'
|
||||
? 'trabalhadores'
|
||||
: 'vagas formativas'}{' '}
|
||||
· {row.period_start} a {row.period_end}
|
||||
</p>
|
||||
<p>
|
||||
Fonte válida até {row.valid_until}
|
||||
{row.valid_until < props.today ? ' · Expirada' : ''}
|
||||
</p>
|
||||
{row.reference_date && (
|
||||
<p>Data de referência: {row.reference_date}</p>
|
||||
)}
|
||||
{props.kind === 'demands' && row.employer && (
|
||||
<p>Empregador declarado: {row.employer}</p>
|
||||
)}
|
||||
<p className="break-words whitespace-pre-wrap">
|
||||
Fonte: {row.source}
|
||||
</p>
|
||||
{!!Object.keys(props.references).length && (
|
||||
<h3 className="font-semibold">
|
||||
Referências no cadastro actual
|
||||
</h3>
|
||||
)}
|
||||
{Object.entries(props.references).map(([field, value]) => (
|
||||
<p key={field}>
|
||||
{labels[field] ?? field}:{' '}
|
||||
{value || 'Não identificado no cadastro actual'}
|
||||
</p>
|
||||
))}
|
||||
{row.submitted_by_name && (
|
||||
<p>Submetida por {row.submitted_by_name}</p>
|
||||
)}
|
||||
{row.reviewed_by_name && (
|
||||
<p>Revisão actual por {row.reviewed_by_name}</p>
|
||||
)}
|
||||
{row.review_reason && (
|
||||
<p className="break-words whitespace-pre-wrap">
|
||||
Último fundamento registado: {row.review_reason}
|
||||
</p>
|
||||
)}
|
||||
{props.kind === 'demands' && (
|
||||
<Link
|
||||
className="underline"
|
||||
href={`/management/education/demands/${row.id}/analysis`}
|
||||
>
|
||||
Analisar procura e oferta
|
||||
</Link>
|
||||
)}
|
||||
</section>
|
||||
<EducationReview
|
||||
key={`${props.kind}:${row.id}:${props.actorId}`}
|
||||
{...props}
|
||||
/>
|
||||
{props.history && (
|
||||
<section className="space-y-3 rounded border p-4">
|
||||
<h2 className="text-xl font-semibold">
|
||||
Registos de revisão disponíveis
|
||||
</h2>
|
||||
<p>
|
||||
Os registos anteriores à preservação dos fundamentos
|
||||
podem não estar disponíveis.
|
||||
</p>
|
||||
{!props.history.data.length && (
|
||||
<p>Sem registos de revisão preservados.</p>
|
||||
)}
|
||||
{props.history.data.map((entry) => (
|
||||
<article
|
||||
key={entry.id}
|
||||
className="space-y-2 border-t pt-3"
|
||||
>
|
||||
<h3 className="font-semibold">
|
||||
Versão {entry.version ?? 'não identificada'} ·{' '}
|
||||
{entry.actor ?? 'Autor não identificado'}
|
||||
</h3>
|
||||
<p>{entry.occurred_at}</p>
|
||||
{entry.available ? (
|
||||
<>
|
||||
<p>
|
||||
{entry.status === 'reviewed'
|
||||
? 'Revista'
|
||||
: 'Rejeitada'}
|
||||
</p>
|
||||
<p className="break-words whitespace-pre-wrap">
|
||||
Fundamento: {entry.reason}
|
||||
</p>
|
||||
{entry.previous_reason && (
|
||||
<p className="break-words whitespace-pre-wrap">
|
||||
Fundamento anterior capturado:{' '}
|
||||
{entry.previous_reason}
|
||||
</p>
|
||||
)}
|
||||
</>
|
||||
) : (
|
||||
<p>
|
||||
Fundamento indisponível para leitura. O
|
||||
registo original foi preservado.
|
||||
</p>
|
||||
)}
|
||||
</article>
|
||||
))}
|
||||
<Pagination page={props.history} />
|
||||
</section>
|
||||
)}
|
||||
</Management>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user