Skip to content

Commit a196a91

Browse files
authored
Merge pull request #1997 from tekdi/release-1.12.0
Release 1.12.0 to admin prod
2 parents e2cf328 + b45b962 commit a196a91

File tree

26 files changed

+370
-101
lines changed

26 files changed

+370
-101
lines changed

apps/admin-app-repo/public/locales/en/common.json

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -315,10 +315,10 @@
315315
"SEARCHBAR_PLACEHOLDER": "Search Center.."
316316
},
317317
"COURSE_PLANNER": {
318-
"LEARNERS_PREREQISITE": "Learners Pre-requisites",
319-
"NO_DATA_PRE": "No data available for Learners Pre-requisites",
320-
"LEARNERS_POSTREQISITE": "Learners Post-requisites",
321-
"NO_DATA_POST": "No data available for Learners Post-requisites",
318+
"LEARNERS_PREREQISITE": "Learners Prepare-requisites",
319+
"NO_DATA_PRE": "No data available for Learners Prepare-requisites",
320+
"LEARNERS_POSTREQISITE": "Learners Practice-requisites",
321+
"NO_DATA_POST": "No data available for Learners Practice-requisites",
322322
"FACILITATORS": "Facilitators Requisites",
323323
"NO_DATA": "No data available for Facilitators Requisites",
324324
"DOWNLOAD_SAMPLE_CSV": "Download Sample CSV",
@@ -355,7 +355,9 @@
355355
"ADD_NEW_TOPIC": "Add New Topic",
356356
"DELETE_PLANNER": "Delete Planner",
357357
"CSV_TEMPLATE": "CSV Template",
358-
"NEW_TOPIC": "New Topic"
358+
"NEW_TOPIC": "New Topic",
359+
"DOWNLOAD_CSV": "Download Uploaded CSV"
360+
359361
},
360362
"MASTER": {
361363
"STATE": "States",

apps/admin-app-repo/src/components/layouts/header/Header.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ const Header = ({
109109
storedUserData?.tenantData[0]?.tenantName !=
110110
TenantName.SECOND_CHANCE_PROGRAM
111111
) {
112-
router.push('/workspace');
112+
// router.push('/workspace');
113+
router.push('/faqs');
113114
} else {
114115
if (locale)
115116
router.push('/course-planner', undefined, { locale: locale });

apps/admin-app-repo/src/config/menuConfig.ts

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ export const MENU_CONFIG = {
115115
title: 'SIDEBAR.TAXONOMY_EDITOR',
116116
icon: '/images/taxonomy.svg',
117117
link: '/taxonomy-manager',
118-
roles: [Role.CCTA, Role.SCTA, Role.CENTRAL_ADMIN],
118+
roles: [ Role.CENTRAL_ADMIN],
119119
},
120120
faqs: {
121121
title: 'SIDEBAR.FAQS',
@@ -126,6 +126,7 @@ export const MENU_CONFIG = {
126126
Role.CENTRAL_ADMIN,
127127
Role.CCTA,
128128
Role.SCTA,
129+
129130
// Role.CENTRAL_ADMIN, // check
130131
],
131132
},
@@ -245,7 +246,7 @@ export const MENU_CONFIG = {
245246
title: 'SIDEBAR.TAXONOMY_EDITOR',
246247
icon: '/images/taxonomy.svg',
247248
link: '/taxonomy-manager',
248-
roles: [Role.CCTA, Role.SCTA, Role.CENTRAL_ADMIN],
249+
roles: [ Role.CENTRAL_ADMIN],
249250
},
250251
},
251252
[TenantName.POS]: {
@@ -296,7 +297,7 @@ export const MENU_CONFIG = {
296297
title: 'SIDEBAR.TAXONOMY_EDITOR',
297298
icon: '/images/taxonomy.svg',
298299
link: '/taxonomy-manager',
299-
roles: [Role.CCTA, Role.SCTA, Role.CENTRAL_ADMIN],
300+
roles: [ Role.CENTRAL_ADMIN],
300301
},
301302
faqs: {
302303
title: 'SIDEBAR.FAQS',
@@ -328,7 +329,25 @@ export const MENU_CONFIG = {
328329
title: 'SIDEBAR.TAXONOMY_EDITOR',
329330
icon: '/images/taxonomy.svg',
330331
link: '/taxonomy-manager',
331-
roles: [Role.CCTA, Role.SCTA, Role.CENTRAL_ADMIN],
332+
roles: [ Role.CENTRAL_ADMIN],
333+
},
334+
faqs: {
335+
title: 'SIDEBAR.FAQS',
336+
icon: '/images/live_help.png',
337+
link: '/faqs',
338+
roles: [
339+
Role.ADMIN,
340+
Role.CENTRAL_ADMIN,
341+
Role.CCTA,
342+
Role.SCTA,
343+
344+
],
345+
},
346+
supportRequest: {
347+
title: 'SIDEBAR.SUPPORT_REQUEST',
348+
icon: '/images/Support.svg',
349+
link: '/support-request',
350+
roles: [Role.ADMIN, Role.CENTRAL_ADMIN, Role.CCTA, Role.SCTA],
332351
},
333352
},
334353
[TenantName.CAMP_TO_CLUB]: {
@@ -397,14 +416,14 @@ export const MENU_CONFIG = {
397416
title: 'SIDEBAR.SUPPORT_REQUEST',
398417
icon: '/images/Support.svg',
399418
link: '/support-request',
400-
roles: [Role.CENTRAL_ADMIN],
419+
roles: [Role.ADMIN, Role.CENTRAL_ADMIN, Role.CCTA, Role.SCTA],
401420
},
402421

403422
faqs: {
404423
title: 'SIDEBAR.FAQS',
405424
icon: '/images/live_help.png',
406425
link: '/faqs',
407-
roles: [Role.CENTRAL_ADMIN],
426+
roles: [Role.ADMIN, Role.CENTRAL_ADMIN, Role.CCTA, Role.SCTA],
408427
},
409428

410429
},

apps/admin-app-repo/src/pages/edit-password.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ const EditForgotPassword = () => {
5050
{
5151
// To do :- hardcoding to be removed
5252
if(storedUserData?.tenantData[0]?.tenantName != TenantName.SECOND_CHANCE_PROGRAM ) {
53-
router.push("/workspace");
53+
// router.push("/workspace");
54+
router.push('/faqs');
5455
} else {
5556
if (locale)
5657
router.push("/course-planner", undefined, { locale: locale });

apps/admin-app-repo/src/pages/facilitator.tsx

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ const Facilitator = () => {
510510
console.error('Error updating team leader:', error);
511511
}
512512
};
513-
513+
console.log('response?.result?.getUserDetails',response?.result?.getUserDetails)
514514
// Define actions
515515
const actions = [
516516
{
@@ -580,21 +580,36 @@ const Facilitator = () => {
580580
</Box>
581581
),
582582
callback: async (row) => {
583+
console.log('row.cohortData:', row.cohortData); // Check what data is available
584+
583585
const selectedUserId = row?.userId;
584-
const selectedUserDetails = await getUserDetailsInfo(
585-
selectedUserId,
586-
true
587-
);
588-
// console.log('selectedUserDetails:', selectedUserDetails);
586+
const selectedUserDetails = await getUserDetailsInfo(selectedUserId, true);
587+
const cohortResponse = await getCohortList(selectedUserId);
588+
console.log('cohortResponse:', cohortResponse);
589+
const centerNames = [...new Set(row.cohortData.map(item => item.centerName))];
589590

590591
const findVillage = selectedUserDetails?.userData?.customFields.find((item) => {
591592
if (item.label === 'VILLAGE' || item.label === 'BLOCK') {
592593
return item;
593594
}
594595
});
595596

596-
// setVillage(findVillage?.selectedValues[0]?.value);
597-
// console.log('row:', row?.customFields[2].selectedValues[0].value);
597+
// Option 1: Get village from cohortData if available
598+
const villagesFromCohort = row.cohortData
599+
?.filter((c: any) => c.cohortMember?.status === 'active')
600+
.map((c: any) => c.villageName || c.village) // adjust property name as per your data
601+
.filter(Boolean);
602+
603+
setUserData({
604+
firstName: row?.firstName || '',
605+
lastName: row?.lastName || '',
606+
village: centerNames.length!==0 ?centerNames :"-" ,
607+
});
608+
setOpen(true);
609+
setUserId(row?.userId);
610+
setReason('');
611+
setChecked(false);
612+
598613
// setEditableUserId(row?.userId);
599614
// const memberStatus = Status.ARCHIVED;
600615
// const statusReason = '';
@@ -607,16 +622,6 @@ const Facilitator = () => {
607622
// });
608623
// setPrefilledFormData({});
609624
// searchData(prefilledFormData, currentPage);
610-
setOpen(true);
611-
setUserId(row?.userId);
612-
setReason('');
613-
setChecked(false);
614-
615-
setUserData({
616-
firstName: row?.firstName || '',
617-
lastName: row?.lastName || '',
618-
village: findVillage?.selectedValues?.[0]?.value || '',
619-
});
620625
},
621626
show: (row) => row.status !== 'archived',
622627
},

apps/admin-app-repo/src/pages/importCsv.tsx

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import {
2929
useMediaQuery,
3030
useTheme,
3131
} from '@mui/material';
32+
import DownloadIcon from '@mui/icons-material/Download';
3233
import dayjs from 'dayjs';
3334
import customParseFormat from 'dayjs/plugin/customParseFormat';
3435
import { useTranslation } from 'next-i18next';
@@ -208,6 +209,105 @@ const ImportCsv = () => {
208209
link.click();
209210
document.body.removeChild(link);
210211
};
212+
const handleUploadCSVDownload= () => {
213+
214+
215+
// Function to flatten tasks recursively
216+
const flattenTasks = (taskList: any[]): any[] => {
217+
let result: any[] = [];
218+
taskList.forEach((task) => {
219+
result.push(task);
220+
if (task.children && task.children.length > 0) {
221+
result = result.concat(flattenTasks(task.children));
222+
}
223+
});
224+
return result;
225+
};
226+
227+
// Flatten all tasks
228+
const allTasks = flattenTasks(userProjectDetails);
229+
230+
if (allTasks.length === 0) {
231+
alert('No data to export');
232+
return;
233+
}
234+
235+
// Find max number of learning resources
236+
const maxLearningResources = Math.max(
237+
...allTasks.map(task => task.learningResources?.length || 0)
238+
);
239+
240+
// Build header
241+
const baseHeaders = ['name', 'externalId', 'type', 'hasAParentTask', 'parentTaskId'];
242+
const learningResourceHeaders: string[] = [];
243+
244+
for (let i = 1; i <= maxLearningResources; i++) {
245+
learningResourceHeaders.push(
246+
`learningResources${i}-name`,
247+
`learningResources${i}-type`,
248+
`learningResources${i}-id`
249+
);
250+
}
251+
252+
const headers = [...baseHeaders, ...learningResourceHeaders, 'startDate', 'endDate'];
253+
254+
// Helper function to escape CSV values
255+
const escapeCSV = (value: any): string => {
256+
if (value === null || value === undefined) return '';
257+
const stringValue = String(value);
258+
if (stringValue.includes(',') || stringValue.includes('"') || stringValue.includes('\n')) {
259+
return `"${stringValue.replace(/"/g, '""')}"`;
260+
}
261+
return stringValue;
262+
};
263+
264+
// Convert tasks to CSV rows
265+
const csvRows = allTasks.map((task) => {
266+
const row: any = {
267+
name: task.name || '',
268+
externalId: task.externalId || '',
269+
type: task.type || '',
270+
hasAParentTask: task.metaInformation?.hasAParentTask || '',
271+
parentTaskId: task.metaInformation?.parentTaskId || '',
272+
startDate: task.metaInformation?.startDate || '',
273+
endDate: task.metaInformation?.endDate || ''
274+
};
275+
276+
// Add learning resources
277+
if (task.learningResources && task.learningResources.length > 0) {
278+
task.learningResources.forEach((lr: any, index: number) => {
279+
const num = index + 1;
280+
row[`learningResources${num}-name`] = lr.name || '';
281+
row[`learningResources${num}-type`] = lr.type || '';
282+
row[`learningResources${num}-id`] = lr.id || '';
283+
});
284+
}
285+
286+
// Fill in empty learning resource columns
287+
for (let i = (task.learningResources?.length || 0) + 1; i <= maxLearningResources; i++) {
288+
row[`learningResources${i}-name`] = '';
289+
row[`learningResources${i}-type`] = '';
290+
row[`learningResources${i}-id`] = '';
291+
}
292+
293+
return headers.map(header => escapeCSV(row[header])).join(',');
294+
});
295+
296+
// Combine header and rows
297+
const csv = [headers.join(','), ...csvRows].join('\n');
298+
299+
// Create blob and download
300+
const blob = new Blob([csv], { type: 'text/csv;charset=utf-8;' });
301+
const link = document.createElement('a');
302+
const url = URL.createObjectURL(blob);
303+
link.setAttribute('href', url);
304+
link.setAttribute('download', `${subject}_${new Date().toISOString().split('T')[0]}.csv`);
305+
link.style.visibility = 'hidden';
306+
document.body.appendChild(link);
307+
link.click();
308+
document.body.removeChild(link);
309+
URL.revokeObjectURL(url);
310+
};
211311

212312
const handleUpload = async () => {
213313
if (selectedFile) {
@@ -516,6 +616,22 @@ const ImportCsv = () => {
516616
{t('COURSE_PLANNER.ADD_NEW_TOPIC')}
517617
</Button>
518618
)}
619+
620+
621+
{userProjectDetails?.length > 0 && (<Button
622+
variant="contained"
623+
startIcon={<DownloadIcon />}
624+
onClick={handleUploadCSVDownload}
625+
sx={{
626+
textTransform: 'none',
627+
//// backgroundColor: '#1976d2',
628+
'&:hover': {
629+
// backgroundColor: '#1565c0',
630+
}
631+
}}
632+
>
633+
{t('COURSE_PLANNER.DOWNLOAD_CSV')}
634+
</Button>)}
519635
{/* <Button
520636
sx={{
521637
borderRadius: '8px',

apps/admin-app-repo/src/pages/learners.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ const Learner = () => {
376376
{
377377
key: 'status',
378378
label: 'Status',
379-
render: (row: any) => transformLabel(row.status),
379+
render: (row: any) => transformLabel(row?.cohortData?.[0]?.cohortMember?.status),
380380
getStyle: (row) => ({ color: row.status === 'active' ? 'green' : 'red' }),
381381
},
382382
];
@@ -612,7 +612,7 @@ const Learner = () => {
612612
setReason('');
613613
setChecked(false);
614614
},
615-
show: (row) => row.status !== 'archived',
615+
show: (row) => row?.cohortData?.[0]?.cohortMember?.status !== 'archived',
616616
},
617617
{
618618
icon: (
@@ -659,7 +659,7 @@ const Learner = () => {
659659
// setReason('');
660660
// setChecked(false);
661661
},
662-
show: (row) => row.status !== 'active',
662+
show: (row) => row?.cohortData?.[0]?.cohortMember?.status !== 'active',
663663
},
664664
// {
665665
// icon: (

apps/admin-app-repo/src/pages/login.tsx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ const LoginPage = () => {
9696
role?.tenantData[0]?.tenantName !=
9797
TenantName.SECOND_CHANCE_PROGRAM
9898
) {
99-
router.push('/workspace');
99+
// router.push('/workspace');
100+
router.push('/faqs');
100101
} else {
101102
router.push('/course-planner', undefined, { locale: locale });
102103
}
@@ -311,8 +312,10 @@ const LoginPage = () => {
311312
const { locale } = router;
312313
// To do :- hardcoding to be removed
313314
if (tenantData?.tenantName != TenantName.SECOND_CHANCE_PROGRAM) {
314-
window.location.href = '/workspace';
315-
router.push('/workspace');
315+
// window.location.href = '/workspace';
316+
// router.push('/workspace');
317+
window.location.href = '/faqs';
318+
router.push('/faqs');
316319
} else {
317320
window.location.href = '/course-planner';
318321
if (locale) {
@@ -396,8 +399,10 @@ const LoginPage = () => {
396399
if (
397400
tenantData?.tenantName != TenantName.SECOND_CHANCE_PROGRAM
398401
) {
399-
window.location.href = '/workspace';
400-
router.push('/workspace');
402+
// window.location.href = '/workspace';
403+
// router.push('/workspace');
404+
window.location.href = '/faqs';
405+
router.push('/faqs');
401406
} else {
402407
window.location.href = '/course-planner';
403408
if (locale) {

0 commit comments

Comments
 (0)