feat: consolidar desenvolvimentos do portal InvestMoz
This commit is contained in:
@@ -344,9 +344,11 @@ function InternalStaffGrant({
|
||||
function Grant({
|
||||
types,
|
||||
organizations,
|
||||
technicalSupportAvailable = false,
|
||||
}: {
|
||||
types: string[];
|
||||
organizations: { id: string; name: string }[];
|
||||
technicalSupportAvailable?: boolean;
|
||||
}) {
|
||||
const [user, setUser] = useState('');
|
||||
const [role, setRole] = useState('validator');
|
||||
@@ -436,8 +438,27 @@ function Grant({
|
||||
setResponsibilities([]);
|
||||
}}
|
||||
>
|
||||
{['validator', 'publisher', 'auditor'].map((v) => (
|
||||
<option key={v}>{v}</option>
|
||||
{[
|
||||
'validator',
|
||||
'publisher',
|
||||
'auditor',
|
||||
...(technicalSupportAvailable
|
||||
? ['technical_support']
|
||||
: []),
|
||||
].map((v) => (
|
||||
<option key={v} value={v}>
|
||||
{
|
||||
(
|
||||
{
|
||||
validator: 'Validador',
|
||||
publisher: 'Publicador',
|
||||
auditor: 'Auditor',
|
||||
technical_support:
|
||||
'Suporte técnico',
|
||||
} as Record<string, string>
|
||||
)[v]
|
||||
}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
@@ -839,7 +860,9 @@ export default function Administration({
|
||||
operatorOrganizations,
|
||||
internalTypes,
|
||||
staffAccounts,
|
||||
technicalSupportAvailable = false,
|
||||
}: {
|
||||
technicalSupportAvailable?: boolean;
|
||||
operatorOrganizations: OperatorOrganization[];
|
||||
internalTypes: string[];
|
||||
staffAccounts: {
|
||||
@@ -920,7 +943,11 @@ export default function Administration({
|
||||
organizations={organizations}
|
||||
operators={operatorOrganizations}
|
||||
/>
|
||||
<Grant types={types} organizations={organizations} />
|
||||
<Grant
|
||||
types={types}
|
||||
organizations={organizations}
|
||||
technicalSupportAvailable={technicalSupportAvailable}
|
||||
/>
|
||||
<Security
|
||||
pair={pair}
|
||||
entries={securityRequests}
|
||||
|
||||
@@ -2,8 +2,11 @@ import { createOperationKey } from '@/lib/operation-key';
|
||||
import { useState } from 'react';
|
||||
import { Management, button, control } from '@/pages/management/shared';
|
||||
import { profileJson } from '@/lib/profile-json';
|
||||
import { Link } from '@inertiajs/react';
|
||||
import { usePagePreparationGuard } from '@/lib/page-preparation-guard';
|
||||
|
||||
type Plan = {
|
||||
technicalSupportUpdateUrl?: string;
|
||||
installed: boolean;
|
||||
consistent: boolean;
|
||||
ready: boolean;
|
||||
@@ -36,6 +39,18 @@ export default function Installation(initial: Plan) {
|
||||
const [confirmationUrl, setConfirmationUrl] = useState<string | null>(null);
|
||||
const [installationKey] = useState(createOperationKey);
|
||||
const [bootstrapKey] = useState(createOperationKey);
|
||||
const [confirmedPreparation, setConfirmedPreparation] = useState({
|
||||
reason: '',
|
||||
first: '',
|
||||
second: '',
|
||||
});
|
||||
usePagePreparationGuard(
|
||||
busy ||
|
||||
reason !== confirmedPreparation.reason ||
|
||||
first !== confirmedPreparation.first ||
|
||||
second !== confirmedPreparation.second,
|
||||
'Existe uma preparação ou uma operação de perfis em curso. Sair desta página?',
|
||||
);
|
||||
async function run(bootstrap = false) {
|
||||
setBusy(true);
|
||||
setMessage('');
|
||||
@@ -55,6 +70,11 @@ export default function Installation(initial: Plan) {
|
||||
: {}),
|
||||
},
|
||||
);
|
||||
setConfirmedPreparation((previous) => ({
|
||||
...previous,
|
||||
reason,
|
||||
...(bootstrap ? { first, second } : {}),
|
||||
}));
|
||||
setMessage(
|
||||
bootstrap
|
||||
? 'Pedido registado, sem atribuir privilégios. O segundo titular deve autenticar-se com MFA e confirmar pelo endereço abaixo.'
|
||||
@@ -85,6 +105,14 @@ export default function Installation(initial: Plan) {
|
||||
}
|
||||
return (
|
||||
<Management title="Instalação dos perfis — 040000">
|
||||
{plan.technicalSupportUpdateUrl && (
|
||||
<Link
|
||||
className="underline"
|
||||
href={plan.technicalSupportUpdateUrl}
|
||||
>
|
||||
Actualização do Suporte técnico
|
||||
</Link>
|
||||
)}
|
||||
<p>
|
||||
Base {plan.target.database}:{plan.target.port} ·{' '}
|
||||
{plan.installed ? 'Schema instalado' : 'Schema por instalar'}
|
||||
|
||||
@@ -0,0 +1,170 @@
|
||||
import { Link } from '@inertiajs/react';
|
||||
import { Management, button, control } from '../management/shared';
|
||||
import {
|
||||
useProfileSupportInstallation,
|
||||
type SupportPlan,
|
||||
} from '@/lib/profile-support-installation';
|
||||
function SupportInstallationForm({ initial }: { initial: SupportPlan }) {
|
||||
const edit = useProfileSupportInstallation(initial),
|
||||
plan = edit.plan;
|
||||
return (
|
||||
<section className="space-y-4">
|
||||
<p>
|
||||
Destino: {plan.target.database}:{plan.target.port}
|
||||
</p>
|
||||
<p>
|
||||
{plan.installed
|
||||
? 'Suporte técnico actualizado'
|
||||
: plan.repairable
|
||||
? 'Migração registada com a restrição anterior; reposição delimitada disponível.'
|
||||
: 'Actualização do Suporte técnico por aplicar'}
|
||||
</p>
|
||||
<p>
|
||||
{plan.ready
|
||||
? 'Provas actuais verificadas.'
|
||||
: 'Dependências ou provas por completar.'}{' '}
|
||||
Backup/restauro: {plan.backupDate ?? 'Prova actual pendente'}
|
||||
</p>
|
||||
{!plan.mfa_confirmed && (
|
||||
<p role="alert">
|
||||
Renove a autenticação MFA nesta conta antes de aplicar a
|
||||
actualização.
|
||||
</p>
|
||||
)}
|
||||
{!plan.consistent && !plan.repairable && (
|
||||
<p role="alert">
|
||||
A estrutura não corresponde à versão reconhecida. Preserve
|
||||
os dados e reconcilie a divergência antes de instalar.
|
||||
</p>
|
||||
)}
|
||||
<ul>
|
||||
{Object.entries(plan.dependencies).map(([name, ok]) => (
|
||||
<li key={name}>
|
||||
{(
|
||||
{
|
||||
profiles_installed: 'Base dos perfis instalada',
|
||||
profiles_consistent:
|
||||
'Base dos perfis consistente',
|
||||
management_020000: 'Gestão de oportunidades',
|
||||
resources_030000: 'Recursos das oportunidades',
|
||||
existing_identity_organization_audit:
|
||||
'Identidades, organizações e auditoria',
|
||||
} as Record<string, string>
|
||||
)[name] ?? 'Dependência da instalação'}
|
||||
: {ok ? 'presente' : 'pendente'}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
<ul>
|
||||
{plan.changes.map((change) => (
|
||||
<li key={change}>{change}</li>
|
||||
))}
|
||||
</ul>
|
||||
<p>{plan.rollback}</p>
|
||||
{edit.stale && (
|
||||
<section
|
||||
className="space-y-2 rounded border p-3"
|
||||
aria-label="Comparar prévia da actualização"
|
||||
>
|
||||
<h2 className="font-semibold">A prévia mudou</h2>
|
||||
<p>
|
||||
Anterior:{' '}
|
||||
{edit.base.installed ? 'Actualizado' : 'Por actualizar'}{' '}
|
||||
·{' '}
|
||||
{edit.base.ready
|
||||
? 'Provas verificadas'
|
||||
: 'Provas pendentes'}{' '}
|
||||
· {edit.base.backupDate ?? 'Sem prova actual'}
|
||||
</p>
|
||||
<p>
|
||||
Actual:{' '}
|
||||
{plan.installed ? 'Actualizado' : 'Por actualizar'} ·{' '}
|
||||
{plan.ready ? 'Provas verificadas' : 'Provas pendentes'}{' '}
|
||||
· {plan.backupDate ?? 'Sem prova actual'}
|
||||
</p>
|
||||
<p>
|
||||
Confira novamente o destino, a estrutura e as alterações
|
||||
indicadas antes de confirmar.
|
||||
</p>
|
||||
<button
|
||||
type="button"
|
||||
className={button}
|
||||
disabled={!edit.canAdopt}
|
||||
onClick={edit.adopt}
|
||||
>
|
||||
Confirmar leitura da prévia actual
|
||||
</button>
|
||||
</section>
|
||||
)}
|
||||
<label className="block">
|
||||
Fundamento da actualização
|
||||
<textarea
|
||||
className={control}
|
||||
minLength={20}
|
||||
maxLength={1000}
|
||||
value={edit.reason}
|
||||
onChange={(event) => edit.change(event.target.value)}
|
||||
/>
|
||||
</label>
|
||||
<label className="block">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={edit.confirmed}
|
||||
disabled={edit.busy || edit.uncertain}
|
||||
onChange={(event) =>
|
||||
edit.setConfirmed(event.target.checked)
|
||||
}
|
||||
/>{' '}
|
||||
Confirmo esta actualização no destino indicado
|
||||
</label>
|
||||
{edit.uncertain && (
|
||||
<p>
|
||||
O envio original aguarda confirmação. A repetição conserva o
|
||||
plano, o fundamento e a confirmação originais.
|
||||
</p>
|
||||
)}
|
||||
<div className="flex flex-wrap gap-3">
|
||||
<button
|
||||
type="button"
|
||||
className={button}
|
||||
disabled={!edit.canSend}
|
||||
onClick={() => void edit.send()}
|
||||
>
|
||||
Aplicar actualização do Suporte técnico
|
||||
</button>
|
||||
{edit.canRetry && (
|
||||
<button
|
||||
type="button"
|
||||
className={button}
|
||||
onClick={() => void edit.send(true)}
|
||||
>
|
||||
Repetir envio original
|
||||
</button>
|
||||
)}
|
||||
<button
|
||||
type="button"
|
||||
className={button}
|
||||
disabled={edit.refreshing}
|
||||
onClick={() => void edit.refresh()}
|
||||
>
|
||||
Actualizar prévia
|
||||
</button>
|
||||
</div>
|
||||
{edit.message && <p role="status">{edit.message}</p>}
|
||||
{edit.error && <p role="alert">{edit.error}</p>}
|
||||
</section>
|
||||
);
|
||||
}
|
||||
export default function SupportInstallation(plan: SupportPlan) {
|
||||
return (
|
||||
<Management title="Actualizar Suporte técnico">
|
||||
<Link className="underline" href="/management/profile-install">
|
||||
Voltar à instalação dos perfis
|
||||
</Link>
|
||||
<SupportInstallationForm
|
||||
key={`${plan.actorId}:${plan.target.database}:${plan.target.port}`}
|
||||
initial={plan}
|
||||
/>
|
||||
</Management>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
import { Link } from '@inertiajs/react';
|
||||
import TechnicalIncidentHandling from '@/components/technical-incident-handling';
|
||||
import TechnicalIncidentNotice from '@/components/technical-incident-notice';
|
||||
import {
|
||||
handlingLabels,
|
||||
commandLabels,
|
||||
incidentOperationLabel,
|
||||
incidentErrorLabel,
|
||||
} from '@/lib/technical-incident-labels';
|
||||
import type { HandlingProps, Command } from '@/lib/technical-incident-handling';
|
||||
import { Management, Pagination, type Paginated } from '../management/shared';
|
||||
export default function TechnicalIncident(
|
||||
props: HandlingProps & {
|
||||
backUrl: string;
|
||||
notice?: { unread: boolean };
|
||||
history: Paginated<{
|
||||
id: string;
|
||||
version: number | null;
|
||||
action: Command | null;
|
||||
status: string | null;
|
||||
actor: string | null;
|
||||
occurred_at: string;
|
||||
note: string | null;
|
||||
note_available: boolean;
|
||||
}>;
|
||||
},
|
||||
) {
|
||||
const row = props.incident;
|
||||
return (
|
||||
<Management title="Tratamento de incidente técnico">
|
||||
<Link className="underline" href={props.backUrl}>
|
||||
Voltar à fila de suporte
|
||||
</Link>
|
||||
<section className="space-y-2 rounded border p-4">
|
||||
<h2 className="font-semibold">
|
||||
{incidentOperationLabel(row.operation)} · versão observada{' '}
|
||||
{row.observed_version}
|
||||
</h2>
|
||||
<p className="break-all">Referência: {row.reference}</p>
|
||||
<p>{row.occurred_at}</p>
|
||||
<p>{incidentErrorLabel(row.error_code)}</p>
|
||||
<p>Estado técnico: {handlingLabels[row.handling.status]}</p>
|
||||
<p>
|
||||
Responsável actual:{' '}
|
||||
{row.handling.assignee_name || 'Por assumir'}
|
||||
</p>
|
||||
</section>
|
||||
{props.notice && (
|
||||
<TechnicalIncidentNotice
|
||||
key={`notice:${props.actorId}:${row.reference}`}
|
||||
actorId={props.actorId}
|
||||
reference={row.reference}
|
||||
unread={props.notice.unread}
|
||||
/>
|
||||
)}
|
||||
<TechnicalIncidentHandling
|
||||
key={`${props.actorId}:${row.reference}`}
|
||||
{...props}
|
||||
/>
|
||||
<section className="space-y-3" aria-label="Histórico do tratamento">
|
||||
<h2 className="text-xl font-semibold">
|
||||
Histórico do tratamento
|
||||
</h2>
|
||||
{!props.history.data.length && <p>Sem tratamento registado.</p>}
|
||||
{props.history.data.map((entry) => (
|
||||
<article
|
||||
className="space-y-2 rounded border p-4"
|
||||
key={entry.id}
|
||||
>
|
||||
<h3 className="font-semibold">
|
||||
Versão {entry.version ?? 'não identificada'} ·{' '}
|
||||
{entry.action
|
||||
? commandLabels[entry.action]
|
||||
: 'Registo anterior'}
|
||||
</h3>
|
||||
<p>
|
||||
{entry.actor || 'Autor não identificado'} ·{' '}
|
||||
{entry.occurred_at}
|
||||
</p>
|
||||
<p>
|
||||
Estado:{' '}
|
||||
{entry.status
|
||||
? handlingLabels[entry.status] ||
|
||||
'Não identificado'
|
||||
: 'Não identificado'}
|
||||
</p>
|
||||
<p className="break-words whitespace-pre-wrap">
|
||||
{entry.note_available
|
||||
? entry.note
|
||||
: 'Nota indisponível para leitura; original preservado.'}
|
||||
</p>
|
||||
</article>
|
||||
))}
|
||||
<Pagination page={props.history} />
|
||||
</section>
|
||||
</Management>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
import { Management, Pagination, type Paginated } from '../management/shared';
|
||||
import type { OpportunityTechnicalIncident } from '@/components/opportunity-technical-incidents';
|
||||
import { Link } from '@inertiajs/react';
|
||||
import {
|
||||
handlingLabels,
|
||||
incidentOperationLabel,
|
||||
incidentErrorLabel,
|
||||
} from '@/lib/technical-incident-labels';
|
||||
import type { HandlingState } from '@/lib/technical-incident-handling';
|
||||
import TechnicalIncidentNotice from '@/components/technical-incident-notice';
|
||||
export default function TechnicalSupport({
|
||||
incidents,
|
||||
actorId,
|
||||
filters = { status: 'all' },
|
||||
}: {
|
||||
actorId?: number;
|
||||
incidents: Paginated<
|
||||
OpportunityTechnicalIncident & {
|
||||
handling?: HandlingState | null;
|
||||
details_url?: string;
|
||||
unread?: boolean;
|
||||
}
|
||||
>;
|
||||
filters?: { status: string; unread?: boolean };
|
||||
}) {
|
||||
function href(status: string, unread = !!filters.unread) {
|
||||
const query = new URLSearchParams({
|
||||
...(status !== 'all' ? { status } : {}),
|
||||
...(unread ? { unread: '1' } : {}),
|
||||
}).toString();
|
||||
return '/suporte-tecnico/incidentes' + (query ? '?' + query : '');
|
||||
}
|
||||
return (
|
||||
<Management title="Suporte técnico — incidentes">
|
||||
<p>
|
||||
Incidentes de submissão, publicação, uploads e preparação de
|
||||
imagens nas organizações e tipos abrangidos pela sua atribuição
|
||||
actual. A fila apresenta metadados técnicos; o perfil de suporte
|
||||
não concede acesso aos processos ou documentos.
|
||||
</p>
|
||||
<nav
|
||||
aria-label="Filtrar por estado técnico"
|
||||
className="flex flex-wrap gap-4"
|
||||
>
|
||||
{Object.entries({ all: 'Todos', ...handlingLabels }).map(
|
||||
([value, label]) => (
|
||||
<Link
|
||||
key={value}
|
||||
className="underline"
|
||||
href={href(value)}
|
||||
aria-current={
|
||||
filters.status === value ? 'page' : undefined
|
||||
}
|
||||
>
|
||||
{label}
|
||||
</Link>
|
||||
),
|
||||
)}
|
||||
</nav>
|
||||
<nav
|
||||
aria-label="Filtrar avisos de suporte"
|
||||
className="flex flex-wrap gap-4"
|
||||
>
|
||||
<Link
|
||||
className="underline"
|
||||
href={href(filters.status, false)}
|
||||
aria-current={!filters.unread ? 'page' : undefined}
|
||||
>
|
||||
Todos os avisos
|
||||
</Link>
|
||||
<Link
|
||||
className="underline"
|
||||
href={href(filters.status, true)}
|
||||
aria-current={filters.unread ? 'page' : undefined}
|
||||
>
|
||||
Por consultar
|
||||
</Link>
|
||||
</nav>
|
||||
{!incidents.data.length && (
|
||||
<p>Não existem incidentes disponíveis neste âmbito.</p>
|
||||
)}
|
||||
{incidents.data.map((incident) => (
|
||||
<article
|
||||
key={incident.reference}
|
||||
className="space-y-2 rounded border p-4"
|
||||
>
|
||||
<h2 className="font-semibold">
|
||||
{incidentOperationLabel(incident.operation)} · versão
|
||||
observada {incident.version}
|
||||
</h2>
|
||||
<p>{incident.occurred_at}</p>
|
||||
<p>{incidentErrorLabel(incident.error_code)}</p>
|
||||
<p className="break-all">
|
||||
Referência: {incident.reference}
|
||||
</p>
|
||||
{actorId && typeof incident.unread === 'boolean' && (
|
||||
<TechnicalIncidentNotice
|
||||
key={`notice:${actorId}:${incident.reference}`}
|
||||
actorId={actorId}
|
||||
reference={incident.reference}
|
||||
unread={incident.unread}
|
||||
/>
|
||||
)}
|
||||
{incident.handling ? (
|
||||
<p>
|
||||
Estado técnico:{' '}
|
||||
{handlingLabels[incident.handling.status]} ·{' '}
|
||||
{incident.handling.assignee_name || 'Por assumir'}
|
||||
</p>
|
||||
) : (
|
||||
<p>
|
||||
Estado técnico indisponível; registos preservados.
|
||||
</p>
|
||||
)}
|
||||
{incident.details_url && (
|
||||
<Link
|
||||
className="underline"
|
||||
href={
|
||||
incident.details_url +
|
||||
(incidents.current_page > 1 ||
|
||||
filters.status !== 'all' ||
|
||||
filters.unread
|
||||
? '?' +
|
||||
new URLSearchParams({
|
||||
...(incidents.current_page > 1
|
||||
? {
|
||||
page: String(
|
||||
incidents.current_page,
|
||||
),
|
||||
}
|
||||
: {}),
|
||||
...(filters.status !== 'all'
|
||||
? { status: filters.status }
|
||||
: {}),
|
||||
...(filters.unread
|
||||
? { unread: '1' }
|
||||
: {}),
|
||||
}).toString()
|
||||
: '')
|
||||
}
|
||||
>
|
||||
Consultar e tratar incidente
|
||||
</Link>
|
||||
)}
|
||||
</article>
|
||||
))}
|
||||
<Pagination page={incidents} />
|
||||
</Management>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user