feat: consolidar desenvolvimentos do portal InvestMoz
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user