feat: consolidar desenvolvimentos do portal InvestMoz
This commit is contained in:
@@ -0,0 +1,199 @@
|
||||
import { Link } from '@inertiajs/react';
|
||||
import AgreementInstrument from '@/components/partnership-agreement-instrument';
|
||||
import { Frame, labels } from './shared';
|
||||
|
||||
type Availability =
|
||||
| 'available'
|
||||
| 'not_recorded'
|
||||
| 'scope_unknown'
|
||||
| 'restricted'
|
||||
| 'malformed';
|
||||
type Snapshot = {
|
||||
availability: Availability;
|
||||
version?: number;
|
||||
status?: string;
|
||||
instrument_availability?: Availability;
|
||||
instrument?: unknown;
|
||||
instrument_partnership_version?: number;
|
||||
instrument_interest_version?: number;
|
||||
};
|
||||
type Entry = {
|
||||
version: number | null;
|
||||
restricted: boolean;
|
||||
action: string | null;
|
||||
actor_name: string | null;
|
||||
occurred_at: string | null;
|
||||
reason: string | null;
|
||||
confirmation_party: string | null;
|
||||
partnership_version: number | null;
|
||||
interest_version: number | null;
|
||||
previous: Snapshot;
|
||||
after: Snapshot;
|
||||
};
|
||||
type Props = {
|
||||
room_id: number;
|
||||
entries: Entry[];
|
||||
first_url: string;
|
||||
next_url: string | null;
|
||||
older_page: boolean;
|
||||
room_href: string;
|
||||
dashboard_href: string;
|
||||
};
|
||||
const actions: Record<string, string> = {
|
||||
record: 'Registo de instrumento',
|
||||
confirm: 'Confirmação de parte',
|
||||
start: 'Início do acompanhamento',
|
||||
complete: 'Conclusão',
|
||||
cancel: 'Cancelamento',
|
||||
renew: 'Renovação',
|
||||
};
|
||||
const unavailable: Record<string, string> = {
|
||||
not_recorded:
|
||||
'Esta informação não ficou guardada no evento. Não foi preenchida com a versão actual.',
|
||||
scope_unknown:
|
||||
'O âmbito deste registo antigo não ficou identificado; o conteúdo não está disponível para esta conta.',
|
||||
restricted:
|
||||
'O registo pertence a uma representação à qual esta conta não tem acesso actual.',
|
||||
malformed:
|
||||
'O instrumento guardado não tem uma estrutura reconhecida. O registo foi conservado.',
|
||||
};
|
||||
function Version({ value, title }: { value: Snapshot; title: string }) {
|
||||
return (
|
||||
<section className="space-y-3 rounded border p-4">
|
||||
<h3 className="font-bold">{title}</h3>
|
||||
{value.availability !== 'available' ? (
|
||||
<p>{unavailable[value.availability]}</p>
|
||||
) : (
|
||||
<>
|
||||
<p>
|
||||
Versão da sala {value.version} ·{' '}
|
||||
{labels[value.status ?? ''] ??
|
||||
value.status ??
|
||||
'Estado não registado'}
|
||||
</p>
|
||||
{value.instrument_availability !== 'available' ? (
|
||||
<p>
|
||||
{
|
||||
unavailable[
|
||||
value.instrument_availability ??
|
||||
'not_recorded'
|
||||
]
|
||||
}
|
||||
</p>
|
||||
) : (
|
||||
<>
|
||||
<p>
|
||||
Contexto do instrumento: proposta{' '}
|
||||
{value.instrument_partnership_version ??
|
||||
'não registada'}{' '}
|
||||
· candidatura{' '}
|
||||
{value.instrument_interest_version ??
|
||||
'não registada'}
|
||||
.
|
||||
</p>
|
||||
<AgreementInstrument value={value.instrument} />
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</section>
|
||||
);
|
||||
}
|
||||
export default function AgreementHistory(p: Props) {
|
||||
return (
|
||||
<Frame title={`Histórico do acordo · Sala ${p.room_id}`}>
|
||||
<div className="space-y-6 break-words">
|
||||
<nav
|
||||
aria-label="Navegação do histórico"
|
||||
className="flex flex-wrap gap-4"
|
||||
>
|
||||
<Link className="underline" href={p.room_href}>
|
||||
Voltar à sala
|
||||
</Link>
|
||||
<Link className="underline" href={p.dashboard_href}>
|
||||
Painel de parcerias
|
||||
</Link>
|
||||
{p.older_page && (
|
||||
<Link className="underline" href={p.first_url}>
|
||||
Versões mais recentes
|
||||
</Link>
|
||||
)}
|
||||
</nav>
|
||||
<p>
|
||||
Consulta das decisões e instrumentos guardados, do mais
|
||||
recente para o mais antigo. Os nomes de pessoas provêm do
|
||||
cadastro actual; as condições, motivos e confirmações são os
|
||||
que ficaram registados. Esta consulta não altera decisões
|
||||
nem certifica assinatura jurídica.
|
||||
</p>
|
||||
{!p.entries.length && (
|
||||
<p>
|
||||
Ainda não existem alterações do acordo guardadas para
|
||||
apresentar.
|
||||
</p>
|
||||
)}
|
||||
{p.entries.map((entry, index) => (
|
||||
<details
|
||||
key={index}
|
||||
open={index === 0}
|
||||
className="space-y-4 rounded border p-4"
|
||||
>
|
||||
<summary className="cursor-pointer font-bold">
|
||||
Versão {entry.version ?? 'não registada'} ·{' '}
|
||||
{entry.restricted
|
||||
? 'Conteúdo reservado'
|
||||
: (actions[entry.action ?? ''] ??
|
||||
'Alteração registada')}
|
||||
</summary>
|
||||
{!entry.restricted && (
|
||||
<>
|
||||
<p>
|
||||
{entry.actor_name ?? 'Autor não registado'}{' '}
|
||||
·{' '}
|
||||
{entry.occurred_at ?? 'Data não registada'}
|
||||
</p>
|
||||
<p>
|
||||
Contexto da decisão: proposta{' '}
|
||||
{entry.partnership_version ??
|
||||
'não registada'}{' '}
|
||||
· candidatura{' '}
|
||||
{entry.interest_version ?? 'não registada'}.
|
||||
</p>
|
||||
{entry.confirmation_party && (
|
||||
<p>
|
||||
Parte que confirmou:{' '}
|
||||
{entry.confirmation_party ===
|
||||
'proponent'
|
||||
? 'Proponente'
|
||||
: 'Candidata'}
|
||||
.
|
||||
</p>
|
||||
)}
|
||||
{entry.reason !== null && (
|
||||
<p className="whitespace-pre-wrap">
|
||||
Motivo: {entry.reason || 'Não indicado'}
|
||||
</p>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
<div className="grid gap-4 lg:grid-cols-2">
|
||||
<Version
|
||||
title="Antes da alteração"
|
||||
value={entry.previous}
|
||||
/>
|
||||
<Version
|
||||
title="Após a alteração"
|
||||
value={entry.after}
|
||||
/>
|
||||
</div>
|
||||
</details>
|
||||
))}
|
||||
{p.next_url && (
|
||||
<Link className="inline-block underline" href={p.next_url}>
|
||||
Consultar versões anteriores
|
||||
</Link>
|
||||
)}
|
||||
</div>
|
||||
</Frame>
|
||||
);
|
||||
}
|
||||
@@ -5,7 +5,8 @@ type Props = {
|
||||
interests: {
|
||||
id: number;
|
||||
partnership_id: number;
|
||||
title: string;
|
||||
title: string | null;
|
||||
partnership_href: string | null;
|
||||
status: string;
|
||||
decision_reason: string | null;
|
||||
room_id: number | null;
|
||||
@@ -38,6 +39,14 @@ export default function Dashboard(p: Props) {
|
||||
{x.title || 'Ideia sem título'}
|
||||
</Link>
|
||||
<p>{labels[x.status] ?? x.status}</p>
|
||||
<p>
|
||||
<Link
|
||||
className="underline"
|
||||
href={`/parcerias/${x.id}/historico`}
|
||||
>
|
||||
Consultar versões e decisões da publicação
|
||||
</Link>
|
||||
</p>
|
||||
<p>
|
||||
Próxima ação:{' '}
|
||||
{['draft', 'returned', 'rejected'].includes(
|
||||
@@ -57,15 +66,30 @@ export default function Dashboard(p: Props) {
|
||||
</h2>
|
||||
{p.interests.map((x) => (
|
||||
<article className="my-4 rounded border p-4" key={x.id}>
|
||||
<Link
|
||||
className="underline"
|
||||
href={'/parcerias/' + x.partnership_id}
|
||||
>
|
||||
{x.title}
|
||||
</Link>
|
||||
{x.partnership_href ? (
|
||||
<Link
|
||||
className="underline"
|
||||
href={x.partnership_href}
|
||||
>
|
||||
{x.title || 'Parceria sem título'}
|
||||
</Link>
|
||||
) : (
|
||||
<p>
|
||||
Parceria {x.partnership_id} · consulta da
|
||||
proposta indisponível com o acesso actual
|
||||
</p>
|
||||
)}
|
||||
<p>
|
||||
{labels[x.status]} · {x.decision_reason}
|
||||
</p>
|
||||
<p>
|
||||
<Link
|
||||
className="underline"
|
||||
href={`/parcerias/candidaturas/${x.id}/historico`}
|
||||
>
|
||||
Consultar versões e decisões
|
||||
</Link>
|
||||
</p>
|
||||
{x.room_id && (
|
||||
<Link
|
||||
className={button}
|
||||
@@ -88,6 +112,13 @@ export default function Dashboard(p: Props) {
|
||||
>
|
||||
{x.title} · {labels[x.status]}
|
||||
</Link>
|
||||
{' · '}
|
||||
<Link
|
||||
className="underline"
|
||||
href={`/parcerias/${x.id}/historico`}
|
||||
>
|
||||
Histórico da publicação
|
||||
</Link>
|
||||
</p>
|
||||
))}
|
||||
</section>
|
||||
@@ -96,6 +127,12 @@ export default function Dashboard(p: Props) {
|
||||
<h2 className="text-xl font-bold">
|
||||
Notificações no portal
|
||||
</h2>
|
||||
<p>
|
||||
São apresentados os avisos cuja consulta está autorizada
|
||||
no âmbito actual e no que ficou guardado no evento.
|
||||
Avisos antigos sem esse âmbito identificável permanecem
|
||||
no registo.
|
||||
</p>
|
||||
{p.notifications.map((n) => (
|
||||
<article className="my-3 rounded border p-3" key={n.id}>
|
||||
<Link href={n.href} className="underline">
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
import { Link, useForm, usePage } from '@inertiajs/react';
|
||||
import { useState } from 'react';
|
||||
import PartnershipPublication from '@/components/partnership-publication';
|
||||
import PublicationSummary from '@/components/partnership-publication-summary';
|
||||
import type { PublicationHistorySummary } from '@/lib/partnership-history';
|
||||
import { Link, usePage } from '@inertiajs/react';
|
||||
import PartnershipCandidacies from '@/components/partnership-candidacies';
|
||||
import { ComplementEntryActions } from '@/components/investment-complements';
|
||||
import StructureGeographyPanel, {
|
||||
type StructureGeography,
|
||||
} from '@/components/structure-geography';
|
||||
import {
|
||||
Frame,
|
||||
Errors,
|
||||
Field,
|
||||
control,
|
||||
button,
|
||||
labels,
|
||||
type Catalogues,
|
||||
@@ -16,10 +18,14 @@ import {
|
||||
type Source,
|
||||
} from './shared';
|
||||
type Props = Catalogues & {
|
||||
publicationActions: string[];
|
||||
publicationCommands: { key: string; action: string; version: number }[];
|
||||
record: Partnership;
|
||||
owner: boolean;
|
||||
canEdit: boolean;
|
||||
moderator: boolean;
|
||||
acceptingInterests: boolean;
|
||||
canStartInterest: boolean;
|
||||
origins: (Source & { geography: StructureGeography | null })[];
|
||||
locations: {
|
||||
id: string;
|
||||
@@ -29,454 +35,11 @@ type Props = Catalogues & {
|
||||
path: { name: string }[];
|
||||
}[];
|
||||
interests: Interest[];
|
||||
history: {
|
||||
event_type: string;
|
||||
actor_id: number;
|
||||
occurred_at: string;
|
||||
payload: string;
|
||||
}[];
|
||||
historySummary: PublicationHistorySummary | null;
|
||||
};
|
||||
function Publication({ p }: { p: Props }) {
|
||||
const form = useForm({ version: p.record.version, action: '', reason: '' });
|
||||
const action = (value: string) => {
|
||||
form.transform((data) => ({ ...data, action: value }));
|
||||
form.post('/parcerias/' + p.record.id + '/estado', {
|
||||
preserveScroll: true,
|
||||
});
|
||||
};
|
||||
return (
|
||||
<section className="space-y-4 rounded border p-5">
|
||||
<h2 className="text-xl font-bold">Pré-visualização e publicação</h2>
|
||||
<p>
|
||||
Estado: {labels[p.record.status] ?? p.record.status}.
|
||||
Verificação da organização, setor e localização permanecem por
|
||||
confirmar quando não há evidência.
|
||||
</p>
|
||||
<Field label="Motivo da ação">
|
||||
<textarea
|
||||
className={control}
|
||||
value={form.data.reason}
|
||||
onChange={(e) => form.setData('reason', e.target.value)}
|
||||
/>
|
||||
</Field>
|
||||
<Errors errors={form.errors} />
|
||||
<div className="flex flex-wrap gap-3">
|
||||
{p.canEdit &&
|
||||
['draft', 'returned', 'rejected'].includes(
|
||||
p.record.status,
|
||||
) && (
|
||||
<button
|
||||
className={button}
|
||||
disabled={form.processing || !form.data.reason}
|
||||
onClick={() => action('submit')}
|
||||
>
|
||||
Submeter para publicação
|
||||
</button>
|
||||
)}
|
||||
{p.moderator &&
|
||||
!p.owner &&
|
||||
['submitted', 'pending'].includes(p.record.status) &&
|
||||
['publish', 'return', 'reject'].map((value) => (
|
||||
<button
|
||||
className={button}
|
||||
key={value}
|
||||
disabled={form.processing || !form.data.reason}
|
||||
onClick={() => action(value)}
|
||||
>
|
||||
{
|
||||
{
|
||||
publish: 'Publicar',
|
||||
return: 'Devolver para correção',
|
||||
reject: 'Rejeitar com fundamento',
|
||||
}[value]
|
||||
}
|
||||
</button>
|
||||
))}
|
||||
{p.canEdit &&
|
||||
['published', 'suspended', 'archived'].includes(
|
||||
p.record.status,
|
||||
) && (
|
||||
<button
|
||||
className={button}
|
||||
disabled={form.processing || !form.data.reason}
|
||||
onClick={() => action('renew')}
|
||||
>
|
||||
Renovar em rascunho
|
||||
</button>
|
||||
)}
|
||||
{p.canEdit &&
|
||||
['draft', 'published', 'suspended', 'rejected'].includes(
|
||||
p.record.status,
|
||||
) && (
|
||||
<button
|
||||
className={button}
|
||||
disabled={form.processing || !form.data.reason}
|
||||
onClick={() => action('archive')}
|
||||
>
|
||||
Arquivar publicação
|
||||
</button>
|
||||
)}
|
||||
{p.canEdit && (
|
||||
<Link
|
||||
className="underline"
|
||||
href={'/parcerias/' + p.record.id + '/editar'}
|
||||
>
|
||||
Editar rascunho
|
||||
</Link>
|
||||
)}
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
function InterestForm({
|
||||
record,
|
||||
interest,
|
||||
organizations,
|
||||
}: {
|
||||
record: Partnership;
|
||||
interest?: Interest;
|
||||
organizations: Catalogues['organizations'];
|
||||
}) {
|
||||
const form = useForm({
|
||||
version: interest?.version ?? null,
|
||||
organization_id: interest?.organization_id ?? '',
|
||||
proposal: interest?.proposal ?? '',
|
||||
payload: {
|
||||
capacity: interest?.payload.capacity ?? '',
|
||||
availability: interest?.payload.availability ?? '',
|
||||
contribution: interest?.payload.contribution ?? '',
|
||||
conflicts: interest?.payload.conflicts ?? '',
|
||||
consent: interest?.payload.consent ?? false,
|
||||
},
|
||||
});
|
||||
return (
|
||||
<form
|
||||
className="space-y-4 rounded border p-5"
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
form.post('/parcerias/' + record.id + '/interesses', {
|
||||
preserveScroll: true,
|
||||
});
|
||||
}}
|
||||
>
|
||||
<h2 className="text-xl font-bold">
|
||||
{interest
|
||||
? 'Atualizar manifestação de interesse'
|
||||
: 'Manifestar interesse'}
|
||||
</h2>
|
||||
<p>
|
||||
Declarações são informações comunicadas por si; não atribuem
|
||||
verificação. Dados desconhecidos podem ser esclarecidos no
|
||||
processo.
|
||||
</p>
|
||||
<Errors errors={form.errors} />
|
||||
<Field label="Participação">
|
||||
<select
|
||||
className={control}
|
||||
value={form.data.organization_id}
|
||||
onChange={(e) =>
|
||||
form.setData('organization_id', e.target.value)
|
||||
}
|
||||
>
|
||||
<option value="">Participação pessoal</option>
|
||||
{organizations.map((o) => (
|
||||
<option key={o.id} value={o.id}>
|
||||
{o.name}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</Field>
|
||||
<Field label="Proposta curta">
|
||||
<textarea
|
||||
className={control}
|
||||
value={form.data.proposal}
|
||||
onChange={(e) => form.setData('proposal', e.target.value)}
|
||||
/>
|
||||
</Field>
|
||||
{(
|
||||
[
|
||||
'capacity',
|
||||
'availability',
|
||||
'contribution',
|
||||
'conflicts',
|
||||
] as const
|
||||
).map((key) => (
|
||||
<Field
|
||||
key={key}
|
||||
label={
|
||||
{
|
||||
capacity: 'Capacidade disponível',
|
||||
availability: 'Disponibilidade',
|
||||
contribution: 'Contribuição proposta',
|
||||
conflicts: 'Conflitos de interesse declarados',
|
||||
}[key]
|
||||
}
|
||||
>
|
||||
<textarea
|
||||
className={control}
|
||||
value={form.data.payload[key]}
|
||||
onChange={(e) =>
|
||||
form.setData('payload', {
|
||||
...form.data.payload,
|
||||
[key]: e.target.value,
|
||||
})
|
||||
}
|
||||
/>
|
||||
</Field>
|
||||
))}
|
||||
<label className="block">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={form.data.payload.consent}
|
||||
onChange={(e) =>
|
||||
form.setData('payload', {
|
||||
...form.data.payload,
|
||||
consent: e.target.checked,
|
||||
})
|
||||
}
|
||||
/>{' '}
|
||||
Autorizo a partilha desta candidatura com o responsável pela
|
||||
parceria.
|
||||
</label>
|
||||
<button className={button} disabled={form.processing}>
|
||||
Guardar interesse
|
||||
</button>
|
||||
</form>
|
||||
);
|
||||
}
|
||||
function Candidacy({
|
||||
interest,
|
||||
owner,
|
||||
canEdit,
|
||||
record,
|
||||
organizations,
|
||||
}: {
|
||||
interest: Interest;
|
||||
owner: boolean;
|
||||
canEdit: boolean;
|
||||
record: Partnership;
|
||||
organizations: Catalogues['organizations'];
|
||||
}) {
|
||||
const assessment = Object.fromEntries(
|
||||
interest.match.criteria.map((c) => [
|
||||
c.code,
|
||||
{
|
||||
state: interest.assessment[c.code]?.state ?? 'unknown',
|
||||
evidence: interest.assessment[c.code]?.evidence ?? '',
|
||||
},
|
||||
]),
|
||||
);
|
||||
const form = useForm({
|
||||
version: interest.version,
|
||||
action: '',
|
||||
reason: '',
|
||||
assessment,
|
||||
});
|
||||
const act = (action: string) => {
|
||||
form.transform((data) => ({
|
||||
...data,
|
||||
action,
|
||||
assessment: action === 'assess' ? data.assessment : {},
|
||||
}));
|
||||
form.post('/parcerias/candidaturas/' + interest.id, {
|
||||
preserveScroll: true,
|
||||
});
|
||||
};
|
||||
return (
|
||||
<article className="space-y-4 rounded border p-5">
|
||||
<h3 className="text-lg font-bold">
|
||||
Candidatura {interest.id} · {labels[interest.status]}
|
||||
</h3>
|
||||
<p>{interest.proposal}</p>
|
||||
<p>{interest.payload.capacity}</p>
|
||||
<p>
|
||||
Disponibilidade:{' '}
|
||||
{interest.payload.availability || 'Por esclarecer'}
|
||||
</p>
|
||||
<p>
|
||||
Contribuição:{' '}
|
||||
{interest.payload.contribution || 'Por esclarecer'}
|
||||
</p>
|
||||
<p>
|
||||
Conflitos declarados:{' '}
|
||||
{interest.payload.conflicts || 'Sem informação'}
|
||||
</p>
|
||||
{interest.decision_reason && (
|
||||
<p>Última decisão: {interest.decision_reason}</p>
|
||||
)}
|
||||
<p>
|
||||
Correspondência: {interest.match.score_min}–
|
||||
{interest.match.score_max}% · Elegibilidade:{' '}
|
||||
{labels[interest.match.eligibility]}. O intervalo distingue
|
||||
dados desconhecidos de incumprimentos; não é uma aprovação.
|
||||
</p>
|
||||
<ul className="space-y-2">
|
||||
{interest.match.criteria.map((c) => (
|
||||
<li key={c.code}>
|
||||
{c.label} · peso {c.weight} · {labels[c.state]}
|
||||
{c.mandatory ? ' · Obrigatório' : ''}
|
||||
{c.evidence && <> · Evidência: {c.evidence}</>}
|
||||
<p className="text-sm">{c.explanation}</p>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
{interest.room_id && (
|
||||
<Link
|
||||
className={button}
|
||||
href={'/parcerias/salas/' + interest.room_id}
|
||||
>
|
||||
Abrir conexão privada
|
||||
</Link>
|
||||
)}
|
||||
{owner &&
|
||||
canEdit &&
|
||||
['submitted', 'clarification', 'shortlisted'].includes(
|
||||
interest.status,
|
||||
) && (
|
||||
<>
|
||||
<details className="space-y-4">
|
||||
<summary>Registar avaliação fundamentada</summary>
|
||||
{interest.match.criteria.map((c) => (
|
||||
<div
|
||||
className="my-3 grid gap-3 md:grid-cols-2"
|
||||
key={c.code}
|
||||
>
|
||||
<Field label={c.label}>
|
||||
<select
|
||||
className={control}
|
||||
value={
|
||||
form.data.assessment[c.code]
|
||||
.state
|
||||
}
|
||||
onChange={(e) =>
|
||||
form.setData('assessment', {
|
||||
...form.data.assessment,
|
||||
[c.code]: {
|
||||
...form.data.assessment[
|
||||
c.code
|
||||
],
|
||||
state: e.target.value,
|
||||
},
|
||||
})
|
||||
}
|
||||
>
|
||||
{['unknown', 'met', 'unmet'].map(
|
||||
(state) => (
|
||||
<option
|
||||
key={state}
|
||||
value={state}
|
||||
>
|
||||
{labels[state]}
|
||||
</option>
|
||||
),
|
||||
)}
|
||||
</select>
|
||||
</Field>
|
||||
<Field label="Referência da evidência">
|
||||
<input
|
||||
className={control}
|
||||
value={
|
||||
form.data.assessment[c.code]
|
||||
.evidence
|
||||
}
|
||||
onChange={(e) =>
|
||||
form.setData('assessment', {
|
||||
...form.data.assessment,
|
||||
[c.code]: {
|
||||
...form.data.assessment[
|
||||
c.code
|
||||
],
|
||||
evidence:
|
||||
e.target.value,
|
||||
},
|
||||
})
|
||||
}
|
||||
/>
|
||||
</Field>
|
||||
</div>
|
||||
))}
|
||||
</details>
|
||||
<Field label="Motivo da decisão ou pedido de esclarecimento">
|
||||
<textarea
|
||||
className={control}
|
||||
value={form.data.reason}
|
||||
onChange={(e) =>
|
||||
form.setData('reason', e.target.value)
|
||||
}
|
||||
/>
|
||||
</Field>
|
||||
<div className="flex flex-wrap gap-3">
|
||||
{[
|
||||
'assess',
|
||||
'clarify',
|
||||
'shortlist',
|
||||
'reject',
|
||||
...(interest.status === 'shortlisted'
|
||||
? ['connect']
|
||||
: []),
|
||||
].map((action) => (
|
||||
<button
|
||||
key={action}
|
||||
className={button}
|
||||
disabled={
|
||||
form.processing || !form.data.reason
|
||||
}
|
||||
onClick={() => act(action)}
|
||||
>
|
||||
{
|
||||
{
|
||||
assess: 'Guardar avaliação',
|
||||
clarify: 'Pedir esclarecimento',
|
||||
shortlist:
|
||||
'Adicionar à lista curta',
|
||||
reject: 'Não selecionar',
|
||||
connect: 'Abrir negociação',
|
||||
}[action]
|
||||
}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
{!owner &&
|
||||
['submitted', 'clarification', 'shortlisted'].includes(
|
||||
interest.status,
|
||||
) && (
|
||||
<>
|
||||
<Field label="Motivo da retirada">
|
||||
<textarea
|
||||
className={control}
|
||||
value={form.data.reason}
|
||||
onChange={(e) =>
|
||||
form.setData('reason', e.target.value)
|
||||
}
|
||||
/>
|
||||
</Field>
|
||||
<button
|
||||
className={button}
|
||||
disabled={form.processing || !form.data.reason}
|
||||
onClick={() => act('withdraw')}
|
||||
>
|
||||
Retirar candidatura
|
||||
</button>
|
||||
</>
|
||||
)}
|
||||
{!owner &&
|
||||
['submitted', 'clarification', 'withdrawn'].includes(
|
||||
interest.status,
|
||||
) && (
|
||||
<InterestForm
|
||||
record={record}
|
||||
interest={interest}
|
||||
organizations={organizations}
|
||||
/>
|
||||
)}
|
||||
<Errors errors={form.errors} />
|
||||
</article>
|
||||
);
|
||||
}
|
||||
export default function Detail(p: Props) {
|
||||
const { auth } = usePage<{ auth: { user: unknown } }>().props;
|
||||
const { auth } = usePage<{ auth: { user: { id: number } | null } }>().props;
|
||||
const [publicationDirty, setPublicationDirty] = useState(false);
|
||||
return (
|
||||
<Frame title={p.record.title || 'Pré-visualização da ideia'}>
|
||||
<ComplementEntryActions target={'partnership:' + p.record.id} />
|
||||
@@ -548,8 +111,13 @@ export default function Detail(p: Props) {
|
||||
)}
|
||||
</section>
|
||||
))}
|
||||
{(p.owner || p.moderator) && (
|
||||
<Publication key={p.record.version} p={p} />
|
||||
{auth.user && (
|
||||
<PartnershipPublication
|
||||
key={`${p.record.id}:${auth.user.id}`}
|
||||
p={p}
|
||||
actorId={auth.user.id}
|
||||
onDirty={setPublicationDirty}
|
||||
/>
|
||||
)}
|
||||
{p.owner && p.interests.length > 0 && (
|
||||
<section className="overflow-x-auto rounded border p-4">
|
||||
@@ -589,40 +157,18 @@ export default function Detail(p: Props) {
|
||||
</table>
|
||||
</section>
|
||||
)}
|
||||
{p.interests.map((i) => (
|
||||
<Candidacy
|
||||
key={i.id + ':' + i.version}
|
||||
interest={i}
|
||||
owner={p.owner}
|
||||
canEdit={p.canEdit}
|
||||
record={p.record}
|
||||
organizations={p.organizations}
|
||||
/>
|
||||
))}
|
||||
{!p.owner &&
|
||||
p.record.status === 'published' &&
|
||||
auth.user &&
|
||||
!p.interests.length && (
|
||||
<InterestForm
|
||||
record={p.record}
|
||||
organizations={p.organizations}
|
||||
/>
|
||||
)}
|
||||
<PartnershipCandidacies
|
||||
key={auth.user?.id ?? 'public'}
|
||||
p={p}
|
||||
otherDirty={publicationDirty}
|
||||
/>
|
||||
{!auth.user && p.record.status === 'published' && (
|
||||
<Link className={button} href="/login">
|
||||
Entrar para manifestar interesse
|
||||
</Link>
|
||||
)}
|
||||
{p.history.length > 0 && (
|
||||
<details>
|
||||
<summary>Histórico e decisões</summary>
|
||||
{p.history.map((h, i) => (
|
||||
<p key={i}>
|
||||
{h.occurred_at} · Autor {h.actor_id} ·{' '}
|
||||
{h.event_type}
|
||||
</p>
|
||||
))}
|
||||
</details>
|
||||
{(p.owner || p.moderator) && p.historySummary && (
|
||||
<PublicationSummary value={p.historySummary} />
|
||||
)}
|
||||
</div>
|
||||
</Frame>
|
||||
|
||||
@@ -1,55 +1,22 @@
|
||||
import { createOperationKey } from '@/lib/operation-key';
|
||||
import { Link, useForm } from '@inertiajs/react';
|
||||
import { Link } from '@inertiajs/react';
|
||||
import { useState } from 'react';
|
||||
import {
|
||||
usePartnershipEdit,
|
||||
type PartnershipEditProps,
|
||||
} from '@/lib/partnership-edit';
|
||||
import PartnershipEditComparison from '@/components/partnership-edit-comparison';
|
||||
import {
|
||||
Frame,
|
||||
Field,
|
||||
Errors,
|
||||
control,
|
||||
button,
|
||||
type Partnership,
|
||||
type Catalogues,
|
||||
} from './shared';
|
||||
type Location = {
|
||||
geo_location_id: string;
|
||||
role: string;
|
||||
source_reference: string;
|
||||
};
|
||||
type Origin = { type: string; target_id: string };
|
||||
type Props = Catalogues & {
|
||||
record: Partnership | null;
|
||||
locations: Location[];
|
||||
origins: Origin[];
|
||||
};
|
||||
type Props = Catalogues & PartnershipEditProps;
|
||||
function Editor(p: Props) {
|
||||
const form = useForm({
|
||||
client_key: createOperationKey(),
|
||||
version: p.record?.version ?? null,
|
||||
title: p.record?.title ?? '',
|
||||
offer: p.record?.offer ?? '',
|
||||
seeking: p.record?.seeking ?? '',
|
||||
organization_id: p.record?.organization_id ?? '',
|
||||
sector_id: p.record?.sector_id?.toString() ?? '',
|
||||
kind: p.record?.kind ?? 'seeking',
|
||||
partnership_type: p.record?.partnership_type ?? '',
|
||||
deadline: p.record?.deadline ?? '',
|
||||
payload: {
|
||||
summary: p.record?.payload.summary ?? '',
|
||||
requirements: p.record?.payload.requirements ?? '',
|
||||
mandatory: p.record?.payload.mandatory ?? ([] as string[]),
|
||||
confidentiality: p.record?.payload.confidentiality ?? 'public',
|
||||
consent: p.record?.payload.consent ?? false,
|
||||
},
|
||||
locations: p.locations.map((x) => ({
|
||||
geo_location_id: x.geo_location_id,
|
||||
role: x.role,
|
||||
source_reference: x.source_reference,
|
||||
})),
|
||||
origins: p.origins.map((x) => ({
|
||||
type: x.type,
|
||||
target_id: x.target_id,
|
||||
})),
|
||||
});
|
||||
const edit = usePartnershipEdit(p);
|
||||
const form = edit.form;
|
||||
const [place, setPlace] = useState('');
|
||||
const [role, setRole] = useState('primary');
|
||||
const [source, setSource] = useState('Declaração do proponente');
|
||||
@@ -65,384 +32,493 @@ function Editor(p: Props) {
|
||||
className="space-y-5"
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
if (p.record) form.put('/parcerias/' + p.record.id);
|
||||
else form.post('/parcerias/rascunhos');
|
||||
edit.save();
|
||||
}}
|
||||
>
|
||||
<Errors errors={form.errors} />
|
||||
<Field label="Título">
|
||||
<input
|
||||
className={control}
|
||||
value={form.data.title}
|
||||
onChange={(e) => form.setData('title', e.target.value)}
|
||||
/>
|
||||
</Field>
|
||||
<div className="grid gap-5 md:grid-cols-2">
|
||||
<Field label="Organização que representa (opcional)">
|
||||
<select
|
||||
className={control}
|
||||
value={form.data.organization_id}
|
||||
onChange={(e) =>
|
||||
form.setData('organization_id', e.target.value)
|
||||
}
|
||||
>
|
||||
<option value="">
|
||||
Ideia pessoal — sem organização indicada
|
||||
</option>
|
||||
{p.organizations.map((x) => (
|
||||
<option key={x.id} value={x.id}>
|
||||
{x.name}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</Field>
|
||||
<Field label="Oferta ou procura">
|
||||
<select
|
||||
className={control}
|
||||
value={form.data.kind}
|
||||
onChange={(e) =>
|
||||
form.setData('kind', e.target.value)
|
||||
}
|
||||
>
|
||||
<option value="seeking">Procura</option>
|
||||
<option value="offering">Oferta</option>
|
||||
</select>
|
||||
</Field>
|
||||
<Field label="Tipo de parceria">
|
||||
<select
|
||||
className={control}
|
||||
value={form.data.partnership_type}
|
||||
onChange={(e) =>
|
||||
form.setData('partnership_type', e.target.value)
|
||||
}
|
||||
>
|
||||
<option value="">Por definir</option>
|
||||
{Object.entries(p.types).map(([k, v]) => (
|
||||
<option key={k} value={k}>
|
||||
{v}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</Field>
|
||||
<Field label="Setor">
|
||||
<select
|
||||
className={control}
|
||||
value={form.data.sector_id}
|
||||
onChange={(e) =>
|
||||
form.setData('sector_id', e.target.value)
|
||||
}
|
||||
>
|
||||
<option value="">Por definir</option>
|
||||
{p.sectors.map((x) => (
|
||||
<option key={x.id} value={x.id}>
|
||||
{x.name}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</Field>
|
||||
</div>
|
||||
<Field label="Resumo público">
|
||||
<textarea
|
||||
className={control}
|
||||
value={form.data.payload.summary}
|
||||
onChange={(e) =>
|
||||
form.setData('payload', {
|
||||
...form.data.payload,
|
||||
summary: e.target.value,
|
||||
})
|
||||
}
|
||||
/>
|
||||
</Field>
|
||||
<Field label="O que oferece">
|
||||
<textarea
|
||||
className={control}
|
||||
value={form.data.offer}
|
||||
onChange={(e) => form.setData('offer', e.target.value)}
|
||||
/>
|
||||
</Field>
|
||||
<Field label="O que procura">
|
||||
<textarea
|
||||
className={control}
|
||||
value={form.data.seeking}
|
||||
onChange={(e) =>
|
||||
form.setData('seeking', e.target.value)
|
||||
}
|
||||
/>
|
||||
</Field>
|
||||
<Field label="Requisitos e critérios desejáveis">
|
||||
<textarea
|
||||
className={control}
|
||||
value={form.data.payload.requirements}
|
||||
onChange={(e) =>
|
||||
form.setData('payload', {
|
||||
...form.data.payload,
|
||||
requirements: e.target.value,
|
||||
})
|
||||
}
|
||||
/>
|
||||
</Field>
|
||||
<fieldset className="space-y-2 rounded border p-4">
|
||||
<legend>
|
||||
Critérios obrigatórios expressos da proposta
|
||||
</legend>
|
||||
<p>
|
||||
Marque apenas condições necessárias. Critérios
|
||||
desejáveis servem a pontuação. Informação desconhecida
|
||||
exige esclarecimento e não constitui incumprimento
|
||||
comprovado.
|
||||
</p>
|
||||
{Object.entries(p.criteria).map(([k, v]) => (
|
||||
<label className="block" key={k}>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={form.data.payload.mandatory.includes(
|
||||
k,
|
||||
)}
|
||||
onChange={(e) =>
|
||||
form.setData('payload', {
|
||||
...form.data.payload,
|
||||
mandatory: e.target.checked
|
||||
? [
|
||||
...form.data.payload
|
||||
.mandatory,
|
||||
k,
|
||||
]
|
||||
: form.data.payload.mandatory.filter(
|
||||
(x) => x !== k,
|
||||
),
|
||||
})
|
||||
}
|
||||
/>{' '}
|
||||
{v}
|
||||
</label>
|
||||
))}
|
||||
</fieldset>
|
||||
<div className="grid gap-4 md:grid-cols-2">
|
||||
<Field label="Prazo para interesses">
|
||||
<PartnershipEditComparison editor={edit} catalogues={p} />
|
||||
<fieldset
|
||||
className="space-y-5"
|
||||
disabled={!edit.editable || edit.invalid}
|
||||
>
|
||||
<legend className="sr-only">Conteúdo da parceria</legend>
|
||||
<Field label="Título">
|
||||
<input
|
||||
type="date"
|
||||
className={control}
|
||||
value={form.data.deadline}
|
||||
value={form.data.title}
|
||||
onChange={(e) =>
|
||||
form.setData('deadline', e.target.value)
|
||||
edit.setData('title', e.target.value)
|
||||
}
|
||||
/>
|
||||
</Field>
|
||||
<Field label="Visibilidade do conteúdo detalhado">
|
||||
<select
|
||||
className={control}
|
||||
value={form.data.payload.confidentiality}
|
||||
onChange={(e) =>
|
||||
form.setData('payload', {
|
||||
...form.data.payload,
|
||||
confidentiality: e.target.value,
|
||||
})
|
||||
}
|
||||
>
|
||||
<option value="public">
|
||||
Público após moderação
|
||||
</option>
|
||||
<option value="private">
|
||||
Resumo público; detalhes privados
|
||||
</option>
|
||||
</select>
|
||||
</Field>
|
||||
</div>
|
||||
<section className="space-y-4 rounded border p-5">
|
||||
<h2 className="font-bold">Localizações e abrangência</h2>
|
||||
<p>
|
||||
A localização de uma origem fica como contexto. Só
|
||||
acrescente uma localização própria com fonte; não se
|
||||
deduz por proximidade ou pertença a cluster.
|
||||
</p>
|
||||
<div className="grid gap-3 md:grid-cols-3">
|
||||
<Field label="Localização do cadastro">
|
||||
<div className="grid gap-5 md:grid-cols-2">
|
||||
<Field label="Organização que representa (opcional)">
|
||||
<select
|
||||
className={control}
|
||||
value={place}
|
||||
onChange={(e) => setPlace(e.target.value)}
|
||||
value={form.data.organization_id}
|
||||
onChange={(e) =>
|
||||
edit.setData(
|
||||
'organization_id',
|
||||
e.target.value,
|
||||
)
|
||||
}
|
||||
>
|
||||
<option value="">Escolher território</option>
|
||||
{p.territories.map((x) => (
|
||||
<option value="">
|
||||
Sem organização indicada
|
||||
</option>
|
||||
{form.data.organization_id &&
|
||||
!p.organizations.some(
|
||||
(organization) =>
|
||||
String(organization.id) ===
|
||||
form.data.organization_id,
|
||||
) && (
|
||||
<option
|
||||
value={form.data.organization_id}
|
||||
>
|
||||
Organização anteriormente indicada —
|
||||
fora da lista actual
|
||||
</option>
|
||||
)}
|
||||
{p.organizations.map((x) => (
|
||||
<option key={x.id} value={x.id}>
|
||||
{x.name} · {x.location_type}
|
||||
{x.name}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
<p className="text-sm">
|
||||
A autoria mantém-se. Sem organização ligada, só
|
||||
o proponente originalmente registado pode editar
|
||||
esta proposta.
|
||||
</p>
|
||||
</Field>
|
||||
<Field label="Oferta ou procura">
|
||||
<select
|
||||
className={control}
|
||||
value={form.data.kind}
|
||||
onChange={(e) =>
|
||||
edit.setData('kind', e.target.value)
|
||||
}
|
||||
>
|
||||
<option value="seeking">Procura</option>
|
||||
<option value="offering">Oferta</option>
|
||||
</select>
|
||||
</Field>
|
||||
<Field label="Tipo de parceria">
|
||||
<select
|
||||
className={control}
|
||||
value={form.data.partnership_type}
|
||||
onChange={(e) =>
|
||||
edit.setData(
|
||||
'partnership_type',
|
||||
e.target.value,
|
||||
)
|
||||
}
|
||||
>
|
||||
<option value="">Por definir</option>
|
||||
{form.data.partnership_type &&
|
||||
!Object.hasOwn(
|
||||
p.types,
|
||||
form.data.partnership_type,
|
||||
) && (
|
||||
<option
|
||||
value={form.data.partnership_type}
|
||||
>
|
||||
Tipo anteriormente indicado — fora
|
||||
da configuração actual
|
||||
</option>
|
||||
)}
|
||||
{Object.entries(p.types).map(([k, v]) => (
|
||||
<option key={k} value={k}>
|
||||
{v}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</Field>
|
||||
<Field label="Papel">
|
||||
<Field label="Setor">
|
||||
<select
|
||||
className={control}
|
||||
value={role}
|
||||
onChange={(e) => setRole(e.target.value)}
|
||||
value={form.data.sector_id}
|
||||
onChange={(e) =>
|
||||
edit.setData('sector_id', e.target.value)
|
||||
}
|
||||
>
|
||||
<option value="primary">Principal</option>
|
||||
<option value="operating">
|
||||
Área de atuação
|
||||
</option>
|
||||
<option value="coverage">Abrangência</option>
|
||||
<option value="">Por definir</option>
|
||||
{form.data.sector_id &&
|
||||
!p.sectors.some(
|
||||
(sector) =>
|
||||
String(sector.id) ===
|
||||
form.data.sector_id,
|
||||
) && (
|
||||
<option value={form.data.sector_id}>
|
||||
Sector anteriormente indicado — fora
|
||||
da lista actual
|
||||
</option>
|
||||
)}
|
||||
{p.sectors.map((x) => (
|
||||
<option key={x.id} value={x.id}>
|
||||
{x.name}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</Field>
|
||||
<Field label="Fonte da localização">
|
||||
</div>
|
||||
<Field label="Resumo público">
|
||||
<textarea
|
||||
className={control}
|
||||
value={form.data.payload.summary}
|
||||
onChange={(e) =>
|
||||
edit.setData('payload', (previous) => ({
|
||||
...previous,
|
||||
summary: e.target.value,
|
||||
}))
|
||||
}
|
||||
/>
|
||||
</Field>
|
||||
<Field label="O que oferece">
|
||||
<textarea
|
||||
className={control}
|
||||
value={form.data.offer}
|
||||
onChange={(e) =>
|
||||
edit.setData('offer', e.target.value)
|
||||
}
|
||||
/>
|
||||
</Field>
|
||||
<Field label="O que procura">
|
||||
<textarea
|
||||
className={control}
|
||||
value={form.data.seeking}
|
||||
onChange={(e) =>
|
||||
edit.setData('seeking', e.target.value)
|
||||
}
|
||||
/>
|
||||
</Field>
|
||||
<Field label="Requisitos e critérios desejáveis">
|
||||
<textarea
|
||||
className={control}
|
||||
value={form.data.payload.requirements}
|
||||
onChange={(e) =>
|
||||
edit.setData('payload', (previous) => ({
|
||||
...previous,
|
||||
requirements: e.target.value,
|
||||
}))
|
||||
}
|
||||
/>
|
||||
</Field>
|
||||
<Field label="Disponibilidade dos recursos ou da colaboração (opcional)">
|
||||
<textarea
|
||||
className={control}
|
||||
maxLength={1000}
|
||||
value={form.data.payload.availability}
|
||||
onChange={(event) =>
|
||||
edit.setData('payload', (previous) => ({
|
||||
...previous,
|
||||
availability: event.target.value,
|
||||
}))
|
||||
}
|
||||
/>
|
||||
<p className="text-sm">
|
||||
Indique quando e em que condições os recursos ou a
|
||||
colaboração estarão disponíveis. O prazo de recepção
|
||||
de interesses é indicado separadamente.
|
||||
</p>
|
||||
</Field>
|
||||
<fieldset className="space-y-2 rounded border p-4">
|
||||
<legend>
|
||||
Critérios obrigatórios expressos da proposta
|
||||
</legend>
|
||||
<p>
|
||||
Marque apenas condições necessárias. Critérios
|
||||
desejáveis servem a pontuação. Informação
|
||||
desconhecida exige esclarecimento e não constitui
|
||||
incumprimento comprovado.
|
||||
</p>
|
||||
{Object.entries(p.criteria).map(([k, v]) => (
|
||||
<label className="block" key={k}>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={form.data.payload.mandatory.includes(
|
||||
k,
|
||||
)}
|
||||
onChange={(e) =>
|
||||
edit.setData('payload', (previous) => ({
|
||||
...previous,
|
||||
mandatory: e.target.checked
|
||||
? [...previous.mandatory, k]
|
||||
: previous.mandatory.filter(
|
||||
(x) => x !== k,
|
||||
),
|
||||
}))
|
||||
}
|
||||
/>{' '}
|
||||
{v}
|
||||
</label>
|
||||
))}
|
||||
</fieldset>
|
||||
{form.data.payload.mandatory
|
||||
.filter((code) => !Object.hasOwn(p.criteria, code))
|
||||
.map((code) => (
|
||||
<p className="rounded border p-3" key={code}>
|
||||
Critério anteriormente indicado — fora da
|
||||
configuração actual: {code}. Retirá-lo da
|
||||
preparação altera apenas a próxima gravação; o
|
||||
histórico mantém-se.{' '}
|
||||
<button
|
||||
type="button"
|
||||
className="underline"
|
||||
disabled={!edit.editable || edit.invalid}
|
||||
onClick={() =>
|
||||
edit.setData('payload', (previous) => ({
|
||||
...previous,
|
||||
mandatory:
|
||||
previous.mandatory.filter(
|
||||
(value) => value !== code,
|
||||
),
|
||||
}))
|
||||
}
|
||||
>
|
||||
Retirar da preparação
|
||||
</button>
|
||||
</p>
|
||||
))}
|
||||
<div className="grid gap-4 md:grid-cols-2">
|
||||
<Field label="Prazo para receber manifestações de interesse (opcional)">
|
||||
<input
|
||||
type="date"
|
||||
className={control}
|
||||
value={source}
|
||||
onChange={(e) => setSource(e.target.value)}
|
||||
value={form.data.deadline}
|
||||
onChange={(e) =>
|
||||
edit.setData('deadline', e.target.value)
|
||||
}
|
||||
/>
|
||||
</Field>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
className={button}
|
||||
disabled={!place || !source}
|
||||
onClick={() => {
|
||||
if (
|
||||
!form.data.locations.some(
|
||||
(x) =>
|
||||
x.geo_location_id === place &&
|
||||
x.role === role,
|
||||
)
|
||||
)
|
||||
form.setData('locations', [
|
||||
...form.data.locations,
|
||||
{
|
||||
geo_location_id: place,
|
||||
role,
|
||||
source_reference: source,
|
||||
},
|
||||
]);
|
||||
}}
|
||||
>
|
||||
Acrescentar localização
|
||||
</button>
|
||||
{form.data.locations.map((l, i) => (
|
||||
<p key={i}>
|
||||
{
|
||||
p.territories.find(
|
||||
(t) => t.id === l.geo_location_id,
|
||||
)?.name
|
||||
}{' '}
|
||||
· {l.role} · {l.source_reference}{' '}
|
||||
<button
|
||||
type="button"
|
||||
className="underline"
|
||||
onClick={() =>
|
||||
form.setData(
|
||||
'locations',
|
||||
form.data.locations.filter(
|
||||
(_, j) => j !== i,
|
||||
),
|
||||
)
|
||||
<Field label="Visibilidade do conteúdo detalhado">
|
||||
<select
|
||||
className={control}
|
||||
value={form.data.payload.confidentiality}
|
||||
onChange={(e) =>
|
||||
edit.setData('payload', (previous) => ({
|
||||
...previous,
|
||||
confidentiality: e.target.value,
|
||||
}))
|
||||
}
|
||||
>
|
||||
Remover
|
||||
</button>
|
||||
</p>
|
||||
))}
|
||||
</section>
|
||||
<section className="space-y-3 rounded border p-5">
|
||||
<h2 className="font-bold">Registos de origem</h2>
|
||||
<Field label="Adicionar origem existente">
|
||||
<select
|
||||
className={control}
|
||||
value={origin}
|
||||
onChange={(e) => setOrigin(e.target.value)}
|
||||
>
|
||||
<option value="">
|
||||
Escolher empresa, investimento, projeto,
|
||||
cluster, zona ou ficha
|
||||
</option>
|
||||
{p.sources?.map((x) => (
|
||||
<option
|
||||
key={x.type + ':' + x.target_id}
|
||||
value={x.type + ':' + x.target_id}
|
||||
>
|
||||
{x.title}
|
||||
<option value="public">
|
||||
Público após moderação
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</Field>
|
||||
<button
|
||||
type="button"
|
||||
className={button}
|
||||
disabled={!origin}
|
||||
onClick={() => {
|
||||
const [type, target_id] = origin.split(':');
|
||||
if (
|
||||
!form.data.origins.some(
|
||||
(x) =>
|
||||
x.type === type &&
|
||||
x.target_id === target_id,
|
||||
)
|
||||
)
|
||||
form.setData('origins', [
|
||||
...form.data.origins,
|
||||
{ type, target_id },
|
||||
]);
|
||||
}}
|
||||
>
|
||||
Ligar origem
|
||||
</button>
|
||||
{form.data.origins.map((o, i) => (
|
||||
<p key={i}>
|
||||
{p.sources?.find(
|
||||
(x) =>
|
||||
x.type === o.type &&
|
||||
x.target_id === o.target_id,
|
||||
)?.title ?? 'Origem documental ligada'}{' '}
|
||||
<button
|
||||
type="button"
|
||||
className="underline"
|
||||
onClick={() =>
|
||||
form.setData(
|
||||
'origins',
|
||||
form.data.origins.filter(
|
||||
(_, j) => j !== i,
|
||||
),
|
||||
)
|
||||
}
|
||||
>
|
||||
Remover
|
||||
</button>
|
||||
<option value="private">
|
||||
Resumo público; detalhes privados
|
||||
</option>
|
||||
</select>
|
||||
</Field>
|
||||
</div>
|
||||
<section className="space-y-4 rounded border p-5">
|
||||
<h2 className="font-bold">
|
||||
Localizações e abrangência
|
||||
</h2>
|
||||
<p>
|
||||
A localização de uma origem fica como contexto. Só
|
||||
acrescente uma localização própria com fonte; não se
|
||||
deduz por proximidade ou pertença a cluster.
|
||||
</p>
|
||||
))}
|
||||
</section>
|
||||
<label className="block">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={form.data.payload.consent}
|
||||
onChange={(e) =>
|
||||
form.setData('payload', {
|
||||
...form.data.payload,
|
||||
consent: e.target.checked,
|
||||
})
|
||||
}
|
||||
/>{' '}
|
||||
Autorizo submeter o conteúdo indicado para divulgação no
|
||||
âmbito escolhido. Não confirma verificação ou certificação.
|
||||
</label>
|
||||
<div className="flex flex-wrap gap-4">
|
||||
<button className={button} disabled={form.processing}>
|
||||
Guardar rascunho
|
||||
</button>
|
||||
{p.record && (
|
||||
<Link
|
||||
className="underline"
|
||||
href={'/parcerias/' + p.record.id}
|
||||
<div className="grid gap-3 md:grid-cols-3">
|
||||
<Field label="Localização do cadastro">
|
||||
<select
|
||||
className={control}
|
||||
value={place}
|
||||
onChange={(e) => setPlace(e.target.value)}
|
||||
>
|
||||
<option value="">
|
||||
Escolher território
|
||||
</option>
|
||||
{p.territories.map((x) => (
|
||||
<option key={x.id} value={x.id}>
|
||||
{x.name} · {x.location_type}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</Field>
|
||||
<Field label="Papel">
|
||||
<select
|
||||
className={control}
|
||||
value={role}
|
||||
onChange={(e) => setRole(e.target.value)}
|
||||
>
|
||||
<option value="primary">Principal</option>
|
||||
<option value="operating">
|
||||
Área de atuação
|
||||
</option>
|
||||
<option value="coverage">
|
||||
Abrangência
|
||||
</option>
|
||||
</select>
|
||||
</Field>
|
||||
<Field label="Fonte da localização">
|
||||
<input
|
||||
className={control}
|
||||
value={source}
|
||||
onChange={(e) => setSource(e.target.value)}
|
||||
/>
|
||||
</Field>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
className={button}
|
||||
disabled={!place || !source}
|
||||
onClick={() => {
|
||||
edit.setData('locations', (previous) =>
|
||||
previous.some(
|
||||
(x) =>
|
||||
x.geo_location_id === place &&
|
||||
x.role === role,
|
||||
)
|
||||
? previous
|
||||
: [
|
||||
...previous,
|
||||
{
|
||||
geo_location_id: place,
|
||||
role,
|
||||
source_reference: source,
|
||||
},
|
||||
],
|
||||
);
|
||||
}}
|
||||
>
|
||||
Pré-visualizar e submeter
|
||||
</Link>
|
||||
)}
|
||||
</div>
|
||||
Acrescentar localização
|
||||
</button>
|
||||
{form.data.locations.map((l, i) => (
|
||||
<p key={i}>
|
||||
{
|
||||
p.territories.find(
|
||||
(t) => t.id === l.geo_location_id,
|
||||
)?.name
|
||||
}{' '}
|
||||
· {l.role} · {l.source_reference}{' '}
|
||||
<button
|
||||
type="button"
|
||||
className="underline"
|
||||
onClick={() =>
|
||||
edit.setData('locations', (previous) =>
|
||||
previous.filter(
|
||||
(item) =>
|
||||
item.geo_location_id !==
|
||||
l.geo_location_id ||
|
||||
item.role !== l.role,
|
||||
),
|
||||
)
|
||||
}
|
||||
>
|
||||
Remover
|
||||
</button>
|
||||
</p>
|
||||
))}
|
||||
</section>
|
||||
<section className="space-y-3 rounded border p-5">
|
||||
<h2 className="font-bold">Registos de origem</h2>
|
||||
<Field label="Adicionar origem existente">
|
||||
<select
|
||||
className={control}
|
||||
value={origin}
|
||||
onChange={(e) => setOrigin(e.target.value)}
|
||||
>
|
||||
<option value="">
|
||||
Escolher empresa, investimento, projeto,
|
||||
cluster, zona ou ficha
|
||||
</option>
|
||||
{p.sources?.map((x) => (
|
||||
<option
|
||||
key={x.type + ':' + x.target_id}
|
||||
value={x.type + ':' + x.target_id}
|
||||
>
|
||||
{x.title}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</Field>
|
||||
<button
|
||||
type="button"
|
||||
className={button}
|
||||
disabled={!origin}
|
||||
onClick={() => {
|
||||
const [type, target_id] = origin.split(':');
|
||||
edit.setData('origins', (previous) =>
|
||||
previous.some(
|
||||
(item) =>
|
||||
item.type === type &&
|
||||
item.target_id === target_id,
|
||||
)
|
||||
? previous
|
||||
: [...previous, { type, target_id }],
|
||||
);
|
||||
}}
|
||||
>
|
||||
Ligar origem
|
||||
</button>
|
||||
{form.data.origins.map((o, i) => (
|
||||
<p key={i}>
|
||||
{p.sources?.find(
|
||||
(x) =>
|
||||
x.type === o.type &&
|
||||
x.target_id === o.target_id,
|
||||
)?.title ?? 'Origem documental ligada'}{' '}
|
||||
<button
|
||||
type="button"
|
||||
className="underline"
|
||||
onClick={() =>
|
||||
edit.setData('origins', (previous) =>
|
||||
previous.filter(
|
||||
(item) =>
|
||||
item.type !== o.type ||
|
||||
item.target_id !==
|
||||
o.target_id,
|
||||
),
|
||||
)
|
||||
}
|
||||
>
|
||||
Remover
|
||||
</button>
|
||||
</p>
|
||||
))}
|
||||
</section>
|
||||
<label className="block">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={form.data.payload.consent}
|
||||
onChange={(e) =>
|
||||
edit.setData('payload', (previous) => ({
|
||||
...previous,
|
||||
consent: e.target.checked,
|
||||
}))
|
||||
}
|
||||
/>{' '}
|
||||
Autorizo submeter o conteúdo indicado para divulgação no
|
||||
âmbito escolhido. Não confirma verificação ou
|
||||
certificação.
|
||||
</label>
|
||||
<div className="flex flex-wrap gap-4">
|
||||
<button
|
||||
className={button}
|
||||
disabled={form.processing || edit.blocked}
|
||||
>
|
||||
{edit.retryingCreation
|
||||
? 'Recuperar gravação anterior'
|
||||
: edit.current?.status === 'published'
|
||||
? 'Guardar revisão em rascunho'
|
||||
: 'Guardar rascunho'}
|
||||
</button>
|
||||
{p.record && (
|
||||
<Link
|
||||
className="underline"
|
||||
href={'/parcerias/' + p.record.id}
|
||||
>
|
||||
Pré-visualizar e submeter
|
||||
</Link>
|
||||
)}
|
||||
</div>
|
||||
</fieldset>
|
||||
</form>
|
||||
</Frame>
|
||||
);
|
||||
}
|
||||
export default function Page(p: Props) {
|
||||
return (
|
||||
<Editor
|
||||
key={`${p.record?.id ?? 'new'}:${p.record?.version ?? 0}`}
|
||||
{...p}
|
||||
/>
|
||||
);
|
||||
return <Editor key={p.editorActorId ?? 'legacy-editor'} {...p} />;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,350 @@
|
||||
import { Link } from '@inertiajs/react';
|
||||
import { Frame, labels } from './shared';
|
||||
|
||||
type Assessment = {
|
||||
code: string;
|
||||
label: string;
|
||||
state: string | null;
|
||||
evidence: string | null;
|
||||
actor_name: string | null;
|
||||
assessed_at: string | null;
|
||||
};
|
||||
type Snapshot = {
|
||||
availability: 'available' | 'not_recorded' | 'scope_unknown' | 'restricted';
|
||||
version?: number | null;
|
||||
status?: string | null;
|
||||
scope_known?: boolean;
|
||||
organization_id?: string | null;
|
||||
organization_name?: string | null;
|
||||
fields?: Record<string, string | null>;
|
||||
consent_known?: boolean;
|
||||
consent?: boolean | null;
|
||||
assessment_recorded?: boolean;
|
||||
assessment?: Assessment[];
|
||||
references?: Record<string, string>;
|
||||
complete?: boolean;
|
||||
};
|
||||
type Matching = {
|
||||
algorithm_version: string | null;
|
||||
weights_hash: string | null;
|
||||
eligibility: string | null;
|
||||
score_min: number | null;
|
||||
score_max: number | null;
|
||||
unknown_weight: number | null;
|
||||
criteria: {
|
||||
code: string;
|
||||
label: string | null;
|
||||
state: string | null;
|
||||
weight: number | null;
|
||||
mandatory: boolean | null;
|
||||
evidence: string | null;
|
||||
explanation: string | null;
|
||||
}[];
|
||||
};
|
||||
type Entry = {
|
||||
version: number | null;
|
||||
restricted: boolean;
|
||||
action: string | null;
|
||||
actor_name: string | null;
|
||||
occurred_at: string | null;
|
||||
reason: string | null;
|
||||
previous: Snapshot;
|
||||
after: Snapshot;
|
||||
matching: Matching | null;
|
||||
partnership_version: number | null;
|
||||
};
|
||||
type Props = {
|
||||
candidacy_id: number;
|
||||
entries: Entry[];
|
||||
next_url: string | null;
|
||||
first_url: string;
|
||||
older_page: boolean;
|
||||
partnership_href: string | null;
|
||||
dashboard_href: string;
|
||||
};
|
||||
const actions: Record<string, string> = {
|
||||
submit: 'Submissão',
|
||||
assess: 'Avaliação',
|
||||
clarify: 'Pedido de esclarecimento',
|
||||
shortlist: 'Selecção para lista curta',
|
||||
reject: 'Rejeição',
|
||||
connect: 'Abertura de negociação',
|
||||
withdraw: 'Retirada',
|
||||
};
|
||||
const fields: Record<string, string> = {
|
||||
proposal: 'Proposta curta',
|
||||
capacity: 'Capacidade disponível',
|
||||
availability: 'Disponibilidade',
|
||||
contribution: 'Contribuição proposta',
|
||||
conflicts: 'Conflitos de interesse declarados',
|
||||
decision_reason: 'Motivo da decisão',
|
||||
};
|
||||
const display = (value: string | null | undefined) =>
|
||||
value ? (labels[value] ?? value) : 'Não consta do registo';
|
||||
function Version({ value, title }: { value: Snapshot; title: string }) {
|
||||
const unavailable = {
|
||||
not_recorded: 'Esta versão não foi guardada no evento.',
|
||||
scope_unknown:
|
||||
'O âmbito desta versão antiga não ficou identificado; o seu conteúdo não está disponível para esta conta.',
|
||||
restricted:
|
||||
'Esta versão pertence a uma representação à qual esta conta não tem acesso actual.',
|
||||
};
|
||||
return (
|
||||
<section className="min-w-0 space-y-3 rounded border p-4">
|
||||
<h3 className="font-bold">{title}</h3>
|
||||
{value.availability !== 'available' ? (
|
||||
<p>{unavailable[value.availability]}</p>
|
||||
) : (
|
||||
<>
|
||||
{!value.complete && (
|
||||
<p>
|
||||
Registo parcial. Os campos em falta não foram
|
||||
completados com dados actuais.
|
||||
</p>
|
||||
)}
|
||||
<p>
|
||||
Versão: {value.version ?? 'Não consta do registo'} ·
|
||||
Estado: {display(value.status)}
|
||||
</p>
|
||||
<p>
|
||||
Participação:{' '}
|
||||
{!value.scope_known
|
||||
? 'Âmbito não registado'
|
||||
: value.organization_id
|
||||
? (value.organization_name ??
|
||||
`Organização ${value.organization_id}`)
|
||||
: 'Em nome pessoal'}
|
||||
</p>
|
||||
<dl className="space-y-2">
|
||||
{Object.entries(fields).map(([key, label]) => (
|
||||
<div key={key}>
|
||||
<dt className="font-semibold">{label}</dt>
|
||||
<dd className="break-words whitespace-pre-wrap">
|
||||
{Object.hasOwn(value.fields ?? {}, key)
|
||||
? value.fields?.[key] || 'Não indicado'
|
||||
: 'Não consta do registo'}
|
||||
</dd>
|
||||
</div>
|
||||
))}
|
||||
<div>
|
||||
<dt className="font-semibold">
|
||||
Autorização de partilha
|
||||
</dt>
|
||||
<dd>
|
||||
{value.consent_known
|
||||
? value.consent
|
||||
? 'Autorizada'
|
||||
: 'Não autorizada'
|
||||
: 'Não consta do registo'}
|
||||
</dd>
|
||||
</div>
|
||||
</dl>
|
||||
<h4 className="font-semibold">Avaliação guardada</h4>
|
||||
{!value.assessment_recorded ? (
|
||||
<p>Não consta do registo.</p>
|
||||
) : !value.assessment?.length ? (
|
||||
<p>Sem critérios avaliados nesta versão.</p>
|
||||
) : (
|
||||
<>
|
||||
<p className="text-sm">
|
||||
Os nomes dos critérios abaixo provêm do catálogo
|
||||
actual; os estados e evidências são os que
|
||||
ficaram guardados.
|
||||
</p>
|
||||
<ul className="space-y-3">
|
||||
{value.assessment.map((item, index) => (
|
||||
<li key={`${item.code}:${index}`}>
|
||||
<p>
|
||||
{item.label} · {display(item.state)}
|
||||
</p>
|
||||
<p className="whitespace-pre-wrap">
|
||||
Evidência:{' '}
|
||||
{item.evidence ||
|
||||
'Não consta do registo'}
|
||||
</p>
|
||||
<p>
|
||||
{item.actor_name ||
|
||||
'Autor não registado'}{' '}
|
||||
·{' '}
|
||||
{item.assessed_at ||
|
||||
'Data não registada'}
|
||||
</p>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</>
|
||||
)}
|
||||
{Object.keys(value.references ?? {}).length > 0 && (
|
||||
<details>
|
||||
<summary>Referências guardadas</summary>
|
||||
<dl>
|
||||
{Object.entries(value.references ?? {}).map(
|
||||
([key, id]) => (
|
||||
<div key={key}>
|
||||
<dt>
|
||||
{key === 'sector_id'
|
||||
? 'Sector'
|
||||
: 'Localização'}{' '}
|
||||
· referência
|
||||
</dt>
|
||||
<dd className="break-all">{id}</dd>
|
||||
</div>
|
||||
),
|
||||
)}
|
||||
</dl>
|
||||
</details>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</section>
|
||||
);
|
||||
}
|
||||
function FrozenMatching({ value }: { value: Matching | null }) {
|
||||
if (!value)
|
||||
return (
|
||||
<p>
|
||||
O contexto de correspondência não ficou guardado ou não está
|
||||
disponível neste âmbito. Não foi recalculado.
|
||||
</p>
|
||||
);
|
||||
return (
|
||||
<section className="space-y-3 rounded border p-4">
|
||||
<h3 className="font-bold">Correspondência guardada na decisão</h3>
|
||||
<p>
|
||||
Intervalo:{' '}
|
||||
{value.score_min === null || value.score_max === null
|
||||
? 'Por determinar'
|
||||
: `${value.score_min}–${value.score_max}%`}{' '}
|
||||
· Elegibilidade: {display(value.eligibility)}. Este registo não
|
||||
constitui aprovação.
|
||||
</p>
|
||||
<p>
|
||||
São apresentados os parâmetros guardados, sem aplicar os
|
||||
critérios actuais.
|
||||
</p>
|
||||
<ul className="space-y-3">
|
||||
{value.criteria.map((item, index) => (
|
||||
<li key={`${item.code}:${index}`}>
|
||||
<p>
|
||||
{item.label ?? item.code} · Peso:{' '}
|
||||
{item.weight ?? 'Por determinar'} ·{' '}
|
||||
{display(item.state)} ·{' '}
|
||||
{item.mandatory === null
|
||||
? 'Obrigatoriedade não registada'
|
||||
: item.mandatory
|
||||
? 'Obrigatório'
|
||||
: 'Não obrigatório'}
|
||||
</p>
|
||||
<p className="whitespace-pre-wrap">
|
||||
Evidência:{' '}
|
||||
{item.evidence || 'Não consta do registo'}
|
||||
</p>
|
||||
<p>{item.explanation || 'Explicação não registada'}</p>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
<details>
|
||||
<summary>Parâmetros do cálculo guardado</summary>
|
||||
<p>
|
||||
Algoritmo:{' '}
|
||||
{value.algorithm_version ?? 'Não consta do registo'}
|
||||
</p>
|
||||
<p className="break-all">
|
||||
Referência dos pesos:{' '}
|
||||
{value.weights_hash ?? 'Não consta do registo'}
|
||||
</p>
|
||||
<p>
|
||||
Peso desconhecido:{' '}
|
||||
{value.unknown_weight ?? 'Por determinar'}
|
||||
</p>
|
||||
</details>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
export default function InterestHistory(p: Props) {
|
||||
return (
|
||||
<Frame title={`Versões e decisões · Candidatura ${p.candidacy_id}`}>
|
||||
<div className="space-y-6 break-words">
|
||||
<nav
|
||||
aria-label="Navegação do histórico"
|
||||
className="flex flex-wrap gap-4"
|
||||
>
|
||||
<Link className="underline" href={p.dashboard_href}>
|
||||
Painel de parcerias
|
||||
</Link>
|
||||
{p.partnership_href && (
|
||||
<Link className="underline" href={p.partnership_href}>
|
||||
Consultar parceria
|
||||
</Link>
|
||||
)}
|
||||
{p.older_page && (
|
||||
<Link className="underline" href={p.first_url}>
|
||||
Versões mais recentes
|
||||
</Link>
|
||||
)}
|
||||
</nav>
|
||||
<p>
|
||||
Consulta dos valores guardados em cada alteração, do mais
|
||||
recente para o mais antigo. Os nomes de pessoas e
|
||||
organizações são os disponíveis no cadastro actual para as
|
||||
referências guardadas.
|
||||
</p>
|
||||
{!p.entries.length && (
|
||||
<p>Ainda não existem versões guardadas para apresentar.</p>
|
||||
)}
|
||||
{p.entries.map((entry, index) => (
|
||||
<details
|
||||
className="space-y-4 rounded border p-4"
|
||||
key={index}
|
||||
open={index === 0}
|
||||
>
|
||||
<summary className="cursor-pointer font-bold">
|
||||
Versão {entry.version ?? 'não registada'} ·{' '}
|
||||
{entry.restricted
|
||||
? 'Conteúdo reservado'
|
||||
: (actions[entry.action ?? ''] ??
|
||||
'Alteração registada')}
|
||||
</summary>
|
||||
{!entry.restricted && (
|
||||
<>
|
||||
<p>
|
||||
{entry.actor_name ?? 'Autor não registado'}{' '}
|
||||
·{' '}
|
||||
{entry.occurred_at ?? 'Data não registada'}
|
||||
</p>
|
||||
<p>
|
||||
Versão da parceria:{' '}
|
||||
{entry.partnership_version ??
|
||||
'Não consta do registo'}
|
||||
</p>
|
||||
{entry.reason && (
|
||||
<p className="whitespace-pre-wrap">
|
||||
Motivo: {entry.reason}
|
||||
</p>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
<div className="grid gap-4 lg:grid-cols-2">
|
||||
<Version
|
||||
title="Antes da alteração"
|
||||
value={entry.previous}
|
||||
/>
|
||||
<Version
|
||||
title="Após a alteração"
|
||||
value={entry.after}
|
||||
/>
|
||||
</div>
|
||||
{!entry.restricted && (
|
||||
<FrozenMatching value={entry.matching} />
|
||||
)}
|
||||
</details>
|
||||
))}
|
||||
{p.next_url && (
|
||||
<Link className="inline-block underline" href={p.next_url}>
|
||||
Consultar versões anteriores
|
||||
</Link>
|
||||
)}
|
||||
</div>
|
||||
</Frame>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,349 @@
|
||||
import { Link } from '@inertiajs/react';
|
||||
import { publicationHistoryActions as actions } from '@/lib/partnership-history';
|
||||
import { Frame, labels } from './shared';
|
||||
|
||||
type Snapshot = {
|
||||
availability: 'available' | 'not_recorded' | 'scope_unknown' | 'restricted';
|
||||
version?: number | null;
|
||||
status?: string | null;
|
||||
scope_known?: boolean;
|
||||
organization_id?: string | null;
|
||||
organization_name?: string | null;
|
||||
fields?: Record<string, string | null>;
|
||||
sector_recorded?: boolean;
|
||||
sector_id?: string | null;
|
||||
consent_known?: boolean;
|
||||
consent?: boolean | null;
|
||||
mandatory_known?: boolean;
|
||||
mandatory?: string[];
|
||||
origins_recorded?: boolean;
|
||||
origins_incomplete?: boolean;
|
||||
origins?: { type: string; target_id: string }[];
|
||||
locations_recorded?: boolean;
|
||||
locations_incomplete?: boolean;
|
||||
locations?: {
|
||||
geo_location_id: string;
|
||||
role: string | null;
|
||||
source_reference: string | null;
|
||||
}[];
|
||||
complete?: boolean;
|
||||
};
|
||||
type Entry = {
|
||||
version: number | null;
|
||||
restricted: boolean;
|
||||
action: string | null;
|
||||
actor_name: string | null;
|
||||
occurred_at: string | null;
|
||||
reason: string | null;
|
||||
previous: Snapshot;
|
||||
after: Snapshot;
|
||||
};
|
||||
type Props = {
|
||||
partnership_id: number;
|
||||
entries: Entry[];
|
||||
first_url: string;
|
||||
next_url: string | null;
|
||||
older_page: boolean;
|
||||
partnership_href: string;
|
||||
dashboard_href: string;
|
||||
};
|
||||
const fields: Record<string, string> = {
|
||||
title: 'Título',
|
||||
kind: 'Oferta ou procura',
|
||||
partnership_type: 'Tipo de parceria',
|
||||
summary: 'Resumo público',
|
||||
offer: 'O que oferece',
|
||||
seeking: 'O que procura',
|
||||
requirements: 'Requisitos',
|
||||
availability: 'Disponibilidade',
|
||||
confidentiality: 'Partilha dos detalhes',
|
||||
deadline: 'Prazo',
|
||||
published_at: 'Data de publicação guardada',
|
||||
};
|
||||
function display(key: string, value: string | null | undefined) {
|
||||
if (!value) return 'Não indicado';
|
||||
if (key === 'kind')
|
||||
return value === 'offering'
|
||||
? 'Oferta'
|
||||
: value === 'seeking'
|
||||
? 'Procura'
|
||||
: value;
|
||||
if (key === 'confidentiality')
|
||||
return value === 'private'
|
||||
? 'Detalhes reservados à conexão privada'
|
||||
: value === 'public'
|
||||
? 'Pública'
|
||||
: value;
|
||||
return value;
|
||||
}
|
||||
function Version({ value, title }: { value: Snapshot; title: string }) {
|
||||
const unavailable = {
|
||||
not_recorded: 'Esta versão não foi guardada no evento.',
|
||||
scope_unknown:
|
||||
'O âmbito ou a identidade desta versão antiga não está suficientemente identificado para a apresentar nesta consulta.',
|
||||
restricted:
|
||||
'Esta versão pertence a uma representação à qual a conta não tem acesso actual.',
|
||||
};
|
||||
return (
|
||||
<section className="min-w-0 space-y-3 rounded border p-4">
|
||||
<h3 className="font-bold">{title}</h3>
|
||||
{value.availability !== 'available' ? (
|
||||
<p>{unavailable[value.availability]}</p>
|
||||
) : (
|
||||
<>
|
||||
{!value.complete && (
|
||||
<p>
|
||||
Registo parcial. Os campos em falta não foram
|
||||
preenchidos com dados actuais.
|
||||
</p>
|
||||
)}
|
||||
<p>
|
||||
Versão: {value.version ?? 'Não consta do registo'} ·
|
||||
Estado:{' '}
|
||||
{value.status
|
||||
? (labels[value.status] ?? value.status)
|
||||
: 'Não consta do registo'}
|
||||
</p>
|
||||
<p>
|
||||
Participação:{' '}
|
||||
{!value.scope_known
|
||||
? 'Âmbito não registado'
|
||||
: value.organization_id
|
||||
? (value.organization_name ??
|
||||
`Organização ${value.organization_id}`)
|
||||
: 'Em nome pessoal'}
|
||||
</p>
|
||||
<dl className="space-y-3">
|
||||
{Object.entries(fields).map(([key, label]) => (
|
||||
<div key={key}>
|
||||
<dt className="font-semibold">{label}</dt>
|
||||
<dd className="break-words whitespace-pre-wrap">
|
||||
{Object.hasOwn(value.fields ?? {}, key)
|
||||
? display(key, value.fields?.[key])
|
||||
: 'Não consta do registo'}
|
||||
</dd>
|
||||
</div>
|
||||
))}
|
||||
<div>
|
||||
<dt className="font-semibold">
|
||||
Autorização de partilha
|
||||
</dt>
|
||||
<dd>
|
||||
{value.consent_known
|
||||
? value.consent
|
||||
? 'Autorizada'
|
||||
: 'Não autorizada'
|
||||
: 'Não consta do registo'}
|
||||
</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt className="font-semibold">
|
||||
Critérios obrigatórios · códigos guardados
|
||||
</dt>
|
||||
<dd>
|
||||
{!value.mandatory_known
|
||||
? 'Não consta do registo'
|
||||
: value.mandatory?.length
|
||||
? value.mandatory.join(', ')
|
||||
: 'Sem critérios obrigatórios nesta versão'}
|
||||
</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt className="font-semibold">
|
||||
Referência do sector
|
||||
</dt>
|
||||
<dd>
|
||||
{value.sector_recorded
|
||||
? (value.sector_id ??
|
||||
'Sem classificação indicada')
|
||||
: 'Não consta do registo'}
|
||||
</dd>
|
||||
</div>
|
||||
</dl>
|
||||
<details>
|
||||
<summary>
|
||||
Referências da origem e localização guardadas
|
||||
</summary>
|
||||
<div className="mt-3 space-y-3">
|
||||
<p>
|
||||
As referências identificam as ligações guardadas
|
||||
nesta versão. Consultar os dados das fontes
|
||||
continua sujeito às suas permissões actuais.
|
||||
</p>
|
||||
<h4 className="font-semibold">Origens</h4>
|
||||
{!value.origins_recorded ? (
|
||||
<p>Não constam do registo.</p>
|
||||
) : (
|
||||
<>
|
||||
{value.origins_incomplete && (
|
||||
<p>
|
||||
Há referências incompletas que não
|
||||
podem ser apresentadas
|
||||
integralmente.
|
||||
</p>
|
||||
)}
|
||||
{!value.origins?.length &&
|
||||
!value.origins_incomplete ? (
|
||||
<p>Sem origens ligadas nesta versão.</p>
|
||||
) : (
|
||||
<ul>
|
||||
{value.origins?.map(
|
||||
(origin, index) => (
|
||||
<li
|
||||
className="break-all"
|
||||
key={index}
|
||||
>
|
||||
{origin.type} ·{' '}
|
||||
{origin.target_id}
|
||||
</li>
|
||||
),
|
||||
)}
|
||||
</ul>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
<h4 className="font-semibold">Localizações</h4>
|
||||
{!value.locations_recorded ? (
|
||||
<p>Não constam do registo.</p>
|
||||
) : (
|
||||
<>
|
||||
{value.locations_incomplete && (
|
||||
<p>
|
||||
Há localizações incompletas que não
|
||||
podem ser apresentadas
|
||||
integralmente.
|
||||
</p>
|
||||
)}
|
||||
{!value.locations?.length &&
|
||||
!value.locations_incomplete ? (
|
||||
<p>
|
||||
Sem localizações ligadas nesta
|
||||
versão.
|
||||
</p>
|
||||
) : (
|
||||
<ul className="space-y-2">
|
||||
{value.locations?.map(
|
||||
(location, index) => (
|
||||
<li
|
||||
className="break-words"
|
||||
key={index}
|
||||
>
|
||||
<p>
|
||||
Referência:{' '}
|
||||
{
|
||||
location.geo_location_id
|
||||
}{' '}
|
||||
·{' '}
|
||||
{location.role
|
||||
? ({
|
||||
primary:
|
||||
'Principal',
|
||||
operating:
|
||||
'Área de actuação',
|
||||
coverage:
|
||||
'Abrangência',
|
||||
}[
|
||||
location
|
||||
.role
|
||||
] ??
|
||||
location.role)
|
||||
: 'Papel não registado'}
|
||||
</p>
|
||||
<p className="whitespace-pre-wrap">
|
||||
Fonte declarada:{' '}
|
||||
{location.source_reference ||
|
||||
'Não consta do registo'}
|
||||
</p>
|
||||
</li>
|
||||
),
|
||||
)}
|
||||
</ul>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</details>
|
||||
</>
|
||||
)}
|
||||
</section>
|
||||
);
|
||||
}
|
||||
export default function PublicationHistory(p: Props) {
|
||||
return (
|
||||
<Frame
|
||||
title={`Versões e decisões da publicação · Parceria ${p.partnership_id}`}
|
||||
>
|
||||
<div className="space-y-6 break-words">
|
||||
<nav
|
||||
className="flex flex-wrap gap-4"
|
||||
aria-label="Navegação do histórico"
|
||||
>
|
||||
<Link className="underline" href={p.dashboard_href}>
|
||||
Painel de parcerias
|
||||
</Link>
|
||||
<Link className="underline" href={p.partnership_href}>
|
||||
Consultar parceria
|
||||
</Link>
|
||||
{p.older_page && (
|
||||
<Link className="underline" href={p.first_url}>
|
||||
Versões mais recentes
|
||||
</Link>
|
||||
)}
|
||||
</nav>
|
||||
<p>
|
||||
São apresentados os valores guardados, do mais recente para
|
||||
o mais antigo. Os nomes de pessoas e organizações provêm do
|
||||
cadastro actual das referências identificadas. Este
|
||||
histórico não restaura nem volta a publicar versões.
|
||||
</p>
|
||||
{!p.entries.length && (
|
||||
<p>Não existem versões guardadas para apresentar.</p>
|
||||
)}
|
||||
{p.entries.map((entry, index) => (
|
||||
<details
|
||||
className="space-y-4 rounded border p-4"
|
||||
key={index}
|
||||
open={index === 0}
|
||||
>
|
||||
<summary className="cursor-pointer font-bold">
|
||||
Versão {entry.version ?? 'não registada'} ·{' '}
|
||||
{entry.restricted
|
||||
? 'Conteúdo reservado'
|
||||
: (actions[entry.action ?? ''] ??
|
||||
'Alteração registada')}
|
||||
</summary>
|
||||
{!entry.restricted && (
|
||||
<>
|
||||
<p>
|
||||
{entry.actor_name ?? 'Autor não registado'}{' '}
|
||||
·{' '}
|
||||
{entry.occurred_at ?? 'Data não registada'}
|
||||
</p>
|
||||
{entry.reason !== null && (
|
||||
<p className="whitespace-pre-wrap">
|
||||
Motivo: {entry.reason}
|
||||
</p>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
<div className="grid gap-4 lg:grid-cols-2">
|
||||
<Version
|
||||
title="Antes da alteração"
|
||||
value={entry.previous}
|
||||
/>
|
||||
<Version
|
||||
title="Após a alteração"
|
||||
value={entry.after}
|
||||
/>
|
||||
</div>
|
||||
</details>
|
||||
))}
|
||||
{p.next_url && (
|
||||
<Link className="inline-block underline" href={p.next_url}>
|
||||
Consultar versões anteriores
|
||||
</Link>
|
||||
)}
|
||||
</div>
|
||||
</Frame>
|
||||
);
|
||||
}
|
||||
@@ -1,5 +1,10 @@
|
||||
import { createOperationKey } from '@/lib/operation-key';
|
||||
import { useForm, usePage, Link, router } from '@inertiajs/react';
|
||||
import { usePage, Link, router } from '@inertiajs/react';
|
||||
import { useCallback, useEffect, useRef, useState } from 'react';
|
||||
import { useRoomEdit, useRoomLeaveGuard } from '@/lib/partnership-room-edit';
|
||||
import RoomComparison from '@/components/partnership-room-comparison';
|
||||
import { useRoomDelivery } from '@/lib/partnership-room-delivery';
|
||||
import { readAgreement } from '@/lib/partnership-agreement';
|
||||
import AgreementInstrument from '@/components/partnership-agreement-instrument';
|
||||
import {
|
||||
Frame,
|
||||
Field,
|
||||
@@ -13,31 +18,44 @@ type Room = {
|
||||
id: number;
|
||||
status: string;
|
||||
version: number;
|
||||
agreement: {
|
||||
title: string;
|
||||
terms: string;
|
||||
confirmations: Record<string, { actor_id: number; date: string }>;
|
||||
legal_signature_status: string;
|
||||
} | null;
|
||||
agreement: unknown;
|
||||
};
|
||||
type Milestone = {
|
||||
id: number;
|
||||
title: string;
|
||||
responsible_id: number;
|
||||
responsible_name: string | null;
|
||||
responsible_is_participant: boolean;
|
||||
due_date: string | null;
|
||||
status: string;
|
||||
evidence: string | null;
|
||||
version: number;
|
||||
client_key?: string | null;
|
||||
};
|
||||
type Props = {
|
||||
agreementActorId: number;
|
||||
agreementParty: 'proponent' | 'candidate' | null;
|
||||
agreementCommands: {
|
||||
key: string;
|
||||
action: string;
|
||||
version: number;
|
||||
status: string;
|
||||
party: string | null;
|
||||
}[];
|
||||
room: Room;
|
||||
partnership: Partnership & { user_id: number };
|
||||
interest: { id: number; user_id: number };
|
||||
interest: { id: number; user_id: number; version: number };
|
||||
canWrite: boolean;
|
||||
participants: {
|
||||
id: number;
|
||||
name: string;
|
||||
parties: ('proponent' | 'candidate')[];
|
||||
}[];
|
||||
messages: {
|
||||
id: number;
|
||||
name: string;
|
||||
author_id: number;
|
||||
client_key?: string | null;
|
||||
body: string;
|
||||
created_at: string;
|
||||
}[];
|
||||
@@ -48,119 +66,267 @@ type Props = {
|
||||
shared: boolean;
|
||||
status: string;
|
||||
malware_scan_status: string;
|
||||
document_id: string;
|
||||
}[];
|
||||
milestones: Milestone[];
|
||||
};
|
||||
function MilestoneForm({ p, item }: { p: Props; item?: Milestone }) {
|
||||
const form = useForm({
|
||||
title: item?.title ?? '',
|
||||
responsible_id: item?.responsible_id ?? p.partnership.user_id,
|
||||
due_date: item?.due_date ?? '',
|
||||
status: item?.status ?? 'pending',
|
||||
evidence: item?.evidence ?? '',
|
||||
version: item?.version ?? null,
|
||||
function MilestoneForm({
|
||||
p,
|
||||
item,
|
||||
onDirty,
|
||||
}: {
|
||||
p: Props;
|
||||
item?: Milestone;
|
||||
onDirty?: (id: string, dirty: boolean) => void;
|
||||
}) {
|
||||
const editor = useRoomEdit({
|
||||
props: p,
|
||||
roomId: p.room.id,
|
||||
kind: 'milestone',
|
||||
itemId: item?.id ?? null,
|
||||
});
|
||||
const form = editor.form;
|
||||
const draftId = 'milestone:' + (item?.id ?? 'new');
|
||||
useEffect(() => {
|
||||
onDirty?.(draftId, editor.dirty);
|
||||
}, [onDirty, draftId, editor.dirty]);
|
||||
useEffect(() => () => onDirty?.(draftId, false), [onDirty, draftId]);
|
||||
if (!editor.editable && !editor.dirty && !editor.problem) return null;
|
||||
const currentResponsible = p.participants.some(
|
||||
(participant) =>
|
||||
String(participant.id) === editor.values.responsible_id,
|
||||
);
|
||||
return (
|
||||
<form
|
||||
data-room-form={draftId}
|
||||
className="space-y-3 rounded border p-4"
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
if (item)
|
||||
form.put(
|
||||
`/parcerias/salas/${p.room.id}/marcos/${item.id}`,
|
||||
{ preserveScroll: true },
|
||||
);
|
||||
else
|
||||
form.post(`/parcerias/salas/${p.room.id}/marcos`, {
|
||||
preserveScroll: true,
|
||||
});
|
||||
if (
|
||||
form.processing ||
|
||||
(!currentResponsible && !editor.recovering)
|
||||
)
|
||||
return;
|
||||
editor.submit();
|
||||
}}
|
||||
>
|
||||
<h3 className="font-bold">
|
||||
{item ? 'Atualizar marco' : 'Acrescentar marco'}
|
||||
</h3>
|
||||
<Field label="Entregável">
|
||||
<input
|
||||
className={control}
|
||||
value={form.data.title}
|
||||
onChange={(e) => form.setData('title', e.target.value)}
|
||||
/>
|
||||
</Field>
|
||||
<Field label="Responsável">
|
||||
<select
|
||||
className={control}
|
||||
value={form.data.responsible_id}
|
||||
onChange={(e) =>
|
||||
form.setData('responsible_id', Number(e.target.value))
|
||||
}
|
||||
>
|
||||
<option value={p.partnership.user_id}>Proponente</option>
|
||||
<option value={p.interest.user_id}>Candidato</option>
|
||||
</select>
|
||||
</Field>
|
||||
<Field label="Data prevista">
|
||||
<input
|
||||
className={control}
|
||||
type="date"
|
||||
value={form.data.due_date}
|
||||
onChange={(e) => form.setData('due_date', e.target.value)}
|
||||
/>
|
||||
</Field>
|
||||
<Field label="Estado">
|
||||
<select
|
||||
className={control}
|
||||
value={form.data.status}
|
||||
onChange={(e) => form.setData('status', e.target.value)}
|
||||
>
|
||||
{['pending', 'progress', 'completed'].map((x) => (
|
||||
<option key={x} value={x}>
|
||||
{x === 'pending' ? 'Pendente' : labels[x]}
|
||||
<RoomComparison
|
||||
editor={editor}
|
||||
labels={{
|
||||
title: 'Entregável',
|
||||
responsible_id: 'Responsável pelo marco',
|
||||
due_date: 'Data prevista',
|
||||
status: 'Estado',
|
||||
evidence: 'Evidência ou referência do resultado',
|
||||
}}
|
||||
display={(key, value) =>
|
||||
key === 'responsible_id'
|
||||
? (p.participants.find(
|
||||
(person) => String(person.id) === value,
|
||||
)?.name ??
|
||||
(String(item?.responsible_id) === value
|
||||
? item?.responsible_name
|
||||
: null) ??
|
||||
'Participante já indisponível')
|
||||
: key === 'status'
|
||||
? value === 'pending'
|
||||
? 'Pendente'
|
||||
: (labels[value] ?? value)
|
||||
: value || 'Não indicado'
|
||||
}
|
||||
/>
|
||||
<fieldset
|
||||
disabled={!editor.editable || form.processing}
|
||||
className="space-y-3"
|
||||
>
|
||||
<Field label="Entregável">
|
||||
<input
|
||||
className={control}
|
||||
value={editor.values.title}
|
||||
onChange={(e) => editor.change('title', e.target.value)}
|
||||
/>
|
||||
</Field>
|
||||
<Field label="Responsável pelo marco">
|
||||
<select
|
||||
className={control}
|
||||
required
|
||||
value={editor.values.responsible_id}
|
||||
onChange={(e) =>
|
||||
editor.change('responsible_id', e.target.value)
|
||||
}
|
||||
>
|
||||
<option value="">
|
||||
Seleccione um participante autorizado
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</Field>
|
||||
<Field label="Evidência ou referência do resultado">
|
||||
<textarea
|
||||
className={control}
|
||||
value={form.data.evidence}
|
||||
onChange={(e) => form.setData('evidence', e.target.value)}
|
||||
/>
|
||||
</Field>
|
||||
{item &&
|
||||
!p.participants.some(
|
||||
(participant) =>
|
||||
participant.id === item.responsible_id,
|
||||
) && (
|
||||
<option
|
||||
value={String(item.responsible_id)}
|
||||
disabled
|
||||
>
|
||||
{item.responsible_name ??
|
||||
'Responsável registado indisponível'}{' '}
|
||||
{item.responsible_is_participant
|
||||
? '— atribuição registada; selecção indisponível neste estado'
|
||||
: '— sem representação actual'}
|
||||
</option>
|
||||
)}
|
||||
{p.participants.map((participant) => (
|
||||
<option
|
||||
key={participant.id}
|
||||
value={String(participant.id)}
|
||||
>
|
||||
{participant.name} —{' '}
|
||||
{participant.parties
|
||||
.map((party) =>
|
||||
party === 'proponent'
|
||||
? 'Proponente'
|
||||
: 'Candidato',
|
||||
)
|
||||
.join(' / ')}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</Field>
|
||||
{editor.editable &&
|
||||
editor.values.responsible_id &&
|
||||
!currentResponsible && (
|
||||
<p role="status">
|
||||
{item &&
|
||||
editor.values.responsible_id ===
|
||||
String(item.responsible_id)
|
||||
? 'A atribuição anterior foi conservada. Para guardar uma alteração, seleccione um participante actualmente autorizado; consultar não altera o responsável.'
|
||||
: 'O participante seleccionado deixou de estar disponível para esta atribuição. Escolha outro participante autorizado antes de guardar.'}
|
||||
</p>
|
||||
)}
|
||||
<Field label="Data prevista">
|
||||
<input
|
||||
className={control}
|
||||
type="date"
|
||||
value={editor.values.due_date}
|
||||
onChange={(e) =>
|
||||
editor.change('due_date', e.target.value)
|
||||
}
|
||||
/>
|
||||
</Field>
|
||||
<Field label="Estado">
|
||||
<select
|
||||
className={control}
|
||||
value={editor.values.status}
|
||||
onChange={(e) =>
|
||||
editor.change('status', e.target.value)
|
||||
}
|
||||
>
|
||||
{['pending', 'progress', 'completed'].map((x) => (
|
||||
<option key={x} value={x}>
|
||||
{x === 'pending' ? 'Pendente' : labels[x]}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</Field>
|
||||
<Field label="Evidência ou referência do resultado">
|
||||
<textarea
|
||||
className={control}
|
||||
value={editor.values.evidence}
|
||||
onChange={(e) =>
|
||||
editor.change('evidence', e.target.value)
|
||||
}
|
||||
/>
|
||||
</Field>
|
||||
</fieldset>
|
||||
<Errors errors={form.errors} />
|
||||
<button className={button} disabled={form.processing}>
|
||||
Guardar marco
|
||||
<button
|
||||
className={button}
|
||||
disabled={
|
||||
form.processing ||
|
||||
editor.blocked ||
|
||||
(!currentResponsible && !editor.recovering)
|
||||
}
|
||||
>
|
||||
{editor.recovering
|
||||
? 'Recuperar criação do marco'
|
||||
: 'Guardar marco'}
|
||||
</button>
|
||||
</form>
|
||||
);
|
||||
}
|
||||
export default function Page(p: Props) {
|
||||
return <RoomPage key={p.room.id + ':' + p.room.version} {...p} />;
|
||||
}
|
||||
function RoomPage(p: Props) {
|
||||
const { auth } = usePage<{ auth: { user: { id: number } } }>().props;
|
||||
const message = useForm({ body: '', client_key: createOperationKey() });
|
||||
const agreement = useForm({
|
||||
version: p.room.version,
|
||||
action: 'record',
|
||||
title: p.room.agreement?.title ?? '',
|
||||
terms: p.room.agreement?.terms ?? '',
|
||||
reason: '',
|
||||
});
|
||||
const upload = useForm<{ file: File | null; shared: boolean }>({
|
||||
file: null,
|
||||
shared: false,
|
||||
});
|
||||
const act = (action: string) => {
|
||||
agreement.transform((data) => ({ ...data, action }));
|
||||
agreement.post(`/parcerias/salas/${p.room.id}/acordo`, {
|
||||
preserveScroll: true,
|
||||
});
|
||||
};
|
||||
const openedRoom = useRef(p.room.id);
|
||||
return (
|
||||
<RoomPage
|
||||
key={openedRoom.current + ':' + auth.user.id}
|
||||
{...p}
|
||||
expectedRoomId={openedRoom.current}
|
||||
/>
|
||||
);
|
||||
}
|
||||
function RoomPage(p: Props & { expectedRoomId: number }) {
|
||||
const instrument = readAgreement(p.room.agreement);
|
||||
const { auth } = usePage<{ auth: { user: { id: number } } }>().props;
|
||||
const mutable =
|
||||
p.canWrite && !['closed', 'cancelled'].includes(p.room.status);
|
||||
p.canWrite &&
|
||||
p.room.id === p.expectedRoomId &&
|
||||
!['closed', 'cancelled'].includes(p.room.status);
|
||||
const messageEdit = useRoomDelivery({
|
||||
roomId: p.expectedRoomId,
|
||||
actorId: auth.user.id,
|
||||
kind: 'message',
|
||||
mutable,
|
||||
canWrite: p.canWrite && p.room.id === p.expectedRoomId,
|
||||
});
|
||||
const message = messageEdit.form;
|
||||
const agreementEdit = useRoomEdit({
|
||||
props: p,
|
||||
roomId: p.expectedRoomId,
|
||||
kind: 'agreement',
|
||||
});
|
||||
const agreement = agreementEdit.form;
|
||||
const uploadEdit = useRoomDelivery({
|
||||
roomId: p.expectedRoomId,
|
||||
actorId: auth.user.id,
|
||||
kind: 'upload',
|
||||
mutable,
|
||||
canWrite: p.canWrite && p.room.id === p.expectedRoomId,
|
||||
});
|
||||
const upload = uploadEdit.form;
|
||||
const uploadInput = useRef<HTMLInputElement>(null);
|
||||
useEffect(() => {
|
||||
if (!upload.data.file && uploadInput.current)
|
||||
uploadInput.current.value = '';
|
||||
}, [upload.data.file]);
|
||||
const act = (action: string) => agreementEdit.submit(action);
|
||||
const childDrafts = useRef(new Map<string, boolean>());
|
||||
const [childDraftCount, setChildDraftCount] = useState(0);
|
||||
const onDirty = useCallback((id: string, dirty: boolean) => {
|
||||
if ((childDrafts.current.get(id) ?? false) === dirty) return;
|
||||
childDrafts.current.set(id, dirty);
|
||||
setChildDraftCount(
|
||||
[...childDrafts.current.values()].filter(Boolean).length,
|
||||
);
|
||||
}, []);
|
||||
useRoomLeaveGuard(
|
||||
agreementEdit.dirty ||
|
||||
messageEdit.dirty ||
|
||||
uploadEdit.dirty ||
|
||||
childDraftCount > 0,
|
||||
);
|
||||
return (
|
||||
<Frame title={'Conexão privada — ' + p.partnership.title}>
|
||||
<div className="space-y-6">
|
||||
{p.room.id !== p.expectedRoomId && (
|
||||
<p role="alert">
|
||||
A resposta não corresponde à sala aberta. Recupere os
|
||||
dados antes de continuar; a sua preparação foi
|
||||
conservada.
|
||||
</p>
|
||||
)}
|
||||
<Link
|
||||
className="underline"
|
||||
href={'/parcerias/' + p.partnership.id}
|
||||
@@ -184,42 +350,53 @@ function RoomPage(p: Props) {
|
||||
<p className="whitespace-pre-wrap">{m.body}</p>
|
||||
</article>
|
||||
))}
|
||||
{mutable && (
|
||||
{(mutable || messageEdit.dirty) && (
|
||||
<form
|
||||
data-room-form="message"
|
||||
className="space-y-3"
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
message.post(
|
||||
`/parcerias/salas/${p.room.id}/mensagens`,
|
||||
{
|
||||
preserveScroll: true,
|
||||
onSuccess: () => {
|
||||
message.setData({
|
||||
body: '',
|
||||
client_key:
|
||||
createOperationKey(),
|
||||
});
|
||||
},
|
||||
},
|
||||
);
|
||||
messageEdit.submit();
|
||||
}}
|
||||
>
|
||||
<Field label="Mensagem privada">
|
||||
<textarea
|
||||
className={control}
|
||||
disabled={message.processing}
|
||||
disabled={message.processing || !mutable}
|
||||
value={message.data.body}
|
||||
onChange={(e) =>
|
||||
message.setData('body', e.target.value)
|
||||
messageEdit.change(
|
||||
'body',
|
||||
e.target.value,
|
||||
)
|
||||
}
|
||||
/>
|
||||
</Field>
|
||||
<Errors errors={message.errors} />
|
||||
{messageEdit.problem && (
|
||||
<p role="alert">{messageEdit.problem}</p>
|
||||
)}
|
||||
{!mutable && messageEdit.dirty && (
|
||||
<p role="status">
|
||||
A mensagem em preparação foi conservada. O
|
||||
estado ou acesso actual não permite novas
|
||||
mensagens.
|
||||
</p>
|
||||
)}
|
||||
{messageEdit.recovering && (
|
||||
<p role="status">
|
||||
Recuperar repete a mensagem original com a
|
||||
mesma chave; o texto escrito depois fica
|
||||
para outra mensagem.
|
||||
</p>
|
||||
)}
|
||||
<button
|
||||
className={button}
|
||||
disabled={message.processing}
|
||||
disabled={messageEdit.blocked}
|
||||
>
|
||||
Enviar mensagem
|
||||
{messageEdit.recovering
|
||||
? 'Recuperar mensagem enviada'
|
||||
: 'Enviar mensagem'}
|
||||
</button>
|
||||
</form>
|
||||
)}
|
||||
@@ -290,39 +467,42 @@ function RoomPage(p: Props) {
|
||||
)}
|
||||
</article>
|
||||
))}
|
||||
{mutable && (
|
||||
{(mutable || uploadEdit.dirty) && (
|
||||
<form
|
||||
data-room-form="upload"
|
||||
className="space-y-3"
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
upload.post(
|
||||
`/parcerias/salas/${p.room.id}/documentos`,
|
||||
{
|
||||
forceFormData: true,
|
||||
preserveScroll: true,
|
||||
},
|
||||
);
|
||||
uploadEdit.submit();
|
||||
}}
|
||||
>
|
||||
<Field label="Anexar PDF ou imagem">
|
||||
<input
|
||||
type="file"
|
||||
ref={uploadInput}
|
||||
disabled={!mutable || upload.processing}
|
||||
className="w-full max-w-full min-w-0"
|
||||
accept=".pdf,.jpg,.jpeg,.png"
|
||||
onChange={(e) =>
|
||||
upload.setData(
|
||||
uploadEdit.change(
|
||||
'file',
|
||||
e.target.files?.[0] ?? null,
|
||||
)
|
||||
}
|
||||
/>
|
||||
</Field>
|
||||
{upload.data.file && (
|
||||
<p role="status">
|
||||
Ficheiro preparado: {upload.data.file.name}
|
||||
</p>
|
||||
)}
|
||||
<label className="block">
|
||||
<input
|
||||
type="checkbox"
|
||||
disabled={!mutable || upload.processing}
|
||||
checked={upload.data.shared}
|
||||
onChange={(e) =>
|
||||
upload.setData(
|
||||
uploadEdit.change(
|
||||
'shared',
|
||||
e.target.checked,
|
||||
)
|
||||
@@ -331,13 +511,35 @@ function RoomPage(p: Props) {
|
||||
Autorizo a consulta pela contraparte desta sala.
|
||||
</label>
|
||||
<Errors errors={upload.errors} />
|
||||
{uploadEdit.problem && (
|
||||
<p role="alert">{uploadEdit.problem}</p>
|
||||
)}
|
||||
{!mutable && uploadEdit.dirty && (
|
||||
<p role="status">
|
||||
O ficheiro em preparação foi conservado em
|
||||
memória. O estado ou acesso actual não
|
||||
permite novos documentos.
|
||||
</p>
|
||||
)}
|
||||
{uploadEdit.recovering && (
|
||||
<p role="status">
|
||||
Recuperar repete o ficheiro e a autorização
|
||||
originais, sem criar outro documento. Uma
|
||||
selecção posterior fica preparada para outro
|
||||
envio.
|
||||
</p>
|
||||
)}
|
||||
<button
|
||||
className={button}
|
||||
disabled={
|
||||
upload.processing || !upload.data.file
|
||||
uploadEdit.blocked ||
|
||||
(!upload.data.file &&
|
||||
!uploadEdit.recovering)
|
||||
}
|
||||
>
|
||||
Guardar documento privado
|
||||
{uploadEdit.recovering
|
||||
? 'Recuperar envio do documento'
|
||||
: 'Guardar documento privado'}
|
||||
</button>
|
||||
</form>
|
||||
)}
|
||||
@@ -353,143 +555,200 @@ function RoomPage(p: Props) {
|
||||
concordância comunicada pelas partes; não certifica
|
||||
assinatura jurídica ou due diligence.
|
||||
</p>
|
||||
{p.room.agreement && (
|
||||
<>
|
||||
<h3 className="font-bold">
|
||||
{p.room.agreement.title}
|
||||
</h3>
|
||||
<p className="whitespace-pre-wrap">
|
||||
{p.room.agreement.terms}
|
||||
</p>
|
||||
<p>
|
||||
Confirmações:{' '}
|
||||
{Object.entries(p.room.agreement.confirmations)
|
||||
.map(
|
||||
([party, c]) =>
|
||||
`${party}: autor ${c.actor_id}, ${c.date}`,
|
||||
)
|
||||
.join('; ') || 'Pendentes'}
|
||||
</p>
|
||||
</>
|
||||
<Link
|
||||
className="inline-block underline"
|
||||
href={`/parcerias/salas/${p.room.id}/historico`}
|
||||
>
|
||||
Consultar histórico do acordo
|
||||
</Link>
|
||||
<AgreementInstrument value={p.room.agreement} />
|
||||
{p.agreementParty && (
|
||||
<p>
|
||||
A sua acção é registada pela parte{' '}
|
||||
{p.agreementParty === 'proponent'
|
||||
? 'proponente'
|
||||
: 'candidata'}
|
||||
, segundo a representação actual. Registar outra
|
||||
versão retira as confirmações dessa versão e
|
||||
conserva o histórico.
|
||||
</p>
|
||||
)}
|
||||
{mutable && (
|
||||
<RoomComparison
|
||||
editor={agreementEdit}
|
||||
labels={{
|
||||
title: 'Título do instrumento',
|
||||
terms: 'Condições e plano de valor',
|
||||
reason: 'Motivo da acção',
|
||||
}}
|
||||
/>
|
||||
{(mutable || agreementEdit.dirty) && (
|
||||
<>
|
||||
<Field label="Motivo da ação">
|
||||
<textarea
|
||||
className={control}
|
||||
value={agreement.data.reason}
|
||||
onChange={(e) =>
|
||||
agreement.setData(
|
||||
'reason',
|
||||
e.target.value,
|
||||
)
|
||||
}
|
||||
/>
|
||||
</Field>
|
||||
{['negotiation', 'agreement_recorded'].includes(
|
||||
p.room.status,
|
||||
) && (
|
||||
<>
|
||||
<Field label="Título do instrumento">
|
||||
<input
|
||||
className={control}
|
||||
value={agreement.data.title}
|
||||
onChange={(e) =>
|
||||
agreement.setData(
|
||||
'title',
|
||||
e.target.value,
|
||||
)
|
||||
<fieldset
|
||||
data-room-form="agreement"
|
||||
disabled={!agreementEdit.editable}
|
||||
className="space-y-4"
|
||||
>
|
||||
<Field label="Motivo da ação">
|
||||
<textarea
|
||||
className={control}
|
||||
value={agreementEdit.values.reason}
|
||||
onChange={(e) =>
|
||||
agreementEdit.change(
|
||||
'reason',
|
||||
e.target.value,
|
||||
)
|
||||
}
|
||||
/>
|
||||
</Field>
|
||||
{([
|
||||
'negotiation',
|
||||
'agreement_recorded',
|
||||
].includes(p.room.status) ||
|
||||
agreementEdit.dirty) && (
|
||||
<>
|
||||
<Field label="Título do instrumento">
|
||||
<input
|
||||
className={control}
|
||||
disabled={
|
||||
![
|
||||
'negotiation',
|
||||
'agreement_recorded',
|
||||
].includes(p.room.status)
|
||||
}
|
||||
value={
|
||||
agreementEdit.values.title
|
||||
}
|
||||
onChange={(e) =>
|
||||
agreementEdit.change(
|
||||
'title',
|
||||
e.target.value,
|
||||
)
|
||||
}
|
||||
/>
|
||||
</Field>
|
||||
<Field label="Condições e plano de valor">
|
||||
<textarea
|
||||
className={control}
|
||||
rows={6}
|
||||
disabled={
|
||||
![
|
||||
'negotiation',
|
||||
'agreement_recorded',
|
||||
].includes(p.room.status)
|
||||
}
|
||||
value={
|
||||
agreementEdit.values.terms
|
||||
}
|
||||
onChange={(e) =>
|
||||
agreementEdit.change(
|
||||
'terms',
|
||||
e.target.value,
|
||||
)
|
||||
}
|
||||
/>
|
||||
</Field>
|
||||
<button
|
||||
className={button}
|
||||
disabled={
|
||||
agreement.processing ||
|
||||
agreementEdit.blocked ||
|
||||
![
|
||||
'negotiation',
|
||||
'agreement_recorded',
|
||||
].includes(p.room.status) ||
|
||||
!agreementEdit.values.reason
|
||||
}
|
||||
/>
|
||||
</Field>
|
||||
<Field label="Condições e plano de valor">
|
||||
<textarea
|
||||
className={control}
|
||||
rows={6}
|
||||
value={agreement.data.terms}
|
||||
onChange={(e) =>
|
||||
agreement.setData(
|
||||
'terms',
|
||||
e.target.value,
|
||||
)
|
||||
onClick={() => act('record')}
|
||||
>
|
||||
Registar versão do acordo
|
||||
</button>
|
||||
</>
|
||||
)}
|
||||
<div className="flex flex-wrap gap-3">
|
||||
{(agreementEdit.values.title !==
|
||||
agreementEdit.current.title ||
|
||||
agreementEdit.values.terms !==
|
||||
agreementEdit.current.terms) && (
|
||||
<p role="status">
|
||||
Há alterações locais no instrumento
|
||||
ainda por registar. As outras acções
|
||||
referem-se à versão actualmente
|
||||
guardada, apresentada acima.
|
||||
</p>
|
||||
)}
|
||||
{p.room.status === 'agreement_recorded' && (
|
||||
<button
|
||||
className={button}
|
||||
disabled={
|
||||
agreement.processing ||
|
||||
agreementEdit.blocked ||
|
||||
!agreementEdit.values.reason
|
||||
}
|
||||
/>
|
||||
</Field>
|
||||
onClick={() => act('confirm')}
|
||||
>
|
||||
{p.agreementParty &&
|
||||
instrument.confirmations[
|
||||
p.agreementParty
|
||||
]?.actorId
|
||||
? 'Actualizar confirmação da minha parte'
|
||||
: 'Confirmar pela minha parte'}
|
||||
</button>
|
||||
)}
|
||||
{p.room.status === 'agreed' && (
|
||||
<button
|
||||
className={button}
|
||||
disabled={
|
||||
agreement.processing ||
|
||||
agreementEdit.blocked ||
|
||||
!agreementEdit.values.reason
|
||||
}
|
||||
onClick={() => act('start')}
|
||||
>
|
||||
Iniciar acompanhamento
|
||||
</button>
|
||||
)}
|
||||
{p.room.status === 'execution' && (
|
||||
<button
|
||||
className={button}
|
||||
disabled={
|
||||
agreement.processing ||
|
||||
agreementEdit.blocked ||
|
||||
!agreementEdit.values.reason
|
||||
}
|
||||
onClick={() => act('complete')}
|
||||
>
|
||||
Concluir após os marcos
|
||||
</button>
|
||||
)}
|
||||
{['agreed', 'execution'].includes(
|
||||
p.room.status,
|
||||
) && (
|
||||
<button
|
||||
className={button}
|
||||
disabled={
|
||||
agreement.processing ||
|
||||
agreementEdit.blocked ||
|
||||
!agreementEdit.values.reason
|
||||
}
|
||||
onClick={() => act('renew')}
|
||||
>
|
||||
Registar renovação
|
||||
</button>
|
||||
)}
|
||||
<button
|
||||
className={button}
|
||||
disabled={
|
||||
agreement.processing ||
|
||||
!agreement.data.reason
|
||||
agreementEdit.blocked ||
|
||||
!agreementEdit.values.reason
|
||||
}
|
||||
onClick={() => act('record')}
|
||||
onClick={() => act('cancel')}
|
||||
>
|
||||
Registar versão do acordo
|
||||
Cancelar conexão com motivo
|
||||
</button>
|
||||
</>
|
||||
)}
|
||||
<div className="flex flex-wrap gap-3">
|
||||
{p.room.status === 'agreement_recorded' && (
|
||||
<button
|
||||
className={button}
|
||||
disabled={
|
||||
agreement.processing ||
|
||||
!agreement.data.reason
|
||||
}
|
||||
onClick={() => act('confirm')}
|
||||
>
|
||||
Confirmar pela minha parte
|
||||
</button>
|
||||
)}
|
||||
{p.room.status === 'agreed' && (
|
||||
<button
|
||||
className={button}
|
||||
disabled={
|
||||
agreement.processing ||
|
||||
!agreement.data.reason
|
||||
}
|
||||
onClick={() => act('start')}
|
||||
>
|
||||
Iniciar acompanhamento
|
||||
</button>
|
||||
)}
|
||||
{p.room.status === 'execution' && (
|
||||
<button
|
||||
className={button}
|
||||
disabled={
|
||||
agreement.processing ||
|
||||
!agreement.data.reason
|
||||
}
|
||||
onClick={() => act('complete')}
|
||||
>
|
||||
Concluir após os marcos
|
||||
</button>
|
||||
)}
|
||||
{['agreed', 'execution'].includes(
|
||||
p.room.status,
|
||||
) && (
|
||||
<button
|
||||
className={button}
|
||||
disabled={
|
||||
agreement.processing ||
|
||||
!agreement.data.reason
|
||||
}
|
||||
onClick={() => act('renew')}
|
||||
>
|
||||
Registar renovação
|
||||
</button>
|
||||
)}
|
||||
<button
|
||||
className={button}
|
||||
disabled={
|
||||
agreement.processing ||
|
||||
!agreement.data.reason
|
||||
}
|
||||
onClick={() => act('cancel')}
|
||||
>
|
||||
Cancelar conexão com motivo
|
||||
</button>
|
||||
</div>
|
||||
<Errors errors={agreement.errors} />
|
||||
</div>
|
||||
<Errors errors={agreement.errors} />
|
||||
</fieldset>
|
||||
</>
|
||||
)}
|
||||
</section>
|
||||
@@ -505,25 +764,23 @@ function RoomPage(p: Props) {
|
||||
.
|
||||
</p>
|
||||
{p.milestones.map((m) => (
|
||||
<article
|
||||
key={m.id + ':' + m.version}
|
||||
className="space-y-3"
|
||||
>
|
||||
<article key={m.id} className="space-y-3">
|
||||
<p>
|
||||
{m.title} ·{' '}
|
||||
{m.status === 'pending'
|
||||
? 'Pendente'
|
||||
: labels[m.status]}{' '}
|
||||
· Prazo: {m.due_date ?? 'Pendente'} ·
|
||||
Responsável ID {m.responsible_id}
|
||||
Responsável:{' '}
|
||||
{m.responsible_name ??
|
||||
'Responsável registado indisponível'}
|
||||
{!m.responsible_is_participant &&
|
||||
' · Sem representação actual; atribuição anterior conservada'}
|
||||
</p>
|
||||
{mutable && <MilestoneForm p={p} item={m} />}
|
||||
<MilestoneForm p={p} item={m} onDirty={onDirty} />
|
||||
</article>
|
||||
))}
|
||||
{mutable &&
|
||||
['agreement_recorded', 'agreed', 'execution'].includes(
|
||||
p.room.status,
|
||||
) && <MilestoneForm p={p} />}
|
||||
<MilestoneForm p={p} onDirty={onDirty} />
|
||||
</section>
|
||||
</div>
|
||||
</Frame>
|
||||
|
||||
@@ -28,6 +28,7 @@ export type Partnership = {
|
||||
title: string;
|
||||
status: string;
|
||||
version: number;
|
||||
client_key?: string | null;
|
||||
kind: string;
|
||||
partnership_type: string | null;
|
||||
sector_id: number | null;
|
||||
@@ -45,6 +46,7 @@ export type Partnership = {
|
||||
};
|
||||
};
|
||||
export type Match = {
|
||||
weights_hash?: string;
|
||||
score_min: number | null;
|
||||
score_max: number | null;
|
||||
eligibility: string;
|
||||
@@ -67,12 +69,16 @@ export type Interest = {
|
||||
status: string;
|
||||
decision_reason: string | null;
|
||||
organization_id: string | null;
|
||||
can_edit?: boolean;
|
||||
commands?: { key: string; version: number; action: string }[];
|
||||
payload: {
|
||||
capacity?: string;
|
||||
availability?: string;
|
||||
contribution?: string;
|
||||
conflicts?: string;
|
||||
consent?: boolean;
|
||||
sector_id?: number | null;
|
||||
territory_id?: string | null;
|
||||
};
|
||||
assessment: Record<string, { state: string; evidence?: string }>;
|
||||
match: Match;
|
||||
|
||||
Reference in New Issue
Block a user