feat: update rental data models, mock data, and auth access controls for enhanced tracking and management
This commit is contained in:
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,7 @@
|
|||||||
const ROLE_PERMISSIONS: Record<string, string[]> = {
|
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'],
|
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'],
|
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'],
|
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'],
|
accountant: ['dashboard.view', 'accounting.view', 'accounting.create', 'accounting.edit', 'accounting.delete'],
|
||||||
investor: ['dashboard.view', 'kyc.request', 'kyc.view'],
|
investor: ['dashboard.view', 'kyc.request', 'kyc.view'],
|
||||||
biker: ['dashboard.view', 'kyc.request', 'kyc.view', 'rentals.view', 'rentals.create'],
|
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'],
|
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 => {
|
export const isAuthenticated = (): boolean => {
|
||||||
return typeof window !== 'undefined' && !!sessionStorage.getItem('authToken');
|
return typeof window !== 'undefined' && !!sessionStorage.getItem('authToken');
|
||||||
};
|
};
|
||||||
@@ -23,10 +32,9 @@ export const getUserName = (): string | null => {
|
|||||||
|
|
||||||
export const getUserPermissions = (): string[] => {
|
export const getUserPermissions = (): string[] => {
|
||||||
if (typeof window === 'undefined') return [];
|
if (typeof window === 'undefined') return [];
|
||||||
const stored = sessionStorage.getItem('userPermissions');
|
|
||||||
if (stored) return JSON.parse(stored);
|
|
||||||
const role = getUserRole();
|
const role = getUserRole();
|
||||||
return role ? (ROLE_PERMISSIONS[role] || []) : [];
|
if (role) return ROLE_PERMISSIONS[role] || [];
|
||||||
|
return [];
|
||||||
};
|
};
|
||||||
|
|
||||||
export const hasPermission = (permission: string): boolean => {
|
export const hasPermission = (permission: string): boolean => {
|
||||||
|
|||||||
Reference in New Issue
Block a user