feat: lead dashboard with authorised portal management groups

This commit is contained in:
2026-11-23 10:52:44 +02:00
parent 0cde594e22
commit d231435d84
17 changed files with 688 additions and 9 deletions
@@ -0,0 +1,118 @@
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 />
)}
</>
);
}
+3 -8
View File
@@ -1,9 +1,8 @@
import ProfileNavigation from '@/components/profile-navigation';
import ContentManagementEntry from '@/components/content-management-entry';
import DashboardManagement from '@/components/dashboard-management';
import DashboardWorkQueue, {
type DashboardQueue,
} from '@/components/dashboard-work-queue';
import { Head, Link } from '@inertiajs/react';
import { Link } from '@inertiajs/react';
import { dashboard } from '@/routes';
import type { InvestmentContext } from '@/pages/investor-path/index';
import type { OpportunityManagementAccess } from '@/types/opportunity-management';
@@ -56,10 +55,7 @@ export default function Dashboard({
}) {
return (
<div className="space-y-8 p-4 md:p-8">
<Head title="Painel" />
<h1 className="text-2xl font-semibold">Painel do portal</h1>
<ProfileNavigation />
<ContentManagementEntry />
<DashboardManagement summaryAvailable={!!summary} />
<section id="meu-trabalho" className="scroll-mt-24">
{workQueue ? (
<DashboardWorkQueue queue={workQueue} />
@@ -308,7 +304,6 @@ export default function Dashboard({
href={`/investimentos/${investorPath.current.id}#${investorPath.current.next.code}`}
>
Próxima acção:{' '}
{investorPath.current.next.code} ·{' '}
{investorPath.current.next.title}
</Link>
)}