@@ -7,8 +7,12 @@ import BusinessObjects from "./business-objects";
|
||||
import type { BusinessObject } from "./business-objects";
|
||||
import BusinessVerifications from "./business-verifications";
|
||||
import type { BusinessVerification } from "./business-verifications";
|
||||
import BusinessWizard from "./business-wizard";
|
||||
import type { FormSchema } from "./business-wizard";
|
||||
|
||||
type Props = {
|
||||
formSchema: FormSchema;
|
||||
sectors: { id: number; name: string }[];
|
||||
record: Business;
|
||||
canEdit: boolean;
|
||||
owner: boolean;
|
||||
@@ -21,6 +25,8 @@ type Props = {
|
||||
history: { version_no: number; action: string; created_at: string; note: string }[];
|
||||
};
|
||||
export default function BusinessPage(props: Props) {
|
||||
if (props.canEdit)
|
||||
return <BusinessWizard key={props.record.id + ":" + props.record.version_no} {...props} />;
|
||||
return <Editor key={`${props.record.id}:${props.record.version_no}`} {...props} />;
|
||||
}
|
||||
function Editor({
|
||||
@@ -34,6 +40,8 @@ function Editor({
|
||||
objectKinds,
|
||||
verificationChecks,
|
||||
verifications,
|
||||
formSchema,
|
||||
sectors,
|
||||
}: Props) {
|
||||
const [payload, setPayload] = useState(record.payload);
|
||||
const [modality, setModality] = useState(record.modality);
|
||||
@@ -86,6 +94,35 @@ function Editor({
|
||||
Informação declarada, pendente de validação. Não constitui anúncio público,
|
||||
certificação, avaliação ou autorização de transmissão.
|
||||
</p>
|
||||
{!canEdit && (
|
||||
<dl className={`${card} space-y-3 break-words`}>
|
||||
<div>
|
||||
<dt className="font-bold">Sector</dt>
|
||||
<dd>
|
||||
{sectors.find((sector) => sector.id === record.sector_id)?.name ?? "—"}
|
||||
</dd>
|
||||
</div>
|
||||
{Object.entries(formSchema)
|
||||
.filter(
|
||||
([key]) =>
|
||||
![
|
||||
"title",
|
||||
"description",
|
||||
"declared_reason",
|
||||
"source_reference",
|
||||
"valid_until",
|
||||
].includes(key),
|
||||
)
|
||||
.map(([key, field]) => (
|
||||
<div key={key}>
|
||||
<dt className="font-bold">{field.pt}</dt>
|
||||
<dd className="whitespace-pre-wrap">
|
||||
{record.payload[key] || "—"}
|
||||
</dd>
|
||||
</div>
|
||||
))}
|
||||
</dl>
|
||||
)}
|
||||
<form
|
||||
className={`${card} space-y-4`}
|
||||
onSubmit={(e) => {
|
||||
|
||||
Reference in New Issue
Block a user