@@ -0,0 +1,626 @@
|
||||
import { Link, useForm, usePage } from '@inertiajs/react';
|
||||
import { Frame, card, input, button } from '@/pages/investment/shared';
|
||||
import {
|
||||
InvestorGuidance,
|
||||
type Guidance,
|
||||
} from '@/components/investor-guidance';
|
||||
import {
|
||||
DocumentReview,
|
||||
type DeskDocument,
|
||||
} from '@/components/desk-internal-operations';
|
||||
|
||||
type Stage = {
|
||||
title: string;
|
||||
requirements: string;
|
||||
status: string;
|
||||
entity: string;
|
||||
dependencies: string[];
|
||||
evidence: string | null;
|
||||
};
|
||||
|
||||
function LinkReview({
|
||||
link,
|
||||
}: {
|
||||
link: { id: string; version: number; url: string; contact: string | null };
|
||||
}) {
|
||||
const form = useForm({
|
||||
version: link.version,
|
||||
available: false,
|
||||
evidence: '',
|
||||
contact: link.contact ?? '',
|
||||
});
|
||||
return (
|
||||
<form
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
form.post(`/management/balcao/ligacoes/${link.id}/conferencia`);
|
||||
}}
|
||||
className="space-y-2 border p-3"
|
||||
>
|
||||
<p>
|
||||
Conferência manual de disponibilidade: {link.url}. Não envia
|
||||
dados do dossier nem integra sistemas externos.
|
||||
</p>
|
||||
<label className="flex gap-2">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={form.data.available}
|
||||
onChange={(e) =>
|
||||
form.setData('available', e.target.checked)
|
||||
}
|
||||
/>
|
||||
Verifiquei que a ligação está disponível
|
||||
</label>
|
||||
<label>
|
||||
Evidência e data da consulta
|
||||
<textarea
|
||||
className={input}
|
||||
required
|
||||
minLength={10}
|
||||
value={form.data.evidence}
|
||||
onChange={(e) => form.setData('evidence', e.target.value)}
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
Contacto alternativo com fonte
|
||||
<input
|
||||
className={input}
|
||||
value={form.data.contact}
|
||||
onChange={(e) => form.setData('contact', e.target.value)}
|
||||
/>
|
||||
</label>
|
||||
<button className={button} disabled={form.processing}>
|
||||
Registar a minha conferência da ligação
|
||||
</button>
|
||||
{Object.entries(form.errors).map(([key, value]) => (
|
||||
<p key={key} role="alert">
|
||||
{value}
|
||||
</p>
|
||||
))}
|
||||
</form>
|
||||
);
|
||||
}
|
||||
type Event = {
|
||||
id: string;
|
||||
action: string;
|
||||
name: string;
|
||||
created_at: string;
|
||||
payload: Record<string, unknown>;
|
||||
};
|
||||
export default function Case({
|
||||
case: dossier,
|
||||
canWrite,
|
||||
manager,
|
||||
requests,
|
||||
services,
|
||||
documents,
|
||||
workflow,
|
||||
stepStates,
|
||||
states,
|
||||
guidance,
|
||||
events,
|
||||
links,
|
||||
legacyRequest,
|
||||
}: {
|
||||
case: {
|
||||
id: string;
|
||||
title: string;
|
||||
version: number;
|
||||
workflow: Record<string, Stage>;
|
||||
investor_id?: string;
|
||||
project_id?: string;
|
||||
journey_id?: string;
|
||||
};
|
||||
canWrite: boolean;
|
||||
manager: boolean;
|
||||
requests: { id: string; status: string; protocol: string | null }[];
|
||||
services: { id: string; title: string; version: number }[];
|
||||
documents: DeskDocument[];
|
||||
links: {
|
||||
id: string;
|
||||
entity: string;
|
||||
purpose: string;
|
||||
contact: string | null;
|
||||
status: string;
|
||||
verified_at: string | null;
|
||||
version: number;
|
||||
url: string;
|
||||
monitor: { available: boolean; reason: string; contact: string };
|
||||
}[];
|
||||
legacyRequest: {
|
||||
id: number;
|
||||
reference: string;
|
||||
status: string;
|
||||
next_action: string | null;
|
||||
next_action_due_at: string | null;
|
||||
responsible_name: string | null;
|
||||
} | null;
|
||||
workflow?: Record<string, Stage>;
|
||||
stepStates: Record<string, string>;
|
||||
states: Record<string, string>;
|
||||
guidance: Guidance | null;
|
||||
events: Event[];
|
||||
}) {
|
||||
const actor = usePage<{ auth: { user: { id: number } } }>().props.auth.user;
|
||||
const requestForm = useForm({
|
||||
service_version_id: services[0]?.id ?? '',
|
||||
client_key: crypto.randomUUID(),
|
||||
});
|
||||
const stageForm = useForm({
|
||||
version: dossier.version,
|
||||
stage: 'E0',
|
||||
status: 'preparing',
|
||||
reason: '',
|
||||
evidence: '',
|
||||
document_id: '',
|
||||
valid_until: '',
|
||||
exception: false,
|
||||
});
|
||||
const upload = useForm<{
|
||||
version: number;
|
||||
file: File | null;
|
||||
document_id: string;
|
||||
category: string;
|
||||
source_reference: string;
|
||||
consent: boolean;
|
||||
}>({
|
||||
version: dossier.version,
|
||||
file: null,
|
||||
document_id: '',
|
||||
category: 'project_evidence',
|
||||
source_reference: '',
|
||||
consent: false,
|
||||
});
|
||||
return (
|
||||
<Frame title={dossier.title}>
|
||||
{legacyRequest && (
|
||||
<section className={card}>
|
||||
<h2 className="text-xl font-bold">
|
||||
Pedido anterior associado — sem nova submissão
|
||||
</h2>
|
||||
<p>
|
||||
{legacyRequest.reference} · {legacyRequest.status} ·
|
||||
Responsável:{' '}
|
||||
{legacyRequest.responsible_name ?? 'Por atribuir'}
|
||||
</p>
|
||||
<p>
|
||||
{legacyRequest.next_action ??
|
||||
'A aguardar orientação do responsável'}{' '}
|
||||
· Prazo interno:{' '}
|
||||
{legacyRequest.next_action_due_at ?? 'Não definido'}
|
||||
</p>
|
||||
{manager && (
|
||||
<Link
|
||||
href={`/management/interests/${legacyRequest.id}`}
|
||||
className="underline"
|
||||
>
|
||||
Continuar no registo original do pedido e CRM
|
||||
</Link>
|
||||
)}
|
||||
</section>
|
||||
)}
|
||||
<Link href="/balcao-virtual/painel" className="underline">
|
||||
Voltar ao Balcão Virtual
|
||||
</Link>
|
||||
<p>
|
||||
Um dossier, os mesmos pedidos, documentos, conversas e tarefas.
|
||||
Projecto existente:{' '}
|
||||
{dossier.project_id ? 'associado' : 'ainda não associado'} ·
|
||||
Investidor:{' '}
|
||||
{dossier.investor_id
|
||||
? 'conta existente associada'
|
||||
: 'por associar'}
|
||||
.
|
||||
</p>
|
||||
{guidance ? (
|
||||
<InvestorGuidance
|
||||
caseId={dossier.id}
|
||||
guidance={guidance}
|
||||
manager={manager}
|
||||
actorId={actor.id}
|
||||
requests={requests}
|
||||
/>
|
||||
) : (
|
||||
<p>A extensão de orientação aguarda instalação autenticada.</p>
|
||||
)}
|
||||
<section className="space-y-3">
|
||||
<h2 className="text-2xl font-bold">
|
||||
Pedido de apoio no fluxo existente
|
||||
</h2>
|
||||
<p>
|
||||
A recomendação ajuda a preparar. Só a sua submissão cria um
|
||||
pedido recebido; a resposta é assinada pelo responsável.
|
||||
</p>
|
||||
{requests.map((r) => (
|
||||
<Link
|
||||
key={r.id}
|
||||
className={card + ' block'}
|
||||
href={`/balcao-virtual/pedidos/${r.id}`}
|
||||
>
|
||||
{r.protocol ?? 'Continuar rascunho de apoio'} —{' '}
|
||||
{states[r.status]}
|
||||
</Link>
|
||||
))}
|
||||
{canWrite && (
|
||||
<form
|
||||
className={card + ' space-y-3'}
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
requestForm.post(
|
||||
`/balcao-virtual/dossiers/${dossier.id}/pedidos`,
|
||||
);
|
||||
}}
|
||||
>
|
||||
<label>
|
||||
Serviço publicado
|
||||
<select
|
||||
className={input}
|
||||
required
|
||||
value={requestForm.data.service_version_id}
|
||||
onChange={(e) =>
|
||||
requestForm.setData(
|
||||
'service_version_id',
|
||||
e.target.value,
|
||||
)
|
||||
}
|
||||
>
|
||||
<option value="">Seleccione</option>
|
||||
{services.map((s) => (
|
||||
<option key={s.id} value={s.id}>
|
||||
{s.title} — v{s.version}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
<button
|
||||
className={button}
|
||||
disabled={
|
||||
requestForm.processing || !services.length
|
||||
}
|
||||
>
|
||||
Preparar rascunho de pedido
|
||||
</button>
|
||||
{!services.length && (
|
||||
<p>
|
||||
Sem serviços publicados. A orientação e os
|
||||
dossiers continuam disponíveis.
|
||||
</p>
|
||||
)}
|
||||
{Object.entries(requestForm.errors).map(([k, v]) => (
|
||||
<p key={k} role="alert">
|
||||
{v}
|
||||
</p>
|
||||
))}
|
||||
</form>
|
||||
)}
|
||||
</section>
|
||||
<section className="space-y-3">
|
||||
<h2 className="text-2xl font-bold">
|
||||
Etapas documentais do Balcão
|
||||
</h2>
|
||||
<p>
|
||||
Estes estados descrevem preparação e conferência no portal.
|
||||
A conclusão interna não significa que uma instituição emitiu
|
||||
aprovação, registo ou licença. Os requisitos do plano são
|
||||
afirmações da fonte; a aplicabilidade deve ser documentada
|
||||
no ato específico.
|
||||
</p>
|
||||
{Object.entries(workflow ?? dossier.workflow).map(
|
||||
([code, s]) => (
|
||||
<article className={card} key={code}>
|
||||
<h3 className="font-bold">
|
||||
{code} — {s.title}
|
||||
</h3>
|
||||
<p>
|
||||
{stepStates[s.status]} · Entidade: {s.entity}
|
||||
</p>
|
||||
<p>{s.requirements}</p>
|
||||
<p>
|
||||
Dependências:{' '}
|
||||
{s.dependencies.join(', ') ||
|
||||
'Nenhuma nesta etapa'}{' '}
|
||||
· Evidência: {s.evidence ?? 'Por documentar'}
|
||||
</p>
|
||||
</article>
|
||||
),
|
||||
)}
|
||||
{(canWrite || manager) && (
|
||||
<form
|
||||
className={card + ' space-y-3'}
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
stageForm.setData('version', dossier.version);
|
||||
stageForm.transform((d) => ({
|
||||
...d,
|
||||
version: dossier.version,
|
||||
}));
|
||||
stageForm.post(
|
||||
`/balcao-virtual/dossiers/${dossier.id}/etapas`,
|
||||
);
|
||||
}}
|
||||
>
|
||||
<label>
|
||||
Etapa
|
||||
<select
|
||||
className={input}
|
||||
value={stageForm.data.stage}
|
||||
onChange={(e) =>
|
||||
stageForm.setData('stage', e.target.value)
|
||||
}
|
||||
>
|
||||
{Object.entries(dossier.workflow).map(
|
||||
([c, s]) => (
|
||||
<option key={c} value={c}>
|
||||
{c} — {s.title}
|
||||
</option>
|
||||
),
|
||||
)}
|
||||
</select>
|
||||
</label>
|
||||
<label>
|
||||
Estado
|
||||
<select
|
||||
className={input}
|
||||
value={stageForm.data.status}
|
||||
onChange={(e) =>
|
||||
stageForm.setData('status', e.target.value)
|
||||
}
|
||||
>
|
||||
{Object.entries(stepStates)
|
||||
.filter(
|
||||
([s]) =>
|
||||
manager ||
|
||||
![
|
||||
'completed',
|
||||
'not_applicable',
|
||||
].includes(s),
|
||||
)
|
||||
.map(([s, label]) => (
|
||||
<option key={s} value={s}>
|
||||
{label}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
<label>
|
||||
Motivo
|
||||
<textarea
|
||||
className={input}
|
||||
required
|
||||
minLength={3}
|
||||
value={stageForm.data.reason}
|
||||
onChange={(e) =>
|
||||
stageForm.setData('reason', e.target.value)
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
Evidência / referência
|
||||
<input
|
||||
className={input}
|
||||
value={stageForm.data.evidence}
|
||||
onChange={(e) =>
|
||||
stageForm.setData(
|
||||
'evidence',
|
||||
e.target.value,
|
||||
)
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
Identificador do documento de suporte
|
||||
<input
|
||||
className={input}
|
||||
value={stageForm.data.document_id}
|
||||
onChange={(e) =>
|
||||
stageForm.setData(
|
||||
'document_id',
|
||||
e.target.value,
|
||||
)
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
<p>
|
||||
Conclusão e não aplicabilidade exigem revisão por
|
||||
outra pessoa autorizada e evidência documental.
|
||||
</p>
|
||||
<button
|
||||
className={button}
|
||||
disabled={stageForm.processing}
|
||||
>
|
||||
Registar etapa
|
||||
</button>
|
||||
{Object.entries(stageForm.errors).map(([k, v]) => (
|
||||
<p key={k} role="alert">
|
||||
{v}
|
||||
</p>
|
||||
))}
|
||||
</form>
|
||||
)}
|
||||
</section>
|
||||
<section className="space-y-3">
|
||||
<h2 className="text-2xl font-bold">
|
||||
Documentos privados reutilizados
|
||||
</h2>
|
||||
{documents.map((d) => (
|
||||
<article key={d.id} className={card}>
|
||||
<p>
|
||||
{d.file_name} · {d.category} ·{' '}
|
||||
{d.malware_scan_status}
|
||||
</p>
|
||||
<p>{d.source_reference}</p>
|
||||
{d.status === 'active' &&
|
||||
d.malware_scan_status === 'clean' && (
|
||||
<a
|
||||
className="underline"
|
||||
href={`/balcao-virtual/dossiers/${dossier.id}/documentos/${d.id}`}
|
||||
>
|
||||
Descarregar com verificação de autorização e
|
||||
hash
|
||||
</a>
|
||||
)}
|
||||
</article>
|
||||
))}
|
||||
{canWrite && (
|
||||
<form
|
||||
className={card + ' space-y-3'}
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
upload.transform((d) => ({
|
||||
...d,
|
||||
version: dossier.version,
|
||||
}));
|
||||
upload.post(
|
||||
`/balcao-virtual/dossiers/${dossier.id}/documentos`,
|
||||
);
|
||||
}}
|
||||
>
|
||||
<label>
|
||||
Ficheiro privado
|
||||
<input
|
||||
className={input}
|
||||
type="file"
|
||||
accept=".pdf,.png,.jpg,.jpeg,.txt"
|
||||
onChange={(e) =>
|
||||
upload.setData(
|
||||
'file',
|
||||
e.target.files?.[0] ?? null,
|
||||
)
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
Ou identificador de documento já autorizado
|
||||
<input
|
||||
className={input}
|
||||
value={upload.data.document_id}
|
||||
onChange={(e) =>
|
||||
upload.setData(
|
||||
'document_id',
|
||||
e.target.value,
|
||||
)
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
Proveniência e referência
|
||||
<input
|
||||
className={input}
|
||||
required
|
||||
value={upload.data.source_reference}
|
||||
onChange={(e) =>
|
||||
upload.setData(
|
||||
'source_reference',
|
||||
e.target.value,
|
||||
)
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
Assunto da evidência — não equivale a validação
|
||||
<select
|
||||
className={input}
|
||||
value={upload.data.category}
|
||||
onChange={(e) =>
|
||||
upload.setData('category', e.target.value)
|
||||
}
|
||||
>
|
||||
<option value="project_evidence">
|
||||
Documento geral do projecto
|
||||
</option>
|
||||
<option value="market_evidence">Mercado</option>
|
||||
<option value="location_evidence">
|
||||
Localização
|
||||
</option>
|
||||
<option value="resource_evidence">
|
||||
Recursos
|
||||
</option>
|
||||
<option value="funding_evidence">
|
||||
Financiamento
|
||||
</option>
|
||||
</select>
|
||||
</label>
|
||||
<label className="flex gap-2">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={upload.data.consent}
|
||||
onChange={(e) =>
|
||||
upload.setData('consent', e.target.checked)
|
||||
}
|
||||
/>
|
||||
Autorizo associar este documento ao dossier privado.
|
||||
</label>
|
||||
<button className={button} disabled={upload.processing}>
|
||||
Associar documento
|
||||
</button>
|
||||
{Object.entries(upload.errors).map(([k, v]) => (
|
||||
<p key={k} role="alert">
|
||||
{v}
|
||||
</p>
|
||||
))}
|
||||
</form>
|
||||
)}
|
||||
</section>
|
||||
{manager && !canWrite && (
|
||||
<DocumentReview
|
||||
caseId={dossier.id}
|
||||
version={dossier.version}
|
||||
documents={documents}
|
||||
/>
|
||||
)}
|
||||
<section className={card}>
|
||||
<h2 className="text-xl font-bold">
|
||||
Ligações institucionais e alternativas
|
||||
</h2>
|
||||
<p>
|
||||
O encaminhamento não transmite o dossier. Ligações
|
||||
indisponíveis não impedem os serviços internos.
|
||||
</p>
|
||||
{links.map((link) => (
|
||||
<article key={link.id}>
|
||||
<p>
|
||||
{link.entity} — {link.purpose} ·{' '}
|
||||
{link.monitor.available
|
||||
? `Disponibilidade conferida internamente em ${link.verified_at}; não valida conteúdo ou decisão oficial`
|
||||
: 'Ligação por verificar ou indisponível'}
|
||||
</p>
|
||||
<p>Contacto alternativo: {link.monitor.contact}</p>
|
||||
<a
|
||||
className="underline"
|
||||
href={`/balcao-virtual/encaminhar/${link.id}?case_id=${dossier.id}`}
|
||||
>
|
||||
Abrir encaminhamento
|
||||
</a>{' '}
|
||||
·{' '}
|
||||
<a
|
||||
className="underline"
|
||||
href={`/balcao-virtual/encaminhar/${link.id}?case_id=${dossier.id}&unavailable=1`}
|
||||
>
|
||||
Ligação indisponível: continuar internamente
|
||||
</a>
|
||||
{manager && <LinkReview link={link} />}
|
||||
</article>
|
||||
))}
|
||||
{!links.length && (
|
||||
<p>
|
||||
Sem ligações verificadas. Prepare os documentos e
|
||||
solicite apoio no pedido existente.
|
||||
</p>
|
||||
)}
|
||||
</section>
|
||||
<details className={card}>
|
||||
<summary>Histórico de autoria, decisões e resultados</summary>
|
||||
{events.map((event) => (
|
||||
<article key={event.id} className="mt-3 border-t pt-3">
|
||||
<p>
|
||||
{event.action} · {event.name} · {event.created_at}
|
||||
</p>
|
||||
<pre className="overflow-auto text-xs break-all whitespace-pre-wrap">
|
||||
{JSON.stringify(event.payload, null, 2)}
|
||||
</pre>
|
||||
</article>
|
||||
))}
|
||||
</details>
|
||||
</Frame>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
import { Link } from '@inertiajs/react';
|
||||
import { Frame, card } from '@/pages/investment/shared';
|
||||
export default function Catalogue({
|
||||
installed,
|
||||
services,
|
||||
prepared,
|
||||
}: {
|
||||
installed: boolean;
|
||||
services: {
|
||||
id: string;
|
||||
version: number;
|
||||
definition: { title: string; result: string };
|
||||
}[];
|
||||
prepared: Record<string, { title: string; result: string }>;
|
||||
}) {
|
||||
return (
|
||||
<Frame title="Serviços do Balcão Virtual">
|
||||
<p>
|
||||
Preparação e acompanhamento internos; a decisão oficial pertence
|
||||
à entidade competente.
|
||||
</p>
|
||||
<Link
|
||||
href={installed ? '/balcao-virtual/painel' : '/balcao-virtual'}
|
||||
className="underline"
|
||||
>
|
||||
{installed
|
||||
? 'Abrir o painel e preparar um pedido'
|
||||
: 'Consultar pedidos existentes'}
|
||||
</Link>
|
||||
{!installed && (
|
||||
<p>
|
||||
Melhorias preparadas; a instalação autenticada e a
|
||||
publicação explícita dos serviços continuam pendentes.
|
||||
</p>
|
||||
)}
|
||||
{(installed
|
||||
? services.map((s) => ({ ...s.definition, version: s.version }))
|
||||
: Object.values(prepared).map((s) => ({ ...s, version: null }))
|
||||
).map((s) => (
|
||||
<article className={card} key={s.title}>
|
||||
<h2 className="text-xl font-bold">{s.title}</h2>
|
||||
<p>{s.result}</p>
|
||||
<p>
|
||||
{s.version
|
||||
? `Versão ${s.version}`
|
||||
: 'Preparado, ainda indisponível para novos pedidos'}
|
||||
</p>
|
||||
</article>
|
||||
))}
|
||||
</Frame>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,196 @@
|
||||
import { Link, useForm } from '@inertiajs/react';
|
||||
import { Frame, card, button, input } from '@/pages/investment/shared';
|
||||
export default function Install({
|
||||
hash,
|
||||
installed,
|
||||
backupVerified,
|
||||
qaVerified,
|
||||
changes,
|
||||
target,
|
||||
pendingMigrations,
|
||||
compatibilityVerified,
|
||||
backupDate,
|
||||
scanner,
|
||||
rollback,
|
||||
databaseReady,
|
||||
}: {
|
||||
hash: string;
|
||||
installed: boolean;
|
||||
backupVerified: boolean;
|
||||
qaVerified: boolean;
|
||||
changes: string[];
|
||||
target: { database: string; port: number };
|
||||
pendingMigrations: string[];
|
||||
compatibilityVerified: boolean;
|
||||
backupDate: string | null;
|
||||
scanner: { available: boolean; reason_code: string | null };
|
||||
rollback: string;
|
||||
databaseReady: boolean;
|
||||
}) {
|
||||
const form = useForm({ hash, confirm: false });
|
||||
const service = useForm({ code: 'project-preparation', confirm: false });
|
||||
return (
|
||||
<Frame title="Instalação autenticada do Balcão e acompanhamento">
|
||||
<Link href="/balcao-virtual" className="mr-4 underline">
|
||||
Voltar ao Balcão
|
||||
</Link>
|
||||
<Link href="/management/balcao/fontes" className="underline">
|
||||
Consultar inventário privado e exemplares de formulários
|
||||
</Link>
|
||||
<section className={card}>
|
||||
<p>
|
||||
Destino: {target.database}, porta {target.port}.
|
||||
Backup/restauro: {backupDate ?? 'Pendente'}.
|
||||
</p>
|
||||
<h2 className="mt-3 text-lg font-semibold">
|
||||
Alterações de esquema ainda necessárias
|
||||
</h2>
|
||||
<ul>
|
||||
{pendingMigrations.map((name) => (
|
||||
<li key={name}>{name}</li>
|
||||
))}
|
||||
</ul>
|
||||
<p>
|
||||
Serão criadas as tabelas internas do Balcão; acrescentadas
|
||||
associações opcionais ao dossier e às tarefas existentes.
|
||||
Não se migram ou apagam pedidos anteriores, não se publicam
|
||||
serviços nem se enviam dados externos.
|
||||
</p>
|
||||
<ul>
|
||||
{changes.map((c) => (
|
||||
<li key={c}>{c}</li>
|
||||
))}
|
||||
</ul>
|
||||
<p>
|
||||
Backup/restauro verificado:{' '}
|
||||
{backupVerified ? 'Sim' : 'Pendente'} · QA desta versão:{' '}
|
||||
{qaVerified ? 'Sim' : 'Pendente'}.
|
||||
</p>
|
||||
<p>
|
||||
Compatibilidade e reversão em cópia restaurada:{' '}
|
||||
{compatibilityVerified ? 'Verificadas' : 'Pendentes'}.
|
||||
</p>
|
||||
<p>
|
||||
Permissões da conexão para criar o esquema e estender
|
||||
tarefas:{' '}
|
||||
{databaseReady
|
||||
? 'Disponíveis'
|
||||
: 'Insuficientes — intervenção autorizada necessária'}
|
||||
.
|
||||
</p>
|
||||
<p>
|
||||
ClamD real:{' '}
|
||||
{scanner.available
|
||||
? 'Disponível'
|
||||
: `Indisponível (${scanner.reason_code ?? 'sem evidência'})`}
|
||||
. Ficheiros sem scan conclusivo continuam pendentes para
|
||||
utilização segura; guardar rascunhos e preparar pedidos
|
||||
mantém-se disponível.
|
||||
</p>
|
||||
<p>{rollback}</p>
|
||||
<p>
|
||||
Confirmação inclui o restauro isolado da base e a
|
||||
integridade dos ficheiros privados. O histórico e os pedidos
|
||||
existentes são preservados.
|
||||
</p>
|
||||
</section>
|
||||
{!installed && (
|
||||
<form
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
form.post('/management/balcao-install');
|
||||
}}
|
||||
>
|
||||
<label className="flex gap-2">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={form.data.confirm}
|
||||
onChange={(e) =>
|
||||
form.setData('confirm', e.target.checked)
|
||||
}
|
||||
/>
|
||||
Confirmo aplicar exactamente as alterações
|
||||
pré-visualizadas.
|
||||
</label>
|
||||
<button
|
||||
className={button}
|
||||
disabled={
|
||||
form.processing ||
|
||||
!form.data.confirm ||
|
||||
!backupVerified ||
|
||||
!qaVerified ||
|
||||
!compatibilityVerified ||
|
||||
!databaseReady
|
||||
}
|
||||
>
|
||||
Aplicar instalação autenticada
|
||||
</button>
|
||||
{Object.entries(form.errors).map(([k, v]) => (
|
||||
<p role="alert" key={k}>
|
||||
{v}
|
||||
</p>
|
||||
))}
|
||||
</form>
|
||||
)}
|
||||
{installed && (
|
||||
<form
|
||||
className={card + ' space-y-3'}
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
service.post('/management/balcao/servicos');
|
||||
}}
|
||||
>
|
||||
<h2 className="text-xl font-bold">
|
||||
Publicar serviço de preparação interna
|
||||
</h2>
|
||||
<p>
|
||||
Publicação do catálogo é uma acção separada; não submete
|
||||
pedidos nem homologa um formulário oficial.
|
||||
</p>
|
||||
<label>
|
||||
Serviço
|
||||
<select
|
||||
className={input}
|
||||
value={service.data.code}
|
||||
onChange={(e) =>
|
||||
service.setData('code', e.target.value)
|
||||
}
|
||||
>
|
||||
<option value="project-preparation">
|
||||
Preparação de projecto
|
||||
</option>
|
||||
<option value="project-change">
|
||||
Alteração de projecto
|
||||
</option>
|
||||
<option value="project-follow-up">
|
||||
Acompanhamento de investimento
|
||||
</option>
|
||||
</select>
|
||||
</label>
|
||||
<label className="flex gap-2">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={service.data.confirm}
|
||||
onChange={(e) =>
|
||||
service.setData('confirm', e.target.checked)
|
||||
}
|
||||
/>
|
||||
Confirmo disponibilizar este serviço de preparação
|
||||
interna.
|
||||
</label>
|
||||
<button
|
||||
className={button}
|
||||
disabled={service.processing || !service.data.confirm}
|
||||
>
|
||||
Publicar este serviço
|
||||
</button>
|
||||
{Object.entries(service.errors).map(([k, v]) => (
|
||||
<p role="alert" key={k}>
|
||||
{v}
|
||||
</p>
|
||||
))}
|
||||
</form>
|
||||
)}
|
||||
</Frame>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,292 @@
|
||||
import { Link, useForm, usePage } from '@inertiajs/react';
|
||||
import { useRef, useState } from 'react';
|
||||
import { Frame, input, button, card } from '@/pages/investment/shared';
|
||||
type Option = {
|
||||
id: string;
|
||||
status?: string;
|
||||
name?: string;
|
||||
version_no?: number;
|
||||
};
|
||||
export default function Panel({
|
||||
cases,
|
||||
queue,
|
||||
legacyRequests,
|
||||
companies,
|
||||
submissions,
|
||||
organizations,
|
||||
simulationDrafts,
|
||||
journeys,
|
||||
states,
|
||||
manager,
|
||||
guidanceTasks,
|
||||
}: {
|
||||
cases: { id: string; title: string }[];
|
||||
queue: {
|
||||
id: string;
|
||||
title: string;
|
||||
protocol: string;
|
||||
status: string;
|
||||
due_at: string | null;
|
||||
}[];
|
||||
legacyRequests: { id: number; reference: string; status: string }[];
|
||||
companies: Option[];
|
||||
submissions: Option[];
|
||||
organizations: Option[];
|
||||
simulationDrafts: Option[];
|
||||
journeys: Option[];
|
||||
states: Record<string, string>;
|
||||
manager: boolean;
|
||||
guidanceTasks: {
|
||||
id: string;
|
||||
title: string;
|
||||
status: string;
|
||||
due_at: string;
|
||||
case_id: string;
|
||||
case_title: string;
|
||||
}[];
|
||||
}) {
|
||||
const params = new URLSearchParams(usePage().url.split('?')[1] ?? '');
|
||||
const pending = useRef(false);
|
||||
const [failure, setFailure] = useState<string | null>(null);
|
||||
const form = useForm({
|
||||
title: '',
|
||||
client_key: crypto.randomUUID(),
|
||||
reuse_consent: false,
|
||||
company_id: '',
|
||||
submission_id: params.get('submission_id') ?? '',
|
||||
simulation_id: params.get('simulation_id') ?? '',
|
||||
organization_id: '',
|
||||
journey_id: params.get('journey_id') ?? '',
|
||||
interest_request_id: '',
|
||||
});
|
||||
const groups = {
|
||||
company_id: ['Empresa existente', companies],
|
||||
submission_id: ['Manifestação ou rascunho existente', submissions],
|
||||
simulation_id: ['Dossier do simulador', simulationDrafts],
|
||||
organization_id: ['Organização representada', organizations],
|
||||
journey_id: ['Percurso territorial existente', journeys],
|
||||
} as const;
|
||||
return (
|
||||
<Frame title="Balcão Virtual — acompanhamento">
|
||||
<nav className="flex flex-wrap gap-4">
|
||||
<Link href="/balcao-virtual/servicos" className="underline">
|
||||
Serviços
|
||||
</Link>
|
||||
<Link href="/investidor/manifestacoes" className="underline">
|
||||
Área do investidor
|
||||
</Link>
|
||||
<Link href="/parcerias/painel" className="underline">
|
||||
Parcerias
|
||||
</Link>
|
||||
{manager && (
|
||||
<Link
|
||||
href="/management/balcao-install"
|
||||
className="underline"
|
||||
>
|
||||
Instalação e serviços
|
||||
</Link>
|
||||
)}
|
||||
</nav>
|
||||
<section className="space-y-3">
|
||||
<h2 className="text-xl font-bold">Dossiers actuais</h2>
|
||||
{cases.map((c) => (
|
||||
<Link
|
||||
key={c.id}
|
||||
className={card + ' block'}
|
||||
href={`/balcao-virtual/dossiers/${c.id}`}
|
||||
>
|
||||
{c.title}
|
||||
</Link>
|
||||
))}
|
||||
{!cases.length && <p>Ainda sem dossier neste fluxo.</p>}
|
||||
</section>
|
||||
<details className={card}>
|
||||
<summary>Preparar acompanhamento de um projecto</summary>
|
||||
<form
|
||||
className="mt-4 space-y-3"
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
if (pending.current) return;
|
||||
pending.current = true;
|
||||
setFailure(null);
|
||||
form.post('/balcao-virtual/dossiers', {
|
||||
preserveState: true,
|
||||
onError: () =>
|
||||
setFailure(
|
||||
'O dossier não foi guardado. Corrija os campos indicados abaixo; os dados preenchidos foram mantidos.',
|
||||
),
|
||||
onHttpException: (response) => {
|
||||
const reasons: Record<number, string> = {
|
||||
403: 'Não tem autorização para a associação selecionada.',
|
||||
404: 'O registo que pretende associar não está disponível.',
|
||||
409: 'Esta operação já foi utilizada com outro conteúdo ou o contexto mudou. Consulte os dossiers atuais antes de repetir.',
|
||||
419: 'A sessão expirou. Inicie sessão novamente antes de repetir.',
|
||||
422: 'Os dados não permitem guardar este dossier. Reveja as associações e o consentimento.',
|
||||
503: 'O servidor está temporariamente indisponível.',
|
||||
};
|
||||
setFailure(
|
||||
`${reasons[response.status] ?? 'O servidor não confirmou a operação.'} Os dados preenchidos foram mantidos.`,
|
||||
);
|
||||
return false;
|
||||
},
|
||||
onNetworkError: () => {
|
||||
setFailure(
|
||||
'A ligação falhou e não foi possível confirmar o resultado. Os dados foram mantidos. Consulte os dossiers atuais antes de repetir; não submeta um pedido para testar.',
|
||||
);
|
||||
return false;
|
||||
},
|
||||
onFinish: () => {
|
||||
pending.current = false;
|
||||
},
|
||||
});
|
||||
}}
|
||||
>
|
||||
<label className="block">
|
||||
Título do projecto
|
||||
<input
|
||||
className={input}
|
||||
value={form.data.title}
|
||||
maxLength={200}
|
||||
required
|
||||
onChange={(e) =>
|
||||
form.setData('title', e.target.value)
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
{Object.entries(groups).map(([key, [label, options]]) => (
|
||||
<label className="block" key={key}>
|
||||
{label}
|
||||
<select
|
||||
className={input}
|
||||
value={form.data[key as keyof typeof groups]}
|
||||
onChange={(e) =>
|
||||
form.setData(
|
||||
key as keyof typeof groups,
|
||||
e.target.value,
|
||||
)
|
||||
}
|
||||
>
|
||||
<option value="">Sem ligação nesta fase</option>
|
||||
{options.map((o) => (
|
||||
<option key={o.id} value={o.id}>
|
||||
{o.name ??
|
||||
`${o.id} — ${o.status ?? `versão ${o.version_no ?? ''}`}`}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
))}
|
||||
<label>
|
||||
Pedido de apoio anterior
|
||||
<select
|
||||
className={input}
|
||||
value={form.data.interest_request_id}
|
||||
onChange={(e) =>
|
||||
form.setData(
|
||||
'interest_request_id',
|
||||
e.target.value,
|
||||
)
|
||||
}
|
||||
>
|
||||
<option value="">Sem associação nesta fase</option>
|
||||
{legacyRequests.map((r) => (
|
||||
<option key={r.id} value={r.id}>
|
||||
{r.reference} — {r.status}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
<label className="flex gap-2">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={form.data.reuse_consent}
|
||||
onChange={(e) =>
|
||||
form.setData('reuse_consent', e.target.checked)
|
||||
}
|
||||
/>
|
||||
Autorizo reutilizar os dados seleccionados para preparar
|
||||
e acompanhar o projecto internamente.
|
||||
</label>
|
||||
<p>
|
||||
O dossier não submete pedidos, não publica documentos e
|
||||
não transmite dados para serviços externos.
|
||||
</p>
|
||||
{Object.entries(form.errors).map(([key, v]) => (
|
||||
<p role="alert" key={key}>
|
||||
{v}
|
||||
</p>
|
||||
))}
|
||||
{failure && (
|
||||
<p
|
||||
role="alert"
|
||||
className="rounded border border-red-700 bg-red-50 p-3"
|
||||
>
|
||||
{failure}
|
||||
</p>
|
||||
)}
|
||||
{form.processing && (
|
||||
<p role="status">
|
||||
A guardar o dossier no servidor. Aguarde a
|
||||
confirmação.
|
||||
</p>
|
||||
)}
|
||||
<button className={button} disabled={form.processing}>
|
||||
{form.processing ? 'A guardar…' : 'Preparar dossier'}
|
||||
</button>
|
||||
</form>
|
||||
</details>
|
||||
<section className="space-y-3">
|
||||
<h2 className="text-xl font-bold">
|
||||
Pedidos em acompanhamento{' '}
|
||||
{manager ? '— equipa / CRM interno' : ''}
|
||||
</h2>
|
||||
{queue.map((r) => (
|
||||
<article className={card} key={r.id}>
|
||||
<Link
|
||||
className="underline"
|
||||
href={`/balcao-virtual/pedidos/${r.id}`}
|
||||
>
|
||||
{r.protocol} — {r.title}
|
||||
</Link>
|
||||
<p>
|
||||
{states[r.status]} · Prazo interno:{' '}
|
||||
{r.due_at ?? 'Não atribuído'}
|
||||
</p>
|
||||
</article>
|
||||
))}
|
||||
{!queue.length && <p>Sem pedidos atribuídos neste fluxo.</p>}
|
||||
</section>
|
||||
<section className="space-y-3">
|
||||
<h2 className="text-xl font-bold">
|
||||
Tarefas assumidas no CRM interno
|
||||
</h2>
|
||||
{guidanceTasks.map((t) => (
|
||||
<article className={card} key={t.id}>
|
||||
<Link
|
||||
className="underline"
|
||||
href={`/balcao-virtual/dossiers/${t.case_id}`}
|
||||
>
|
||||
{t.case_title} ? {t.title}
|
||||
</Link>
|
||||
<p>
|
||||
{t.status} ? Prazo interno: {t.due_at}
|
||||
</p>
|
||||
</article>
|
||||
))}
|
||||
</section>
|
||||
<section>
|
||||
<h2 className="text-xl font-bold">
|
||||
Pedidos anteriores preservados
|
||||
</h2>
|
||||
{legacyRequests.map((r) => (
|
||||
<p key={r.reference}>
|
||||
{r.reference} — {r.status}
|
||||
</p>
|
||||
))}
|
||||
{!legacyRequests.length && (
|
||||
<p>Sem pedidos anteriores associados à conta.</p>
|
||||
)}
|
||||
</section>
|
||||
</Frame>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,578 @@
|
||||
import { Link, useForm } from '@inertiajs/react';
|
||||
import { Frame, card, input, button } from '@/pages/investment/shared';
|
||||
import {
|
||||
DocumentReview,
|
||||
RequestOperations,
|
||||
type DeskDocument,
|
||||
type DeskPayment,
|
||||
} from '@/components/desk-internal-operations';
|
||||
|
||||
type Field = {
|
||||
label: string;
|
||||
type: string;
|
||||
required: boolean;
|
||||
options?: Record<string, string>;
|
||||
when?: { field: string; equals: string };
|
||||
};
|
||||
export default function RequestPage({
|
||||
request,
|
||||
case: dossier,
|
||||
definition,
|
||||
owner,
|
||||
manager,
|
||||
analyst,
|
||||
fieldsEditable,
|
||||
states,
|
||||
transitions,
|
||||
findings,
|
||||
messages,
|
||||
analysts,
|
||||
territories,
|
||||
events,
|
||||
documents,
|
||||
payments,
|
||||
caseVersion,
|
||||
}: {
|
||||
request: {
|
||||
id: string;
|
||||
version: number;
|
||||
status: string;
|
||||
payload: Record<string, string>;
|
||||
protocol: string | null;
|
||||
editable_fields: string[];
|
||||
analyst_id: number | null;
|
||||
due_at: string | null;
|
||||
};
|
||||
case: { id: string; title: string };
|
||||
definition: {
|
||||
title: string;
|
||||
fields: Record<string, Field>;
|
||||
result: string;
|
||||
};
|
||||
owner: boolean;
|
||||
manager: boolean;
|
||||
analyst: boolean;
|
||||
fieldsEditable: boolean;
|
||||
states: Record<string, string>;
|
||||
transitions: string[];
|
||||
findings: {
|
||||
code: string;
|
||||
explanation: string;
|
||||
recommendation: string;
|
||||
severity: string;
|
||||
}[];
|
||||
messages: {
|
||||
id: string;
|
||||
body: string;
|
||||
name: string;
|
||||
kind: string;
|
||||
created_at: string;
|
||||
}[];
|
||||
analysts: { id: number; name: string }[];
|
||||
territories: { id: string; name: string }[];
|
||||
documents: DeskDocument[];
|
||||
payments: DeskPayment[];
|
||||
caseVersion: number;
|
||||
events: {
|
||||
id: string;
|
||||
action: string;
|
||||
name: string;
|
||||
created_at: string;
|
||||
payload: Record<string, unknown>;
|
||||
}[];
|
||||
}) {
|
||||
const form = useForm({
|
||||
version: request.version,
|
||||
payload: request.payload,
|
||||
consent: false,
|
||||
reason: '',
|
||||
submit: false,
|
||||
});
|
||||
const decision = useForm({
|
||||
version: request.version,
|
||||
status: transitions[0] ?? '',
|
||||
reason: '',
|
||||
editable_fields: [] as string[],
|
||||
});
|
||||
const assignment = useForm({
|
||||
version: request.version,
|
||||
analyst_id: String(request.analyst_id ?? ''),
|
||||
reason: '',
|
||||
due_at: '',
|
||||
});
|
||||
const message = useForm({ body: '', client_key: crypto.randomUUID() });
|
||||
const canEdit = owner && fieldsEditable;
|
||||
return (
|
||||
<Frame title={definition.title}>
|
||||
<Link
|
||||
className="underline"
|
||||
href={`/balcao-virtual/dossiers/${dossier.id}`}
|
||||
>
|
||||
Voltar ao dossier {dossier.title}
|
||||
</Link>
|
||||
<p>{definition.result}</p>
|
||||
<section className={card}>
|
||||
<h2 className="text-xl font-bold">
|
||||
{request.protocol
|
||||
? 'Pedido submetido pelo investidor'
|
||||
: 'Rascunho — ainda não submetido'}
|
||||
</h2>
|
||||
<p>
|
||||
{states[request.status]} · Protocolo:{' '}
|
||||
{request.protocol ?? 'Ainda sem protocolo'}
|
||||
</p>
|
||||
<p>
|
||||
Responsável real:{' '}
|
||||
{request.analyst_id ?? 'A aguardar atribuição'} · Prazo
|
||||
interno: {request.due_at ?? 'Não definido'}
|
||||
</p>
|
||||
{request.protocol && (
|
||||
<a
|
||||
className="underline"
|
||||
href={`/balcao-virtual/pedidos/${request.id}/recibo`}
|
||||
>
|
||||
Descarregar recibo interno e snapshot
|
||||
</a>
|
||||
)}
|
||||
</section>
|
||||
<section className={card + ' space-y-3'}>
|
||||
<h2 className="text-xl font-bold">
|
||||
Verificações automáticas de preparação
|
||||
</h2>
|
||||
{findings.map((f) => (
|
||||
<p key={f.code}>
|
||||
{f.explanation} {f.recommendation} (
|
||||
{f.severity === 'error'
|
||||
? 'Contradição nos valores declarados'
|
||||
: 'Informação / evidência pendente'}
|
||||
)
|
||||
</p>
|
||||
))}
|
||||
<p>
|
||||
A análise automática não é uma resposta do responsável nem
|
||||
uma aprovação oficial.
|
||||
</p>
|
||||
</section>
|
||||
<form
|
||||
className={card + ' space-y-3'}
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
form.transform((d) => ({
|
||||
...d,
|
||||
version: request.version,
|
||||
submit: false,
|
||||
}));
|
||||
form.put(`/balcao-virtual/pedidos/${request.id}`);
|
||||
}}
|
||||
>
|
||||
{Object.entries(definition.fields)
|
||||
.filter(
|
||||
([, f]) =>
|
||||
!f.when ||
|
||||
form.data.payload[f.when.field] === f.when.equals,
|
||||
)
|
||||
.map(([key, f]) => (
|
||||
<label className="block" key={key}>
|
||||
{f.label}
|
||||
{f.required ? ' *' : ''}
|
||||
{f.type === 'select' || f.type === 'territory' ? (
|
||||
<select
|
||||
className={input}
|
||||
disabled={
|
||||
!canEdit ||
|
||||
(request.status === 'returned' &&
|
||||
!request.editable_fields.includes(
|
||||
key,
|
||||
))
|
||||
}
|
||||
value={form.data.payload[key] ?? ''}
|
||||
onChange={(e) =>
|
||||
form.setData('payload', {
|
||||
...form.data.payload,
|
||||
[key]: e.target.value,
|
||||
})
|
||||
}
|
||||
>
|
||||
<option value="">Por preencher</option>
|
||||
{(f.type === 'territory'
|
||||
? territories.map((t) => [t.id, t.name])
|
||||
: Object.entries(f.options ?? {})
|
||||
).map(([v, l]) => (
|
||||
<option key={v} value={v}>
|
||||
{l}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
) : f.type === 'textarea' ? (
|
||||
<textarea
|
||||
className={input}
|
||||
disabled={
|
||||
!canEdit ||
|
||||
(request.status === 'returned' &&
|
||||
!request.editable_fields.includes(
|
||||
key,
|
||||
))
|
||||
}
|
||||
value={form.data.payload[key] ?? ''}
|
||||
onChange={(e) =>
|
||||
form.setData('payload', {
|
||||
...form.data.payload,
|
||||
[key]: e.target.value,
|
||||
})
|
||||
}
|
||||
/>
|
||||
) : (
|
||||
<input
|
||||
type={
|
||||
f.type === 'date'
|
||||
? 'date'
|
||||
: f.type === 'number'
|
||||
? 'number'
|
||||
: 'text'
|
||||
}
|
||||
step={
|
||||
f.type === 'number' ? '0.01' : undefined
|
||||
}
|
||||
className={input}
|
||||
disabled={
|
||||
!canEdit ||
|
||||
(request.status === 'returned' &&
|
||||
!request.editable_fields.includes(
|
||||
key,
|
||||
))
|
||||
}
|
||||
value={form.data.payload[key] ?? ''}
|
||||
onChange={(e) =>
|
||||
form.setData('payload', {
|
||||
...form.data.payload,
|
||||
[key]: e.target.value,
|
||||
})
|
||||
}
|
||||
/>
|
||||
)}
|
||||
</label>
|
||||
))}
|
||||
{canEdit && (
|
||||
<>
|
||||
<label>
|
||||
Justificação de correcção
|
||||
<textarea
|
||||
className={input}
|
||||
value={form.data.reason}
|
||||
onChange={(e) =>
|
||||
form.setData('reason', e.target.value)
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
<button className={button} disabled={form.processing}>
|
||||
Guardar rascunho
|
||||
</button>
|
||||
<label className="flex gap-2">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={form.data.consent}
|
||||
onChange={(e) =>
|
||||
form.setData('consent', e.target.checked)
|
||||
}
|
||||
/>
|
||||
Revi o conteúdo e autorizo a submissão para análise
|
||||
interna.
|
||||
</label>
|
||||
<button
|
||||
type="button"
|
||||
className={button}
|
||||
disabled={form.processing || !form.data.consent}
|
||||
onClick={() => {
|
||||
form.transform((d) => ({
|
||||
...d,
|
||||
version: request.version,
|
||||
submit: true,
|
||||
}));
|
||||
form.put(
|
||||
`/balcao-virtual/pedidos/${request.id}`,
|
||||
);
|
||||
}}
|
||||
>
|
||||
Submeter este pedido
|
||||
</button>
|
||||
</>
|
||||
)}
|
||||
{Object.entries(form.errors).map(([k, v]) => (
|
||||
<p key={k} role="alert">
|
||||
{v}
|
||||
</p>
|
||||
))}
|
||||
</form>
|
||||
{!owner && (manager || analyst) && transitions.length > 0 && (
|
||||
<form
|
||||
className={card + ' space-y-3'}
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
decision.transform((d) => ({
|
||||
...d,
|
||||
version: request.version,
|
||||
}));
|
||||
decision.post(
|
||||
`/balcao-virtual/pedidos/${request.id}/estado`,
|
||||
);
|
||||
}}
|
||||
>
|
||||
<h2 className="text-xl font-bold">
|
||||
Resposta / análise do responsável
|
||||
</h2>
|
||||
<label>
|
||||
Estado
|
||||
<select
|
||||
className={input}
|
||||
value={decision.data.status}
|
||||
onChange={(e) =>
|
||||
decision.setData('status', e.target.value)
|
||||
}
|
||||
>
|
||||
{transitions
|
||||
.filter(
|
||||
(s) =>
|
||||
manager ||
|
||||
![
|
||||
'accepted',
|
||||
'rejected',
|
||||
'closed',
|
||||
].includes(s),
|
||||
)
|
||||
.map((s) => (
|
||||
<option value={s} key={s}>
|
||||
{states[s]}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
<label>
|
||||
Fundamento da resposta
|
||||
<textarea
|
||||
className={input}
|
||||
required
|
||||
minLength={3}
|
||||
value={decision.data.reason}
|
||||
onChange={(e) =>
|
||||
decision.setData('reason', e.target.value)
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
{decision.data.status === 'returned' && (
|
||||
<fieldset>
|
||||
<legend>Campos autorizados para correcção</legend>
|
||||
{Object.entries(definition.fields).map(([k, f]) => (
|
||||
<label className="block" key={k}>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={decision.data.editable_fields.includes(
|
||||
k,
|
||||
)}
|
||||
onChange={(e) =>
|
||||
decision.setData(
|
||||
'editable_fields',
|
||||
e.target.checked
|
||||
? [
|
||||
...decision.data
|
||||
.editable_fields,
|
||||
k,
|
||||
]
|
||||
: decision.data.editable_fields.filter(
|
||||
(v) => v !== k,
|
||||
),
|
||||
)
|
||||
}
|
||||
/>{' '}
|
||||
{f.label}
|
||||
</label>
|
||||
))}
|
||||
</fieldset>
|
||||
)}
|
||||
<button className={button} disabled={decision.processing}>
|
||||
Registar resposta fundamentada
|
||||
</button>
|
||||
{Object.entries(decision.errors).map(([k, v]) => (
|
||||
<p role="alert" key={k}>
|
||||
{v}
|
||||
</p>
|
||||
))}
|
||||
</form>
|
||||
)}
|
||||
{manager &&
|
||||
!['draft', 'closed', 'cancelled'].includes(request.status) && (
|
||||
<form
|
||||
className={card + ' space-y-3'}
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
assignment.transform((d) => ({
|
||||
...d,
|
||||
version: request.version,
|
||||
}));
|
||||
assignment.post(
|
||||
`/balcao-virtual/pedidos/${request.id}/responsavel`,
|
||||
);
|
||||
}}
|
||||
>
|
||||
<h2 className="text-xl font-bold">
|
||||
Atribuir responsável existente
|
||||
</h2>
|
||||
<label>
|
||||
Responsável
|
||||
<select
|
||||
className={input}
|
||||
required
|
||||
value={assignment.data.analyst_id}
|
||||
onChange={(e) =>
|
||||
assignment.setData(
|
||||
'analyst_id',
|
||||
e.target.value,
|
||||
)
|
||||
}
|
||||
>
|
||||
<option value="">Seleccione</option>
|
||||
{analysts.map((a) => (
|
||||
<option key={a.id} value={a.id}>
|
||||
{a.name}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
<label>
|
||||
Prazo interno
|
||||
<input
|
||||
className={input}
|
||||
type="datetime-local"
|
||||
value={assignment.data.due_at}
|
||||
onChange={(e) =>
|
||||
assignment.setData('due_at', e.target.value)
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
Motivo
|
||||
<textarea
|
||||
className={input}
|
||||
required
|
||||
value={assignment.data.reason}
|
||||
onChange={(e) =>
|
||||
assignment.setData('reason', e.target.value)
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
<button
|
||||
className={button}
|
||||
disabled={assignment.processing}
|
||||
>
|
||||
Atribuir acompanhamento
|
||||
</button>
|
||||
{Object.entries(assignment.errors).map(([k, v]) => (
|
||||
<p role="alert" key={k}>
|
||||
{v}
|
||||
</p>
|
||||
))}
|
||||
</form>
|
||||
)}
|
||||
<section className={card + ' space-y-3'}>
|
||||
<h2 className="text-xl font-bold">
|
||||
Conversa do pedido existente
|
||||
</h2>
|
||||
{messages.map((m) => (
|
||||
<article key={m.id} className="rounded border p-3">
|
||||
<p>
|
||||
{m.kind === 'responsible_response'
|
||||
? 'Resposta de responsável'
|
||||
: m.kind === 'investor_message'
|
||||
? 'Mensagem do investidor'
|
||||
: 'Mensagem histórica — tipo original não registado'}{' '}
|
||||
— {m.name} · {m.created_at}
|
||||
</p>
|
||||
<p className="break-words whitespace-pre-wrap">
|
||||
{m.body}
|
||||
</p>
|
||||
</article>
|
||||
))}
|
||||
{!['closed', 'cancelled'].includes(request.status) && (
|
||||
<form
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
message.post(
|
||||
`/balcao-virtual/pedidos/${request.id}/mensagens`,
|
||||
{
|
||||
onSuccess: () => {
|
||||
message.reset('body');
|
||||
message.setData(
|
||||
'client_key',
|
||||
crypto.randomUUID(),
|
||||
);
|
||||
},
|
||||
},
|
||||
);
|
||||
}}
|
||||
>
|
||||
<label>
|
||||
Mensagem privada
|
||||
<textarea
|
||||
className={input}
|
||||
value={message.data.body}
|
||||
required
|
||||
onChange={(e) =>
|
||||
message.setData('body', e.target.value)
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
<button
|
||||
className={button}
|
||||
disabled={message.processing}
|
||||
>
|
||||
Enviar esta mensagem no pedido
|
||||
</button>
|
||||
{Object.entries(message.errors).map(([k, v]) => (
|
||||
<p role="alert" key={k}>
|
||||
{v}
|
||||
</p>
|
||||
))}
|
||||
</form>
|
||||
)}
|
||||
</section>
|
||||
{!owner && (manager || analyst) && (
|
||||
<DocumentReview
|
||||
caseId={dossier.id}
|
||||
version={caseVersion}
|
||||
documents={documents}
|
||||
requestId={request.id}
|
||||
/>
|
||||
)}
|
||||
{!['closed', 'cancelled'].includes(request.status) && (
|
||||
<RequestOperations
|
||||
requestId={request.id}
|
||||
owner={owner}
|
||||
reviewer={!owner && (manager || analyst)}
|
||||
documents={documents}
|
||||
payments={payments}
|
||||
/>
|
||||
)}
|
||||
<section className={card}>
|
||||
<h2 className="text-xl font-bold">Respostas e histórico</h2>
|
||||
{events.map((e) => (
|
||||
<article className="mt-3 border-t pt-3" key={e.id}>
|
||||
<p>
|
||||
{e.action} · {e.name} · {e.created_at}
|
||||
</p>
|
||||
{typeof e.payload.reason === 'string' && (
|
||||
<p>{e.payload.reason}</p>
|
||||
)}
|
||||
{[
|
||||
'document_reviewed',
|
||||
'payment_reviewed',
|
||||
'manual_communication_recorded',
|
||||
].includes(e.action) && (
|
||||
<pre className="text-xs break-all whitespace-pre-wrap">
|
||||
{JSON.stringify(e.payload, null, 2)}
|
||||
</pre>
|
||||
)}
|
||||
</article>
|
||||
))}
|
||||
</section>
|
||||
</Frame>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
import { Link } from '@inertiajs/react';
|
||||
import { Frame, card } from '@/pages/investment/shared';
|
||||
|
||||
export default function Sources({
|
||||
total,
|
||||
attachmentCount,
|
||||
forms,
|
||||
}: {
|
||||
total: number;
|
||||
attachmentCount: number;
|
||||
forms: {
|
||||
identifier: string;
|
||||
sha256: string;
|
||||
size: number;
|
||||
edition: string;
|
||||
provenance: string;
|
||||
consultation: string;
|
||||
legal_documentary_status: string;
|
||||
rule_use: string;
|
||||
official_confirmation: string;
|
||||
fields_status: string;
|
||||
}[];
|
||||
}) {
|
||||
return (
|
||||
<Frame title="Acervo e exemplares de formulários">
|
||||
<Link href="/balcao-virtual/painel" className="underline">
|
||||
Voltar ao Balcão
|
||||
</Link>
|
||||
<p>
|
||||
Inventário privado: {total} ficheiros e {attachmentCount} anexos
|
||||
incorporados. O inventário integral foi preservado antes da
|
||||
selecção. Nada foi importado ou publicado automaticamente.
|
||||
</p>
|
||||
<p>
|
||||
Os exemplares abaixo preservam origem, hash e campos no
|
||||
original. Edição, homologação e correspondência a formulários
|
||||
oficiais permanecem por verificar. Esta pendência permite
|
||||
continuar a preparar o dossier.
|
||||
</p>
|
||||
{forms.map((f) => (
|
||||
<article key={f.sha256 + f.identifier} className={card}>
|
||||
<h2 className="font-bold">{f.identifier}</h2>
|
||||
<p>
|
||||
{f.provenance} · {f.size} bytes · edição:{' '}
|
||||
{f.edition === 'not_identified'
|
||||
? 'por identificar'
|
||||
: f.edition}
|
||||
</p>
|
||||
<p className="text-xs break-all">SHA-256: {f.sha256}</p>
|
||||
<p>
|
||||
Consulta: inventário local, sem autorização de
|
||||
publicação. Situação documental: não verificada.
|
||||
Utilização em regras ou cálculos: nenhuma.
|
||||
</p>
|
||||
<p>
|
||||
Confirmação oficial: pendente. Campos: preservados no
|
||||
ficheiro original; correspondência por verificar.
|
||||
</p>
|
||||
</article>
|
||||
))}
|
||||
{!forms.length && (
|
||||
<p>
|
||||
Inventário não disponível nesta instalação. Os serviços de
|
||||
preparação não dependem da sua publicação.
|
||||
</p>
|
||||
)}
|
||||
</Frame>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user