@@ -1,27 +1,27 @@
|
||||
import { router } from "@inertiajs/react";
|
||||
import { useState } from "react";
|
||||
import { api, button, card, Field, input } from "./shared";
|
||||
import type { BusinessObject } from "./business-objects";
|
||||
import { router } from '@inertiajs/react';
|
||||
import { useState } from 'react';
|
||||
import { api, button, card, Field, input } from './shared';
|
||||
import type { BusinessObject } from './business-objects';
|
||||
|
||||
const labels: Record<string, string> = {
|
||||
identity: "Identidade",
|
||||
representation: "Representação",
|
||||
declared_ownership: "Titularidade declarada",
|
||||
documentary_ownership: "Titularidade documental",
|
||||
document_received: "Documento recebido",
|
||||
document_validated: "Documento validado",
|
||||
independent_valuation: "Avaliação independente",
|
||||
land_right_documented: "Direito fundiário documentado",
|
||||
license_confirmed: "Licença confirmada",
|
||||
validity: "Validade",
|
||||
legal_transfer: "Transmissibilidade jurídica",
|
||||
prior_authorization: "Autorização prévia",
|
||||
confirmed: "Confirmado pelo revisor",
|
||||
rejected: "Não confirmado",
|
||||
inconclusive: "Inconclusivo",
|
||||
revoked: "Revogado",
|
||||
stale: "Rever após alteração dos dados",
|
||||
expired: "Expirado",
|
||||
identity: 'Identidade',
|
||||
representation: 'Representação',
|
||||
declared_ownership: 'Titularidade declarada',
|
||||
documentary_ownership: 'Titularidade documental',
|
||||
document_received: 'Documento recebido',
|
||||
document_validated: 'Documento validado',
|
||||
independent_valuation: 'Avaliação independente',
|
||||
land_right_documented: 'Direito fundiário documentado',
|
||||
license_confirmed: 'Licença confirmada',
|
||||
validity: 'Validade',
|
||||
legal_transfer: 'Transmissibilidade jurídica',
|
||||
prior_authorization: 'Autorização prévia',
|
||||
confirmed: 'Confirmado pelo revisor',
|
||||
rejected: 'Não confirmado',
|
||||
inconclusive: 'Inconclusivo',
|
||||
revoked: 'Revogado',
|
||||
stale: 'Rever após alteração dos dados',
|
||||
expired: 'Expirado',
|
||||
};
|
||||
export type BusinessVerification = {
|
||||
check: string;
|
||||
@@ -49,31 +49,38 @@ export default function BusinessVerifications({
|
||||
objects: BusinessObject[];
|
||||
}) {
|
||||
const [busy, setBusy] = useState(false);
|
||||
const [error, setError] = useState("");
|
||||
const [outcome, setOutcome] = useState("inconclusive");
|
||||
const [error, setError] = useState('');
|
||||
const [outcome, setOutcome] = useState('inconclusive');
|
||||
return (
|
||||
<section className={`${card} space-y-4`}>
|
||||
<h2 className="text-xl font-bold">Verificações e evidências</h2>
|
||||
<p>
|
||||
Cada conclusão corresponde apenas ao aspecto e à versão analisados. Não constitui
|
||||
certificação global, autorização de publicação ou garantia de transmissão.
|
||||
Alterações aos dados exigem nova revisão.
|
||||
Cada conclusão corresponde apenas ao aspecto e à versão
|
||||
analisados. Não constitui certificação global, autorização de
|
||||
publicação ou garantia de transmissão. Alterações aos dados
|
||||
exigem nova revisão.
|
||||
</p>
|
||||
{findings.length === 0 && <p>Ainda não existem verificações registadas.</p>}
|
||||
{findings.length === 0 && (
|
||||
<p>Ainda não existem verificações registadas.</p>
|
||||
)}
|
||||
<ul className="space-y-4">
|
||||
{findings.map((finding) => (
|
||||
<li key={finding.version_no} className="break-words">
|
||||
<strong>
|
||||
{labels[finding.check]} · {labels[finding.effective_outcome]}
|
||||
{labels[finding.check]} ·{' '}
|
||||
{labels[finding.effective_outcome]}
|
||||
</strong>
|
||||
<p>
|
||||
{objects.find((object) => object.id === finding.object_id)?.payload
|
||||
.label ?? "Negócio"}{" "}
|
||||
{objects.find(
|
||||
(object) => object.id === finding.object_id,
|
||||
)?.payload.label ?? 'Negócio'}{' '}
|
||||
· versão {finding.version_no}
|
||||
</p>
|
||||
<p>Evidência: {finding.evidence_reference}</p>
|
||||
<p>{finding.note}</p>
|
||||
{finding.valid_until && <p>Válido até {finding.valid_until}</p>}
|
||||
{finding.valid_until && (
|
||||
<p>Válido até {finding.valid_until}</p>
|
||||
)}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
@@ -82,20 +89,25 @@ export default function BusinessVerifications({
|
||||
className="space-y-4"
|
||||
onSubmit={async (event) => {
|
||||
event.preventDefault();
|
||||
const data = Object.fromEntries(new FormData(event.currentTarget));
|
||||
const data = Object.fromEntries(
|
||||
new FormData(event.currentTarget),
|
||||
);
|
||||
setBusy(true);
|
||||
setError("");
|
||||
setError('');
|
||||
try {
|
||||
await api(`/api/v1/existing-business/listings/${id}/verifications`, {
|
||||
...data,
|
||||
version_no: version,
|
||||
});
|
||||
await api(
|
||||
`/api/v1/existing-business/listings/${id}/verifications`,
|
||||
{
|
||||
...data,
|
||||
version_no: version,
|
||||
},
|
||||
);
|
||||
router.reload();
|
||||
} catch (failure) {
|
||||
setError(
|
||||
failure instanceof Error
|
||||
? failure.message
|
||||
: "Não foi possível registar a verificação.",
|
||||
: 'Não foi possível registar a verificação.',
|
||||
);
|
||||
} finally {
|
||||
setBusy(false);
|
||||
@@ -127,15 +139,20 @@ export default function BusinessVerifications({
|
||||
className={input}
|
||||
name="outcome"
|
||||
value={outcome}
|
||||
onChange={(event) => setOutcome(event.target.value)}
|
||||
onChange={(event) =>
|
||||
setOutcome(event.target.value)
|
||||
}
|
||||
>
|
||||
{["inconclusive", "confirmed", "rejected", "revoked"].map(
|
||||
(value) => (
|
||||
<option key={value} value={value}>
|
||||
{labels[value]}
|
||||
</option>
|
||||
),
|
||||
)}
|
||||
{[
|
||||
'inconclusive',
|
||||
'confirmed',
|
||||
'rejected',
|
||||
'revoked',
|
||||
].map((value) => (
|
||||
<option key={value} value={value}>
|
||||
{labels[value]}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</Field>
|
||||
<Field label="Referência da evidência consultada">
|
||||
@@ -161,7 +178,7 @@ export default function BusinessVerifications({
|
||||
className={input}
|
||||
type="date"
|
||||
name="valid_until"
|
||||
required={outcome === "confirmed"}
|
||||
required={outcome === 'confirmed'}
|
||||
/>
|
||||
</Field>
|
||||
<button className={button} disabled={busy}>
|
||||
|
||||
Reference in New Issue
Block a user