169 lines
6.8 KiB
TypeScript
169 lines
6.8 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"],
|
|
["/clusters", "Clusters"],
|
|
["/corredores", "Corredores"],
|
|
["/zonas", "ZEE, ZFI e parques"],
|
|
["/projectos-ancora", "Projectos âncora"],
|
|
["/educacao", "Educação"],
|
|
["/sectores", "Sectores Prioritários"],
|
|
["/como-investir", "Como Investir"],
|
|
["/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),
|
|
"/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-24 [&_input]:scroll-mb-24 [&_select]:scroll-mb-24 [&_textarea]:scroll-mb-24 [&_button]: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="flex flex-wrap items-center gap-2 border-b bg-background px-5 py-3 text-sm text-foreground"
|
|
>
|
|
{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="fixed right-3 bottom-3 z-50 max-w-[calc(100vw-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"
|
|
>
|
|
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>
|
|
))}
|
|
{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>
|
|
);
|
|
}
|