119 lines
5.0 KiB
TypeScript
119 lines
5.0 KiB
TypeScript
import { Head, Link, usePage } from '@inertiajs/react';
|
|
import ProfileNavigation from '@/components/profile-navigation';
|
|
import {
|
|
canShowLegacyManagement,
|
|
portalNavigation,
|
|
type PortalNavAccess,
|
|
} from '@/lib/portal-navigation';
|
|
|
|
export default function DashboardManagement({
|
|
summaryAvailable,
|
|
}: {
|
|
summaryAvailable: boolean;
|
|
}) {
|
|
const { props } = usePage<{
|
|
auth?: {
|
|
user?: unknown;
|
|
canManagePortal?: boolean;
|
|
legacyManagementAccess?: boolean;
|
|
};
|
|
profileAccess?: PortalNavAccess['profileAccess'];
|
|
opportunityManagement?: PortalNavAccess['opportunityManagement'];
|
|
contentManagementHref?: PortalNavAccess['contentManagementHref'];
|
|
contentManagementAccess?: PortalNavAccess['contentManagementAccess'];
|
|
scopedAdministration?: PortalNavAccess['scopedAdministration'];
|
|
administrationNavigation?: PortalNavAccess['administrationNavigation'];
|
|
dashboardNavigation?: PortalNavAccess['dashboardNavigation'];
|
|
existingBusinessEnabled?: boolean;
|
|
businessReviewUrl?: string | null;
|
|
educationEnabled?: boolean;
|
|
aiEnabled?: boolean;
|
|
legacyContentEnabled?: boolean;
|
|
procurementEnabled?: boolean;
|
|
}>();
|
|
const administration = portalNavigation({
|
|
authenticated: !!props.auth?.user,
|
|
manager: canShowLegacyManagement(props.auth),
|
|
profileAccess: props.profileAccess,
|
|
opportunityManagement: props.opportunityManagement,
|
|
contentManagementHref: props.contentManagementHref,
|
|
contentManagementAccess: props.contentManagementAccess,
|
|
scopedAdministration: props.scopedAdministration,
|
|
administrationNavigation: props.administrationNavigation,
|
|
dashboardNavigation: props.dashboardNavigation,
|
|
businesses: props.existingBusinessEnabled,
|
|
businessReviewUrl: props.businessReviewUrl,
|
|
education: props.educationEnabled,
|
|
ai: props.aiEnabled,
|
|
legacyContent: props.legacyContentEnabled,
|
|
procurement: props.procurementEnabled,
|
|
}).find((group) => group.id === 'administration');
|
|
const groups =
|
|
administration?.children?.filter(
|
|
(group) => group.id !== 'collaborative-dashboard',
|
|
) ?? [];
|
|
const managing = summaryAvailable || !!administration;
|
|
const title = managing
|
|
? 'Dashboard de gestão do portal'
|
|
: 'A minha área de trabalho';
|
|
return (
|
|
<>
|
|
<Head title={title} />
|
|
<header className="space-y-2">
|
|
<h1 className="text-2xl font-semibold">{title}</h1>
|
|
<p className="text-muted-foreground max-w-3xl">
|
|
{managing
|
|
? 'Gira as oportunidades, os conteúdos e os acessos do portal nas áreas que lhe estão atribuídas.'
|
|
: 'Consulte os seus investimentos, as tarefas e os acessos disponíveis para a sua conta.'}
|
|
</p>
|
|
</header>
|
|
{groups.length > 0 && (
|
|
<section
|
|
aria-label="Gestão do portal"
|
|
className="grid gap-4 md:grid-cols-2"
|
|
>
|
|
{groups.map((group) => (
|
|
<section
|
|
key={group.id}
|
|
className="min-w-0 space-y-3 rounded-xl border p-5"
|
|
>
|
|
<h2 className="text-lg font-semibold">
|
|
{group.label}
|
|
</h2>
|
|
<nav
|
|
aria-label={group.label}
|
|
className="grid gap-2"
|
|
>
|
|
{group.children?.map(
|
|
(item) =>
|
|
item.href && (
|
|
<Link
|
|
key={item.id}
|
|
href={item.href}
|
|
className="hover:bg-muted focus-visible:outline-primary rounded-lg px-3 py-2 underline underline-offset-4 focus-visible:outline-2"
|
|
>
|
|
{item.label}
|
|
</Link>
|
|
),
|
|
)}
|
|
</nav>
|
|
</section>
|
|
))}
|
|
</section>
|
|
)}
|
|
{managing ? (
|
|
<details className="rounded-xl border p-4">
|
|
<summary className="cursor-pointer font-medium">
|
|
A minha conta e oportunidades próprias
|
|
</summary>
|
|
<div className="mt-3">
|
|
<ProfileNavigation />
|
|
</div>
|
|
</details>
|
|
) : (
|
|
<ProfileNavigation />
|
|
)}
|
|
</>
|
|
);
|
|
}
|