@@ -0,0 +1,301 @@
|
||||
import { Head, Link, useForm } from '@inertiajs/react';
|
||||
|
||||
export type LegacyArticle = {
|
||||
id: number;
|
||||
title: string;
|
||||
author: string;
|
||||
legacy_id: number;
|
||||
legacy_category: string;
|
||||
published_at: string;
|
||||
modified_at: string;
|
||||
source_url: string;
|
||||
href: string;
|
||||
landing_href: string;
|
||||
start_href: string;
|
||||
group: { label: string; heading: string };
|
||||
related_articles: { id: number; slug: string; title: string; href: string }[];
|
||||
html: string;
|
||||
library_href: string;
|
||||
image: { href: string; alt: string; source_url: string } | null;
|
||||
sector: { name: string; slug: string } | null;
|
||||
territorial_references: string[];
|
||||
territorial_status: string;
|
||||
opportunities: {
|
||||
title: string;
|
||||
slug: string;
|
||||
province: string;
|
||||
summary: string;
|
||||
}[];
|
||||
};
|
||||
|
||||
export default function LegacySector({
|
||||
article,
|
||||
articles = [article],
|
||||
view,
|
||||
query = '',
|
||||
match = true,
|
||||
contentContext,
|
||||
}: {
|
||||
article: LegacyArticle;
|
||||
articles?: LegacyArticle[];
|
||||
view: 'landing' | 'article';
|
||||
query?: string;
|
||||
match?: boolean;
|
||||
contentContext?: { id: string; title: string } | null;
|
||||
}) {
|
||||
const search = useForm({ q: query });
|
||||
return (
|
||||
<main className="legacy-agronegocio mx-auto max-w-6xl space-y-8 rounded-2xl bg-[#f6f3ea] p-4 sm:p-8">
|
||||
<Head
|
||||
title={
|
||||
view === 'landing' ? `Explorar ${article.group.label}` : article.title
|
||||
}
|
||||
/>
|
||||
<style>{`
|
||||
.legacy-agronegocio { color: #10352b; font-family: 'Noto Sans', system-ui, sans-serif; }
|
||||
.legacy-agronegocio h1, .legacy-agronegocio h2 { font-family: 'Noto Serif', Georgia, serif; }
|
||||
.legacy-agronegocio a, .legacy-agronegocio button { outline-offset: 4px; }
|
||||
.legacy-agronegocio a:focus-visible, .legacy-agronegocio button:focus-visible { outline: 3px solid #b22222; }
|
||||
.legacy-article { font-size: 1.0625rem; line-height: 1.8; overflow-wrap: anywhere; }
|
||||
.legacy-article p, .legacy-article ul, .legacy-article ol { margin-block: 1.2em; }
|
||||
.legacy-article ul { list-style: disc; padding-inline-start: 1.6em; }
|
||||
.legacy-article ol { list-style: decimal; padding-inline-start: 1.6em; }
|
||||
.legacy-article a { text-decoration: underline; }
|
||||
`}</style>
|
||||
<nav className="flex flex-wrap gap-4" aria-label={article.group.label}>
|
||||
<Link href={article.landing_href} className="underline">
|
||||
Explorar {article.group.label}
|
||||
</Link>
|
||||
<Link href="/sectores" className="underline">
|
||||
Todos os setores
|
||||
</Link>
|
||||
<Link href={article.library_href} className="underline">
|
||||
Exemplar na biblioteca
|
||||
</Link>
|
||||
</nav>
|
||||
<header className="overflow-hidden rounded-2xl border bg-white">
|
||||
{article.image && (
|
||||
<img
|
||||
className="aspect-video w-full object-cover"
|
||||
src={article.image.href}
|
||||
alt={article.image.alt}
|
||||
width={900}
|
||||
height={506}
|
||||
/>
|
||||
)}
|
||||
<div className="space-y-3 p-5 sm:p-8">
|
||||
<p className="text-sm font-semibold tracking-wide text-[#b22222] uppercase">
|
||||
Conhecer · preparar · acompanhar
|
||||
</p>
|
||||
<h1 className="text-3xl font-semibold sm:text-4xl">
|
||||
{view === 'landing'
|
||||
? article.group.heading
|
||||
: article.title}
|
||||
</h1>
|
||||
<p>
|
||||
Explore o setor e prepare a sua ideia com o contexto
|
||||
guardado no dossier.
|
||||
</p>
|
||||
<p className="text-sm">
|
||||
Fonte: {article.author} · Publicado em{' '}
|
||||
<time dateTime={article.published_at}>
|
||||
{article.published_at.slice(0, 10)}
|
||||
</time>{' '}
|
||||
· Atualizado em{' '}
|
||||
<time dateTime={article.modified_at}>
|
||||
{article.modified_at.slice(0, 10)}
|
||||
</time>
|
||||
</p>
|
||||
</div>
|
||||
</header>
|
||||
{view === 'landing' ? (
|
||||
<section className="space-y-4" aria-labelledby="learn-title">
|
||||
<h2 id="learn-title" className="text-2xl font-semibold">
|
||||
Compreender o setor
|
||||
</h2>
|
||||
<form
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
search.get(article.landing_href);
|
||||
}}
|
||||
className="flex flex-wrap gap-3"
|
||||
>
|
||||
<label className="grid flex-1 gap-1">
|
||||
Pesquisar no conteúdo
|
||||
<input
|
||||
className="min-w-0 rounded border p-3"
|
||||
value={search.data.q}
|
||||
onChange={(e) =>
|
||||
search.setData('q', e.target.value)
|
||||
}
|
||||
maxLength={120}
|
||||
type="search"
|
||||
/>
|
||||
</label>
|
||||
<button
|
||||
className="self-end rounded bg-[#b22222] px-5 py-3 text-white"
|
||||
disabled={search.processing}
|
||||
>
|
||||
Pesquisar
|
||||
</button>
|
||||
</form>
|
||||
{match ? (
|
||||
<div className="grid gap-4 sm:grid-cols-2">
|
||||
{articles.map((item) => (
|
||||
<article key={item.id} className="space-y-3 rounded-xl border bg-white p-5">
|
||||
<h3 className="text-xl font-semibold">
|
||||
<Link className="underline" href={item.href}>
|
||||
{item.title}
|
||||
</Link>
|
||||
</h3>
|
||||
<p>
|
||||
Conteúdo editorial preservado do portal Tempo.
|
||||
</p>
|
||||
<Link
|
||||
className="inline-block rounded bg-[#10352b] px-5 py-3 text-white"
|
||||
href={item.href}
|
||||
>
|
||||
Ler o artigo
|
||||
</Link>
|
||||
</article>
|
||||
))}
|
||||
</div>
|
||||
) : (
|
||||
<p role="status">
|
||||
Nenhum conteúdo corresponde à pesquisa.
|
||||
</p>
|
||||
)}
|
||||
</section>
|
||||
) : (
|
||||
<section
|
||||
aria-label="Artigo educativo"
|
||||
className="legacy-article max-w-3xl"
|
||||
dangerouslySetInnerHTML={{ __html: article.html }}
|
||||
/>
|
||||
)}
|
||||
{view === 'article' && article.related_articles.length > 0 && (
|
||||
<section className="space-y-3" aria-labelledby="related-title">
|
||||
<h2 id="related-title" className="text-2xl font-semibold">Outras leituras no setor</h2>
|
||||
<ul className="grid gap-3 sm:grid-cols-2">
|
||||
{article.related_articles.map((item) => (
|
||||
<li key={item.id}><Link className="underline" href={item.href}>{item.title}</Link></li>
|
||||
))}
|
||||
</ul>
|
||||
</section>
|
||||
)}
|
||||
<section
|
||||
className="space-y-4 rounded-xl border bg-white p-5"
|
||||
aria-labelledby="locations-title"
|
||||
>
|
||||
<h2 id="locations-title" className="text-2xl font-semibold">
|
||||
Contexto territorial
|
||||
</h2>
|
||||
<ul className="flex flex-wrap gap-3">
|
||||
{article.territorial_references.map((name) => (
|
||||
<li key={name} className="rounded border px-3 py-2">
|
||||
{name}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
<p>{article.territorial_status}</p>
|
||||
<div className="flex flex-wrap gap-4">
|
||||
<Link href="/carteira?kind=corridor" className="underline">
|
||||
Consultar os corredores cadastrados
|
||||
</Link>
|
||||
<Link href="/zonas" className="underline">
|
||||
Consultar localizações e mapas disponíveis
|
||||
</Link>
|
||||
</div>
|
||||
</section>
|
||||
<section
|
||||
className="space-y-4"
|
||||
aria-labelledby="opportunities-title"
|
||||
>
|
||||
<h2 id="opportunities-title" className="text-2xl font-semibold">
|
||||
Oportunidades publicadas no setor
|
||||
</h2>
|
||||
<p>
|
||||
Cadastros independentes do artigo, com a sua própria autoria
|
||||
e situação de publicação.
|
||||
</p>
|
||||
{article.opportunities.length ? (
|
||||
<ul className="grid gap-4 sm:grid-cols-2">
|
||||
{article.opportunities.map((o) => (
|
||||
<li
|
||||
key={o.slug}
|
||||
className="rounded-xl border bg-white p-5"
|
||||
>
|
||||
<h3 className="font-semibold">
|
||||
<Link
|
||||
className="underline"
|
||||
href={`/oportunidades/${o.slug}`}
|
||||
>
|
||||
{o.title}
|
||||
</Link>
|
||||
</h3>
|
||||
<p>{o.province}</p>
|
||||
<p>{o.summary}</p>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
) : (
|
||||
<p>
|
||||
Ainda não há oportunidades publicadas neste setor. Pode
|
||||
desenvolver uma ideia no seu dossier.
|
||||
</p>
|
||||
)}
|
||||
</section>
|
||||
<section
|
||||
className="space-y-3 rounded-xl bg-[#10352b] p-6 text-white"
|
||||
aria-labelledby="prepare-title"
|
||||
>
|
||||
<h2 id="prepare-title" className="text-2xl font-semibold">
|
||||
Preparar a sua ideia
|
||||
</h2>
|
||||
<p>
|
||||
A leitura é pública. Para guardar dados pessoais, escolha ou
|
||||
crie um dossier na sua conta.
|
||||
</p>
|
||||
<Link
|
||||
className="inline-block rounded bg-white px-5 py-3 font-semibold text-[#10352b]"
|
||||
href={
|
||||
contentContext
|
||||
? `/investimentos/${contentContext.id}`
|
||||
: article.start_href
|
||||
}
|
||||
>
|
||||
{contentContext
|
||||
? `Continuar: ${contentContext.title}`
|
||||
: 'Iniciar ou continuar uma ideia'}
|
||||
</Link>
|
||||
</section>
|
||||
<footer className="space-y-2 border-t pt-4 text-sm">
|
||||
<p>
|
||||
Conteúdo editorial de {article.author}. Categoria original:{' '}
|
||||
{article.legacy_category}. Não representa uma oportunidade
|
||||
concreta, autorização de investimento ou cálculo.
|
||||
</p>
|
||||
<a
|
||||
className="underline"
|
||||
href={article.source_url}
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
Consultar a página original
|
||||
</a>
|
||||
{article.image && (
|
||||
<p>
|
||||
<a
|
||||
className="underline"
|
||||
href={article.image.source_url}
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
Origem da imagem
|
||||
</a>{' '}
|
||||
· Autoria individual e data de criação não indicadas no
|
||||
legado.
|
||||
</p>
|
||||
)}
|
||||
</footer>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
@@ -161,7 +161,9 @@ export default function Manage({
|
||||
requirementCatalogue,
|
||||
requirementAssociationsEnabled,
|
||||
disclosureAuthorization,
|
||||
legacyContentEnabled = false,
|
||||
}: {
|
||||
legacyContentEnabled?: boolean;
|
||||
documents: DocumentFile[];
|
||||
resources: Resource[];
|
||||
requirementCatalogue: { key: string; label: string; tax: string }[];
|
||||
@@ -533,9 +535,9 @@ export default function Manage({
|
||||
}
|
||||
/>
|
||||
</Field>
|
||||
<Field label="Assunto">
|
||||
<Field label={legacyContentEnabled ? 'Assunto (opcional)' : 'Assunto'}>
|
||||
<input
|
||||
required
|
||||
required={!legacyContentEnabled}
|
||||
className={control}
|
||||
value={form.data.topic}
|
||||
onChange={(e) =>
|
||||
|
||||
@@ -264,6 +264,7 @@ function RequestForm({
|
||||
{field === 'country' ? (
|
||||
<CountrySelect
|
||||
countries={countries}
|
||||
label="País do requerente"
|
||||
value={form.data.country}
|
||||
onChange={(value) =>
|
||||
form.setData('country', value)
|
||||
@@ -290,6 +291,7 @@ function RequestForm({
|
||||
País de origem declarado desta solicitação
|
||||
<CountrySelect
|
||||
countries={countries}
|
||||
label="País de origem declarado desta solicitação"
|
||||
value={form.data.declared_origin_country_code}
|
||||
onChange={(value) =>
|
||||
form.setData('declared_origin_country_code', value)
|
||||
|
||||
Reference in New Issue
Block a user