This commit is contained in:
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user