191 lines
8.1 KiB
TypeScript
191 lines
8.1 KiB
TypeScript
import { Link, usePage } from '@inertiajs/react';
|
|
import { useId, useState } from 'react';
|
|
import type { ReactNode } from 'react';
|
|
|
|
export const portalLinks = [
|
|
['/', 'Início'],
|
|
['/oportunidades', 'Oportunidades de Investimento'],
|
|
['/educacao', 'Educação'],
|
|
['/sectores', 'Sectores Prioritários'],
|
|
['/como-investir', 'Como Investir'],
|
|
['/terra-duat', 'Terra e DUAT'],
|
|
['/legislacao', 'Legislação e Incentivos'],
|
|
['/documentos', 'Documentos e Formulários'],
|
|
['/apoio', 'Apoio ao Investidor'],
|
|
] as const;
|
|
const names: Record<string, string> = {
|
|
'/investidor/negocios': 'Os meus negócios',
|
|
'/management/negocios': 'Revisão de negócios',
|
|
...Object.fromEntries(portalLinks),
|
|
'/investidor/terra-duat': 'Os meus pedidos Terra e DUAT',
|
|
'/management/terra-duat': 'Gestão de Terra e DUAT',
|
|
'/parcerias': 'Bolsa de Parcerias',
|
|
'/simulador-fiscal': 'Simulador Fiscal',
|
|
'/balcao-virtual': 'Balcão Virtual',
|
|
'/investidor/manifestacoes': 'Manifestações e favoritos',
|
|
'/investidor/profile': 'Perfil e empresas',
|
|
'/investidor/notifications': 'Notificações',
|
|
'/management/investment/references': 'Referências e formulários',
|
|
'/management/investment/zones': 'Gestão de ZEE, ZFI e parques',
|
|
'/formularios/investidor': 'Formulário de investidor',
|
|
'/formularios/empresa': 'Formulário de empresa',
|
|
'/manifestar-interesse': 'Manifestar interesse',
|
|
'/carteira': 'Corredores, clusters e projectos',
|
|
'/investidor': 'O meu painel',
|
|
'/login': 'Entrar',
|
|
'/register': 'Criar conta',
|
|
'/dashboard': 'Painel',
|
|
'/acesso-gestao': 'Acesso à gestão',
|
|
'/management/portfolio': 'Carteira de investimento',
|
|
'/management/ai': 'Assistência',
|
|
'/management/interests': 'Pedidos de interesse',
|
|
'/management/portal-services': 'Documentos e parcerias',
|
|
};
|
|
export default function PortalNavigation({
|
|
children,
|
|
}: {
|
|
children: ReactNode;
|
|
}) {
|
|
const { url, props } = usePage();
|
|
const path = url.split('?')[0];
|
|
const parent = Object.keys(names)
|
|
.filter((p) => p !== '/' && path.startsWith(`${p}/`))
|
|
.sort((a, b) => b.length - a.length)[0];
|
|
const pageProps = props as {
|
|
record?: { title?: string; name?: string };
|
|
zone?: { name?: string };
|
|
sector?: { name?: string };
|
|
initialOpportunity?: { title?: string };
|
|
};
|
|
const title =
|
|
names[path] ??
|
|
pageProps.record?.title ??
|
|
pageProps.record?.name ??
|
|
pageProps.zone?.name ??
|
|
pageProps.sector?.name ??
|
|
pageProps.initialOpportunity?.title ??
|
|
(path.includes('/edit')
|
|
? 'Editar registo'
|
|
: path.startsWith('/management')
|
|
? 'Gestão do portal'
|
|
: path.startsWith('/settings')
|
|
? 'Definições da conta'
|
|
: 'Detalhes');
|
|
return (
|
|
<div className="pb-8 lg:pb-24 [&_button]:scroll-mb-24 [&_input]:scroll-mb-24 [&_select]:scroll-mb-24 [&_textarea]:scroll-mb-24">
|
|
<a
|
|
href="#portal-content"
|
|
className="sr-only focus:not-sr-only focus:block focus:bg-white focus:p-4 focus:text-emerald-900"
|
|
>
|
|
Saltar para o conteúdo
|
|
</a>
|
|
<nav
|
|
aria-label="Caminho de navegação"
|
|
className="bg-background text-foreground flex flex-wrap items-center gap-2 border-b px-5 py-3 text-sm"
|
|
>
|
|
{path === '/' ? (
|
|
<span aria-current="page">Início</span>
|
|
) : (
|
|
<>
|
|
<Link href="/" className="underline">
|
|
Início
|
|
</Link>
|
|
<span aria-hidden="true">/</span>
|
|
{parent && (
|
|
<>
|
|
<Link href={parent} className="underline">
|
|
{names[parent]}
|
|
</Link>
|
|
<span aria-hidden="true">/</span>
|
|
</>
|
|
)}
|
|
<span aria-current="page">{title}</span>
|
|
</>
|
|
)}
|
|
</nav>
|
|
<div id="portal-content" tabIndex={-1}>
|
|
{children}
|
|
</div>
|
|
<a
|
|
href="/apoio"
|
|
className="mx-3 mt-4 block max-w-[calc(100%-1.5rem)] rounded-xl bg-emerald-800 px-5 py-3 text-center text-sm font-semibold text-white shadow-xl focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-emerald-600 lg:fixed lg:right-3 lg:bottom-3 lg:z-50 lg:mx-0 lg:mt-0 lg:max-w-[calc(100vw-1.5rem)]"
|
|
>
|
|
Contactar Apoio ao Investidor
|
|
</a>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
export function PortalMenu() {
|
|
const { existingBusinessEnabled } = usePage<{
|
|
existingBusinessEnabled?: boolean;
|
|
}>().props;
|
|
const [expanded, setExpanded] = useState(false);
|
|
const menuId = useId();
|
|
return (
|
|
<nav
|
|
aria-label="Áreas do portal"
|
|
className="border-b bg-white px-5 py-4 text-sm text-slate-800"
|
|
>
|
|
<div className="flex items-center justify-between gap-4 md:hidden">
|
|
<Link href="/" className="font-bold">
|
|
Portal do Investidor
|
|
</Link>
|
|
<button
|
|
type="button"
|
|
className="rounded-lg border px-3 py-2 font-semibold focus-visible:outline-2 focus-visible:outline-emerald-700"
|
|
aria-expanded={expanded}
|
|
aria-controls={menuId}
|
|
onClick={() => setExpanded(!expanded)}
|
|
>
|
|
{expanded ? 'Fechar menu' : 'Abrir menu'}
|
|
</button>
|
|
</div>
|
|
<div
|
|
id={menuId}
|
|
className={`${expanded ? 'flex' : 'hidden'} mt-4 flex-wrap gap-x-5 gap-y-3 md:mt-0 md:flex`}
|
|
>
|
|
{portalLinks.map(([href, label]) => (
|
|
<Link
|
|
key={href}
|
|
href={href}
|
|
className="underline underline-offset-4"
|
|
>
|
|
{label}
|
|
</Link>
|
|
))}
|
|
<details className="relative">
|
|
<summary className="cursor-pointer underline underline-offset-4 focus-visible:outline-2 focus-visible:outline-emerald-700">
|
|
Catálogos territoriais e económicos
|
|
</summary>
|
|
<ul className="mt-2 grid gap-2 rounded-lg border bg-white p-4 shadow-sm md:absolute md:z-20 md:min-w-64">
|
|
<li><Link className="underline" href="/carteira?kind=cluster">Clusters</Link></li>
|
|
<li><Link className="underline" href="/carteira?kind=corridor">Corredores</Link></li>
|
|
<li><Link className="underline" href="/zonas">ZEE, ZFI e parques industriais</Link></li>
|
|
<li><Link className="underline" href="/carteira?kind=project">Projectos âncora</Link></li>
|
|
<li><Link className="underline" href="/oportunidades">Oportunidades publicadas</Link></li>
|
|
<li><Link className="underline" href="/negocios">Negócios existentes e participações publicadas</Link></li>
|
|
</ul>
|
|
</details>
|
|
{existingBusinessEnabled && (
|
|
<Link href="/investidor/negocios" className="underline">
|
|
Os meus negócios
|
|
</Link>
|
|
)}
|
|
<Link href="/parcerias" className="underline">
|
|
Bolsa de Parcerias
|
|
</Link>
|
|
<Link href="/simulador-fiscal" className="underline">
|
|
Simulador Fiscal
|
|
</Link>
|
|
<Link href="/balcao-virtual" className="underline">
|
|
Balcão Virtual
|
|
</Link>
|
|
<Link href="/investidor/manifestacoes" className="underline">
|
|
Área do investidor
|
|
</Link>
|
|
</div>
|
|
</nav>
|
|
);
|
|
}
|