vrsao 2
tests / ci (push) Canceled after 0s

This commit is contained in:
2026-10-08 14:02:01 +02:00
parent bdd766c68a
commit 1106509116
354 changed files with 48275 additions and 24635 deletions
+65 -62
View File
@@ -1,4 +1,4 @@
import { useForm, usePage, Link, router } from "@inertiajs/react";
import { useForm, usePage, Link, router } from '@inertiajs/react';
import {
Frame,
Field,
@@ -7,7 +7,7 @@ import {
button,
labels,
type Partnership,
} from "./shared";
} from './shared';
type Room = {
id: number;
status: string;
@@ -52,11 +52,11 @@ type Props = {
};
function MilestoneForm({ p, item }: { p: Props; item?: Milestone }) {
const form = useForm({
title: item?.title ?? "",
title: item?.title ?? '',
responsible_id: item?.responsible_id ?? p.partnership.user_id,
due_date: item?.due_date ?? "",
status: item?.status ?? "pending",
evidence: item?.evidence ?? "",
due_date: item?.due_date ?? '',
status: item?.status ?? 'pending',
evidence: item?.evidence ?? '',
version: item?.version ?? null,
});
return (
@@ -76,13 +76,13 @@ function MilestoneForm({ p, item }: { p: Props; item?: Milestone }) {
}}
>
<h3 className="font-bold">
{item ? "Atualizar marco" : "Acrescentar marco"}
{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)}
onChange={(e) => form.setData('title', e.target.value)}
/>
</Field>
<Field label="Responsável">
@@ -90,7 +90,7 @@ function MilestoneForm({ p, item }: { p: Props; item?: Milestone }) {
className={control}
value={form.data.responsible_id}
onChange={(e) =>
form.setData("responsible_id", Number(e.target.value))
form.setData('responsible_id', Number(e.target.value))
}
>
<option value={p.partnership.user_id}>Proponente</option>
@@ -102,18 +102,18 @@ function MilestoneForm({ p, item }: { p: Props; item?: Milestone }) {
className={control}
type="date"
value={form.data.due_date}
onChange={(e) => form.setData("due_date", e.target.value)}
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)}
onChange={(e) => form.setData('status', e.target.value)}
>
{["pending", "progress", "completed"].map((x) => (
{['pending', 'progress', 'completed'].map((x) => (
<option key={x} value={x}>
{x === "pending" ? "Pendente" : labels[x]}
{x === 'pending' ? 'Pendente' : labels[x]}
</option>
))}
</select>
@@ -122,7 +122,7 @@ function MilestoneForm({ p, item }: { p: Props; item?: Milestone }) {
<textarea
className={control}
value={form.data.evidence}
onChange={(e) => form.setData("evidence", e.target.value)}
onChange={(e) => form.setData('evidence', e.target.value)}
/>
</Field>
<Errors errors={form.errors} />
@@ -133,17 +133,17 @@ function MilestoneForm({ p, item }: { p: Props; item?: Milestone }) {
);
}
export default function Page(p: Props) {
return <RoomPage key={p.room.id + ":" + p.room.version} {...p} />;
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: crypto.randomUUID() });
const message = useForm({ body: '', client_key: crypto.randomUUID() });
const agreement = useForm({
version: p.room.version,
action: "record",
title: p.room.agreement?.title ?? "",
terms: p.room.agreement?.terms ?? "",
reason: "",
action: 'record',
title: p.room.agreement?.title ?? '',
terms: p.room.agreement?.terms ?? '',
reason: '',
});
const upload = useForm<{ file: File | null; shared: boolean }>({
file: null,
@@ -156,13 +156,13 @@ function RoomPage(p: Props) {
});
};
const mutable =
p.canWrite && !["closed", "cancelled"].includes(p.room.status);
p.canWrite && !['closed', 'cancelled'].includes(p.room.status);
return (
<Frame title={"Conexão privada — " + p.partnership.title}>
<Frame title={'Conexão privada — ' + p.partnership.title}>
<div className="space-y-6">
<Link
className="underline"
href={"/parcerias/" + p.partnership.id}
href={'/parcerias/' + p.partnership.id}
>
Regressar à parceria
</Link>
@@ -176,7 +176,7 @@ function RoomPage(p: Props) {
Mensagens e esclarecimentos
</h2>
{p.messages.map((m) => (
<article className="rounded bg-muted p-4" key={m.id}>
<article className="bg-muted rounded p-4" key={m.id}>
<p className="font-semibold">
{m.name} · {m.created_at}
</p>
@@ -194,7 +194,7 @@ function RoomPage(p: Props) {
preserveScroll: true,
onSuccess: () => {
message.setData({
body: "",
body: '',
client_key: crypto.randomUUID(),
});
},
@@ -207,7 +207,7 @@ function RoomPage(p: Props) {
className={control}
value={message.data.body}
onChange={(e) =>
message.setData("body", e.target.value)
message.setData('body', e.target.value)
}
/>
</Field>
@@ -234,10 +234,10 @@ function RoomPage(p: Props) {
{p.documents.map((d) => (
<article key={d.id}>
<p>
{d.file_name} ·{" "}
{d.file_name} ·{' '}
{d.shared
? "Partilhado com a contraparte"
: "Privado do autor"}{" "}
? 'Partilhado com a contraparte'
: 'Privado do autor'}{' '}
· Análise: {d.malware_scan_status}
</p>
{mutable && d.owner_id === auth.user.id && (
@@ -252,12 +252,12 @@ function RoomPage(p: Props) {
}
>
{d.shared
? "Retirar autorização de partilha"
: "Autorizar partilha com a contraparte"}
? 'Retirar autorização de partilha'
: 'Autorizar partilha com a contraparte'}
</button>
)}
{d.status === "active" &&
d.malware_scan_status === "clean" && (
{d.status === 'active' &&
d.malware_scan_status === 'clean' && (
<a
className="underline"
href={`/parcerias/salas/${p.room.id}/documentos/${d.id}`}
@@ -284,11 +284,11 @@ function RoomPage(p: Props) {
<Field label="Anexar PDF ou imagem">
<input
type="file"
className="w-full min-w-0 max-w-full"
className="w-full max-w-full min-w-0"
accept=".pdf,.jpg,.jpeg,.png"
onChange={(e) =>
upload.setData(
"file",
'file',
e.target.files?.[0] ?? null,
)
}
@@ -300,11 +300,11 @@ function RoomPage(p: Props) {
checked={upload.data.shared}
onChange={(e) =>
upload.setData(
"shared",
'shared',
e.target.checked,
)
}
/>{" "}
/>{' '}
Autorizo a consulta pela contraparte desta sala.
</label>
<Errors errors={upload.errors} />
@@ -339,13 +339,13 @@ function RoomPage(p: Props) {
{p.room.agreement.terms}
</p>
<p>
Confirmações:{" "}
Confirmações:{' '}
{Object.entries(p.room.agreement.confirmations)
.map(
([party, c]) =>
`${party}: autor ${c.actor_id}, ${c.date}`,
)
.join("; ") || "Pendentes"}
.join('; ') || 'Pendentes'}
</p>
</>
)}
@@ -357,13 +357,13 @@ function RoomPage(p: Props) {
value={agreement.data.reason}
onChange={(e) =>
agreement.setData(
"reason",
'reason',
e.target.value,
)
}
/>
</Field>
{["negotiation", "agreement_recorded"].includes(
{['negotiation', 'agreement_recorded'].includes(
p.room.status,
) && (
<>
@@ -373,7 +373,7 @@ function RoomPage(p: Props) {
value={agreement.data.title}
onChange={(e) =>
agreement.setData(
"title",
'title',
e.target.value,
)
}
@@ -386,7 +386,7 @@ function RoomPage(p: Props) {
value={agreement.data.terms}
onChange={(e) =>
agreement.setData(
"terms",
'terms',
e.target.value,
)
}
@@ -398,50 +398,50 @@ function RoomPage(p: Props) {
agreement.processing ||
!agreement.data.reason
}
onClick={() => act("record")}
onClick={() => act('record')}
>
Registar versão do acordo
</button>
</>
)}
<div className="flex flex-wrap gap-3">
{p.room.status === "agreement_recorded" && (
{p.room.status === 'agreement_recorded' && (
<button
className={button}
disabled={
agreement.processing ||
!agreement.data.reason
}
onClick={() => act("confirm")}
onClick={() => act('confirm')}
>
Confirmar pela minha parte
</button>
)}
{p.room.status === "agreed" && (
{p.room.status === 'agreed' && (
<button
className={button}
disabled={
agreement.processing ||
!agreement.data.reason
}
onClick={() => act("start")}
onClick={() => act('start')}
>
Iniciar acompanhamento
</button>
)}
{p.room.status === "execution" && (
{p.room.status === 'execution' && (
<button
className={button}
disabled={
agreement.processing ||
!agreement.data.reason
}
onClick={() => act("complete")}
onClick={() => act('complete')}
>
Concluir após os marcos
</button>
)}
{["agreed", "execution"].includes(
{['agreed', 'execution'].includes(
p.room.status,
) && (
<button
@@ -450,7 +450,7 @@ function RoomPage(p: Props) {
agreement.processing ||
!agreement.data.reason
}
onClick={() => act("renew")}
onClick={() => act('renew')}
>
Registar renovação
</button>
@@ -461,7 +461,7 @@ function RoomPage(p: Props) {
agreement.processing ||
!agreement.data.reason
}
onClick={() => act("cancel")}
onClick={() => act('cancel')}
>
Cancelar conexão com motivo
</button>
@@ -473,29 +473,32 @@ function RoomPage(p: Props) {
<section className="space-y-4">
<h2 className="text-xl font-bold">Marcos e responsáveis</h2>
<p>
Participação atual:{" "}
Participação atual:{' '}
{auth.user.id === p.partnership.user_id
? "Proponente"
? 'Proponente'
: auth.user.id === p.interest.user_id
? "Candidato"
: "Representante autorizado"}
? 'Candidato'
: 'Representante autorizado'}
.
</p>
{p.milestones.map((m) => (
<article
key={m.id + ":" + m.version}
key={m.id + ':' + m.version}
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}
{m.title} ·{' '}
{m.status === 'pending'
? 'Pendente'
: labels[m.status]}{' '}
· Prazo: {m.due_date ?? 'Pendente'} ·
Responsável ID {m.responsible_id}
</p>
{mutable && <MilestoneForm p={p} item={m} />}
</article>
))}
{mutable &&
["agreement_recorded", "agreed", "execution"].includes(
['agreement_recorded', 'agreed', 'execution'].includes(
p.room.status,
) && <MilestoneForm p={p} />}
</section>