789 lines
36 KiB
TypeScript
789 lines
36 KiB
TypeScript
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,
|
|
Errors,
|
|
control,
|
|
button,
|
|
labels,
|
|
type Partnership,
|
|
} from './shared';
|
|
type Room = {
|
|
id: number;
|
|
status: string;
|
|
version: number;
|
|
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; 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;
|
|
}[];
|
|
documents: {
|
|
id: number;
|
|
owner_id: number;
|
|
file_name: string;
|
|
shared: boolean;
|
|
status: string;
|
|
malware_scan_status: string;
|
|
document_id: string;
|
|
}[];
|
|
milestones: Milestone[];
|
|
};
|
|
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 (
|
|
form.processing ||
|
|
(!currentResponsible && !editor.recovering)
|
|
)
|
|
return;
|
|
editor.submit();
|
|
}}
|
|
>
|
|
<h3 className="font-bold">
|
|
{item ? 'Atualizar marco' : 'Acrescentar marco'}
|
|
</h3>
|
|
<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>
|
|
{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 ||
|
|
editor.blocked ||
|
|
(!currentResponsible && !editor.recovering)
|
|
}
|
|
>
|
|
{editor.recovering
|
|
? 'Recuperar criação do marco'
|
|
: 'Guardar marco'}
|
|
</button>
|
|
</form>
|
|
);
|
|
}
|
|
export default function Page(p: Props) {
|
|
const { auth } = usePage<{ auth: { user: { id: number } } }>().props;
|
|
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 &&
|
|
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}
|
|
>
|
|
Regressar à parceria
|
|
</Link>
|
|
<p>
|
|
Estado da conexão: {labels[p.room.status]}. Esta sala
|
|
pertence apenas às partes autorizadas; não encerra outras
|
|
candidaturas.
|
|
</p>
|
|
<section className="space-y-4 rounded border p-5">
|
|
<h2 className="text-xl font-bold">
|
|
Mensagens e esclarecimentos
|
|
</h2>
|
|
{p.messages.map((m) => (
|
|
<article className="bg-muted rounded p-4" key={m.id}>
|
|
<p className="font-semibold">
|
|
{m.name} · {m.created_at}
|
|
</p>
|
|
<p className="whitespace-pre-wrap">{m.body}</p>
|
|
</article>
|
|
))}
|
|
{(mutable || messageEdit.dirty) && (
|
|
<form
|
|
data-room-form="message"
|
|
className="space-y-3"
|
|
onSubmit={(e) => {
|
|
e.preventDefault();
|
|
messageEdit.submit();
|
|
}}
|
|
>
|
|
<Field label="Mensagem privada">
|
|
<textarea
|
|
className={control}
|
|
disabled={message.processing || !mutable}
|
|
value={message.data.body}
|
|
onChange={(e) =>
|
|
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={messageEdit.blocked}
|
|
>
|
|
{messageEdit.recovering
|
|
? 'Recuperar mensagem enviada'
|
|
: 'Enviar mensagem'}
|
|
</button>
|
|
</form>
|
|
)}
|
|
</section>
|
|
<section className="space-y-4 rounded border p-5">
|
|
<h2 className="text-xl font-bold">
|
|
Documentos autorizados
|
|
</h2>
|
|
<p>
|
|
O original fica no repositório privado. A partilha exige
|
|
autorização explícita; o download exige análise
|
|
antimalware limpa e hash correspondente. Anexar não
|
|
confirma autenticidade nem vigência.
|
|
</p>
|
|
<p
|
|
role="status"
|
|
aria-live="polite"
|
|
aria-label="Documentos disponíveis nesta sala"
|
|
>
|
|
{p.documents.length
|
|
? `${p.documents.length} documento(s) disponível(is) para esta conta.`
|
|
: 'Nenhum documento está autorizado para consulta por esta conta nesta sala.'}
|
|
</p>
|
|
{!mutable &&
|
|
p.documents.some(
|
|
(d) => d.shared && d.owner_id === auth.user.id,
|
|
) && (
|
|
<p role="status" aria-live="polite">
|
|
A sala está encerrada. O autor pode retirar uma
|
|
autorização de partilha existente; novas
|
|
partilhas permanecem indisponíveis.
|
|
</p>
|
|
)}
|
|
{p.documents.map((d) => (
|
|
<article key={d.id}>
|
|
<p>
|
|
{d.file_name} ·{' '}
|
|
{d.shared
|
|
? 'Partilhado com a contraparte'
|
|
: 'Privado do autor'}{' '}
|
|
· Análise: {d.malware_scan_status}
|
|
</p>
|
|
{d.owner_id === auth.user.id &&
|
|
(mutable || d.shared) && (
|
|
<button
|
|
className="underline"
|
|
onClick={() =>
|
|
router.post(
|
|
`/parcerias/salas/${p.room.id}/documentos/${d.id}/partilha`,
|
|
{ shared: !d.shared },
|
|
{ preserveScroll: true },
|
|
)
|
|
}
|
|
>
|
|
{d.shared
|
|
? 'Retirar autorização de partilha'
|
|
: 'Autorizar partilha com a contraparte'}
|
|
</button>
|
|
)}
|
|
{d.status === 'active' &&
|
|
d.malware_scan_status === 'clean' && (
|
|
<a
|
|
className="underline"
|
|
href={`/parcerias/salas/${p.room.id}/documentos/${d.id}`}
|
|
>
|
|
Descarregar documento
|
|
</a>
|
|
)}
|
|
</article>
|
|
))}
|
|
{(mutable || uploadEdit.dirty) && (
|
|
<form
|
|
data-room-form="upload"
|
|
className="space-y-3"
|
|
onSubmit={(e) => {
|
|
e.preventDefault();
|
|
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) =>
|
|
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) =>
|
|
uploadEdit.change(
|
|
'shared',
|
|
e.target.checked,
|
|
)
|
|
}
|
|
/>{' '}
|
|
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={
|
|
uploadEdit.blocked ||
|
|
(!upload.data.file &&
|
|
!uploadEdit.recovering)
|
|
}
|
|
>
|
|
{uploadEdit.recovering
|
|
? 'Recuperar envio do documento'
|
|
: 'Guardar documento privado'}
|
|
</button>
|
|
</form>
|
|
)}
|
|
</section>
|
|
<section className="space-y-4 rounded border p-5">
|
|
<h2 className="text-xl font-bold">
|
|
Acordo e plano conjunto
|
|
</h2>
|
|
<p>
|
|
Registe o instrumento, objetivos, contribuições,
|
|
responsabilidades, indicadores, riscos, dependências e
|
|
condições de saída. A confirmação no portal regista a
|
|
concordância comunicada pelas partes; não certifica
|
|
assinatura jurídica ou due diligence.
|
|
</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>
|
|
)}
|
|
<RoomComparison
|
|
editor={agreementEdit}
|
|
labels={{
|
|
title: 'Título do instrumento',
|
|
terms: 'Condições e plano de valor',
|
|
reason: 'Motivo da acção',
|
|
}}
|
|
/>
|
|
{(mutable || agreementEdit.dirty) && (
|
|
<>
|
|
<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
|
|
}
|
|
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
|
|
}
|
|
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 ||
|
|
agreementEdit.blocked ||
|
|
!agreementEdit.values.reason
|
|
}
|
|
onClick={() => act('cancel')}
|
|
>
|
|
Cancelar conexão com motivo
|
|
</button>
|
|
</div>
|
|
<Errors errors={agreement.errors} />
|
|
</fieldset>
|
|
</>
|
|
)}
|
|
</section>
|
|
<section className="space-y-4">
|
|
<h2 className="text-xl font-bold">Marcos e responsáveis</h2>
|
|
<p>
|
|
Participação atual:{' '}
|
|
{auth.user.id === p.partnership.user_id
|
|
? 'Proponente'
|
|
: auth.user.id === p.interest.user_id
|
|
? 'Candidato'
|
|
: 'Representante autorizado'}
|
|
.
|
|
</p>
|
|
{p.milestones.map((m) => (
|
|
<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:{' '}
|
|
{m.responsible_name ??
|
|
'Responsável registado indisponível'}
|
|
{!m.responsible_is_participant &&
|
|
' · Sem representação actual; atribuição anterior conservada'}
|
|
</p>
|
|
<MilestoneForm p={p} item={m} onDirty={onDirty} />
|
|
</article>
|
|
))}
|
|
<MilestoneForm p={p} onDirty={onDirty} />
|
|
</section>
|
|
</div>
|
|
</Frame>
|
|
);
|
|
}
|