@@ -1,10 +1,11 @@
|
||||
import { Link, router } from "@inertiajs/react";
|
||||
import { useState } from "react";
|
||||
import { Link, router } from '@inertiajs/react';
|
||||
import TerritoryGeometryPreview from '@/components/territory-geometry-preview';
|
||||
import { useState } from 'react';
|
||||
import {
|
||||
TerritoryLevel,
|
||||
type TerritoryOption,
|
||||
} from "@/components/investment-territory";
|
||||
import { Management, Field, button, control } from "./shared";
|
||||
} from '@/components/investment-territory';
|
||||
import { Management, Field, button, control } from './shared';
|
||||
|
||||
type Payload = Record<string, string | number | boolean | null | object>;
|
||||
type Resource = {
|
||||
@@ -26,101 +27,101 @@ type Resource = {
|
||||
sha256: string;
|
||||
};
|
||||
};
|
||||
type Kind = "locations" | "images" | "documents";
|
||||
type Kind = 'locations' | 'images' | 'documents';
|
||||
const fields: Record<Kind, string[]> = {
|
||||
locations: [
|
||||
"title",
|
||||
"address",
|
||||
"operational_unit",
|
||||
"role_description",
|
||||
"area_value",
|
||||
"area_unit",
|
||||
"allocation_percentage",
|
||||
"multi_district_rationale",
|
||||
"source_reference",
|
||||
"source_date",
|
||||
'title',
|
||||
'address',
|
||||
'operational_unit',
|
||||
'role_description',
|
||||
'area_value',
|
||||
'area_unit',
|
||||
'allocation_percentage',
|
||||
'multi_district_rationale',
|
||||
'source_reference',
|
||||
'source_date',
|
||||
],
|
||||
images: [
|
||||
"title",
|
||||
"caption",
|
||||
"alt_text",
|
||||
"author_source",
|
||||
"captured_at",
|
||||
"rights_valid_until",
|
||||
"role_description",
|
||||
"sort_order",
|
||||
"source_reference",
|
||||
'title',
|
||||
'caption',
|
||||
'alt_text',
|
||||
'author_source',
|
||||
'captured_at',
|
||||
'rights_valid_until',
|
||||
'role_description',
|
||||
'sort_order',
|
||||
'source_reference',
|
||||
],
|
||||
documents: [
|
||||
"title",
|
||||
"category",
|
||||
"issuer",
|
||||
"edition",
|
||||
"source_date",
|
||||
"valid_until",
|
||||
"source_reference",
|
||||
"section",
|
||||
"supported_statement",
|
||||
'title',
|
||||
'category',
|
||||
'issuer',
|
||||
'edition',
|
||||
'source_date',
|
||||
'valid_until',
|
||||
'source_reference',
|
||||
'section',
|
||||
'supported_statement',
|
||||
],
|
||||
};
|
||||
const labels: Record<string, string> = {
|
||||
role: "Papel da localização",
|
||||
imageRole: "Tipo de imagem",
|
||||
territorial_purpose: "Natureza da relação territorial",
|
||||
rights_status: "Direitos de utilização",
|
||||
visibility: "Âmbito de consulta",
|
||||
classification: "Classificação documental",
|
||||
location_id: "Localização associada",
|
||||
rights_document_id: "Comprovativo de direitos",
|
||||
title: "Título",
|
||||
address: "Referência física",
|
||||
operational_unit: "Unidade operacional",
|
||||
role_description: "Descrição do papel outro",
|
||||
area_value: "Área",
|
||||
area_unit: "Unidade de área",
|
||||
allocation_percentage: "Distribuição (%)",
|
||||
multi_district_rationale: "Fundamento multidistrito/interprovincial",
|
||||
source_reference: "Fonte / referência",
|
||||
source_date: "Data da fonte",
|
||||
caption: "Legenda",
|
||||
alt_text: "Texto alternativo",
|
||||
author_source: "Autor / fonte",
|
||||
captured_at: "Data da imagem",
|
||||
rights_valid_until: "Validade dos direitos",
|
||||
sort_order: "Ordem",
|
||||
category: "Categoria documental",
|
||||
issuer: "Emissor",
|
||||
edition: "Edição / versão",
|
||||
valid_until: "Validade",
|
||||
section: "Página / secção",
|
||||
supported_statement: "Afirmação fundamentada",
|
||||
role: 'Papel da localização',
|
||||
imageRole: 'Tipo de imagem',
|
||||
territorial_purpose: 'Natureza da relação territorial',
|
||||
rights_status: 'Direitos de utilização',
|
||||
visibility: 'Âmbito de consulta',
|
||||
classification: 'Classificação documental',
|
||||
location_id: 'Localização associada',
|
||||
rights_document_id: 'Comprovativo de direitos',
|
||||
title: 'Título',
|
||||
address: 'Referência física',
|
||||
operational_unit: 'Unidade operacional',
|
||||
role_description: 'Descrição do papel outro',
|
||||
area_value: 'Área',
|
||||
area_unit: 'Unidade de área',
|
||||
allocation_percentage: 'Distribuição (%)',
|
||||
multi_district_rationale: 'Fundamento multidistrito/interprovincial',
|
||||
source_reference: 'Fonte / referência',
|
||||
source_date: 'Data da fonte',
|
||||
caption: 'Legenda',
|
||||
alt_text: 'Texto alternativo',
|
||||
author_source: 'Autor / fonte',
|
||||
captured_at: 'Data da imagem',
|
||||
rights_valid_until: 'Validade dos direitos',
|
||||
sort_order: 'Ordem',
|
||||
category: 'Categoria documental',
|
||||
issuer: 'Emissor',
|
||||
edition: 'Edição / versão',
|
||||
valid_until: 'Validade',
|
||||
section: 'Página / secção',
|
||||
supported_statement: 'Afirmação fundamentada',
|
||||
};
|
||||
const choices: Record<string, string[]> = {
|
||||
role: [
|
||||
"headquarters",
|
||||
"production",
|
||||
"raw_material",
|
||||
"storage",
|
||||
"logistics",
|
||||
"market",
|
||||
"support",
|
||||
"other",
|
||||
'headquarters',
|
||||
'production',
|
||||
'raw_material',
|
||||
'storage',
|
||||
'logistics',
|
||||
'market',
|
||||
'support',
|
||||
'other',
|
||||
],
|
||||
imageRole: [
|
||||
"cover",
|
||||
"gallery",
|
||||
"location",
|
||||
"asset",
|
||||
"product",
|
||||
"plan",
|
||||
"rendering",
|
||||
"evidence",
|
||||
"other",
|
||||
'cover',
|
||||
'gallery',
|
||||
'location',
|
||||
'asset',
|
||||
'product',
|
||||
'plan',
|
||||
'rendering',
|
||||
'evidence',
|
||||
'other',
|
||||
],
|
||||
territorial_purpose: ["implementation", "context", "impact", "coverage"],
|
||||
rights_status: ["owned", "licensed", "authorized", "public_domain"],
|
||||
visibility: ["internal", "authenticated", "public"],
|
||||
classification: ["public", "internal", "confidential", "restricted"],
|
||||
territorial_purpose: ['implementation', 'context', 'impact', 'coverage'],
|
||||
rights_status: ['owned', 'licensed', 'authorized', 'public_domain'],
|
||||
visibility: ['internal', 'authenticated', 'public'],
|
||||
classification: ['public', 'internal', 'confidential', 'restricted'],
|
||||
};
|
||||
|
||||
export default function OpportunityResources({
|
||||
@@ -143,17 +144,17 @@ export default function OpportunityResources({
|
||||
assessment: string[];
|
||||
imageProcessingAvailable: boolean;
|
||||
}) {
|
||||
const [kind, setKind] = useState<Kind>("locations");
|
||||
const [kind, setKind] = useState<Kind>('locations');
|
||||
const [editing, setEditing] = useState<Resource | null>(null);
|
||||
const [payload, setPayload] = useState<Payload>({});
|
||||
const [path, setPath] = useState<TerritoryOption[]>([]);
|
||||
const [geometry, setGeometry] = useState("");
|
||||
const [geometry, setGeometry] = useState('');
|
||||
const [file, setFile] = useState<File | null>(null);
|
||||
const [reason, setReason] = useState("");
|
||||
const [reason, setReason] = useState('');
|
||||
const [confirm, setConfirm] = useState(false);
|
||||
const [key, setKey] = useState(() => crypto.randomUUID());
|
||||
const [busy, setBusy] = useState(false);
|
||||
const [message, setMessage] = useState("");
|
||||
const [message, setMessage] = useState('');
|
||||
const [errors, setErrors] = useState<Record<string, string>>({});
|
||||
const set = (name: string, value: Payload[string]) =>
|
||||
setPayload((previous) => ({ ...previous, [name]: value }));
|
||||
@@ -165,57 +166,57 @@ export default function OpportunityResources({
|
||||
setGeometry(
|
||||
record?.payload.geometry
|
||||
? JSON.stringify(record.payload.geometry)
|
||||
: "",
|
||||
: '',
|
||||
);
|
||||
setFile(null);
|
||||
setKey(crypto.randomUUID());
|
||||
setConfirm(false);
|
||||
setErrors({});
|
||||
}
|
||||
async function execute(action: "save" | "delete" | "restore" | "prepare") {
|
||||
async function execute(action: 'save' | 'delete' | 'restore' | 'prepare') {
|
||||
if (busy) return;
|
||||
setBusy(true);
|
||||
setErrors({});
|
||||
setMessage("");
|
||||
setMessage('');
|
||||
try {
|
||||
const form = new FormData();
|
||||
form.set("etag", etag);
|
||||
form.set("reason", reason);
|
||||
form.set("creation_key", key);
|
||||
if (editing) form.set("version", String(editing.version));
|
||||
if (action === "save") {
|
||||
form.set('etag', etag);
|
||||
form.set('reason', reason);
|
||||
form.set('creation_key', key);
|
||||
if (editing) form.set('version', String(editing.version));
|
||||
if (action === 'save') {
|
||||
const values = { ...payload };
|
||||
if (kind === "locations") {
|
||||
if (kind === 'locations') {
|
||||
[
|
||||
"province_id",
|
||||
"district_id",
|
||||
"admin_post_id",
|
||||
"locality_id",
|
||||
'province_id',
|
||||
'district_id',
|
||||
'admin_post_id',
|
||||
'locality_id',
|
||||
].forEach(
|
||||
(name, index) =>
|
||||
(values[name] = path[index]?.id ?? null),
|
||||
);
|
||||
values.geometry = geometry ? JSON.parse(geometry) : null;
|
||||
}
|
||||
form.set("payload", JSON.stringify(values));
|
||||
if (file) form.set("file", file);
|
||||
form.set('payload', JSON.stringify(values));
|
||||
if (file) form.set('file', file);
|
||||
} else {
|
||||
form.set("action", action);
|
||||
form.set("confirm", confirm ? "1" : "0");
|
||||
form.set('action', action);
|
||||
form.set('confirm', confirm ? '1' : '0');
|
||||
}
|
||||
const url = `/management/opportunities/${opportunity.id}/resources/${kind}${editing ? `/${editing.id}` : ""}${action === "save" ? "" : action === "prepare" ? "/prepare" : "/lifecycle"}`;
|
||||
const url = `/management/opportunities/${opportunity.id}/resources/${kind}${editing ? `/${editing.id}` : ''}${action === 'save' ? '' : action === 'prepare' ? '/prepare' : '/lifecycle'}`;
|
||||
const csrf =
|
||||
document.cookie
|
||||
.split("; ")
|
||||
.find((v) => v.startsWith("XSRF-TOKEN="))
|
||||
?.split("=")
|
||||
.split('; ')
|
||||
.find((v) => v.startsWith('XSRF-TOKEN='))
|
||||
?.split('=')
|
||||
.slice(1)
|
||||
.join("=") ?? "";
|
||||
.join('=') ?? '';
|
||||
const result = await fetch(url, {
|
||||
method: "POST",
|
||||
method: 'POST',
|
||||
headers: {
|
||||
Accept: "application/json",
|
||||
"X-XSRF-TOKEN": decodeURIComponent(csrf),
|
||||
Accept: 'application/json',
|
||||
'X-XSRF-TOKEN': decodeURIComponent(csrf),
|
||||
},
|
||||
body: form,
|
||||
});
|
||||
@@ -227,7 +228,7 @@ export default function OpportunityResources({
|
||||
([name, value]) => [
|
||||
name,
|
||||
Array.isArray(value)
|
||||
? value.join(" ")
|
||||
? value.join(' ')
|
||||
: String(value),
|
||||
],
|
||||
),
|
||||
@@ -239,30 +240,30 @@ export default function OpportunityResources({
|
||||
setEditing(null);
|
||||
setPayload({});
|
||||
setPath([]);
|
||||
setGeometry("");
|
||||
setGeometry('');
|
||||
setFile(null);
|
||||
setKey(crypto.randomUUID());
|
||||
setConfirm(false);
|
||||
router.reload({
|
||||
onFinish: () =>
|
||||
document.getElementById("resource-result")?.focus(),
|
||||
document.getElementById('resource-result')?.focus(),
|
||||
});
|
||||
} catch (error) {
|
||||
setMessage(
|
||||
error instanceof Error
|
||||
? error.message
|
||||
: "Falha de ligação; preenchimento preservado.",
|
||||
: 'Falha de ligação; preenchimento preservado.',
|
||||
);
|
||||
} finally {
|
||||
setBusy(false);
|
||||
setTimeout(
|
||||
() => document.getElementById("resource-result")?.focus(),
|
||||
() => document.getElementById('resource-result')?.focus(),
|
||||
0,
|
||||
);
|
||||
}
|
||||
}
|
||||
const unavailable =
|
||||
!!opportunity.deleted_at || opportunity.status === "archived";
|
||||
!!opportunity.deleted_at || opportunity.status === 'archived';
|
||||
return (
|
||||
<Management title="Imagens, documentos e localizações">
|
||||
<Link href={`/management/opportunities/${opportunity.id}/edit`}>
|
||||
@@ -280,11 +281,29 @@ export default function OpportunityResources({
|
||||
className="rounded border p-3"
|
||||
>
|
||||
{message ||
|
||||
"Guardar é independente de validar, submeter e publicar."}
|
||||
'Guardar é independente de validar, submeter e publicar.'}
|
||||
{errors.etag && <p>{errors.etag}</p>}
|
||||
</div>
|
||||
{kind === 'images' && !imageProcessingAvailable && <p role="status" className="rounded border border-amber-500 p-3">Processamento de imagens indisponível: GD/WebP não está carregado no servidor. Pode guardar o original e os metadados; miniaturas e imagens para divulgação ficam pendentes.</p>}
|
||||
{kind !== 'locations' && <p className="rounded border p-3">Pode guardar anexos para preparação. Cada ficheiro permanece sem download ou pré-visualização enquanto o seu scan não estiver concluído. ClamD pendente não impede guardar metadados, locais ou rascunhos; testes com scanner simulado não verificam os seus ficheiros.</p>}
|
||||
{kind === 'images' && !imageProcessingAvailable && (
|
||||
<p
|
||||
role="status"
|
||||
className="rounded border border-amber-500 p-3"
|
||||
>
|
||||
Processamento de imagens indisponível: GD/WebP não está
|
||||
carregado no servidor. Pode guardar o original e os
|
||||
metadados; miniaturas e imagens para divulgação ficam
|
||||
pendentes.
|
||||
</p>
|
||||
)}
|
||||
{kind !== 'locations' && (
|
||||
<p className="rounded border p-3">
|
||||
Pode guardar anexos para preparação. Cada ficheiro permanece
|
||||
sem download ou pré-visualização enquanto o seu scan não
|
||||
estiver concluído. ClamD pendente não impede guardar
|
||||
metadados, locais ou rascunhos; testes com scanner simulado
|
||||
não verificam os seus ficheiros.
|
||||
</p>
|
||||
)}
|
||||
<section>
|
||||
<h2>Conferência e pendências</h2>
|
||||
<ul>
|
||||
@@ -304,18 +323,18 @@ export default function OpportunityResources({
|
||||
</section>
|
||||
)}
|
||||
<nav className="flex flex-wrap gap-3">
|
||||
{(["locations", "images", "documents"] as Kind[]).map((k) => (
|
||||
{(['locations', 'images', 'documents'] as Kind[]).map((k) => (
|
||||
<button
|
||||
className={button}
|
||||
key={k}
|
||||
disabled={busy}
|
||||
onClick={() => select(k)}
|
||||
>
|
||||
{k === "locations"
|
||||
? "Localizações"
|
||||
: k === "images"
|
||||
? "Imagens"
|
||||
: "Documentos"}
|
||||
{k === 'locations'
|
||||
? 'Localizações'
|
||||
: k === 'images'
|
||||
? 'Imagens'
|
||||
: 'Documentos'}
|
||||
</button>
|
||||
))}
|
||||
</nav>
|
||||
@@ -326,21 +345,21 @@ export default function OpportunityResources({
|
||||
{String(
|
||||
r.payload.title ??
|
||||
r.file?.file_name ??
|
||||
"Recurso incompleto",
|
||||
)}{" "}
|
||||
· v{r.version} ·{" "}
|
||||
'Recurso incompleto',
|
||||
)}{' '}
|
||||
· v{r.version} ·{' '}
|
||||
{r.deleted_at
|
||||
? "eliminado logicamente"
|
||||
: "rascunho"}
|
||||
? 'eliminado logicamente'
|
||||
: 'rascunho'}
|
||||
</p>
|
||||
{r.file && (
|
||||
<p className="break-all">
|
||||
Scan: {r.file.malware_scan_status} · motor:{" "}
|
||||
{r.file.malware_engine ?? "não executado"} ·
|
||||
Scan: {r.file.malware_scan_status} · motor:{' '}
|
||||
{r.file.malware_engine ?? 'não executado'} ·
|
||||
hash: {r.file.sha256}
|
||||
</p>
|
||||
)}
|
||||
{kind === "images" &&
|
||||
{kind === 'images' &&
|
||||
!r.deleted_at &&
|
||||
!!r.derivativePreviews?.length && (
|
||||
<img
|
||||
@@ -348,14 +367,14 @@ export default function OpportunityResources({
|
||||
src={r.derivativePreviews[0].url}
|
||||
srcSet={r.derivativePreviews
|
||||
.map((p) => `${p.url} ${p.width}w`)
|
||||
.join(", ")}
|
||||
.join(', ')}
|
||||
alt={String(
|
||||
r.payload.alt_text ??
|
||||
"Pré-visualização interna pendente de descrição",
|
||||
'Pré-visualização interna pendente de descrição',
|
||||
)}
|
||||
onError={() =>
|
||||
setMessage(
|
||||
"Pré-visualização indisponível ou endereço expirado; recarregue. Dados preservados.",
|
||||
'Pré-visualização indisponível ou endereço expirado; recarregue. Dados preservados.',
|
||||
)
|
||||
}
|
||||
/>
|
||||
@@ -366,7 +385,7 @@ export default function OpportunityResources({
|
||||
>
|
||||
Ver / editar / restaurar
|
||||
</button>
|
||||
{r.file?.malware_scan_status === "clean" &&
|
||||
{r.file?.malware_scan_status === 'clean' &&
|
||||
!r.deleted_at && (
|
||||
<a
|
||||
href={`/management/opportunities/${opportunity.id}/resources/${kind}/${r.id}/download`}
|
||||
@@ -380,22 +399,26 @@ export default function OpportunityResources({
|
||||
<form
|
||||
onSubmit={(event) => {
|
||||
event.preventDefault();
|
||||
void execute("save");
|
||||
void execute('save');
|
||||
}}
|
||||
className="space-y-3"
|
||||
>
|
||||
<h2>
|
||||
{editing
|
||||
? "Editar recurso / nova versão"
|
||||
: "Novo recurso incompleto"}
|
||||
? 'Editar recurso / nova versão'
|
||||
: 'Novo recurso incompleto'}
|
||||
</h2>
|
||||
{kind === "locations" && (
|
||||
{kind === 'locations' && (
|
||||
<div>
|
||||
<TerritoryGeometryPreview
|
||||
territoryId={path.at(-1)?.id}
|
||||
management
|
||||
/>
|
||||
{[0, 1, 2, 3].map((index) => (
|
||||
<TerritoryLevel
|
||||
key={index}
|
||||
index={index}
|
||||
parent={path[index - 1]?.id ?? ""}
|
||||
parent={path[index - 1]?.id ?? ''}
|
||||
selected={path[index]}
|
||||
onChange={(value) =>
|
||||
setPath((previous) =>
|
||||
@@ -410,10 +433,10 @@ export default function OpportunityResources({
|
||||
fieldError={
|
||||
errors[
|
||||
[
|
||||
"province_id",
|
||||
"district_id",
|
||||
"admin_post_id",
|
||||
"locality_id",
|
||||
'province_id',
|
||||
'district_id',
|
||||
'admin_post_id',
|
||||
'locality_id',
|
||||
][index]
|
||||
]
|
||||
}
|
||||
@@ -421,7 +444,7 @@ export default function OpportunityResources({
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
{kind !== "locations" && (
|
||||
{kind !== 'locations' && (
|
||||
<Field
|
||||
label="Original / substituir por nova versão"
|
||||
error={errors.file}
|
||||
@@ -431,9 +454,9 @@ export default function OpportunityResources({
|
||||
aria-label="Original / substituir por nova versão"
|
||||
type="file"
|
||||
accept={
|
||||
kind === "images"
|
||||
? ".jpg,.jpeg,.png,.webp"
|
||||
: ".pdf,.docx,.xlsx,.png,.jpg,.jpeg"
|
||||
kind === 'images'
|
||||
? '.jpg,.jpeg,.png,.webp'
|
||||
: '.pdf,.docx,.xlsx,.png,.jpg,.jpeg'
|
||||
}
|
||||
onChange={(event) =>
|
||||
setFile(event.target.files?.[0] ?? null)
|
||||
@@ -454,13 +477,13 @@ export default function OpportunityResources({
|
||||
<input
|
||||
aria-label={labels[name]}
|
||||
className={control}
|
||||
value={String(payload[name] ?? "")}
|
||||
value={String(payload[name] ?? '')}
|
||||
type={
|
||||
name.includes("date") ||
|
||||
name.endsWith("_at") ||
|
||||
name.endsWith("_until")
|
||||
? "date"
|
||||
: "text"
|
||||
name.includes('date') ||
|
||||
name.endsWith('_at') ||
|
||||
name.endsWith('_until')
|
||||
? 'date'
|
||||
: 'text'
|
||||
}
|
||||
onChange={(event) =>
|
||||
set(name, event.target.value || null)
|
||||
@@ -468,19 +491,19 @@ export default function OpportunityResources({
|
||||
/>
|
||||
</Field>
|
||||
))}
|
||||
{(kind === "locations"
|
||||
? ["role", "territorial_purpose"]
|
||||
: kind === "images"
|
||||
? ["imageRole", "rights_status", "visibility"]
|
||||
: ["classification", "visibility"]
|
||||
{(kind === 'locations'
|
||||
? ['role', 'territorial_purpose']
|
||||
: kind === 'images'
|
||||
? ['imageRole', 'rights_status', 'visibility']
|
||||
: ['classification', 'visibility']
|
||||
).map((name) => (
|
||||
<Field
|
||||
key={name}
|
||||
label={labels[name] ?? name}
|
||||
error={
|
||||
errors[name === "imageRole" ? "role" : name] ??
|
||||
errors[name === 'imageRole' ? 'role' : name] ??
|
||||
errors[
|
||||
`payload.${name === "imageRole" ? "role" : name}`
|
||||
`payload.${name === 'imageRole' ? 'role' : name}`
|
||||
]
|
||||
}
|
||||
>
|
||||
@@ -488,12 +511,12 @@ export default function OpportunityResources({
|
||||
className={control}
|
||||
aria-label={labels[name] ?? name}
|
||||
value={String(
|
||||
payload[name === "imageRole" ? "role" : name] ??
|
||||
"",
|
||||
payload[name === 'imageRole' ? 'role' : name] ??
|
||||
'',
|
||||
)}
|
||||
onChange={(event) =>
|
||||
set(
|
||||
name === "imageRole" ? "role" : name,
|
||||
name === 'imageRole' ? 'role' : name,
|
||||
event.target.value || null,
|
||||
)
|
||||
}
|
||||
@@ -505,7 +528,7 @@ export default function OpportunityResources({
|
||||
</select>
|
||||
</Field>
|
||||
))}
|
||||
{kind === "locations" && (
|
||||
{kind === 'locations' && (
|
||||
<Field
|
||||
label="GeoJSON documentado (opcional)"
|
||||
error={errors.geometry}
|
||||
@@ -523,8 +546,8 @@ export default function OpportunityResources({
|
||||
</p>
|
||||
</Field>
|
||||
)}
|
||||
{kind === "images" &&
|
||||
(["location_id", "rights_document_id"] as const).map(
|
||||
{kind === 'images' &&
|
||||
(['location_id', 'rights_document_id'] as const).map(
|
||||
(name) => (
|
||||
<Field
|
||||
key={name}
|
||||
@@ -535,16 +558,16 @@ export default function OpportunityResources({
|
||||
>
|
||||
<select
|
||||
className={control}
|
||||
value={String(payload[name] ?? "")}
|
||||
value={String(payload[name] ?? '')}
|
||||
onChange={(event) =>
|
||||
set(name, event.target.value || null)
|
||||
}
|
||||
>
|
||||
<option value="">Pendente</option>
|
||||
{resources[
|
||||
name === "location_id"
|
||||
? "locations"
|
||||
: "documents"
|
||||
name === 'location_id'
|
||||
? 'locations'
|
||||
: 'documents'
|
||||
]
|
||||
.filter((r) => !r.deleted_at)
|
||||
.map((r) => (
|
||||
@@ -560,30 +583,30 @@ export default function OpportunityResources({
|
||||
</Field>
|
||||
),
|
||||
)}
|
||||
{kind !== "documents" && (
|
||||
{kind !== 'documents' && (
|
||||
<label>
|
||||
<input
|
||||
key={key}
|
||||
type="checkbox"
|
||||
checked={
|
||||
!!payload[
|
||||
kind === "images"
|
||||
? "is_cover"
|
||||
: "is_primary"
|
||||
kind === 'images'
|
||||
? 'is_cover'
|
||||
: 'is_primary'
|
||||
]
|
||||
}
|
||||
onChange={(event) =>
|
||||
set(
|
||||
kind === "images"
|
||||
? "is_cover"
|
||||
: "is_primary",
|
||||
kind === 'images'
|
||||
? 'is_cover'
|
||||
: 'is_primary',
|
||||
event.target.checked,
|
||||
)
|
||||
}
|
||||
/>
|
||||
{kind === "images"
|
||||
? "Selecionar capa de preparação"
|
||||
: "Localização principal"}
|
||||
{kind === 'images'
|
||||
? 'Selecionar capa de preparação'
|
||||
: 'Localização principal'}
|
||||
</label>
|
||||
)}
|
||||
<Field
|
||||
@@ -610,12 +633,14 @@ export default function OpportunityResources({
|
||||
</label>
|
||||
)}
|
||||
<div className="flex flex-wrap gap-3">
|
||||
{kind === "images" && editing && !editing.deleted_at && (
|
||||
{kind === 'images' && editing && !editing.deleted_at && (
|
||||
<button
|
||||
type="button"
|
||||
className={button}
|
||||
disabled={busy || unavailable || !imageProcessingAvailable}
|
||||
onClick={() => void execute("prepare")}
|
||||
disabled={
|
||||
busy || unavailable || !imageProcessingAvailable
|
||||
}
|
||||
onClick={() => void execute('prepare')}
|
||||
>
|
||||
Preparar WebP e miniaturas
|
||||
</button>
|
||||
@@ -633,13 +658,13 @@ export default function OpportunityResources({
|
||||
disabled={busy || unavailable}
|
||||
onClick={() =>
|
||||
void execute(
|
||||
editing.deleted_at ? "restore" : "delete",
|
||||
editing.deleted_at ? 'restore' : 'delete',
|
||||
)
|
||||
}
|
||||
>
|
||||
{editing.deleted_at
|
||||
? "Restaurar recurso"
|
||||
: "Excluir recurso logicamente"}
|
||||
? 'Restaurar recurso'
|
||||
: 'Excluir recurso logicamente'}
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user