feat: update rental data models, mock data, and auth access controls for enhanced tracking and management

This commit is contained in:
sazzadulalambd
2026-05-10 01:22:17 +06:00
parent 20ce14ae68
commit 0924d84983
3 changed files with 1417 additions and 920 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,7 @@
const ROLE_PERMISSIONS: Record<string, string[]> = {
super_admin: ['kyc.request', 'kyc.view', 'kyc.doc_upload', 'kyc.doc_approve', 'kyc.doc_reject', 'kyc.make_valid_user', 'dashboard.view'],
admin_manager: ['kyc.request', 'kyc.view', 'kyc.doc_upload', 'kyc.doc_approve', 'kyc.doc_reject', 'kyc.make_valid_user', 'dashboard.view'],
staff: ['kyc.request', 'kyc.view', 'kyc.doc_upload', 'dashboard.view'],
super_admin: ['kyc.request', 'kyc.view', 'kyc.doc_upload', 'kyc.doc_approve', 'kyc.doc_reject', 'kyc.make_valid_user', 'dashboard.view', 'rental.view', 'rental.create', 'rental.accept', 'rental.reject', 'rental.cancel', 'rental.edit', 'rental.image_approve', 'rental.lock', 'rental.unlock'],
admin_manager: ['kyc.request', 'kyc.view', 'kyc.doc_upload', 'kyc.doc_approve', 'kyc.doc_reject', 'kyc.make_valid_user', 'dashboard.view', 'rental.view', 'rental.create', 'rental.accept', 'rental.reject', 'rental.cancel', 'rental.edit', 'rental.image_approve', 'rental.lock', 'rental.unlock'],
staff: ['kyc.request', 'kyc.view', 'kyc.doc_upload', 'dashboard.view', 'rental.view', 'rental.create'],
accountant: ['dashboard.view', 'accounting.view', 'accounting.create', 'accounting.edit', 'accounting.delete'],
investor: ['dashboard.view', 'kyc.request', 'kyc.view'],
biker: ['dashboard.view', 'kyc.request', 'kyc.view', 'rentals.view', 'rentals.create'],
@@ -9,6 +9,15 @@ const ROLE_PERMISSIONS: Record<string, string[]> = {
merchant: ['dashboard.view', 'kyc.request', 'kyc.view', 'merchants.view'],
};
export const canRentalAccept = () => hasPermission('rental.accept');
export const canRentalReject = () => hasPermission('rental.reject');
export const canRentalCancel = () => hasPermission('rental.cancel');
export const canRentalEdit = () => hasPermission('rental.edit');
export const canRentalImageApprove = () => hasPermission('rental.image_approve');
export const canRentalLock = () => hasPermission('rental.lock');
export const canRentalUnlock = () => hasPermission('rental.unlock');
export const canRentalCreate = () => hasPermission('rental.create');
export const isAuthenticated = (): boolean => {
return typeof window !== 'undefined' && !!sessionStorage.getItem('authToken');
};
@@ -23,10 +32,9 @@ export const getUserName = (): string | null => {
export const getUserPermissions = (): string[] => {
if (typeof window === 'undefined') return [];
const stored = sessionStorage.getItem('userPermissions');
if (stored) return JSON.parse(stored);
const role = getUserRole();
return role ? (ROLE_PERMISSIONS[role] || []) : [];
if (role) return ROLE_PERMISSIONS[role] || [];
return [];
};
export const hasPermission = (permission: string): boolean => {