From faa22e93e0b27f8403f1c798e9d46f8cdc3bb9da Mon Sep 17 00:00:00 2001
From: Ichsan Kurniawan <43689091+ichsankurnia@users.noreply.github.com>
Date: Tue, 17 Nov 2026 21:46:07 +0700
Subject: [PATCH] Align task pages with access permissions
Use the shared page-permission helper across task routes and gate client creation controls on CREATE_CLIENT. Remove an unused profile permission import.
---
app/(dashboard)/profile/page.tsx | 2 +-
.../client-detail/[client_id]/(main)/page.tsx | 4 ++--
.../[client_id]/[assignment_id]/page.tsx | 4 ++--
.../[client_id]/project-assignments/page.tsx | 4 ++--
.../project-detail/[project_id]/page.tsx | 4 ++--
app/(dashboard)/task/component/HomeTask.tsx | 21 +++++++++++--------
.../task/component/client/Client.tsx | 2 +-
app/(dashboard)/task/page.tsx | 6 +++---
8 files changed, 25 insertions(+), 22 deletions(-)
diff --git a/app/(dashboard)/profile/page.tsx b/app/(dashboard)/profile/page.tsx
index ed83631..69a7afb 100644
--- a/app/(dashboard)/profile/page.tsx
+++ b/app/(dashboard)/profile/page.tsx
@@ -9,7 +9,7 @@ import LazyLoading from '@/components/loader/LazyLoading';
import { type IProfile } from './components/type';
import { type IUser } from '@/app/admin/administration/user/component/type';
-import { getAccessPagePermission, getCacheServerSession, getNonAdminAccessPagePermission } from '@/lib/get-access-data';
+import { getAccessPagePermission, getCacheServerSession } from '@/lib/get-access-data';
const ForgotPassword = lazy(() => import('./components/ForgotPassword'));
const ChangeTheme = lazy(() => import("./components/ChangeTheme"))
diff --git a/app/(dashboard)/task/client-detail/[client_id]/(main)/page.tsx b/app/(dashboard)/task/client-detail/[client_id]/(main)/page.tsx
index da120af..88bccdc 100644
--- a/app/(dashboard)/task/client-detail/[client_id]/(main)/page.tsx
+++ b/app/(dashboard)/task/client-detail/[client_id]/(main)/page.tsx
@@ -9,7 +9,7 @@ import { getQueryStringFilteredAssignments } from '@/lib/fetchData';
import { getFilteredAssignments } from '../../../data';
import { getClientById, getAssignmentsByClient } from '../../../utils/queries';
import Reveal from '@/components/ui/reveal';
-import { getNonAdminAccessPagePermission } from '@/lib/get-access-data';
+import { getAccessPagePermission } from '@/lib/get-access-data';
type Props = {
params: Promise<{ client_id: string }>
@@ -55,7 +55,7 @@ export async function generateMetadata({ params }: Props): Promise {
}
export default async function ClientDetailPage({ params, searchParams }: Props) {
- const actions = await getNonAdminAccessPagePermission('/task', 'VIEW_CLIENT')
+ const actions = await getAccessPagePermission('/task', 'VIEW_CLIENT', false)
const { client_id } = await params;
diff --git a/app/(dashboard)/task/client-detail/[client_id]/[assignment_id]/page.tsx b/app/(dashboard)/task/client-detail/[client_id]/[assignment_id]/page.tsx
index 6ea2751..75811f2 100644
--- a/app/(dashboard)/task/client-detail/[client_id]/[assignment_id]/page.tsx
+++ b/app/(dashboard)/task/client-detail/[client_id]/[assignment_id]/page.tsx
@@ -3,7 +3,7 @@ import { Button } from '@/components/ui/button';
import Link from 'next/link';
import AssignmentDetailComponent from './AssignmentDetailComponent';
import { getClientById, getAssignmentById } from '../../../utils/queries';
-import { getNonAdminAccessPagePermission } from '@/lib/get-access-data';
+import { getAccessPagePermission } from '@/lib/get-access-data';
type Props = {
params: Promise<{ client_id: string; assignment_id: string }>
@@ -46,7 +46,7 @@ export async function generateMetadata({ params }: Props): Promise {
}
export default async function AssignmentDetailPage({ params }: Props) {
- const actions = await getNonAdminAccessPagePermission('/task', 'VIEW_ASSIGNMENT')
+ const actions = await getAccessPagePermission('/task', 'VIEW_ASSIGNMENT', false)
const { client_id, assignment_id } = await params;
diff --git a/app/(dashboard)/task/client-detail/[client_id]/project-assignments/page.tsx b/app/(dashboard)/task/client-detail/[client_id]/project-assignments/page.tsx
index a5a0fab..ba4edbc 100644
--- a/app/(dashboard)/task/client-detail/[client_id]/project-assignments/page.tsx
+++ b/app/(dashboard)/task/client-detail/[client_id]/project-assignments/page.tsx
@@ -1,7 +1,7 @@
import type { Metadata } from 'next';
import ProjectAssignmentForm from "./ProjectAssignmentForm";
import { getClientById, getAssignmentById } from "../../../utils/queries";
-import { getNonAdminAccessPagePermission } from '@/lib/get-access-data';
+import { getAccessPagePermission } from '@/lib/get-access-data';
type Props = {
params: Promise<{ client_id?: string }>
@@ -15,7 +15,7 @@ export async function generateMetadata({ params, searchParams }: Props): Promise
const assignmentId = typeof resolvedSearchParams?.assignment_id === 'string' ? resolvedSearchParams.assignment_id : undefined;
const isPromote = resolvedSearchParams?.promote === 'true' || resolvedSearchParams?.is_promote === 'true';
- await getNonAdminAccessPagePermission('/task', isPromote ? 'PROMOTE_ASSIGNMENT' : isEdit ? 'UPDATE_ASSIGNMENT' : 'CREATE_ASSIGNMENT');
+ await getAccessPagePermission('/task', isPromote ? 'PROMOTE_ASSIGNMENT' : isEdit ? 'UPDATE_ASSIGNMENT' : 'CREATE_ASSIGNMENT', false);
try {
const clientPromise = client_id ? getClientById(client_id) : Promise.resolve(undefined);
diff --git a/app/(dashboard)/task/client-detail/[client_id]/project-detail/[project_id]/page.tsx b/app/(dashboard)/task/client-detail/[client_id]/project-detail/[project_id]/page.tsx
index b41e150..5ec5c9e 100644
--- a/app/(dashboard)/task/client-detail/[client_id]/project-detail/[project_id]/page.tsx
+++ b/app/(dashboard)/task/client-detail/[client_id]/project-detail/[project_id]/page.tsx
@@ -10,7 +10,7 @@ import FilterComponent from '@/app/(dashboard)/task/component/FilterComponent';
import { COMPLETE_STATUS_LIST, getFilteredAssignments, ONPROGRESS_STATUS_LIST } from '@/app/(dashboard)/task/data';
import { getClientById, getProjectAssignment } from '../../../../utils/queries';
import Reveal from '@/components/ui/reveal';
-import { getNonAdminAccessPagePermission } from '@/lib/get-access-data';
+import { getAccessPagePermission } from '@/lib/get-access-data';
type Props = {
params: Promise<{ client_id: string; project_id: string }>
@@ -18,7 +18,7 @@ type Props = {
};
export async function generateMetadata({ params, searchParams }: Props): Promise {
- const actions = await getNonAdminAccessPagePermission('/task', 'VIEW_PROJECT')
+ await getAccessPagePermission('/task', 'VIEW_PROJECT', false)
const { client_id, project_id } = await params;
const searchParams_ = await searchParams;
diff --git a/app/(dashboard)/task/component/HomeTask.tsx b/app/(dashboard)/task/component/HomeTask.tsx
index 1b2b90f..78e21c6 100644
--- a/app/(dashboard)/task/component/HomeTask.tsx
+++ b/app/(dashboard)/task/component/HomeTask.tsx
@@ -15,9 +15,10 @@ import { calculateOverviewStats } from '../utils/client-overview-helpers';
interface HomeTaskProps {
clients?: IClient[];
+ actions?: string[]
}
-export default function HomeTask({ clients = [] }: HomeTaskProps) {
+export default function HomeTask({ clients = [], actions }: HomeTaskProps) {
const router = useRouter();
const [showForm, setShowForm] = useState(false);
@@ -60,14 +61,16 @@ export default function HomeTask({ clients = [] }: HomeTaskProps) {
Complete overview of all clients, projects, personnel and work orders in one place.
-
-
-
+ {actions?.includes("CREATE_CLIENT") &&
+
+
+
+ }
{/* Top Stat Cards (4 Cards Grid) */}
diff --git a/app/(dashboard)/task/component/client/Client.tsx b/app/(dashboard)/task/component/client/Client.tsx
index f4bafc9..903b2f5 100644
--- a/app/(dashboard)/task/component/client/Client.tsx
+++ b/app/(dashboard)/task/component/client/Client.tsx
@@ -75,7 +75,7 @@ export default function Client({ clients, actions, initialLayout = 'grid' }: Cli
Try to change the filter or create one to get started.
- {actions?.includes('CREATE') &&
+ {actions?.includes('CREATE_CLIENT') &&