Files
Investidor-V2/resources/js/pages/partnerships/detail.tsx
T

177 lines
7.7 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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,
button,
labels,
type Catalogues,
type Interest,
type Partnership,
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;
name: string;
role: string;
source_reference: string;
path: { name: string }[];
}[];
interests: Interest[];
historySummary: PublicationHistorySummary | null;
};
export default function Detail(p: 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} />
<div className="space-y-6">
<p>
{p.record.partnership_type
? p.types[p.record.partnership_type]
: 'Tipo por completar'}{' '}
· {p.record.kind === 'offering' ? 'Oferta' : 'Procura'} ·{' '}
{labels[p.record.status] ?? p.record.status}
</p>
<p className="whitespace-pre-wrap">
{p.record.payload.summary}
</p>
<section className="space-y-3 rounded border p-5">
<h2 className="text-xl font-bold">Oferta e procura</h2>
<p className="whitespace-pre-wrap">{p.record.offer}</p>
<p className="whitespace-pre-wrap">{p.record.seeking}</p>
{p.record.offer === null && (
<p>
O conteúdo detalhado está reservado à conexão
privada.
</p>
)}
<p>{p.record.payload.requirements}</p>
<p>Prazo: {p.record.deadline ?? 'Por definir'}</p>
</section>
<section className="space-y-3 rounded border p-5">
<h2 className="text-xl font-bold">
Localizações próprias da parceria
</h2>
{p.locations.length ? (
p.locations.map((l, i) => (
<p key={i}>
{l.path.map((n) => n.name).join(' → ')} ·{' '}
{
{
primary: 'Principal',
operating: 'Área de atuação',
coverage: 'Abrangência',
}[l.role]
}{' '}
· Fonte: {l.source_reference}. Validação
independente pendente.
</p>
))
) : (
<p>Localização própria não indicada.</p>
)}
</section>
{p.origins.map((source, i) => (
<section key={i} className="space-y-3 rounded border p-5">
<h2 className="text-xl font-bold">
Origem:{' '}
<Link className="underline" href={source.href}>
{source.title}
</Link>
</h2>
<p>
As localizações do registo de origem são contexto
documental; não confirmam a implantação da parceria.
</p>
{source.geography && (
<StructureGeographyPanel
geography={source.geography}
cluster={source.type === 'cluster'}
dossierId={'partnership-source-' + i}
/>
)}
</section>
))}
{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">
<h2 className="text-xl font-bold">
Comparação de candidatos
</h2>
<table className="w-full text-left">
<thead>
<tr>
<th>Candidatura</th>
<th>Estado</th>
<th>Correspondência</th>
<th>Pendências</th>
</tr>
</thead>
<tbody>
{p.interests.map((i) => (
<tr key={i.id}>
<td>{i.id}</td>
<td>{labels[i.status]}</td>
<td>
{i.match.score_min}–
{i.match.score_max}%
</td>
<td>
{i.match.criteria
.filter(
(c) =>
c.state === 'unknown',
)
.map((c) => c.label)
.join(', ')}
</td>
</tr>
))}
</tbody>
</table>
</section>
)}
<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.owner || p.moderator) && p.historySummary && (
<PublicationSummary value={p.historySummary} />
)}
</div>
</Frame>
);
}