task-j1
This commit is contained in:
@@ -1,31 +1,67 @@
|
||||
import { HydrationBoundary, dehydrate } from '@tanstack/react-query';
|
||||
import { auth } from '@/auth';
|
||||
import PageContainer from '@/components/layout/page-container';
|
||||
import { CrmProductionPlaceholder } from '@/features/foundation/components/crm-production-placeholder';
|
||||
import { crmDashboardQueryOptions } from '@/features/crm/dashboard/api/queries';
|
||||
import { CrmDashboard } from '@/features/crm/dashboard/components/crm-dashboard';
|
||||
import { PERMISSIONS } from '@/lib/auth/rbac';
|
||||
import { getQueryClient } from '@/lib/query-client';
|
||||
import { searchParamsCache } from '@/lib/searchparams';
|
||||
import type { SearchParams } from 'nuqs/server';
|
||||
|
||||
export const metadata = {
|
||||
title: 'Dashboard: CRM'
|
||||
};
|
||||
|
||||
export default function CrmDashboardRoute() {
|
||||
type PageProps = {
|
||||
searchParams: Promise<SearchParams>;
|
||||
};
|
||||
|
||||
export default async function CrmDashboardRoute(props: PageProps) {
|
||||
const searchParams = await props.searchParams;
|
||||
const session = await auth();
|
||||
const canRead =
|
||||
session?.user?.systemRole === 'super_admin' ||
|
||||
(!!session?.user?.activeOrganizationId &&
|
||||
(session.user.activeMembershipRole === 'admin' ||
|
||||
session.user.activePermissions.includes(PERMISSIONS.crmDashboardRead)));
|
||||
const canExport =
|
||||
session?.user?.systemRole === 'super_admin' ||
|
||||
(!!session?.user?.activeOrganizationId &&
|
||||
(session.user.activeMembershipRole === 'admin' ||
|
||||
session.user.activePermissions.includes(PERMISSIONS.crmDashboardExport)));
|
||||
|
||||
searchParamsCache.parse(searchParams);
|
||||
|
||||
const filters = {
|
||||
dateFrom: searchParamsCache.get('dateFrom'),
|
||||
dateTo: searchParamsCache.get('dateTo'),
|
||||
branch: searchParamsCache.get('branch'),
|
||||
salesman: searchParamsCache.get('salesman'),
|
||||
projectPartyRole: searchParamsCache.get('projectPartyRole'),
|
||||
productType: searchParamsCache.get('productType')
|
||||
};
|
||||
const queryClient = getQueryClient();
|
||||
|
||||
if (canRead) {
|
||||
void queryClient.prefetchQuery(crmDashboardQueryOptions(filters));
|
||||
}
|
||||
|
||||
return (
|
||||
<PageContainer
|
||||
pageTitle='CRM Foundation'
|
||||
pageDescription='Production CRM routes are now isolated from legacy mock state and ready for foundation-backed modules.'
|
||||
pageTitle='CRM Dashboard'
|
||||
pageDescription='Production KPI dashboard, revenue analytics, approval visibility, and sales insights from real CRM data.'
|
||||
access={canRead}
|
||||
accessFallback={
|
||||
<div className='text-muted-foreground rounded-lg border border-dashed p-8 text-center'>
|
||||
You do not have access to the CRM dashboard.
|
||||
</div>
|
||||
}
|
||||
>
|
||||
<CrmProductionPlaceholder
|
||||
title='CRM production workspace'
|
||||
summary='Task B.1 isolates the production CRM path so Task C can start on real architecture instead of in-memory demo state.'
|
||||
foundationItems={[
|
||||
'Current user context',
|
||||
'Organization context',
|
||||
'Permission helpers',
|
||||
'Branch scope abstraction',
|
||||
'Master options service',
|
||||
'Document sequence service',
|
||||
'Audit log helper'
|
||||
]}
|
||||
nextStep='Start Customer and Contact modules on top of Route Handlers, Drizzle, and organization-first access checks.'
|
||||
demoHref='/dashboard/crm-demo'
|
||||
/>
|
||||
{canRead ? (
|
||||
<HydrationBoundary state={dehydrate(queryClient)}>
|
||||
<CrmDashboard canExport={canExport} />
|
||||
</HydrationBoundary>
|
||||
) : null}
|
||||
</PageContainer>
|
||||
);
|
||||
}
|
||||
|
||||
40
src/app/dashboard/crm/settings/approval-workflows/page.tsx
Normal file
40
src/app/dashboard/crm/settings/approval-workflows/page.tsx
Normal file
@@ -0,0 +1,40 @@
|
||||
import { auth } from '@/auth';
|
||||
import { HydrationBoundary, dehydrate } from '@tanstack/react-query';
|
||||
import PageContainer from '@/components/layout/page-container';
|
||||
import { ApprovalWorkflowSettings } from '@/features/foundation/approval/components/approval-workflow-settings';
|
||||
import { approvalWorkflowsQueryOptions } from '@/features/foundation/approval/queries';
|
||||
import { PERMISSIONS } from '@/lib/auth/rbac';
|
||||
import { getQueryClient } from '@/lib/query-client';
|
||||
|
||||
export default async function ApprovalWorkflowsRoute() {
|
||||
const session = await auth();
|
||||
const canRead =
|
||||
session?.user?.systemRole === 'super_admin' ||
|
||||
(!!session?.user?.activeOrganizationId &&
|
||||
(session.user.activeMembershipRole === 'admin' ||
|
||||
session.user.activePermissions.includes(PERMISSIONS.crmApprovalWorkflowRead)));
|
||||
const queryClient = getQueryClient();
|
||||
|
||||
if (canRead) {
|
||||
void queryClient.prefetchQuery(approvalWorkflowsQueryOptions());
|
||||
}
|
||||
|
||||
return (
|
||||
<PageContainer
|
||||
pageTitle='Approval Workflows'
|
||||
pageDescription='Configure sequential CRM approval workflows and business-role steps without touching the runtime approval engine.'
|
||||
access={canRead}
|
||||
accessFallback={
|
||||
<div className='text-muted-foreground rounded-lg border border-dashed p-8 text-center'>
|
||||
You do not have access to CRM approval workflow settings.
|
||||
</div>
|
||||
}
|
||||
>
|
||||
{canRead ? (
|
||||
<HydrationBoundary state={dehydrate(queryClient)}>
|
||||
<ApprovalWorkflowSettings />
|
||||
</HydrationBoundary>
|
||||
) : null}
|
||||
</PageContainer>
|
||||
);
|
||||
}
|
||||
@@ -1,23 +1,40 @@
|
||||
import { auth } from '@/auth';
|
||||
import { HydrationBoundary, dehydrate } from '@tanstack/react-query';
|
||||
import PageContainer from '@/components/layout/page-container';
|
||||
import { CrmProductionPlaceholder } from '@/features/foundation/components/crm-production-placeholder';
|
||||
import { DocumentSequenceSettings } from '@/features/foundation/document-sequence/components/document-sequence-settings';
|
||||
import { documentSequencesQueryOptions } from '@/features/foundation/document-sequence/queries';
|
||||
import { PERMISSIONS } from '@/lib/auth/rbac';
|
||||
import { getQueryClient } from '@/lib/query-client';
|
||||
|
||||
export default async function DocumentSequencesRoute() {
|
||||
const session = await auth();
|
||||
const canRead =
|
||||
session?.user?.systemRole === 'super_admin' ||
|
||||
(!!session?.user?.activeOrganizationId &&
|
||||
(session.user.activeMembershipRole === 'admin' ||
|
||||
session.user.activePermissions.includes(PERMISSIONS.crmDocumentSequenceRead)));
|
||||
const queryClient = getQueryClient();
|
||||
|
||||
if (canRead) {
|
||||
void queryClient.prefetchQuery(documentSequencesQueryOptions());
|
||||
}
|
||||
|
||||
export default function DocumentSequencesRoute() {
|
||||
return (
|
||||
<PageContainer
|
||||
pageTitle='Document Sequences'
|
||||
pageDescription='The sequence foundation is ready, but a production management UI has not been introduced yet.'
|
||||
pageDescription='Manage organization-scoped running numbers, prefixes, and branch-aware sequence resets.'
|
||||
access={canRead}
|
||||
accessFallback={
|
||||
<div className='text-muted-foreground rounded-lg border border-dashed p-8 text-center'>
|
||||
You do not have access to CRM document sequences.
|
||||
</div>
|
||||
}
|
||||
>
|
||||
<CrmProductionPlaceholder
|
||||
title='Document sequence UI pending'
|
||||
summary='Sequence generation now exists in the foundation layer, but the old mock settings page has been isolated to the demo route.'
|
||||
foundationItems={[
|
||||
'Preview and generate sequence helpers',
|
||||
'Organization-scoped sequence table',
|
||||
'Branch-aware sequence support'
|
||||
]}
|
||||
nextStep='Add a production management page only when the product requires editable sequence settings.'
|
||||
demoHref='/dashboard/crm-demo/settings/document-sequences'
|
||||
/>
|
||||
{canRead ? (
|
||||
<HydrationBoundary state={dehydrate(queryClient)}>
|
||||
<DocumentSequenceSettings />
|
||||
</HydrationBoundary>
|
||||
) : null}
|
||||
</PageContainer>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user