@@ -10,22 +10,27 @@ type Record = {
|
||||
slug: string;
|
||||
is_active?: boolean;
|
||||
status?: string;
|
||||
geography_scope?: string;
|
||||
primary_territory?: { name: string; location_type: string; source_system?: string; source_code?: string | null } | null;
|
||||
};
|
||||
export default function Catalog({
|
||||
resource,
|
||||
records,
|
||||
filters,
|
||||
sectors,
|
||||
geographyReviewCount = 0,
|
||||
}: {
|
||||
resource: 'sectors' | 'opportunities';
|
||||
records: Paginated<Record>;
|
||||
filters: { q?: string; status?: string; sector_id?: number | string };
|
||||
filters: { q?: string; status?: string; sector_id?: number | string; geography_scope?: string };
|
||||
sectors: { id: number; name: string }[];
|
||||
geographyReviewCount?: number;
|
||||
}) {
|
||||
const form = useForm({
|
||||
q: filters.q ?? '',
|
||||
status: filters.status ?? '',
|
||||
sector_id: String(filters.sector_id ?? ''),
|
||||
geography_scope: filters.geography_scope ?? '',
|
||||
});
|
||||
return (
|
||||
<Management
|
||||
@@ -34,6 +39,11 @@ export default function Catalog({
|
||||
<Link className={button} href={`/management/${resource}/create`}>
|
||||
Criar {resource === 'sectors' ? 'sector' : 'oportunidade'}
|
||||
</Link>
|
||||
{resource === 'opportunities' && (
|
||||
<p role="status" className="my-3">
|
||||
{geographyReviewCount} oportunidade(s) aguardam confirmação do âmbito geográfico. A lista não altera localizações; confirme apenas com fontes existentes.
|
||||
</p>
|
||||
)}
|
||||
<form
|
||||
className="flex flex-wrap gap-3"
|
||||
onSubmit={(event) => {
|
||||
@@ -74,6 +84,7 @@ export default function Catalog({
|
||||
))}
|
||||
</select>
|
||||
{resource === 'opportunities' && (
|
||||
<>
|
||||
<select
|
||||
aria-label="Sector"
|
||||
className={`${control} max-w-xs`}
|
||||
@@ -89,6 +100,20 @@ export default function Catalog({
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
<select
|
||||
aria-label="Âmbito geográfico"
|
||||
className={`${control} max-w-xs`}
|
||||
value={form.data.geography_scope}
|
||||
onChange={(event) => form.setData('geography_scope', event.target.value)}
|
||||
>
|
||||
<option value="">Todos os âmbitos</option>
|
||||
<option value="unspecified">Pendente de confirmação</option>
|
||||
<option value="specific">Localização específica</option>
|
||||
<option value="multiple">Várias localizações</option>
|
||||
<option value="national">Âmbito nacional</option>
|
||||
<option value="digital">Digital/sem instalação definida</option>
|
||||
</select>
|
||||
</>
|
||||
)}
|
||||
<button className={button} disabled={form.processing}>
|
||||
Pesquisar
|
||||
@@ -123,6 +148,11 @@ export default function Catalog({
|
||||
: 'Inactivo'
|
||||
: states[record.status ?? 'draft']}
|
||||
</p>
|
||||
{resource === 'opportunities' && record.geography_scope === 'unspecified' && (
|
||||
<p className="mt-1 text-sm">
|
||||
Pendente de confirmação; território já registado: {record.primary_territory?.name ?? 'nenhum'}. Fonte do território: {record.primary_territory?.source_system ?? 'não indicada'}{record.primary_territory?.source_code ? `, código ${record.primary_territory.source_code}` : ''}. A classificação não é alterada automaticamente.
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
<Link
|
||||
className="underline"
|
||||
|
||||
@@ -67,6 +67,7 @@ export default function Editor({
|
||||
initial.maturity_level = String(record?.maturity_level ?? "");
|
||||
initial.status = String(record?.status ?? "draft");
|
||||
initial.is_featured = Boolean(record?.is_featured ?? false);
|
||||
initial.geography_scope = String(record?.geography_scope ?? "unspecified");
|
||||
initial.territory_version = String(record?.territory_version ?? 0);
|
||||
["province_id", "district_id", "admin_post_id", "locality_id"].forEach((field, index) => {
|
||||
initial[field] = territoryPath[index]?.id ?? "";
|
||||
@@ -180,6 +181,22 @@ export default function Editor({
|
||||
))}
|
||||
</select>
|
||||
</Field>
|
||||
<Field label="Âmbito geográfico" error={form.errors.geography_scope}>
|
||||
<select className={control} value={String(form.data.geography_scope)} onChange={(e) => {
|
||||
form.setData("geography_scope", e.target.value);
|
||||
if (e.target.value === "national" || e.target.value === "digital") {
|
||||
setCreationPath([]);
|
||||
form.setData((data) => ({ ...data, geography_scope: e.target.value,
|
||||
province_id: "", district_id: "", admin_post_id: "", locality_id: "" }));
|
||||
}
|
||||
}}>
|
||||
<option value="unspecified">Não especificado</option>
|
||||
<option value="specific">Localização específica</option>
|
||||
<option value="multiple">Várias localizações</option>
|
||||
<option value="national">Âmbito nacional</option>
|
||||
<option value="digital">Digital/sem instalação definida</option>
|
||||
</select>
|
||||
</Field>
|
||||
<Field label="Estado" error={form.errors.status}>
|
||||
<select
|
||||
className={control}
|
||||
|
||||
@@ -45,7 +45,8 @@ type Consent = { purpose: string; policy_version: string | null; status: string;
|
||||
|
||||
export default function InterestDetail({ interest, history = [], assignees = [], consents = [] }: { interest: Interest; history?: Transition[]; assignees?: Assignee[]; consents?: Consent[] }) {
|
||||
const form = useForm({ status: interest.status, note: "", next_action: interest.next_action ?? "", next_action_due_at: interest.next_action_due_at?.slice(0, 10) ?? "", assigned_to: interest.assigned_to?.toString() ?? "" });
|
||||
const consentForm = useForm({ reason: "" });
|
||||
const contactConsentForm = useForm({ reason: "" });
|
||||
const sharingConsentForm = useForm({ reason: "" });
|
||||
const rows: [string, string | number | null][] = [
|
||||
["Nome", interest.full_name],
|
||||
["Email", interest.email],
|
||||
@@ -111,15 +112,26 @@ export default function InterestDetail({ interest, history = [], assignees = [],
|
||||
{consent.withdrawn_at && <p className="text-sm">Revogado {dateTime(consent.withdrawn_at)}</p>}
|
||||
</article>
|
||||
))}
|
||||
{consents.some((consent) => consent.purpose === "respond_to_interest" && consent.status === "granted") && (
|
||||
<form className="max-w-sm space-y-3" onSubmit={(event) => {
|
||||
event.preventDefault();
|
||||
contactConsentForm.patch(`/management/interests/${interest.id}/consent/contact`);
|
||||
}}>
|
||||
<Field label="Motivo do pedido de revogação" error={contactConsentForm.errors.reason}>
|
||||
<textarea className={control} minLength={10} maxLength={2000} required rows={3} value={contactConsentForm.data.reason} onChange={(event) => contactConsentForm.setData("reason", event.target.value)} />
|
||||
</Field>
|
||||
<button className={button} disabled={contactConsentForm.processing}>Revogar autorização de contacto</button>
|
||||
</form>
|
||||
)}
|
||||
{consents.some((consent) => consent.purpose === "share_contact_with_proponent" && consent.status === "granted") && (
|
||||
<form className="max-w-sm space-y-3" onSubmit={(event) => {
|
||||
event.preventDefault();
|
||||
consentForm.patch(`/management/interests/${interest.id}/consent/proponent`);
|
||||
sharingConsentForm.patch(`/management/interests/${interest.id}/consent/proponent`);
|
||||
}}>
|
||||
<Field label="Motivo do pedido de revogação" error={consentForm.errors.reason}>
|
||||
<textarea className={control} minLength={10} maxLength={2000} required rows={3} value={consentForm.data.reason} onChange={(event) => consentForm.setData("reason", event.target.value)} />
|
||||
<Field label="Motivo do pedido de revogação" error={sharingConsentForm.errors.reason}>
|
||||
<textarea className={control} minLength={10} maxLength={2000} required rows={3} value={sharingConsentForm.data.reason} onChange={(event) => sharingConsentForm.setData("reason", event.target.value)} />
|
||||
</Field>
|
||||
<button className={button} disabled={consentForm.processing}>Revogar autorização de partilha</button>
|
||||
<button className={button} disabled={sharingConsentForm.processing}>Revogar autorização de partilha</button>
|
||||
</form>
|
||||
)}
|
||||
</section>
|
||||
|
||||
@@ -53,6 +53,7 @@ export function Management({ title, children }: { title: string; children: React
|
||||
<Link href="/management/crm/investors">Investidores</Link>
|
||||
<Link href="/management/projects">Projectos</Link>
|
||||
<Link href="/management/clusters">Clusters</Link>
|
||||
<Link href="/management/corridors">Corredores</Link>
|
||||
<Link href="/management/territory-associations">
|
||||
Localizações dos investimentos
|
||||
</Link>
|
||||
|
||||
Reference in New Issue
Block a user