hirarchchy changed
This commit is contained in:
parent
2d0a5fce22
commit
af479db2f0
@ -69,7 +69,7 @@ export const API = {
|
|||||||
removeParticipant: (id: string) => client.delete(`/collaboration/participants/${id}`),
|
removeParticipant: (id: string) => client.delete(`/collaboration/participants/${id}`),
|
||||||
|
|
||||||
// User management routes
|
// User management routes
|
||||||
getUsers: () => client.get('/admin/users'),
|
getUsers: (params?: any) => client.get('/admin/users', { params }),
|
||||||
createUser: (data: any) => client.post('/admin/users', data),
|
createUser: (data: any) => client.post('/admin/users', data),
|
||||||
updateUser: (id: string, data: any) => client.put(`/admin/users/${id}`, data),
|
updateUser: (id: string, data: any) => client.put(`/admin/users/${id}`, data),
|
||||||
updateUserStatus: (id: string, data: any) => client.patch(`/admin/users/${id}/status`, data),
|
updateUserStatus: (id: string, data: any) => client.patch(`/admin/users/${id}/status`, data),
|
||||||
|
|||||||
@ -310,6 +310,9 @@ export function ApplicationDetails() {
|
|||||||
inaugurationDate: getStageDate('Inauguration'),
|
inaugurationDate: getStageDate('Inauguration'),
|
||||||
participants: data.participants || [],
|
participants: data.participants || [],
|
||||||
dealerCode: data.dealerCode,
|
dealerCode: data.dealerCode,
|
||||||
|
zoneId: data.zoneId,
|
||||||
|
regionId: data.regionId,
|
||||||
|
areaId: data.areaId,
|
||||||
};
|
};
|
||||||
setApplication(mappedApp);
|
setApplication(mappedApp);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -693,31 +696,51 @@ export function ApplicationDetails() {
|
|||||||
}
|
}
|
||||||
}, [activeTab, applicationId]);
|
}, [activeTab, applicationId]);
|
||||||
|
|
||||||
useEffect(() => {
|
const fetchUsers = async (type?: string) => {
|
||||||
const fetchUsers = async () => {
|
// Only fetch users if user has admin/DD roles to avoid 403s
|
||||||
// Only fetch users if user has admin/DD roles to avoid 403s
|
if (!currentUser || !['DD Admin', 'Super Admin'].includes(currentUser.role)) {
|
||||||
if (!currentUser || !['DD Admin', 'Super Admin'].includes(currentUser.role)) {
|
return;
|
||||||
return;
|
}
|
||||||
}
|
try {
|
||||||
try {
|
const params: any = {};
|
||||||
const response = await onboardingService.getUsers();
|
if (type) {
|
||||||
if (Array.isArray(response)) {
|
const roleMapping: any = {
|
||||||
setUsers(response);
|
'level1': ['DD-ZM', 'RBM'],
|
||||||
} else if (response && Array.isArray(response.data)) {
|
'level2': ['DD Lead', 'ZBH'],
|
||||||
setUsers(response.data);
|
'level3': ['NBH', 'DD Head']
|
||||||
} else if (response && Array.isArray(response.users)) {
|
};
|
||||||
setUsers(response.users);
|
params.roleCode = roleMapping[type];
|
||||||
} else {
|
|
||||||
console.warn('Unexpected users response:', response);
|
// Include location from the application
|
||||||
setUsers([]);
|
if (application) {
|
||||||
|
params.locationId = application.locationId || application.areaId || application.regionId || application.zoneId;
|
||||||
}
|
}
|
||||||
} catch (error) {
|
}
|
||||||
console.error('Failed to fetch users', error);
|
|
||||||
|
const response = await onboardingService.getUsers(params);
|
||||||
|
if (Array.isArray(response)) {
|
||||||
|
setUsers(response);
|
||||||
|
} else if (response && Array.isArray(response.data)) {
|
||||||
|
setUsers(response.data);
|
||||||
|
} else if (response && Array.isArray(response.users)) {
|
||||||
|
setUsers(response.users);
|
||||||
|
} else {
|
||||||
|
console.warn('Unexpected users response:', response);
|
||||||
setUsers([]);
|
setUsers([]);
|
||||||
}
|
}
|
||||||
};
|
} catch (error) {
|
||||||
fetchUsers();
|
console.error('Failed to fetch users', error);
|
||||||
}, []);
|
setUsers([]);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (showScheduleModal) {
|
||||||
|
fetchUsers(interviewType);
|
||||||
|
} else {
|
||||||
|
fetchUsers(); // Default fetch for other modals like Assign
|
||||||
|
}
|
||||||
|
}, [showScheduleModal, interviewType]);
|
||||||
|
|
||||||
const handleScheduleInterview = async () => {
|
const handleScheduleInterview = async () => {
|
||||||
if (!interviewDate) {
|
if (!interviewDate) {
|
||||||
@ -847,8 +870,8 @@ export function ApplicationDetails() {
|
|||||||
name: '3rd Level Interview',
|
name: '3rd Level Interview',
|
||||||
status: ['Level 3 Approved', 'FDD Verification', 'LOI In Progress', 'Payment Pending', 'LOI Issued', 'Statutory LOI Ack', 'Dealer Code Generation', 'Architecture Team Assigned', 'Architecture Document Upload', 'Architecture Team Completion', 'LOA Pending', 'EOR In Progress', 'EOR Complete', 'Inauguration', 'Approved'].includes(application.status) ? 'completed' : ['Level 3 Interview Pending'].includes(application.status) ? 'active' : 'pending',
|
status: ['Level 3 Approved', 'FDD Verification', 'LOI In Progress', 'Payment Pending', 'LOI Issued', 'Statutory LOI Ack', 'Dealer Code Generation', 'Architecture Team Assigned', 'Architecture Document Upload', 'Architecture Team Completion', 'LOA Pending', 'EOR In Progress', 'EOR Complete', 'Inauguration', 'Approved'].includes(application.status) ? 'completed' : ['Level 3 Interview Pending'].includes(application.status) ? 'active' : 'pending',
|
||||||
date: application.level3InterviewDate,
|
date: application.level3InterviewDate,
|
||||||
description: 'NBH + DD-Head evaluation',
|
description: 'NBH + DD Head evaluation',
|
||||||
evaluators: ['NBH', 'DD-Head'],
|
evaluators: ['NBH', 'DD Head'],
|
||||||
documentsUploaded: 2
|
documentsUploaded: 2
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -2321,7 +2344,7 @@ export function ApplicationDetails() {
|
|||||||
Work Note
|
Work Note
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
{currentUser && ['DD Admin', 'Super Admin'].includes(currentUser.role) && (
|
{currentUser && ['DD Admin', 'Super Admin', 'DD AM', 'ASM'].includes(currentUser.role) && (
|
||||||
<Button
|
<Button
|
||||||
variant="outline"
|
variant="outline"
|
||||||
className="w-full"
|
className="w-full"
|
||||||
|
|||||||
@ -67,9 +67,9 @@ const QuestionnaireResponseView: React.FC<QuestionnaireResponseViewProps> = ({ a
|
|||||||
<Badge variant="outline" className="text-slate-600 bg-slate-50">
|
<Badge variant="outline" className="text-slate-600 bg-slate-50">
|
||||||
{section}
|
{section}
|
||||||
</Badge>
|
</Badge>
|
||||||
{(options.length > 0) && (
|
{(options.length > 0 && maxScore > 0) && (
|
||||||
<Badge className={score > 0 ? "bg-green-600" : "bg-slate-400"}>
|
<Badge className={score > 0 ? "bg-green-600" : "bg-slate-400"}>
|
||||||
{score}/{maxScore > 0 ? maxScore : '?'}
|
{score}/{maxScore}
|
||||||
</Badge>
|
</Badge>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -113,6 +113,9 @@ export interface Application {
|
|||||||
architectureStatus?: string;
|
architectureStatus?: string;
|
||||||
dealerCode?: any;
|
dealerCode?: any;
|
||||||
dealer?: any;
|
dealer?: any;
|
||||||
|
zoneId?: string;
|
||||||
|
regionId?: string;
|
||||||
|
areaId?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Participant {
|
export interface Participant {
|
||||||
|
|||||||
@ -37,9 +37,9 @@ export const onboardingService = {
|
|||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
getUsers: async () => {
|
getUsers: async (params?: any) => {
|
||||||
try {
|
try {
|
||||||
const response: any = await API.getUsers();
|
const response: any = await API.getUsers(params);
|
||||||
return response.data?.data || response.data;
|
return response.data?.data || response.data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Get users error:', error);
|
console.error('Get users error:', error);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user