@@ -1,4 +1,4 @@
|
||||
import { Field, input, button, card } from "./shared";
|
||||
import { Field, input, button, card } from './shared';
|
||||
|
||||
export type ZoneTargets = {
|
||||
opportunities: { id: number; title: string }[];
|
||||
@@ -38,15 +38,17 @@ export default function ZoneRelations({
|
||||
return (
|
||||
<>
|
||||
<form
|
||||
className={card + " grid gap-4 md:grid-cols-2"}
|
||||
className={card + ' grid gap-4 md:grid-cols-2'}
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
const data = Object.fromEntries(new FormData(e.currentTarget));
|
||||
if (typeof data.target !== "string") return;
|
||||
const [kind, target] = data.target.split(":");
|
||||
const data = Object.fromEntries(
|
||||
new FormData(e.currentTarget),
|
||||
);
|
||||
if (typeof data.target !== 'string') return;
|
||||
const [kind, target] = data.target.split(':');
|
||||
delete data.target;
|
||||
void action(
|
||||
`/api/v2/investment/admin/zones/${id}/${kind === "opportunity_id" ? "links" : "relations"}`,
|
||||
`/api/v2/investment/admin/zones/${id}/${kind === 'opportunity_id' ? 'links' : 'relations'}`,
|
||||
{ ...data, [kind]: target },
|
||||
);
|
||||
}}
|
||||
@@ -64,12 +66,15 @@ export default function ZoneRelations({
|
||||
))}
|
||||
{targets.dossiers.map((d) => {
|
||||
const field = d.project_id
|
||||
? "project_id"
|
||||
? 'project_id'
|
||||
: d.cluster_id
|
||||
? "cluster_id"
|
||||
: "corridor_id";
|
||||
? 'cluster_id'
|
||||
: 'corridor_id';
|
||||
return (
|
||||
<option key={d.id} value={`${field}:${d[field]}`}>
|
||||
<option
|
||||
key={d.id}
|
||||
value={`${field}:${d[field]}`}
|
||||
>
|
||||
{d.title} · ficha territorial
|
||||
</option>
|
||||
);
|
||||
@@ -79,9 +84,13 @@ export default function ZoneRelations({
|
||||
<Field label="Tipo de associação">
|
||||
<select className={input} name="association_type">
|
||||
<option value="potential">Potencial</option>
|
||||
<option value="official">Oficial, com título próprio</option>
|
||||
<option value="official">
|
||||
Oficial, com título próprio
|
||||
</option>
|
||||
<option value="influence">Área de influência</option>
|
||||
<option value="proximity">Proximidade geográfica</option>
|
||||
<option value="proximity">
|
||||
Proximidade geográfica
|
||||
</option>
|
||||
<option value="historical">Histórica</option>
|
||||
</select>
|
||||
</Field>
|
||||
@@ -99,7 +108,9 @@ export default function ZoneRelations({
|
||||
</Field>
|
||||
<Field label="Fonte jurídica, obrigatória para associação oficial">
|
||||
<select name="legal_source_id" className={input}>
|
||||
<option value="">Não aplicável à relação proposta</option>
|
||||
<option value="">
|
||||
Não aplicável à relação proposta
|
||||
</option>
|
||||
{sources.map((s) => (
|
||||
<option key={s.id} value={s.id}>
|
||||
{s.title}
|
||||
@@ -126,7 +137,12 @@ export default function ZoneRelations({
|
||||
/>
|
||||
</Field>
|
||||
<Field label="Válida desde">
|
||||
<input name="valid_from" type="date" className={input} required />
|
||||
<input
|
||||
name="valid_from"
|
||||
type="date"
|
||||
className={input}
|
||||
required
|
||||
/>
|
||||
</Field>
|
||||
<Field label="Válida até">
|
||||
<input name="valid_until" type="date" className={input} />
|
||||
@@ -139,51 +155,61 @@ export default function ZoneRelations({
|
||||
<h2 className="text-xl font-bold">Relações territoriais</h2>
|
||||
{relations.map((r) => (
|
||||
<p key={r.id}>
|
||||
{r.association_type} · {r.validation_status}{" "}
|
||||
{r.association_type} · {r.validation_status}{' '}
|
||||
<button
|
||||
disabled={busy || r.validation_status === "revoked"}
|
||||
disabled={busy || r.validation_status === 'revoked'}
|
||||
className={button}
|
||||
onClick={() =>
|
||||
action(
|
||||
`/api/v2/investment/admin/zone-relations/${r.id}/${r.validation_status === "pending" ? "validate" : "revoke"}`,
|
||||
`/api/v2/investment/admin/zone-relations/${r.id}/${r.validation_status === 'pending' ? 'validate' : 'revoke'}`,
|
||||
{ version_no: r.version_no },
|
||||
)
|
||||
}
|
||||
>
|
||||
{r.validation_status === "pending" ? "Validar" : "Revogar"}
|
||||
{r.validation_status === 'pending'
|
||||
? 'Validar'
|
||||
: 'Revogar'}
|
||||
</button>
|
||||
</p>
|
||||
))}
|
||||
</section>
|
||||
<form
|
||||
className={card + " grid gap-4 md:grid-cols-2"}
|
||||
className={card + ' grid gap-4 md:grid-cols-2'}
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
const data = Object.fromEntries(new FormData(e.currentTarget));
|
||||
if (typeof data.geometry !== "string") return;
|
||||
const data = Object.fromEntries(
|
||||
new FormData(e.currentTarget),
|
||||
);
|
||||
if (typeof data.geometry !== 'string') return;
|
||||
const raw = data.geometry;
|
||||
try {
|
||||
data.geometry = JSON.parse(raw);
|
||||
void action(`/api/v2/investment/admin/zones/${id}/geometries`, data);
|
||||
void action(
|
||||
`/api/v2/investment/admin/zones/${id}/geometries`,
|
||||
data,
|
||||
);
|
||||
} catch {
|
||||
const field = e.currentTarget.elements.namedItem(
|
||||
"geometry",
|
||||
'geometry',
|
||||
) as HTMLTextAreaElement;
|
||||
field.setCustomValidity("Introduza GeoJSON válido.");
|
||||
field.setCustomValidity('Introduza GeoJSON válido.');
|
||||
field.reportValidity();
|
||||
}
|
||||
}}
|
||||
>
|
||||
<h2 className="text-xl font-bold md:col-span-2">Geometria para revisão GIS</h2>
|
||||
<h2 className="text-xl font-bold md:col-span-2">
|
||||
Geometria para revisão GIS
|
||||
</h2>
|
||||
<p>
|
||||
GeoJSON no SRID 4326, até 200 KB. Não desenhe um perímetro sem fonte autorizada.
|
||||
GeoJSON no SRID 4326, até 200 KB. Não desenhe um perímetro
|
||||
sem fonte autorizada.
|
||||
</p>
|
||||
<Field label="GeoJSON">
|
||||
<textarea
|
||||
name="geometry"
|
||||
className={input}
|
||||
required
|
||||
onChange={(e) => e.currentTarget.setCustomValidity("")}
|
||||
onChange={(e) => e.currentTarget.setCustomValidity('')}
|
||||
/>
|
||||
</Field>
|
||||
<Field label="Finalidade">
|
||||
@@ -191,7 +217,9 @@ export default function ZoneRelations({
|
||||
<option value="site">Localização</option>
|
||||
<option value="influence">Área de influência</option>
|
||||
<option value="alternative">Alternativa</option>
|
||||
<option value="official_perimeter">Perímetro oficial</option>
|
||||
<option value="official_perimeter">
|
||||
Perímetro oficial
|
||||
</option>
|
||||
</select>
|
||||
</Field>
|
||||
<Field label="Fonte jurídica do perímetro">
|
||||
@@ -205,13 +233,27 @@ export default function ZoneRelations({
|
||||
</select>
|
||||
</Field>
|
||||
<Field label="Proveniência da geometria">
|
||||
<input className={input} name="source_reference" required minLength={10} />
|
||||
<input
|
||||
className={input}
|
||||
name="source_reference"
|
||||
required
|
||||
minLength={10}
|
||||
/>
|
||||
</Field>
|
||||
<Field label="Entidade indicada para validação">
|
||||
<input className={input} name="validating_entity" required />
|
||||
<input
|
||||
className={input}
|
||||
name="validating_entity"
|
||||
required
|
||||
/>
|
||||
</Field>
|
||||
<Field label="Data da observação">
|
||||
<input className={input} type="date" name="observed_at" required />
|
||||
<input
|
||||
className={input}
|
||||
type="date"
|
||||
name="observed_at"
|
||||
required
|
||||
/>
|
||||
</Field>
|
||||
<button disabled={busy} className={button}>
|
||||
Submeter geometria
|
||||
@@ -221,20 +263,20 @@ export default function ZoneRelations({
|
||||
<h2 className="text-xl font-bold">Revisão GIS</h2>
|
||||
{geometries.map((g) => (
|
||||
<p key={g.id}>
|
||||
{g.purpose} · {g.validation_status}{" "}
|
||||
{g.purpose} · {g.validation_status}{' '}
|
||||
<button
|
||||
className={button}
|
||||
disabled={busy || g.validation_status === "revoked"}
|
||||
disabled={busy || g.validation_status === 'revoked'}
|
||||
onClick={() =>
|
||||
action(
|
||||
`/api/v2/investment/admin/zone-geometries/${g.id}/${g.validation_status === "pending" ? "validate" : "revoke"}`,
|
||||
`/api/v2/investment/admin/zone-geometries/${g.id}/${g.validation_status === 'pending' ? 'validate' : 'revoke'}`,
|
||||
{ version_no: g.version_no },
|
||||
)
|
||||
}
|
||||
>
|
||||
{g.validation_status === "pending"
|
||||
? "Validar e autorizar divulgação"
|
||||
: "Retirar geometria"}
|
||||
{g.validation_status === 'pending'
|
||||
? 'Validar e autorizar divulgação'
|
||||
: 'Retirar geometria'}
|
||||
</button>
|
||||
</p>
|
||||
))}
|
||||
|
||||
Reference in New Issue
Block a user