feat: add private business intake review and reserved objects
This commit is contained in:
@@ -17,6 +17,8 @@ export const portalLinks = [
|
||||
["/apoio", "Apoio ao Investidor"],
|
||||
] as const;
|
||||
const names: Record<string, string> = {
|
||||
"/investidor/negocios": "Os meus negócios",
|
||||
"/management/negocios": "Revisão de negócios",
|
||||
...Object.fromEntries(portalLinks),
|
||||
"/parcerias": "Bolsa de Parcerias",
|
||||
"/simulador-fiscal": "Simulador Fiscal",
|
||||
@@ -47,13 +49,16 @@ export default function PortalNavigation({ children }: { children: ReactNode })
|
||||
.filter((p) => p !== "/" && path.startsWith(`${p}/`))
|
||||
.sort((a, b) => b.length - a.length)[0];
|
||||
const pageProps = props as {
|
||||
record?: { title?: string };
|
||||
record?: { title?: string; name?: string };
|
||||
zone?: { name?: string };
|
||||
sector?: { name?: string };
|
||||
initialOpportunity?: { title?: string };
|
||||
};
|
||||
const title =
|
||||
names[path] ??
|
||||
pageProps.record?.title ??
|
||||
pageProps.record?.name ??
|
||||
pageProps.zone?.name ??
|
||||
pageProps.sector?.name ??
|
||||
pageProps.initialOpportunity?.title ??
|
||||
(path.includes("/edit")
|
||||
@@ -109,6 +114,7 @@ export default function PortalNavigation({ children }: { children: ReactNode })
|
||||
}
|
||||
|
||||
export function PortalMenu() {
|
||||
const { existingBusinessEnabled } = usePage<{ existingBusinessEnabled?: boolean }>().props;
|
||||
const [expanded, setExpanded] = useState(false);
|
||||
const menuId = useId();
|
||||
return (
|
||||
@@ -139,6 +145,11 @@ export function PortalMenu() {
|
||||
{label}
|
||||
</Link>
|
||||
))}
|
||||
{existingBusinessEnabled && (
|
||||
<Link href="/investidor/negocios" className="underline">
|
||||
Os meus negócios
|
||||
</Link>
|
||||
)}
|
||||
<Link href="/parcerias" className="underline">
|
||||
Bolsa de Parcerias
|
||||
</Link>
|
||||
|
||||
@@ -0,0 +1,286 @@
|
||||
import { router } from "@inertiajs/react";
|
||||
import { useState } from "react";
|
||||
import { Field, input, button, card, api } from "./shared";
|
||||
|
||||
export type BusinessObject = {
|
||||
id: string;
|
||||
kind: string;
|
||||
verification_status: string;
|
||||
payload: Record<string, string>;
|
||||
};
|
||||
const kinds: Record<string, string> = {
|
||||
company: "Empresa",
|
||||
participation: "Participação",
|
||||
asset: "Activo físico",
|
||||
property: "Imóvel/propriedade",
|
||||
unit: "Unidade imobiliária",
|
||||
improvement: "Benfeitoria",
|
||||
agricultural_investment: "Investimento agrícola",
|
||||
land_right: "Direito fundiário",
|
||||
contract: "Contrato",
|
||||
license: "Licença",
|
||||
authorization: "Autorização",
|
||||
encumbrance: "Ónus ou encargo",
|
||||
valuation: "Avaliação declarada",
|
||||
capital_request: "Pedido de capital",
|
||||
};
|
||||
const fields: Record<string, string> = {
|
||||
label: "Designação reservada",
|
||||
declared_holder: "Titular declarado",
|
||||
document_reference: "Referência documental",
|
||||
source_reference: "Fonte da informação",
|
||||
competent_entity: "Entidade emissora/competente declarada",
|
||||
purpose: "Finalidade autorizada declarada",
|
||||
location_description: "Localização reservada",
|
||||
boundaries_description: "Limites declarados",
|
||||
occupancy: "Ocupação/utilização",
|
||||
condition: "Conservação/operação",
|
||||
encumbrances: "Ónus, garantias ou litígios declarados",
|
||||
restrictions: "Restrições declaradas",
|
||||
required_authorizations: "Autorizações necessárias declaradas",
|
||||
transfer_condition: "Condição de cessão/transmissão declarada",
|
||||
valid_from: "Início de validade",
|
||||
valid_until: "Fim de validade",
|
||||
area: "Área (decimal com ponto)",
|
||||
participation_percent: "Participação (%)",
|
||||
amount: "Valor (decimal com ponto)",
|
||||
currency: "Moeda (código de três letras)",
|
||||
};
|
||||
export default function BusinessObjects({
|
||||
businessId,
|
||||
version,
|
||||
editable,
|
||||
objects,
|
||||
objectKinds,
|
||||
}: {
|
||||
businessId: string;
|
||||
version: number;
|
||||
editable: boolean;
|
||||
objects: BusinessObject[];
|
||||
objectKinds: string[];
|
||||
}) {
|
||||
const [kind, setKind] = useState(objectKinds[0]);
|
||||
const [objectId, setObjectId] = useState<string | null>(null);
|
||||
const [payload, setPayload] = useState<Record<string, string>>({});
|
||||
const [reason, setReason] = useState("");
|
||||
const [error, setError] = useState("");
|
||||
const [busy, setBusy] = useState(false);
|
||||
return (
|
||||
<section className={`${card} space-y-4`}>
|
||||
<h2 className="text-xl font-bold">Activos, contratos e direitos declarados</h2>
|
||||
<p>
|
||||
Registe separadamente cada elemento. Todos ficam pendentes de verificação; a
|
||||
declaração não confirma titularidade, validade ou transmissibilidade. Não use este
|
||||
formulário para anexar ficheiros.
|
||||
</p>
|
||||
{!objects.length && <p>Nenhum elemento registado.</p>}
|
||||
{objects.map((o) => (
|
||||
<article key={o.id} className="rounded border p-4">
|
||||
<h3 className="font-bold">
|
||||
{kinds[o.kind]} · {o.payload.label}
|
||||
</h3>
|
||||
<p>Pendente de verificação</p>
|
||||
<dl>
|
||||
{Object.entries(o.payload)
|
||||
.filter(([key, value]) => key !== "label" && value)
|
||||
.map(([key, value]) => (
|
||||
<div key={key}>
|
||||
<dt className="font-semibold">
|
||||
{fields[key] ??
|
||||
(
|
||||
{
|
||||
area_unit: "Unidade da área",
|
||||
value_kind: "Natureza do valor",
|
||||
contract_type: "Tipo de contrato",
|
||||
} as Record<string, string>
|
||||
)[key] ??
|
||||
key}
|
||||
</dt>
|
||||
<dd className="break-words">
|
||||
{key === "value_kind"
|
||||
? ((
|
||||
{
|
||||
asking: "Pedido",
|
||||
indicative: "Indicativo",
|
||||
appraised: "Avaliado — declaração pendente",
|
||||
proposed: "Proposto",
|
||||
negotiated: "Negociado — declaração pendente",
|
||||
confirmed: "Confirmado — declaração pendente",
|
||||
} as Record<string, string>
|
||||
)[value] ?? value)
|
||||
: value}
|
||||
</dd>
|
||||
</div>
|
||||
))}
|
||||
</dl>
|
||||
{editable && (
|
||||
<button
|
||||
type="button"
|
||||
className={button}
|
||||
onClick={() => {
|
||||
setObjectId(o.id);
|
||||
setKind(o.kind);
|
||||
setPayload(o.payload);
|
||||
setReason("");
|
||||
}}
|
||||
>
|
||||
Editar elemento
|
||||
</button>
|
||||
)}
|
||||
</article>
|
||||
))}
|
||||
{editable && (
|
||||
<form
|
||||
className="space-y-4"
|
||||
onSubmit={async (e) => {
|
||||
e.preventDefault();
|
||||
setBusy(true);
|
||||
setError("");
|
||||
try {
|
||||
await api(
|
||||
`/api/v1/existing-business/listings/${businessId}/objects${objectId ? `/${objectId}` : ""}`,
|
||||
{
|
||||
...(objectId ? { _method: "PUT" } : {}),
|
||||
kind,
|
||||
payload,
|
||||
reason,
|
||||
version_no: version,
|
||||
},
|
||||
);
|
||||
router.reload();
|
||||
} catch (err) {
|
||||
setError(
|
||||
err instanceof Error
|
||||
? err.message
|
||||
: "Não foi possível guardar o elemento.",
|
||||
);
|
||||
} finally {
|
||||
setBusy(false);
|
||||
}
|
||||
}}
|
||||
>
|
||||
<h3 className="font-bold">
|
||||
{objectId ? "Editar elemento reservado" : "Acrescentar elemento reservado"}
|
||||
</h3>
|
||||
<Field label="Natureza">
|
||||
<select
|
||||
className={input}
|
||||
value={kind}
|
||||
disabled={!!objectId || busy}
|
||||
onChange={(e) => setKind(e.target.value)}
|
||||
>
|
||||
{objectKinds.map((k) => (
|
||||
<option key={k} value={k}>
|
||||
{kinds[k]}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</Field>
|
||||
<div className="grid gap-4 md:grid-cols-2">
|
||||
{Object.entries(fields).map(([key, label]) => (
|
||||
<Field key={key} label={label}>
|
||||
<input
|
||||
className={input}
|
||||
type={key.startsWith("valid_") ? "date" : "text"}
|
||||
value={payload[key] ?? ""}
|
||||
maxLength={key === "label" ? 200 : 2000}
|
||||
required={key === "label" || key === "source_reference"}
|
||||
onChange={(e) =>
|
||||
setPayload({ ...payload, [key]: e.target.value })
|
||||
}
|
||||
/>
|
||||
</Field>
|
||||
))}
|
||||
<Field label="Unidade da área">
|
||||
<select
|
||||
className={input}
|
||||
value={payload.area_unit ?? ""}
|
||||
onChange={(e) =>
|
||||
setPayload({ ...payload, area_unit: e.target.value })
|
||||
}
|
||||
>
|
||||
<option value="">Não indicada</option>
|
||||
{["m2", "ha", "km2"].map((x) => (
|
||||
<option key={x}>{x}</option>
|
||||
))}
|
||||
</select>
|
||||
</Field>
|
||||
<Field label="Natureza do valor">
|
||||
<select
|
||||
className={input}
|
||||
value={payload.value_kind ?? ""}
|
||||
onChange={(e) =>
|
||||
setPayload({ ...payload, value_kind: e.target.value })
|
||||
}
|
||||
>
|
||||
<option value="">Não indicada</option>
|
||||
{Object.entries({
|
||||
asking: "Pedido",
|
||||
indicative: "Indicativo",
|
||||
appraised: "Avaliado (declaração por verificar)",
|
||||
proposed: "Proposto",
|
||||
negotiated: "Negociado (declaração por verificar)",
|
||||
confirmed: "Confirmado (declaração por verificar)",
|
||||
}).map(([key, label]) => (
|
||||
<option key={key} value={key}>
|
||||
{label}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</Field>
|
||||
<Field label="Tipo de contrato">
|
||||
<select
|
||||
className={input}
|
||||
value={payload.contract_type ?? ""}
|
||||
onChange={(e) =>
|
||||
setPayload({ ...payload, contract_type: e.target.value })
|
||||
}
|
||||
>
|
||||
<option value="">Não indicado</option>
|
||||
{Object.entries({
|
||||
purchase: "Compra",
|
||||
sale: "Venda",
|
||||
lease: "Arrendamento",
|
||||
operation: "Exploração",
|
||||
management: "Gestão",
|
||||
other: "Outro",
|
||||
}).map(([key, label]) => (
|
||||
<option key={key} value={key}>
|
||||
{label}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</Field>
|
||||
</div>
|
||||
<Field label="Motivo do registo ou alteração">
|
||||
<textarea
|
||||
className={input}
|
||||
value={reason}
|
||||
minLength={10}
|
||||
maxLength={1000}
|
||||
required
|
||||
onChange={(e) => setReason(e.target.value)}
|
||||
/>
|
||||
</Field>
|
||||
{error && <p role="alert">{error}</p>}
|
||||
<button className={button} disabled={busy}>
|
||||
{busy ? "A guardar…" : "Guardar elemento reservado"}
|
||||
</button>
|
||||
{objectId && (
|
||||
<button
|
||||
type="button"
|
||||
className="ml-4 underline"
|
||||
onClick={() => {
|
||||
setObjectId(null);
|
||||
setPayload({});
|
||||
setReason("");
|
||||
}}
|
||||
>
|
||||
Cancelar edição
|
||||
</button>
|
||||
)}
|
||||
</form>
|
||||
)}
|
||||
</section>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
export type Business = {
|
||||
id: string;
|
||||
code: string;
|
||||
modality: string;
|
||||
status: string;
|
||||
classification: string;
|
||||
version_no: number;
|
||||
payload: {
|
||||
title: string;
|
||||
description?: string;
|
||||
declared_reason?: string;
|
||||
source_reference?: string;
|
||||
valid_until?: string;
|
||||
};
|
||||
};
|
||||
export const businessStates: Record<string, string> = {
|
||||
draft: "Rascunho",
|
||||
submitted: "Submetido",
|
||||
in_review: "Em revisão",
|
||||
needs_information: "Pendente de informação",
|
||||
withdrawn: "Retirado",
|
||||
};
|
||||
export const businessModalities: Record<string, string> = {
|
||||
company_sale: "Venda da empresa",
|
||||
participation_sale: "Venda de participação",
|
||||
capital_increase: "Aumento de capital",
|
||||
financial_investor: "Investidor financeiro",
|
||||
strategic_partner: "Sócio estratégico",
|
||||
buyer_search: "Procura de comprador",
|
||||
position_assignment: "Cessão de posição",
|
||||
franchise: "Franchising",
|
||||
asset_sale: "Venda de activos",
|
||||
asset_lease: "Arrendamento de activos",
|
||||
business_unit_transfer: "Transferência de unidade de negócio",
|
||||
joint_venture: "Joint venture",
|
||||
succession: "Sucessão empresarial",
|
||||
recovery: "Recuperação",
|
||||
expansion: "Expansão",
|
||||
internationalization: "Internacionalização",
|
||||
real_estate: "Imobiliário",
|
||||
agricultural_investment: "Investimento agrícola",
|
||||
land_right: "Direito fundiário",
|
||||
mining_license: "Licença mineira",
|
||||
forestry_license: "Licença florestal",
|
||||
};
|
||||
@@ -0,0 +1,237 @@
|
||||
import { Link, router } from "@inertiajs/react";
|
||||
import { useState } from "react";
|
||||
import { Frame, Field, input, button, card, api } from "./shared";
|
||||
import { businessModalities, businessStates } from "./business-types";
|
||||
import type { Business } from "./business-types";
|
||||
import BusinessObjects from "./business-objects";
|
||||
import type { BusinessObject } from "./business-objects";
|
||||
|
||||
type Props = {
|
||||
record: Business;
|
||||
canEdit: boolean;
|
||||
owner: boolean;
|
||||
canReview: boolean;
|
||||
modalities: string[];
|
||||
objects: BusinessObject[];
|
||||
objectKinds: string[];
|
||||
history: { version_no: number; action: string; created_at: string; note: string }[];
|
||||
};
|
||||
export default function BusinessPage(props: Props) {
|
||||
return <Editor key={`${props.record.id}:${props.record.version_no}`} {...props} />;
|
||||
}
|
||||
function Editor({
|
||||
record,
|
||||
canEdit,
|
||||
owner,
|
||||
canReview,
|
||||
modalities,
|
||||
history,
|
||||
objects,
|
||||
objectKinds,
|
||||
}: Props) {
|
||||
const [payload, setPayload] = useState(record.payload);
|
||||
const [modality, setModality] = useState(record.modality);
|
||||
const [note, setNote] = useState("");
|
||||
const [consent, setConsent] = useState(false);
|
||||
const [busy, setBusy] = useState(false);
|
||||
const [error, setError] = useState("");
|
||||
const dirty =
|
||||
JSON.stringify(payload) !== JSON.stringify(record.payload) || modality !== record.modality;
|
||||
const run = async (action?: string) => {
|
||||
setBusy(true);
|
||||
setError("");
|
||||
try {
|
||||
await api(
|
||||
`/api/v1/existing-business/listings/${record.id}${action ? "/transitions" : ""}`,
|
||||
action
|
||||
? { action, version_no: record.version_no, note, review_consent: consent }
|
||||
: {
|
||||
_method: "PUT",
|
||||
modality,
|
||||
classification: record.classification,
|
||||
payload,
|
||||
reason: note,
|
||||
version_no: record.version_no,
|
||||
},
|
||||
);
|
||||
router.reload();
|
||||
} catch (err) {
|
||||
setError(
|
||||
err instanceof Error
|
||||
? err.message
|
||||
: "Não foi possível guardar. Recarregue se a versão mudou.",
|
||||
);
|
||||
} finally {
|
||||
setBusy(false);
|
||||
}
|
||||
};
|
||||
return (
|
||||
<Frame title={record.payload.title}>
|
||||
<Link
|
||||
className="underline"
|
||||
href={owner ? "/investidor/negocios" : "/management/negocios"}
|
||||
>
|
||||
Voltar à lista
|
||||
</Link>
|
||||
<p>
|
||||
{businessStates[record.status]} · versão {record.version_no} · informação reservada
|
||||
</p>
|
||||
<p>
|
||||
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>
|
||||
<form
|
||||
className={`${card} space-y-4`}
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
void run();
|
||||
}}
|
||||
>
|
||||
<fieldset disabled={!canEdit || busy} className="space-y-4">
|
||||
<Field label="Modalidade">
|
||||
<select
|
||||
className={input}
|
||||
value={modality}
|
||||
onChange={(e) => setModality(e.target.value)}
|
||||
>
|
||||
{modalities.map((m) => (
|
||||
<option value={m} key={m}>
|
||||
{businessModalities[m] ?? m}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</Field>
|
||||
{(
|
||||
[
|
||||
["title", "Título privado"],
|
||||
["description", "Descrição reservada"],
|
||||
["declared_reason", "Motivo declarado"],
|
||||
["source_reference", "Referência da fonte"],
|
||||
["valid_until", "Validade declarada"],
|
||||
] as const
|
||||
).map(([key, label]) => (
|
||||
<Field key={key} label={label}>
|
||||
{key === "description" ? (
|
||||
<textarea
|
||||
className={input}
|
||||
rows={5}
|
||||
maxLength={10000}
|
||||
value={payload[key] ?? ""}
|
||||
onChange={(e) =>
|
||||
setPayload({ ...payload, [key]: e.target.value })
|
||||
}
|
||||
/>
|
||||
) : (
|
||||
<input
|
||||
className={input}
|
||||
type={key === "valid_until" ? "date" : "text"}
|
||||
maxLength={key === "title" ? 200 : 2000}
|
||||
value={payload[key] ?? ""}
|
||||
onChange={(e) =>
|
||||
setPayload({ ...payload, [key]: e.target.value })
|
||||
}
|
||||
/>
|
||||
)}
|
||||
</Field>
|
||||
))}
|
||||
</fieldset>
|
||||
<Field label="Motivo da alteração ou nota para a revisão">
|
||||
<textarea
|
||||
className={input}
|
||||
value={note}
|
||||
onChange={(e) => setNote(e.target.value)}
|
||||
minLength={10}
|
||||
maxLength={1000}
|
||||
required
|
||||
/>
|
||||
</Field>
|
||||
{error && <p role="alert">{error}</p>}
|
||||
{canEdit && (
|
||||
<button className={button} disabled={busy || note.trim().length < 10}>
|
||||
Guardar rascunho
|
||||
</button>
|
||||
)}
|
||||
{dirty && <p role="status">Guarde as alterações antes de mudar de estado.</p>}
|
||||
</form>
|
||||
{owner && canEdit && (
|
||||
<label className="flex gap-3">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={consent}
|
||||
onChange={(e) => setConsent(e.target.checked)}
|
||||
/>
|
||||
Autorizo a análise interna desta submissão pelos revisores designados. Esta
|
||||
autorização não permite publicação.
|
||||
</label>
|
||||
)}
|
||||
<div className="flex flex-wrap gap-3">
|
||||
{owner && canEdit && (
|
||||
<button
|
||||
className={button}
|
||||
disabled={busy || dirty || !consent || note.trim().length < 10}
|
||||
onClick={() => void run("submitted")}
|
||||
>
|
||||
Submeter para análise
|
||||
</button>
|
||||
)}
|
||||
{canReview && record.status === "submitted" && (
|
||||
<button
|
||||
className={button}
|
||||
disabled={busy || note.trim().length < 10}
|
||||
onClick={() => void run("in_review")}
|
||||
>
|
||||
Iniciar revisão
|
||||
</button>
|
||||
)}
|
||||
{canReview && record.status === "in_review" && (
|
||||
<button
|
||||
className={button}
|
||||
disabled={busy || note.trim().length < 10}
|
||||
onClick={() => void run("needs_information")}
|
||||
>
|
||||
Pedir informação
|
||||
</button>
|
||||
)}
|
||||
{owner && record.status !== "withdrawn" && (
|
||||
<button
|
||||
className={button}
|
||||
disabled={busy || dirty || note.trim().length < 10}
|
||||
onClick={() => void run("withdrawn")}
|
||||
>
|
||||
Retirar submissão
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
<BusinessObjects
|
||||
businessId={record.id}
|
||||
version={record.version_no}
|
||||
editable={canEdit && !dirty && !busy}
|
||||
objects={objects}
|
||||
objectKinds={objectKinds}
|
||||
/>
|
||||
<section className={card}>
|
||||
<h2 className="text-xl font-bold">Histórico</h2>
|
||||
<ol>
|
||||
{history.map((h) => (
|
||||
<li key={h.version_no}>
|
||||
Versão {h.version_no} ·{" "}
|
||||
{businessStates[h.action] ??
|
||||
(
|
||||
{
|
||||
created: "Criado",
|
||||
updated: "Alterado",
|
||||
archived: "Arquivado",
|
||||
object_added: "Elemento declarado acrescentado",
|
||||
object_updated: "Elemento declarado alterado",
|
||||
} as Record<string, string>
|
||||
)[h.action] ??
|
||||
h.action}{" "}
|
||||
· {new Date(h.created_at).toLocaleString("pt-MZ")}
|
||||
<p>{h.note}</p>
|
||||
</li>
|
||||
))}
|
||||
</ol>
|
||||
</section>
|
||||
</Frame>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
import { Link, router } from "@inertiajs/react";
|
||||
import { useState } from "react";
|
||||
import { Frame, Field, input, button, card, api } from "./shared";
|
||||
import { businessModalities, businessStates } from "./business-types";
|
||||
import type { Business } from "./business-types";
|
||||
|
||||
export default function Businesses({
|
||||
records,
|
||||
management,
|
||||
modalities,
|
||||
}: {
|
||||
records: { data: Business[]; prev_page_url: string | null; next_page_url: string | null };
|
||||
management: boolean;
|
||||
modalities: string[];
|
||||
}) {
|
||||
const [title, setTitle] = useState("");
|
||||
const [modality, setModality] = useState(modalities[0]);
|
||||
const [error, setError] = useState("");
|
||||
const [busy, setBusy] = useState(false);
|
||||
return (
|
||||
<Frame title={management ? "Revisão de negócios" : "Os meus negócios"}>
|
||||
<p>
|
||||
Área privada de preparação e revisão. A submissão não confirma titularidade,
|
||||
validade ou transmissibilidade do negócio, activo ou direito.
|
||||
</p>
|
||||
{!management && (
|
||||
<form
|
||||
className={`${card} space-y-4`}
|
||||
onSubmit={async (e) => {
|
||||
e.preventDefault();
|
||||
setBusy(true);
|
||||
setError("");
|
||||
try {
|
||||
const result = await api("/api/v1/existing-business/listings", {
|
||||
modality,
|
||||
classification: "confidential",
|
||||
reason: "Criação de rascunho pelo proprietário",
|
||||
payload: { title },
|
||||
});
|
||||
router.visit(`/investidor/negocios/${result.id}`);
|
||||
} catch (err) {
|
||||
setError(
|
||||
err instanceof Error
|
||||
? err.message
|
||||
: "Não foi possível criar o rascunho.",
|
||||
);
|
||||
} finally {
|
||||
setBusy(false);
|
||||
}
|
||||
}}
|
||||
>
|
||||
<h2 className="text-xl font-bold">Preparar negócio</h2>
|
||||
<Field label="Título privado">
|
||||
<input
|
||||
className={input}
|
||||
value={title}
|
||||
onChange={(e) => setTitle(e.target.value)}
|
||||
required
|
||||
maxLength={200}
|
||||
/>
|
||||
</Field>
|
||||
<Field label="Modalidade">
|
||||
<select
|
||||
className={input}
|
||||
value={modality}
|
||||
onChange={(e) => setModality(e.target.value)}
|
||||
>
|
||||
{modalities.map((m) => (
|
||||
<option key={m} value={m}>
|
||||
{businessModalities[m] ?? m}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</Field>
|
||||
{error && <p role="alert">{error}</p>}
|
||||
<button className={button} disabled={busy}>
|
||||
{busy ? "A criar…" : "Criar rascunho privado"}
|
||||
</button>
|
||||
</form>
|
||||
)}
|
||||
{!records.data.length && <p role="status">Não existem negócios nesta lista.</p>}
|
||||
{records.data.map((r) => (
|
||||
<article className={card} key={r.id}>
|
||||
<Link className="font-bold underline" href={`/investidor/negocios/${r.id}`}>
|
||||
{r.payload.title}
|
||||
</Link>
|
||||
<p>
|
||||
{businessModalities[r.modality]} · {businessStates[r.status]} · versão{" "}
|
||||
{r.version_no}
|
||||
</p>
|
||||
</article>
|
||||
))}
|
||||
<nav aria-label="Paginação dos negócios" className="flex gap-4">
|
||||
{records.prev_page_url && <Link href={records.prev_page_url}>Anterior</Link>}
|
||||
{records.next_page_url && <Link href={records.next_page_url}>Seguinte</Link>}
|
||||
</nav>
|
||||
</Frame>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user