This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
import { useRef, useState } from "react";
|
||||
import type { FormEvent } from "react";
|
||||
import { newSubmissionKey } from "@/lib/portal-api";
|
||||
import { Frame, Field, button, card, input } from "./shared";
|
||||
|
||||
type Opportunity = { id: string; slug: string; title: string; sector?: { name: string } | null };
|
||||
type Props = { record: Opportunity; modalities: string[] };
|
||||
type Form = {
|
||||
fullName: string; email: string; phone: string; investorType: string; country: string;
|
||||
sectorInterest: string; modality: string; investmentRange: string; message: string; privacyConsent: boolean; shareWithProponent: boolean;
|
||||
};
|
||||
|
||||
export default function BusinessInterest({ record, modalities }: Props) {
|
||||
const [form, setForm] = useState<Form>({ fullName: "", email: "", phone: "", investorType: "empresa", country: "MZ", sectorInterest: record.sector?.name ?? "", modality: modalities[0] ?? "", investmentRange: "", message: "", privacyConsent: false, shareWithProponent: false });
|
||||
const [busy, setBusy] = useState(false);
|
||||
const [error, setError] = useState("");
|
||||
const [receipt, setReceipt] = useState("");
|
||||
const key = useRef(newSubmissionKey());
|
||||
const update = <K extends keyof Form>(field: K, value: Form[K]) => setForm((current) => ({ ...current, [field]: value }));
|
||||
const submit = async (event: FormEvent<HTMLFormElement>) => {
|
||||
event.preventDefault();
|
||||
if (!form.privacyConsent) { setError("Aceite o tratamento de dados para enviar o pedido."); return; }
|
||||
setBusy(true); setError("");
|
||||
const xsrf = decodeURIComponent(document.cookie.split("; ").find((cookie) => cookie.startsWith("XSRF-TOKEN="))?.slice(11) ?? "");
|
||||
try {
|
||||
const response = await fetch("/api/v1/interest-requests", {
|
||||
method: "POST", credentials: "same-origin",
|
||||
headers: { Accept: "application/json", "Content-Type": "application/json", "X-XSRF-TOKEN": xsrf, "Idempotency-Key": key.current },
|
||||
body: JSON.stringify({ ...form, existingBusinessId: record.id }),
|
||||
});
|
||||
const data = await response.json();
|
||||
if (!response.ok) throw new Error(data.message ?? "Não foi possível enviar a manifestação.");
|
||||
setReceipt(data.data.reference);
|
||||
key.current = newSubmissionKey();
|
||||
} catch (cause) {
|
||||
setError(cause instanceof Error ? cause.message : "Não foi possível enviar a manifestação.");
|
||||
} finally { setBusy(false); }
|
||||
};
|
||||
return (
|
||||
<Frame title="Manifestar interesse">
|
||||
<p>Oportunidade: <strong>{record.title}</strong></p>
|
||||
{receipt ? <section className={card} role="status"><h2 className="text-xl font-bold">Pedido recebido</h2><p>Referência: {receipt}</p><p>A equipa fará a triagem antes de qualquer partilha com o proponente.</p></section> : (
|
||||
<form className={`${card} space-y-4`} onSubmit={submit}>
|
||||
<Field label="Nome ou denominação"><input className={input} required minLength={3} maxLength={150} value={form.fullName} onChange={(e) => update("fullName", e.target.value)} /></Field>
|
||||
<Field label="Email"><input className={input} type="email" required maxLength={150} value={form.email} onChange={(e) => update("email", e.target.value)} /></Field>
|
||||
<Field label="Telefone"><input className={input} type="tel" maxLength={30} value={form.phone} onChange={(e) => update("phone", e.target.value)} /></Field>
|
||||
<Field label="Tipo de investidor"><select className={input} value={form.investorType} onChange={(e) => update("investorType", e.target.value)}><option value="empresa">Empresa</option><option value="individual">Pessoa singular</option><option value="fundo">Fundo</option><option value="entidade_publica">Entidade pública</option><option value="outro">Outro</option></select></Field>
|
||||
<Field label="País"><input className={input} required maxLength={100} value={form.country} onChange={(e) => update("country", e.target.value)} /></Field>
|
||||
<Field label="Sector de interesse"><input className={input} required maxLength={150} value={form.sectorInterest} onChange={(e) => update("sectorInterest", e.target.value)} /></Field>
|
||||
<Field label="Modalidade pretendida"><select className={input} required value={form.modality} onChange={(e) => update("modality", e.target.value)}>{modalities.map((modality) => <option key={modality} value={modality}>{modality.replaceAll("_", " ")}</option>)}</select></Field>
|
||||
<Field label="Intervalo de investimento"><input className={input} maxLength={80} value={form.investmentRange} onChange={(e) => update("investmentRange", e.target.value)} /></Field>
|
||||
<Field label="Motivação e pedido"><textarea className={input} required minLength={20} maxLength={2000} rows={5} value={form.message} onChange={(e) => update("message", e.target.value)} /></Field>
|
||||
<label className="flex items-start gap-3"><input type="checkbox" required checked={form.privacyConsent} onChange={(e) => update("privacyConsent", e.target.checked)} /><span>Autorizo o tratamento destes dados para responder a esta manifestação. O envio não confirma elegibilidade nem permite partilha automática com o proponente.</span></label>
|
||||
<label className="flex items-start gap-3"><input type="checkbox" checked={form.shareWithProponent} onChange={(e) => update("shareWithProponent", e.target.checked)} /><span>Autorizo, se necessário para avaliar esta manifestação, a partilha do meu nome, email, telefone e mensagem com o proponente. Esta autorização é opcional e pode ser retirada junto da equipa.</span></label>
|
||||
{error && <p role="alert">{error}</p>}
|
||||
<button className={button} disabled={busy}>{busy ? "A enviar…" : "Enviar manifestação"}</button>
|
||||
</form>
|
||||
)}
|
||||
</Frame>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
import { Link, router } from "@inertiajs/react";
|
||||
import { useState } from "react";
|
||||
import { Frame, button, card, input } from "./shared";
|
||||
|
||||
type PublicBusiness = {
|
||||
id: string; slug: string; title: string; objective?: string | null; stage?: string | null;
|
||||
amount_min?: string | null; amount_max?: string | null; currency?: string | null;
|
||||
sector?: { name: string; slug: string } | null; province?: string | null;
|
||||
};
|
||||
type Props = { results: { data: PublicBusiness[]; links: { url: string | null; label: string; active: boolean }[] }; filters: { q?: string } };
|
||||
|
||||
export default function BusinessMarketplace({ results, filters }: Props) {
|
||||
const [query, setQuery] = useState(filters.q ?? "");
|
||||
return (
|
||||
<Frame title="Oportunidades de negócio">
|
||||
<p>Explore oportunidades aprovadas para publicação. A informação está sujeita a diligência independente.</p>
|
||||
<form className="flex flex-wrap gap-3" onSubmit={(event) => {
|
||||
event.preventDefault();
|
||||
router.get("/negocios", { q: query || undefined }, { preserveState: true, preserveScroll: true });
|
||||
}}>
|
||||
<label className="sr-only" htmlFor="business-search">Pesquisar negócios</label>
|
||||
<input id="business-search" className={input} value={query} maxLength={120} onChange={(event) => setQuery(event.target.value)} />
|
||||
<button className={button}>Pesquisar</button>
|
||||
</form>
|
||||
{!results.data.length && <p role="status">Não existem oportunidades publicadas com estes critérios.</p>}
|
||||
<ul className="grid gap-4 md:grid-cols-2">
|
||||
{results.data.map((record) => (
|
||||
<li className={card} key={record.id}>
|
||||
<h2 className="text-xl font-bold"><Link className="underline" href={`/negocios/${record.slug}`}>{record.title}</Link></h2>
|
||||
<p>{[record.sector?.name, record.province, record.stage].filter(Boolean).join(" · ")}</p>
|
||||
{(record.amount_min || record.amount_max) && <p>{record.amount_min ?? "—"} – {record.amount_max ?? "—"} {record.currency}</p>}
|
||||
{record.objective && <p className="mt-3 line-clamp-3">{record.objective}</p>}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
<nav aria-label="Paginação das oportunidades" className="flex flex-wrap gap-3">
|
||||
{results.links.map((link) => link.url ? <Link key={link.label} href={link.url} className={link.active ? "font-bold underline" : "underline"} dangerouslySetInnerHTML={{ __html: link.label }} /> : null)}
|
||||
</nav>
|
||||
</Frame>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import { Link } from "@inertiajs/react";
|
||||
import { Frame, button, card } from "./shared";
|
||||
|
||||
type Business = {
|
||||
slug: string; title: string; objective?: string | null; stage?: string | null; activity_code?: string | null;
|
||||
amount_min?: string | null; amount_max?: string | null; available_percentage?: string | null; currency?: string | null;
|
||||
province?: string | null; district?: string | null; locality?: string | null; sector?: { name: string; slug: string } | null;
|
||||
};
|
||||
|
||||
export default function BusinessOpportunity({ record }: { record: Business }) {
|
||||
return (
|
||||
<Frame title={record.title}>
|
||||
<Link href="/negocios" className="underline">Voltar às oportunidades</Link>
|
||||
<section className={`${card} space-y-4`}>
|
||||
<p>{[record.sector?.name, record.stage, record.activity_code].filter(Boolean).join(" · ")}</p>
|
||||
{(record.province || record.district || record.locality) && <p>{[record.locality, record.district, record.province].filter(Boolean).join(", ")}</p>}
|
||||
{(record.amount_min || record.amount_max) && <p>Montante indicativo: {record.amount_min ?? "—"} – {record.amount_max ?? "—"} {record.currency}</p>}
|
||||
{record.available_percentage && <p>Participação indicada: {record.available_percentage}%</p>}
|
||||
{record.objective && <div><h2 className="font-bold">Objectivo</h2><p className="whitespace-pre-wrap">{record.objective}</p></div>}
|
||||
<p className="text-sm">A publicação não constitui garantia de titularidade, avaliação, transmissibilidade ou retorno.</p>
|
||||
<Link className={button} href={`/negocios/${record.slug}/manifestar-interesse`}>Manifestar interesse</Link>
|
||||
</section>
|
||||
</Frame>
|
||||
);
|
||||
}
|
||||
@@ -6,6 +6,21 @@ export type Business = {
|
||||
classification: string;
|
||||
version_no: number;
|
||||
sector_id?: number | null;
|
||||
public_title?: string | null;
|
||||
activity_code?: string | null;
|
||||
stage?: string | null;
|
||||
objective?: string | null;
|
||||
currency?: string | null;
|
||||
amount_min?: string | null;
|
||||
amount_max?: string | null;
|
||||
available_percentage?: string | null;
|
||||
funds_use?: string | null;
|
||||
submitted_at?: string | null;
|
||||
published_at?: string | null;
|
||||
expires_at?: string | null;
|
||||
next_action?: string | null;
|
||||
next_action_due_at?: string | null;
|
||||
assigned_to?: number | null;
|
||||
payload: {
|
||||
[key: string]: string | undefined;
|
||||
title: string;
|
||||
@@ -21,6 +36,17 @@ export const businessStates: Record<string, string> = {
|
||||
in_review: "Em revisão",
|
||||
needs_information: "Pendente de informação",
|
||||
withdrawn: "Retirado",
|
||||
triage: "Triagem",
|
||||
information_pending: "Informação pendente",
|
||||
review: "Em revisão",
|
||||
approval_l1: "Aprovação nível 1",
|
||||
approval_l2: "Aprovação nível 2",
|
||||
approved: "Aprovado",
|
||||
published: "Publicado",
|
||||
suspended: "Suspenso",
|
||||
rejected: "Rejeitado",
|
||||
cancelled: "Cancelado",
|
||||
archived: "Arquivado",
|
||||
};
|
||||
export const businessModalities: Record<string, string> = {
|
||||
company_sale: "Venda da empresa",
|
||||
|
||||
@@ -52,6 +52,7 @@ export default function BusinessWizard({
|
||||
});
|
||||
const [modality, setModality] = useState(record.modality);
|
||||
const [sectorId, setSectorId] = useState(record.sector_id ?? null);
|
||||
const [publicTitle, setPublicTitle] = useState(record.public_title ?? "");
|
||||
const [version, setVersion] = useState(record.version_no);
|
||||
const versionRef = useRef(record.version_no);
|
||||
const saved = useRef(
|
||||
@@ -59,6 +60,7 @@ export default function BusinessWizard({
|
||||
payload: record.payload,
|
||||
modality: record.modality,
|
||||
sectorId: record.sector_id ?? null,
|
||||
publicTitle: record.public_title ?? "",
|
||||
}),
|
||||
);
|
||||
const inFlight = useRef(false);
|
||||
@@ -68,7 +70,7 @@ export default function BusinessWizard({
|
||||
const [confirmation, setConfirmation] = useState("");
|
||||
const heading = useRef<HTMLHeadingElement>(null);
|
||||
const step = Math.max(1, Math.min(8, Number(payload.wizard_step ?? 1)));
|
||||
const serialized = JSON.stringify({ payload, modality, sectorId });
|
||||
const serialized = JSON.stringify({ payload, modality, sectorId, publicTitle });
|
||||
const dirty = serialized !== saved.current;
|
||||
const save = useCallback(async () => {
|
||||
if (inFlight.current) return false;
|
||||
@@ -82,6 +84,7 @@ export default function BusinessWizard({
|
||||
payload,
|
||||
modality,
|
||||
sector_id: sectorId,
|
||||
public_title: publicTitle || null,
|
||||
classification: record.classification,
|
||||
reason: "Gravação do formulário privado por etapas",
|
||||
version_no: versionRef.current,
|
||||
@@ -97,7 +100,7 @@ export default function BusinessWizard({
|
||||
inFlight.current = false;
|
||||
setBusy(false);
|
||||
}
|
||||
}, [serialized, payload, modality, sectorId, record.id, record.classification]);
|
||||
}, [serialized, payload, modality, sectorId, publicTitle, record.id, record.classification]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!dirty || busy || error) return;
|
||||
@@ -201,6 +204,20 @@ export default function BusinessWizard({
|
||||
>
|
||||
<fieldset className="space-y-4">
|
||||
<legend className="sr-only">{steps[step - 1][english ? 1 : 0]}</legend>
|
||||
{step === 3 && (
|
||||
<Field label={t("Título público proposto", "Proposed public title")}>
|
||||
<input
|
||||
className={input}
|
||||
value={publicTitle}
|
||||
maxLength={180}
|
||||
onChange={(event) => setPublicTitle(event.target.value)}
|
||||
aria-describedby="public-title-help"
|
||||
/>
|
||||
<span id="public-title-help" className="text-sm">
|
||||
{t("Será revisto antes de qualquer publicação.", "Reviewed before any publication.")}
|
||||
</span>
|
||||
</Field>
|
||||
)}
|
||||
{step === 3 && (
|
||||
<Field label={t("Sector", "Sector")}>
|
||||
<select
|
||||
@@ -294,6 +311,10 @@ export default function BusinessWizard({
|
||||
)}
|
||||
{step === 8 && (
|
||||
<dl className="space-y-3 break-words">
|
||||
<div>
|
||||
<dt className="font-semibold">{t("Título público proposto", "Proposed public title")}</dt>
|
||||
<dd>{publicTitle || "—"}</dd>
|
||||
</div>
|
||||
{Object.entries(formSchema).map(([key, field]) => (
|
||||
<div key={key}>
|
||||
<dt className="font-semibold">
|
||||
|
||||
@@ -17,6 +17,10 @@ type Props = {
|
||||
canEdit: boolean;
|
||||
owner: boolean;
|
||||
canReview: boolean;
|
||||
canTriage: boolean;
|
||||
canApproveLevelOne: boolean;
|
||||
canApproveLevelTwo: boolean;
|
||||
canPublish: boolean;
|
||||
modalities: string[];
|
||||
objects: BusinessObject[];
|
||||
objectKinds: string[];
|
||||
@@ -34,6 +38,10 @@ function Editor({
|
||||
canEdit,
|
||||
owner,
|
||||
canReview,
|
||||
canTriage,
|
||||
canApproveLevelOne,
|
||||
canApproveLevelTwo,
|
||||
canPublish,
|
||||
modalities,
|
||||
history,
|
||||
objects,
|
||||
@@ -235,6 +243,51 @@ function Editor({
|
||||
Pedir informação
|
||||
</button>
|
||||
)}
|
||||
{canTriage && record.status === "submitted" && (
|
||||
<button className={button} disabled={busy || note.trim().length < 10} onClick={() => void run("triage")}>
|
||||
Iniciar triagem
|
||||
</button>
|
||||
)}
|
||||
{canReview && record.status === "triage" && (
|
||||
<button className={button} disabled={busy || note.trim().length < 10} onClick={() => void run("in_review")}>
|
||||
Encaminhar para revisão
|
||||
</button>
|
||||
)}
|
||||
{canReview && record.status === "in_review" && (
|
||||
<>
|
||||
<button className={button} disabled={busy || note.trim().length < 10} onClick={() => void run("approval_l1")}>
|
||||
Enviar para aprovação nÃvel 1
|
||||
</button>
|
||||
<button className={button} disabled={busy || note.trim().length < 10} onClick={() => void run("rejected")}>
|
||||
Rejeitar
|
||||
</button>
|
||||
</>
|
||||
)}
|
||||
{canApproveLevelOne && record.status === "approval_l1" && (
|
||||
<>
|
||||
<button className={button} disabled={busy || note.trim().length < 10} onClick={() => void run("approval_l2")}>
|
||||
Aprovar nÃvel 1 e enviar ao nÃvel 2
|
||||
</button>
|
||||
<button className={button} disabled={busy || note.trim().length < 10} onClick={() => void run("rejected")}>
|
||||
Rejeitar
|
||||
</button>
|
||||
</>
|
||||
)}
|
||||
{canApproveLevelTwo && record.status === "approval_l2" && (
|
||||
<>
|
||||
<button className={button} disabled={busy || note.trim().length < 10} onClick={() => void run("approved")}>
|
||||
Aprovar nÃvel 2
|
||||
</button>
|
||||
<button className={button} disabled={busy || note.trim().length < 10} onClick={() => void run("rejected")}>
|
||||
Rejeitar
|
||||
</button>
|
||||
</>
|
||||
)}
|
||||
{canPublish && record.status === "approved" && (
|
||||
<button className={button} disabled={busy || note.trim().length < 10} onClick={() => void run("published")}>
|
||||
Publicar
|
||||
</button>
|
||||
)}
|
||||
{owner && record.status !== "withdrawn" && (
|
||||
<button
|
||||
className={button}
|
||||
|
||||
@@ -311,7 +311,7 @@ export default function Catalogue({
|
||||
index={index}
|
||||
parent={territoryPath[index - 1]?.id ?? ""}
|
||||
selected={territoryPath[index]}
|
||||
endpoint="/api/v1/investment/territory-options"
|
||||
endpoint="/api/v1/catalogs/jurisdictions"
|
||||
onChange={(value) => {
|
||||
const path = [
|
||||
...territoryPath.slice(0, index),
|
||||
|
||||
@@ -14,6 +14,11 @@ type Interest = {
|
||||
investment_range: string | null;
|
||||
message: string;
|
||||
status: string;
|
||||
existing_business_id: string | null;
|
||||
modality: string | null;
|
||||
assigned_to: number | null;
|
||||
next_action: string | null;
|
||||
next_action_due_at: string | null;
|
||||
consented_at: string | null;
|
||||
reviewed_at: string | null;
|
||||
reviewed_by: number | null;
|
||||
@@ -34,8 +39,13 @@ function dateTime(value: string | null) {
|
||||
timeZone: "Africa/Maputo",
|
||||
}).format(new Date(value));
|
||||
}
|
||||
export default function InterestDetail({ interest }: { interest: Interest }) {
|
||||
const form = useForm({ status: interest.status });
|
||||
type Transition = { from_status: string | null; to_status: string; actor_id: number | null; note: string | null; created_at: string };
|
||||
type Assignee = { id: number; name: string };
|
||||
type Consent = { purpose: string; policy_version: string | null; status: string; granted_at: string | null; withdrawn_at: string | null };
|
||||
|
||||
export default function InterestDetail({ interest, history = [], assignees = [], consents = [] }: { interest: Interest; history?: Transition[]; assignees?: Assignee[]; consents?: Consent[] }) {
|
||||
const form = useForm({ status: interest.status, note: "", next_action: interest.next_action ?? "", next_action_due_at: interest.next_action_due_at?.slice(0, 10) ?? "", assigned_to: interest.assigned_to?.toString() ?? "" });
|
||||
const consentForm = useForm({ reason: "" });
|
||||
const rows: [string, string | number | null][] = [
|
||||
["Nome", interest.full_name],
|
||||
["Email", interest.email],
|
||||
@@ -44,6 +54,8 @@ export default function InterestDetail({ interest }: { interest: Interest }) {
|
||||
["País", interest.country],
|
||||
["Sector", interest.sector_interest],
|
||||
["Oportunidade", interest.opportunity_reference],
|
||||
["Negócio publicado", interest.existing_business_id],
|
||||
["Modalidade", interest.modality],
|
||||
["Faixa de investimento", interest.investment_range],
|
||||
["Recebido em (Maputo)", dateTime(interest.created_at)],
|
||||
["Consentimento em (Maputo)", dateTime(interest.consented_at)],
|
||||
@@ -90,6 +102,27 @@ export default function InterestDetail({ interest }: { interest: Interest }) {
|
||||
<h2 className="font-semibold">Mensagem</h2>
|
||||
<p className="mt-2 break-words whitespace-pre-wrap">{interest.message}</p>
|
||||
</section>
|
||||
<section className="space-y-3">
|
||||
<h2 className="font-semibold">Consentimentos e versões</h2>
|
||||
{consents.map((consent, index) => (
|
||||
<article key={`${consent.purpose}-${index}`} className="rounded border p-3">
|
||||
<p>{consent.purpose}: {consent.status}</p>
|
||||
<p className="text-sm">Política {consent.policy_version ?? "—"} · concedido {dateTime(consent.granted_at)}</p>
|
||||
{consent.withdrawn_at && <p className="text-sm">Revogado {dateTime(consent.withdrawn_at)}</p>}
|
||||
</article>
|
||||
))}
|
||||
{consents.some((consent) => consent.purpose === "share_contact_with_proponent" && consent.status === "granted") && (
|
||||
<form className="max-w-sm space-y-3" onSubmit={(event) => {
|
||||
event.preventDefault();
|
||||
consentForm.patch(`/management/interests/${interest.id}/consent/proponent`);
|
||||
}}>
|
||||
<Field label="Motivo do pedido de revogação" error={consentForm.errors.reason}>
|
||||
<textarea className={control} minLength={10} maxLength={2000} required rows={3} value={consentForm.data.reason} onChange={(event) => consentForm.setData("reason", event.target.value)} />
|
||||
</Field>
|
||||
<button className={button} disabled={consentForm.processing}>Revogar autorização de partilha</button>
|
||||
</form>
|
||||
)}
|
||||
</section>
|
||||
<form
|
||||
className="max-w-sm space-y-4"
|
||||
onSubmit={(e) => {
|
||||
@@ -103,17 +136,42 @@ export default function InterestDetail({ interest }: { interest: Interest }) {
|
||||
value={form.data.status}
|
||||
onChange={(e) => form.setData("status", e.target.value)}
|
||||
>
|
||||
{["received", "in_review", "contacted", "closed"].map((key) => (
|
||||
{["received", "submitted", "in_review", "reviewed", "qualification", "qualified", "contacted", "contact_accepted", "referred", "due_diligence", "negotiation", "pending", "refused", "converted", "cancelled", "closed"].map((key) => (
|
||||
<option key={key} value={key}>
|
||||
{states[key]}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</Field>
|
||||
<Field label="Nota de acompanhamento" error={form.errors.note}>
|
||||
<textarea className={control} rows={3} value={form.data.note} onChange={(e) => form.setData("note", e.target.value)} />
|
||||
</Field>
|
||||
<Field label="Próxima acção" error={form.errors.next_action}>
|
||||
<input className={control} value={form.data.next_action} onChange={(e) => form.setData("next_action", e.target.value)} />
|
||||
</Field>
|
||||
<Field label="Prazo da próxima acção" error={form.errors.next_action_due_at}>
|
||||
<input type="date" className={control} value={form.data.next_action_due_at} onChange={(e) => form.setData("next_action_due_at", e.target.value)} />
|
||||
</Field>
|
||||
<Field label="Responsável" error={form.errors.assigned_to}>
|
||||
<select className={control} value={form.data.assigned_to} onChange={(e) => form.setData("assigned_to", e.target.value)}>
|
||||
<option value="">Sem responsável</option>
|
||||
{assignees.map((assignee) => <option key={assignee.id} value={assignee.id}>{assignee.name}</option>)}
|
||||
</select>
|
||||
</Field>
|
||||
<button className={button} disabled={form.processing}>
|
||||
{form.processing ? "A guardar…" : "Guardar estado"}
|
||||
</button>
|
||||
</form>
|
||||
<section className="space-y-3">
|
||||
<h2 className="font-semibold">Histórico do fluxo</h2>
|
||||
{!history.length && <p>Sem alterações de estado registadas.</p>}
|
||||
{history.map((entry, index) => (
|
||||
<article key={`${entry.created_at}-${index}`} className="rounded border p-3">
|
||||
<p>{entry.from_status ? `${states[entry.from_status] ?? entry.from_status} → ` : ""}{states[entry.to_status] ?? entry.to_status} · {dateTime(entry.created_at)}</p>
|
||||
{entry.note && <p className="mt-1 whitespace-pre-wrap">{entry.note}</p>}
|
||||
</article>
|
||||
))}
|
||||
</section>
|
||||
</Management>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -9,6 +9,11 @@ type Interest = {
|
||||
full_name: string;
|
||||
email: string;
|
||||
sector_interest: string;
|
||||
existing_business_id: string | null;
|
||||
modality: string | null;
|
||||
assignee: { id: number; name: string } | null;
|
||||
next_action: string | null;
|
||||
next_action_due_at: string | null;
|
||||
status: string;
|
||||
};
|
||||
export default function Interests({
|
||||
@@ -16,17 +21,18 @@ export default function Interests({
|
||||
filters,
|
||||
}: {
|
||||
requests: Paginated<Interest>;
|
||||
filters: { q?: string; status?: string };
|
||||
filters: { q?: string; status?: string; follow_up?: string };
|
||||
}) {
|
||||
const [q, setQ] = useState(filters.q ?? '');
|
||||
const [status, setStatus] = useState(filters.status ?? '');
|
||||
const [followUp, setFollowUp] = useState(filters.follow_up ?? '');
|
||||
return (
|
||||
<Management title="Manifestações de interesse">
|
||||
<form
|
||||
className="flex flex-wrap gap-3"
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
router.get('/management/interests', { q, status });
|
||||
router.get('/management/interests', { q, status, follow_up: followUp });
|
||||
}}
|
||||
>
|
||||
<input
|
||||
@@ -43,7 +49,7 @@ export default function Interests({
|
||||
onChange={(e) => setStatus(e.target.value)}
|
||||
>
|
||||
<option value="">Todos os estados</option>
|
||||
{['received', 'in_review', 'contacted', 'closed'].map(
|
||||
{Object.keys(states).filter((key) => ['received', 'submitted', 'in_review', 'reviewed', 'qualification', 'qualified', 'contacted', 'contact_accepted', 'referred', 'due_diligence', 'negotiation', 'pending', 'refused', 'converted', 'cancelled', 'closed'].includes(key)).map(
|
||||
(key) => (
|
||||
<option key={key} value={key}>
|
||||
{states[key]}
|
||||
@@ -51,6 +57,12 @@ export default function Interests({
|
||||
),
|
||||
)}
|
||||
</select>
|
||||
<select aria-label="Acompanhamento" className={`${control} max-w-xs`} value={followUp} onChange={(e) => setFollowUp(e.target.value)}>
|
||||
<option value="">Todos os acompanhamentos</option>
|
||||
<option value="overdue">Acções atrasadas</option>
|
||||
<option value="upcoming">Acções por vencer</option>
|
||||
<option value="unassigned">Sem responsável</option>
|
||||
</select>
|
||||
<button className={button}>Pesquisar</button>
|
||||
</form>
|
||||
<div className="overflow-x-auto">
|
||||
@@ -62,6 +74,10 @@ export default function Interests({
|
||||
'Nome',
|
||||
'Email',
|
||||
'Sector',
|
||||
'Modalidade',
|
||||
'Responsável',
|
||||
'Próxima acção',
|
||||
'Prazo',
|
||||
'Estado',
|
||||
].map((label) => (
|
||||
<th key={label} className="border-b p-3">
|
||||
@@ -88,6 +104,14 @@ export default function Interests({
|
||||
<td className="border-b p-3">
|
||||
{item.sector_interest}
|
||||
</td>
|
||||
<td className="border-b p-3">
|
||||
{item.modality ?? (item.existing_business_id ? 'Negócio' : '—')}
|
||||
</td>
|
||||
<td className="border-b p-3">{item.assignee?.name ?? '—'}</td>
|
||||
<td className="border-b p-3">{item.next_action ?? '—'}</td>
|
||||
<td className={`border-b p-3 ${item.next_action_due_at && new Date(item.next_action_due_at) < new Date() ? 'font-semibold text-red-700' : ''}`}>
|
||||
{item.next_action_due_at ? `${new Date(item.next_action_due_at) < new Date() ? 'Atrasada · ' : ''}${new Intl.DateTimeFormat('pt-MZ', { dateStyle: 'medium', timeZone: 'Africa/Maputo' }).format(new Date(item.next_action_due_at))}` : '—'}
|
||||
</td>
|
||||
<td className="border-b p-3">
|
||||
{states[item.status] ?? item.status}
|
||||
</td>
|
||||
|
||||
@@ -15,8 +15,20 @@ export const button =
|
||||
"inline-flex items-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground disabled:opacity-50";
|
||||
export const states: Record<string, string> = {
|
||||
received: "Recebido",
|
||||
submitted: "Submetido",
|
||||
in_review: "Em análise",
|
||||
contacted: "Contactado",
|
||||
reviewed: "Revisto",
|
||||
qualification: "Em qualificação",
|
||||
qualified: "Qualificado",
|
||||
contact_accepted: "Contacto aceite",
|
||||
referred: "Encaminhado",
|
||||
due_diligence: "Diligência devida",
|
||||
negotiation: "Em negociação",
|
||||
pending: "Pendente",
|
||||
refused: "Recusado",
|
||||
converted: "Convertido",
|
||||
cancelled: "Cancelado",
|
||||
closed: "Encerrado",
|
||||
draft: "Rascunho",
|
||||
published: "Publicado",
|
||||
|
||||
@@ -3,6 +3,7 @@ import { useState } from "react";
|
||||
import { PortalMenu } from "@/layouts/portal-navigation";
|
||||
import { newSubmissionKey } from "@/lib/portal-api";
|
||||
import { ProvinceSelect } from "@/components/investment-territory";
|
||||
import { SimulationForm } from "@/components/simulation-form";
|
||||
|
||||
const input = "w-full rounded-lg border border-slate-300 bg-white p-3 text-slate-900";
|
||||
const button =
|
||||
@@ -293,105 +294,7 @@ function PartnershipForm() {
|
||||
}
|
||||
|
||||
function Simulator() {
|
||||
const [base, setBase] = useState("");
|
||||
const [rate, setRate] = useState("");
|
||||
const [reduction, setReduction] = useState("0");
|
||||
const [currency, setCurrency] = useState("MZN");
|
||||
const valid =
|
||||
base !== "" &&
|
||||
rate !== "" &&
|
||||
reduction !== "" &&
|
||||
Number.isFinite(Number(base)) &&
|
||||
Number(base) >= 0 &&
|
||||
Number(base) <= 1e12 &&
|
||||
Number(rate) >= 0 &&
|
||||
Number(rate) <= 100 &&
|
||||
Number(reduction) >= 0 &&
|
||||
Number(reduction) <= 100;
|
||||
const gross = (Number(base) * Number(rate)) / 100;
|
||||
const net = gross * (1 - Number(reduction) / 100);
|
||||
const format = (n: number) =>
|
||||
new Intl.NumberFormat("pt-MZ", { style: "currency", currency }).format(n);
|
||||
return (
|
||||
<section className="max-w-2xl space-y-5 rounded-xl border bg-white p-6">
|
||||
<h2 className="text-xl font-bold">Cenário com parâmetros próprios</h2>
|
||||
<p>
|
||||
Introduza uma base tributável e uma taxa que pretende comparar. Não existem taxas
|
||||
legais ou incentivos automáticos neste cálculo; a redução é uma hipótese introduzida
|
||||
por si.
|
||||
</p>
|
||||
<label className="block">
|
||||
Moeda
|
||||
<select
|
||||
className={input}
|
||||
value={currency}
|
||||
onChange={(e) => setCurrency(e.target.value)}
|
||||
>
|
||||
{["MZN", "USD", "EUR", "ZAR"].map((c) => (
|
||||
<option key={c}>{c}</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
<label className="block">
|
||||
Base tributável
|
||||
<input
|
||||
className={input}
|
||||
type="number"
|
||||
min="0"
|
||||
max="1000000000000"
|
||||
step="0.01"
|
||||
value={base}
|
||||
onChange={(e) => setBase(e.target.value)}
|
||||
/>
|
||||
</label>
|
||||
<label className="block">
|
||||
Taxa a simular (%)
|
||||
<input
|
||||
className={input}
|
||||
type="number"
|
||||
min="0"
|
||||
max="100"
|
||||
step="0.01"
|
||||
value={rate}
|
||||
onChange={(e) => setRate(e.target.value)}
|
||||
/>
|
||||
</label>
|
||||
<label className="block">
|
||||
Redução hipotética do imposto (%)
|
||||
<input
|
||||
className={input}
|
||||
type="number"
|
||||
min="0"
|
||||
max="100"
|
||||
step="0.01"
|
||||
value={reduction}
|
||||
onChange={(e) => setReduction(e.target.value)}
|
||||
/>
|
||||
</label>
|
||||
<div role="status" className="rounded bg-emerald-50 p-5">
|
||||
{valid ? (
|
||||
<>
|
||||
<p>
|
||||
Sem redução: <strong>{format(gross)}</strong>
|
||||
</p>
|
||||
<p>Redução simulada: {format(gross - net)}</p>
|
||||
<p>
|
||||
Total do cenário: <strong>{format(net)}</strong>
|
||||
</p>
|
||||
<p className="mt-3 text-sm">
|
||||
Base × taxa ÷ 100 × (1 − redução ÷ 100). Não inclui outros impostos,
|
||||
deduções, escalões ou regras sectoriais.
|
||||
</p>
|
||||
</>
|
||||
) : (
|
||||
<p>Preencha a base e uma taxa válida entre 0 e 100%.</p>
|
||||
)}
|
||||
</div>
|
||||
<Link href="/apoio" className="underline">
|
||||
Pedir esclarecimento sobre o enquadramento aplicável
|
||||
</Link>
|
||||
</section>
|
||||
);
|
||||
return <SimulationForm />;
|
||||
}
|
||||
|
||||
export default function Services(p: Props) {
|
||||
|
||||
Reference in New Issue
Block a user