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}`),
|
||||
|
||||
// User management routes
|
||||
getUsers: () => client.get('/admin/users'),
|
||||
getUsers: (params?: any) => client.get('/admin/users', { params }),
|
||||
createUser: (data: any) => client.post('/admin/users', data),
|
||||
updateUser: (id: string, data: any) => client.put(`/admin/users/${id}`, data),
|
||||
updateUserStatus: (id: string, data: any) => client.patch(`/admin/users/${id}/status`, data),
|
||||
|
||||
@ -310,6 +310,9 @@ export function ApplicationDetails() {
|
||||
inaugurationDate: getStageDate('Inauguration'),
|
||||
participants: data.participants || [],
|
||||
dealerCode: data.dealerCode,
|
||||
zoneId: data.zoneId,
|
||||
regionId: data.regionId,
|
||||
areaId: data.areaId,
|
||||
};
|
||||
setApplication(mappedApp);
|
||||
} catch (error) {
|
||||
@ -693,14 +696,28 @@ export function ApplicationDetails() {
|
||||
}
|
||||
}, [activeTab, applicationId]);
|
||||
|
||||
useEffect(() => {
|
||||
const fetchUsers = async () => {
|
||||
const fetchUsers = async (type?: string) => {
|
||||
// Only fetch users if user has admin/DD roles to avoid 403s
|
||||
if (!currentUser || !['DD Admin', 'Super Admin'].includes(currentUser.role)) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const response = await onboardingService.getUsers();
|
||||
const params: any = {};
|
||||
if (type) {
|
||||
const roleMapping: any = {
|
||||
'level1': ['DD-ZM', 'RBM'],
|
||||
'level2': ['DD Lead', 'ZBH'],
|
||||
'level3': ['NBH', 'DD Head']
|
||||
};
|
||||
params.roleCode = roleMapping[type];
|
||||
|
||||
// Include location from the application
|
||||
if (application) {
|
||||
params.locationId = application.locationId || application.areaId || application.regionId || application.zoneId;
|
||||
}
|
||||
}
|
||||
|
||||
const response = await onboardingService.getUsers(params);
|
||||
if (Array.isArray(response)) {
|
||||
setUsers(response);
|
||||
} else if (response && Array.isArray(response.data)) {
|
||||
@ -716,8 +733,14 @@ export function ApplicationDetails() {
|
||||
setUsers([]);
|
||||
}
|
||||
};
|
||||
fetchUsers();
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (showScheduleModal) {
|
||||
fetchUsers(interviewType);
|
||||
} else {
|
||||
fetchUsers(); // Default fetch for other modals like Assign
|
||||
}
|
||||
}, [showScheduleModal, interviewType]);
|
||||
|
||||
const handleScheduleInterview = async () => {
|
||||
if (!interviewDate) {
|
||||
@ -847,8 +870,8 @@ export function ApplicationDetails() {
|
||||
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',
|
||||
date: application.level3InterviewDate,
|
||||
description: 'NBH + DD-Head evaluation',
|
||||
evaluators: ['NBH', 'DD-Head'],
|
||||
description: 'NBH + DD Head evaluation',
|
||||
evaluators: ['NBH', 'DD Head'],
|
||||
documentsUploaded: 2
|
||||
},
|
||||
{
|
||||
@ -2321,7 +2344,7 @@ export function ApplicationDetails() {
|
||||
Work Note
|
||||
</Button>
|
||||
|
||||
{currentUser && ['DD Admin', 'Super Admin'].includes(currentUser.role) && (
|
||||
{currentUser && ['DD Admin', 'Super Admin', 'DD AM', 'ASM'].includes(currentUser.role) && (
|
||||
<Button
|
||||
variant="outline"
|
||||
className="w-full"
|
||||
|
||||
@ -67,9 +67,9 @@ const QuestionnaireResponseView: React.FC<QuestionnaireResponseViewProps> = ({ a
|
||||
<Badge variant="outline" className="text-slate-600 bg-slate-50">
|
||||
{section}
|
||||
</Badge>
|
||||
{(options.length > 0) && (
|
||||
{(options.length > 0 && maxScore > 0) && (
|
||||
<Badge className={score > 0 ? "bg-green-600" : "bg-slate-400"}>
|
||||
{score}/{maxScore > 0 ? maxScore : '?'}
|
||||
{score}/{maxScore}
|
||||
</Badge>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@ -113,6 +113,9 @@ export interface Application {
|
||||
architectureStatus?: string;
|
||||
dealerCode?: any;
|
||||
dealer?: any;
|
||||
zoneId?: string;
|
||||
regionId?: string;
|
||||
areaId?: string;
|
||||
}
|
||||
|
||||
export interface Participant {
|
||||
|
||||
@ -37,9 +37,9 @@ export const onboardingService = {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
getUsers: async () => {
|
||||
getUsers: async (params?: any) => {
|
||||
try {
|
||||
const response: any = await API.getUsers();
|
||||
const response: any = await API.getUsers(params);
|
||||
return response.data?.data || response.data;
|
||||
} catch (error) {
|
||||
console.error('Get users error:', error);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user