@@ -0,0 +1,105 @@
|
||||
import { Head, Link, useForm } from '@inertiajs/react';
|
||||
import { useState } from 'react';
|
||||
|
||||
export type InvestmentContext = {
|
||||
id: string;
|
||||
title: string;
|
||||
version: number;
|
||||
updated_at: string;
|
||||
};
|
||||
|
||||
export default function InvestmentContexts({
|
||||
contexts,
|
||||
}: {
|
||||
contexts: InvestmentContext[];
|
||||
}) {
|
||||
const [key] = useState(() => globalThis.crypto.randomUUID());
|
||||
const form = useForm({ title: '', client_key: key, reuse_consent: false });
|
||||
return (
|
||||
<main className="mx-auto max-w-5xl space-y-6 p-4 md:p-8">
|
||||
<Head title="Os meus investimentos" />
|
||||
<h1 className="text-2xl font-semibold">Os meus investimentos</h1>
|
||||
<p>
|
||||
Prepare cada investimento no seu dossier. Pode trabalhar em
|
||||
várias etapas em paralelo.
|
||||
</p>
|
||||
<ul className="grid gap-4 md:grid-cols-2">
|
||||
{contexts.map((item) => (
|
||||
<li key={item.id} className="rounded-xl border p-4">
|
||||
<Link
|
||||
className="font-semibold underline"
|
||||
href={`/investimentos/${item.id}`}
|
||||
>
|
||||
{item.title}
|
||||
</Link>
|
||||
<p className="text-sm">
|
||||
Guardado em{' '}
|
||||
{new Date(item.updated_at).toLocaleString('pt-MZ')}
|
||||
</p>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
{!contexts.length && (
|
||||
<p>Ainda não criou um investimento neste percurso.</p>
|
||||
)}
|
||||
<form
|
||||
className="max-w-xl space-y-4 rounded-xl border p-5"
|
||||
onSubmit={(event) => {
|
||||
event.preventDefault();
|
||||
form.post('/investimentos');
|
||||
}}
|
||||
>
|
||||
<h2 className="text-lg font-semibold">
|
||||
Preparar um investimento
|
||||
</h2>
|
||||
<label className="grid gap-1">
|
||||
Título
|
||||
<input
|
||||
required
|
||||
maxLength={200}
|
||||
className="rounded border p-2"
|
||||
value={form.data.title}
|
||||
onChange={(event) =>
|
||||
form.setData('title', event.target.value)
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
<label className="flex gap-2">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={form.data.reuse_consent}
|
||||
onChange={(event) =>
|
||||
form.setData('reuse_consent', event.target.checked)
|
||||
}
|
||||
/>
|
||||
Autorizo reutilizar o meu perfil neste dossier privado.
|
||||
</label>
|
||||
{Object.values(form.errors).map((error, index) => (
|
||||
<p key={index} role="alert">
|
||||
{error}
|
||||
</p>
|
||||
))}
|
||||
<button
|
||||
disabled={form.processing}
|
||||
className="bg-primary text-primary-foreground rounded px-4 py-2"
|
||||
>
|
||||
Criar e guardar dossier
|
||||
</button>
|
||||
</form>
|
||||
<nav className="flex flex-wrap gap-4" aria-label="Ferramentas">
|
||||
<Link className="underline" href="/simulador-fiscal">
|
||||
Simulador
|
||||
</Link>
|
||||
<Link className="underline" href="/balcao-virtual/painel">
|
||||
Balcão
|
||||
</Link>
|
||||
<Link className="underline" href="/investidor">
|
||||
Oportunidades guardadas
|
||||
</Link>
|
||||
<Link className="underline" href="/dashboard">
|
||||
Painel
|
||||
</Link>
|
||||
</nav>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,744 @@
|
||||
import { Head, Link, router, useForm, usePage } from '@inertiajs/react';
|
||||
import { useState } from 'react';
|
||||
import {
|
||||
pathStates,
|
||||
recoverPathResult,
|
||||
type PathResult,
|
||||
} from '@/lib/investor-path';
|
||||
|
||||
type Step = {
|
||||
code: string;
|
||||
title: string;
|
||||
phase: number;
|
||||
state: string;
|
||||
saved_state: string;
|
||||
reason: string;
|
||||
applicability: string;
|
||||
preparation_allowed: boolean;
|
||||
action_gaps: Record<string, string[]>;
|
||||
detail: { scope?: string };
|
||||
source_paragraph: number;
|
||||
};
|
||||
type Path = {
|
||||
case: { id: string; title: string; version: number; closed: boolean };
|
||||
phases: Record<string, string>;
|
||||
steps: Step[];
|
||||
definition_version: number;
|
||||
facts: { land_needed: string; external_funding: string; viability: string };
|
||||
fact_reasons: Record<string, string>;
|
||||
canWrite: boolean;
|
||||
canReview: boolean;
|
||||
next: { code: string; title: string; href: string; action: string } | null;
|
||||
tools: Record<string, string | null>;
|
||||
results: PathResult[];
|
||||
documents: {
|
||||
id: string;
|
||||
document_id: string;
|
||||
file_name: string;
|
||||
status: string;
|
||||
malware_scan_status: string;
|
||||
}[];
|
||||
requests: { id: string; status: string; protocol: string | null }[];
|
||||
services: { id: string; title: string }[];
|
||||
tasks: {
|
||||
id: string;
|
||||
title: string;
|
||||
status: string;
|
||||
version_no: number;
|
||||
assignee_user_id: number;
|
||||
due_at: string;
|
||||
}[];
|
||||
};
|
||||
|
||||
function Result({ result }: { result: PathResult }) {
|
||||
try {
|
||||
const values = recoverPathResult(result);
|
||||
return (
|
||||
<li className="space-y-1 rounded border p-3">
|
||||
<p>
|
||||
Resultado financeiro ·{' '}
|
||||
{result.currency ?? 'moeda por indicar'}
|
||||
</p>
|
||||
<p>
|
||||
Ponto de equilíbrio:{' '}
|
||||
{values.breakEven.value?.breakEvenUnits ??
|
||||
values.breakEven.error}{' '}
|
||||
unidades
|
||||
</p>
|
||||
<p>
|
||||
Necessidade de financiamento:{' '}
|
||||
{values.funding.value?.gap ?? values.funding.error}
|
||||
</p>
|
||||
<p className="text-sm">
|
||||
Estimativa recalculada pelas fórmulas da ferramenta a partir
|
||||
das entradas guardadas, versão {result.draft_version}. Não
|
||||
constitui decisão de financiamento.
|
||||
</p>
|
||||
<p className="text-xs break-all">
|
||||
Evidência {result.id} · {result.engine}
|
||||
</p>
|
||||
</li>
|
||||
);
|
||||
} catch (error) {
|
||||
return (
|
||||
<li role="alert">
|
||||
{error instanceof Error
|
||||
? error.message
|
||||
: 'Resultado indisponível'}
|
||||
</li>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function Stage({ step, path }: { step: Step; path: Path }) {
|
||||
const form = useForm({
|
||||
version: path.case.version,
|
||||
state: path.canWrite ? 'preparing' : 'reviewing',
|
||||
action: path.canWrite ? 'prepare' : 'review',
|
||||
reason: '',
|
||||
document_id: '',
|
||||
authority: '',
|
||||
reference: '',
|
||||
decision_date: '',
|
||||
});
|
||||
const ownerStates = [
|
||||
'not_started',
|
||||
'preparing',
|
||||
'ready_to_submit',
|
||||
'submitted',
|
||||
'waiting_external',
|
||||
'completed',
|
||||
];
|
||||
const reviewStates = [
|
||||
'reviewing',
|
||||
'correction_required',
|
||||
'approved',
|
||||
'rejected',
|
||||
'expired',
|
||||
];
|
||||
const states = path.canWrite ? ownerStates : reviewStates;
|
||||
return (
|
||||
<article id={step.code} className="space-y-3 rounded-xl border p-4">
|
||||
<h3 className="font-semibold">
|
||||
{step.code} · {step.title}
|
||||
</h3>
|
||||
<p>{pathStates[step.state]}</p>
|
||||
{step.reason && (
|
||||
<p className="text-sm">Fundamento: {step.reason}</p>
|
||||
)}
|
||||
{step.applicability === 'undetermined' && (
|
||||
<p className="text-sm">
|
||||
Aplicabilidade por determinar. A preparação pode avançar.
|
||||
</p>
|
||||
)}
|
||||
{step.state === 'dispensed' && (
|
||||
<p className="text-sm">
|
||||
Dispensa apenas de preparação deste ramo; não é dispensa
|
||||
legal. O estado anterior e o histórico foram preservados.
|
||||
</p>
|
||||
)}
|
||||
{Object.entries(step.action_gaps)
|
||||
.filter(([, gaps]) => gaps.length)
|
||||
.map(([action, gaps]) => (
|
||||
<p key={action} className="text-sm">
|
||||
{action === 'submit'
|
||||
? 'Submissão'
|
||||
: action === 'operate'
|
||||
? 'Operação'
|
||||
: 'Execução'}{' '}
|
||||
aguarda {gaps.join(', ')}. Pode continuar a preparar.
|
||||
</p>
|
||||
))}
|
||||
<p className="text-xs">
|
||||
Documento original, parágrafo {step.source_paragraph}.{' '}
|
||||
{step.detail.scope === 'internal_validation'
|
||||
? 'Conferência interna; não equivale a decisão externa.'
|
||||
: step.detail.scope === 'external_document_recorded'
|
||||
? 'Acto externo registado a partir de documento.'
|
||||
: 'Preparação declarada pelo promotor.'}
|
||||
</p>
|
||||
{step.preparation_allowed && (path.canWrite || path.canReview) && (
|
||||
<details>
|
||||
<summary className="cursor-pointer underline">
|
||||
Registar avanço ou pendência
|
||||
</summary>
|
||||
<form
|
||||
className="mt-3 grid gap-3"
|
||||
onSubmit={(event) => {
|
||||
event.preventDefault();
|
||||
form.transform((data) => ({
|
||||
...data,
|
||||
version: path.case.version,
|
||||
document_id: data.document_id || null,
|
||||
decision_date: data.decision_date || null,
|
||||
}));
|
||||
form.post(
|
||||
`/investimentos/${path.case.id}/etapas/${step.code}`,
|
||||
{ preserveScroll: true },
|
||||
);
|
||||
}}
|
||||
>
|
||||
<label className="grid gap-1">
|
||||
Estado
|
||||
<select
|
||||
className="rounded border p-2"
|
||||
value={form.data.state}
|
||||
onChange={(e) =>
|
||||
form.setData('state', e.target.value)
|
||||
}
|
||||
>
|
||||
{states.map((state) => (
|
||||
<option key={state} value={state}>
|
||||
{pathStates[state]}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
<label className="grid gap-1">
|
||||
Acção
|
||||
<select
|
||||
className="rounded border p-2"
|
||||
value={form.data.action}
|
||||
onChange={(e) =>
|
||||
form.setData('action', e.target.value)
|
||||
}
|
||||
>
|
||||
{(path.canWrite
|
||||
? [
|
||||
['prepare', 'Preparar'],
|
||||
['submit', 'Registar submissão'],
|
||||
['execute', 'Executar'],
|
||||
['operate', 'Operar'],
|
||||
]
|
||||
: [
|
||||
['review', 'Conferência interna'],
|
||||
[
|
||||
'record_external',
|
||||
'Registar acto externo',
|
||||
],
|
||||
]
|
||||
).map(([value, label]) => (
|
||||
<option key={value} value={value}>
|
||||
{label}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
<label className="grid gap-1">
|
||||
Fundamento
|
||||
<textarea
|
||||
required
|
||||
minLength={3}
|
||||
maxLength={3000}
|
||||
className="rounded border p-2"
|
||||
value={form.data.reason}
|
||||
onChange={(e) =>
|
||||
form.setData('reason', e.target.value)
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
<label className="grid gap-1">
|
||||
Referência de submissão ou decisão
|
||||
<input
|
||||
className="rounded border p-2"
|
||||
value={form.data.reference}
|
||||
onChange={(e) =>
|
||||
form.setData('reference', e.target.value)
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
{path.canReview && (
|
||||
<>
|
||||
<label className="grid gap-1">
|
||||
Documento de suporte
|
||||
<select
|
||||
className="rounded border p-2"
|
||||
value={form.data.document_id}
|
||||
onChange={(e) =>
|
||||
form.setData(
|
||||
'document_id',
|
||||
e.target.value,
|
||||
)
|
||||
}
|
||||
>
|
||||
<option value="">Seleccionar</option>
|
||||
{path.documents.map((doc) => (
|
||||
<option
|
||||
key={doc.id}
|
||||
value={doc.document_id}
|
||||
>
|
||||
{doc.file_name} ·{' '}
|
||||
{doc.malware_scan_status}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
<label className="grid gap-1">
|
||||
Entidade externa
|
||||
<input
|
||||
className="rounded border p-2"
|
||||
value={form.data.authority}
|
||||
onChange={(e) =>
|
||||
form.setData(
|
||||
'authority',
|
||||
e.target.value,
|
||||
)
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
<label className="grid gap-1">
|
||||
Data do acto
|
||||
<input
|
||||
type="date"
|
||||
className="rounded border p-2"
|
||||
value={form.data.decision_date}
|
||||
onChange={(e) =>
|
||||
form.setData(
|
||||
'decision_date',
|
||||
e.target.value,
|
||||
)
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
</>
|
||||
)}
|
||||
{Object.values(form.errors).map((error, i) => (
|
||||
<p key={i} role="alert">
|
||||
{error}
|
||||
</p>
|
||||
))}
|
||||
<button
|
||||
disabled={form.processing}
|
||||
className="rounded border p-2"
|
||||
>
|
||||
Guardar registo
|
||||
</button>
|
||||
</form>
|
||||
</details>
|
||||
)}
|
||||
</article>
|
||||
);
|
||||
}
|
||||
|
||||
export default function InvestmentPath(path: Path) {
|
||||
const { auth, flash } = usePage<{
|
||||
auth: { user: { id: number } };
|
||||
flash: { success?: string };
|
||||
}>().props;
|
||||
const facts = useForm({
|
||||
version: path.case.version,
|
||||
...path.facts,
|
||||
reason: '',
|
||||
});
|
||||
const task = useForm({
|
||||
version: path.case.version,
|
||||
code: 'S02',
|
||||
title: '',
|
||||
due_at: '',
|
||||
consent: false,
|
||||
});
|
||||
const [service, setService] = useState(path.services[0]?.id ?? '');
|
||||
const [requestKey] = useState(() => crypto.randomUUID());
|
||||
const [taskReason, setTaskReason] = useState('');
|
||||
const [error, setError] = useState('');
|
||||
function support() {
|
||||
router.post(
|
||||
`/balcao-virtual/dossiers/${path.case.id}/pedidos`,
|
||||
{ service_version_id: service, client_key: requestKey },
|
||||
{ onError: (errors) => setError(Object.values(errors).join('; ')) },
|
||||
);
|
||||
}
|
||||
return (
|
||||
<main className="mx-auto max-w-6xl space-y-6 p-4 md:p-8">
|
||||
<Head title={path.case.title} />
|
||||
<Link className="underline" href="/investimentos">
|
||||
Os meus investimentos
|
||||
</Link>
|
||||
<h1 className="text-2xl font-semibold">{path.case.title}</h1>
|
||||
{flash?.success && <output>{flash.success}</output>}
|
||||
{error && <p role="alert">{error}</p>}
|
||||
<section className="rounded-xl border p-4">
|
||||
<h2 className="font-semibold">Próxima acção</h2>
|
||||
{path.next ? (
|
||||
<a className="underline" href={path.next.href}>
|
||||
{path.next.action}: {path.next.code} · {path.next.title}
|
||||
</a>
|
||||
) : (
|
||||
<p>Reveja as pendências e o acompanhamento.</p>
|
||||
)}
|
||||
<p className="text-sm">
|
||||
Pode preparar etapas independentes enquanto aguarda
|
||||
informação. Percurso v{path.definition_version}; os outros
|
||||
roteiros mantêm a numeração original.
|
||||
</p>
|
||||
</section>
|
||||
<nav
|
||||
className="flex flex-wrap gap-4"
|
||||
aria-label="Ferramentas do investimento"
|
||||
>
|
||||
{Object.entries(path.tools)
|
||||
.filter(([key, url]) => url && key !== 'guidance')
|
||||
.map(([key, url]) => (
|
||||
<Link className="underline" key={key} href={url!}>
|
||||
{
|
||||
(
|
||||
{
|
||||
simulator: 'Plano e simulador',
|
||||
desk: 'Balcão e histórico',
|
||||
library: 'Biblioteca',
|
||||
opportunities: 'Oportunidades',
|
||||
territory: 'Território e mapas',
|
||||
partners: 'Parcerias',
|
||||
} as Record<string, string>
|
||||
)[key]
|
||||
}
|
||||
</Link>
|
||||
))}
|
||||
</nav>
|
||||
{path.canWrite && (
|
||||
<form
|
||||
className="grid gap-3 rounded-xl border p-4 sm:grid-cols-2"
|
||||
onSubmit={(event) => {
|
||||
event.preventDefault();
|
||||
facts.transform((data) => ({
|
||||
...data,
|
||||
version: path.case.version,
|
||||
}));
|
||||
facts.post(
|
||||
`/investimentos/${path.case.id}/aplicabilidade`,
|
||||
{ preserveScroll: true },
|
||||
);
|
||||
}}
|
||||
>
|
||||
<h2 className="font-semibold sm:col-span-2">
|
||||
Decisões do promotor e aplicabilidade
|
||||
</h2>
|
||||
{(
|
||||
[
|
||||
['land_needed', 'Precisa de terra?'],
|
||||
[
|
||||
'external_funding',
|
||||
'Precisa de financiamento externo?',
|
||||
],
|
||||
] as const
|
||||
).map(([key, label]) => (
|
||||
<label className="grid gap-1" key={key}>
|
||||
{label}
|
||||
<select
|
||||
className="rounded border p-2"
|
||||
value={facts.data[key]}
|
||||
onChange={(e) =>
|
||||
facts.setData(key, e.target.value)
|
||||
}
|
||||
>
|
||||
<option value="unknown">Por determinar</option>
|
||||
<option value="yes">Sim</option>
|
||||
<option value="no">Não</option>
|
||||
</select>
|
||||
</label>
|
||||
))}
|
||||
<label className="grid gap-1">
|
||||
Decisão sobre viabilidade
|
||||
<select
|
||||
className="rounded border p-2"
|
||||
value={facts.data.viability}
|
||||
onChange={(e) =>
|
||||
facts.setData('viability', e.target.value)
|
||||
}
|
||||
>
|
||||
<option value="unknown">Por determinar</option>
|
||||
<option value="proceed">Prosseguir</option>
|
||||
<option value="reformulate">Reformular</option>
|
||||
<option value="archive">Arquivar a ideia</option>
|
||||
</select>
|
||||
</label>
|
||||
<label className="grid gap-1">
|
||||
Fundamento
|
||||
<textarea
|
||||
required
|
||||
minLength={3}
|
||||
className="rounded border p-2"
|
||||
value={facts.data.reason}
|
||||
onChange={(e) =>
|
||||
facts.setData('reason', e.target.value)
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
{Object.values(facts.errors).map((message, i) => (
|
||||
<p key={i} role="alert">
|
||||
{message}
|
||||
</p>
|
||||
))}
|
||||
<button
|
||||
disabled={facts.processing}
|
||||
className="rounded border p-2"
|
||||
>
|
||||
Guardar decisões
|
||||
</button>
|
||||
</form>
|
||||
)}
|
||||
{Object.entries(path.phases).map(([number, label]) => (
|
||||
<section className="space-y-3" key={number}>
|
||||
<h2 className="text-lg font-semibold">
|
||||
Fase {number} · {label}
|
||||
</h2>
|
||||
<div className="grid items-start gap-3 md:grid-cols-2">
|
||||
{path.steps
|
||||
.filter((step) => step.phase === Number(number))
|
||||
.map((step) => (
|
||||
<Stage
|
||||
key={step.code}
|
||||
step={step}
|
||||
path={path}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
</section>
|
||||
))}
|
||||
<section className="space-y-3">
|
||||
<h2 className="text-lg font-semibold">
|
||||
Resultados devolvidos ao dossier
|
||||
</h2>
|
||||
<ul className="grid gap-3 md:grid-cols-2">
|
||||
{path.results.map((result) => (
|
||||
<Result key={result.id} result={result} />
|
||||
))}
|
||||
</ul>
|
||||
{!path.results.length && (
|
||||
<p>
|
||||
Nenhum resultado financeiro disponível para esta conta
|
||||
neste dossier.
|
||||
</p>
|
||||
)}
|
||||
</section>
|
||||
<section className="space-y-3 rounded-xl border p-4">
|
||||
<h2 className="text-lg font-semibold">Apoio no Balcão</h2>
|
||||
{path.canWrite && (
|
||||
<>
|
||||
<label className="grid gap-1">
|
||||
Serviço
|
||||
<select
|
||||
className="rounded border p-2"
|
||||
value={service}
|
||||
onChange={(e) => setService(e.target.value)}
|
||||
>
|
||||
{path.services.map((item) => (
|
||||
<option key={item.id} value={item.id}>
|
||||
{item.title}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
<button
|
||||
disabled={!service}
|
||||
className="rounded border p-2"
|
||||
onClick={support}
|
||||
>
|
||||
Preparar pedido com dados do dossier
|
||||
</button>
|
||||
<p className="text-sm">
|
||||
Cria um rascunho; reveja os dados no Balcão antes de
|
||||
submeter.
|
||||
</p>
|
||||
</>
|
||||
)}
|
||||
<ul>
|
||||
{path.requests.map((item) => (
|
||||
<li key={item.id}>
|
||||
<Link
|
||||
className="underline"
|
||||
href={`/balcao-virtual/pedidos/${item.id}`}
|
||||
>
|
||||
{item.protocol ?? 'Rascunho'} · {item.status}
|
||||
</Link>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</section>
|
||||
<section className="space-y-3 rounded-xl border p-4">
|
||||
<h2 className="text-lg font-semibold">Documentos</h2>
|
||||
<ul>
|
||||
{path.documents.map((doc) => (
|
||||
<li key={doc.id}>
|
||||
<Link
|
||||
className="underline"
|
||||
href={`/balcao-virtual/dossiers/${path.case.id}/documentos/${doc.id}`}
|
||||
>
|
||||
{doc.file_name}
|
||||
</Link>{' '}
|
||||
· {doc.status} · {doc.malware_scan_status}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
<Link className="underline" href={path.tools.desk!}>
|
||||
Anexar ou conferir no Balcão
|
||||
</Link>
|
||||
</section>
|
||||
<section className="space-y-3 rounded-xl border p-4">
|
||||
<h2 className="text-lg font-semibold">
|
||||
Acompanhamento interno
|
||||
</h2>
|
||||
{path.canWrite && (
|
||||
<form
|
||||
className="grid gap-3"
|
||||
onSubmit={(event) => {
|
||||
event.preventDefault();
|
||||
task.transform((data) => ({
|
||||
...data,
|
||||
version: path.case.version,
|
||||
}));
|
||||
task.post(
|
||||
`/investimentos/${path.case.id}/tarefas`,
|
||||
{ preserveScroll: true },
|
||||
);
|
||||
}}
|
||||
>
|
||||
<label className="grid gap-1">
|
||||
Etapa
|
||||
<select
|
||||
className="rounded border p-2"
|
||||
value={task.data.code}
|
||||
onChange={(e) =>
|
||||
task.setData('code', e.target.value)
|
||||
}
|
||||
>
|
||||
{path.steps
|
||||
.filter((step) => step.preparation_allowed)
|
||||
.map((step) => (
|
||||
<option
|
||||
key={step.code}
|
||||
value={step.code}
|
||||
>
|
||||
{step.code} · {step.title}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
<label className="grid gap-1">
|
||||
Tarefa
|
||||
<input
|
||||
required
|
||||
className="rounded border p-2"
|
||||
value={task.data.title}
|
||||
onChange={(e) =>
|
||||
task.setData('title', e.target.value)
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
<label className="grid gap-1">
|
||||
Prazo
|
||||
<input
|
||||
required
|
||||
type="datetime-local"
|
||||
className="rounded border p-2"
|
||||
value={task.data.due_at}
|
||||
onChange={(e) =>
|
||||
task.setData('due_at', e.target.value)
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
<label className="flex gap-2">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={task.data.consent}
|
||||
onChange={(e) =>
|
||||
task.setData('consent', e.target.checked)
|
||||
}
|
||||
/>
|
||||
Assumo esta tarefa no acompanhamento interno.
|
||||
</label>
|
||||
{Object.values(task.errors).map((message, i) => (
|
||||
<p key={i} role="alert">
|
||||
{message}
|
||||
</p>
|
||||
))}
|
||||
<button
|
||||
disabled={task.processing}
|
||||
className="rounded border p-2"
|
||||
>
|
||||
Guardar tarefa
|
||||
</button>
|
||||
</form>
|
||||
)}
|
||||
<label className="grid gap-1">
|
||||
Fundamento do resultado ou atribuição
|
||||
<input
|
||||
className="rounded border p-2"
|
||||
value={taskReason}
|
||||
onChange={(e) => setTaskReason(e.target.value)}
|
||||
/>
|
||||
</label>
|
||||
<ul className="space-y-2">
|
||||
{path.tasks.map((item) => (
|
||||
<li className="rounded border p-3" key={item.id}>
|
||||
{item.title} · {item.status} · prazo{' '}
|
||||
{new Date(item.due_at).toLocaleString('pt-MZ')}
|
||||
{(item.assignee_user_id === auth.user.id ||
|
||||
path.canReview) && (
|
||||
<div className="mt-2 flex flex-wrap gap-3">
|
||||
{['in_progress', 'done'].map((status) => (
|
||||
<button
|
||||
key={status}
|
||||
disabled={
|
||||
taskReason.trim().length < 3
|
||||
}
|
||||
className="rounded border p-2"
|
||||
onClick={() =>
|
||||
router.post(
|
||||
`/balcao-virtual/dossiers/${path.case.id}/tarefas/${item.id}`,
|
||||
{
|
||||
version:
|
||||
item.version_no,
|
||||
status,
|
||||
reason: taskReason,
|
||||
},
|
||||
{
|
||||
preserveScroll: true,
|
||||
onError: (errors) =>
|
||||
setError(
|
||||
Object.values(
|
||||
errors,
|
||||
).join('; '),
|
||||
),
|
||||
},
|
||||
)
|
||||
}
|
||||
>
|
||||
{status === 'done'
|
||||
? 'Registar conclusão'
|
||||
: 'Iniciar tarefa'}
|
||||
</button>
|
||||
))}
|
||||
{path.canReview && (
|
||||
<button
|
||||
disabled={
|
||||
taskReason.trim().length < 3
|
||||
}
|
||||
className="rounded border p-2"
|
||||
onClick={() =>
|
||||
router.post(
|
||||
`/balcao-virtual/dossiers/${path.case.id}/tarefas/${item.id}`,
|
||||
{
|
||||
version:
|
||||
item.version_no,
|
||||
status: item.status,
|
||||
assignee_user_id:
|
||||
auth.user.id,
|
||||
reason: taskReason,
|
||||
},
|
||||
{ preserveScroll: true },
|
||||
)
|
||||
}
|
||||
>
|
||||
Assumir acompanhamento
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</section>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user