345 lines
14 KiB
TypeScript
345 lines
14 KiB
TypeScript
import { Head, Link, useForm } from '@inertiajs/react';
|
|
import EducationalArticleCard, {
|
|
type EducationalArticle,
|
|
} from '@/components/educational-article-card';
|
|
|
|
export type LegacyArticle = {
|
|
summary: string;
|
|
opportunities_href?: string | null;
|
|
opportunities_label?: string | null;
|
|
has_opportunities?: boolean;
|
|
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: (EducationalArticle & { id: number })[];
|
|
html: string;
|
|
library_href: string;
|
|
image: { href: string; alt: string; source_url: string } | null;
|
|
related_sectors?: { id: number; name: string; slug: string }[];
|
|
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>
|
|
{article.sector?.slug === 'agronegocio' && (
|
|
<Link
|
|
className="inline-flex rounded-lg bg-emerald-800 px-5 py-3 font-semibold text-white"
|
|
href="/oportunidades?sector=agronegocio&view=corridors"
|
|
>
|
|
Explorar oportunidades por corredor
|
|
</Link>
|
|
)}
|
|
<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) => (
|
|
<EducationalArticleCard
|
|
key={item.id}
|
|
article={item}
|
|
/>
|
|
))}
|
|
</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}>
|
|
<EducationalArticleCard article={item} />
|
|
</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">
|
|
{article.related_sectors?.length
|
|
? 'Oportunidades nos sectores relacionados'
|
|
: 'Oportunidades publicadas no setor'}
|
|
</h2>
|
|
{!!article.related_sectors?.length && (
|
|
<nav
|
|
aria-label="Sectores relacionados"
|
|
className="flex flex-wrap gap-4 rounded border bg-emerald-50 p-5"
|
|
>
|
|
<p className="w-full">
|
|
Este artigo histórico abrange dois sectores. Escolha
|
|
o contexto a preparar:
|
|
</p>
|
|
{article.related_sectors.map((s) => (
|
|
<Link
|
|
key={s.id}
|
|
className="font-semibold underline"
|
|
href={`/sectores/${s.slug}`}
|
|
>
|
|
{s.name}
|
|
</Link>
|
|
))}
|
|
</nav>
|
|
)}
|
|
{article.sector && (
|
|
<Link
|
|
className="underline"
|
|
href={`/sectores/${article.sector.slug}`}
|
|
>
|
|
Explorar negócios e ações neste setor
|
|
</Link>
|
|
)}
|
|
<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>
|
|
);
|
|
}
|