Skip to content

Commit af1c11d

Browse files
authored
Merge pull request #2287 from tekdi/feat-prod-fix
Feat prod fix to 13 prod
2 parents ba35f06 + 9204ca1 commit af1c11d

File tree

8 files changed

+197
-65
lines changed

8 files changed

+197
-65
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,8 @@
544544
"DATE_OF_BIRTH": "Date of Birth",
545545
"TEST_BELONG_TO": "test belongs to below center",
546546
"WAS_BELONG_TO": "was archived in the below location",
547-
"CONFIRM_TO_ACTIVATE":"Are you sure you want to activate this user again?"
547+
"CONFIRM_TO_ACTIVATE":"Are you sure you want to activate this user again?",
548+
"BELONG_TO": "belongs to below center"
548549
},
549550
"FORM_ERROR_MESSAGES": {
550551
"INVALID_INPUT": "Invalid Input.",

apps/admin-app-repo/src/components/DeleteDetails.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ interface DeleteDetailsProps {
1616
firstName: string;
1717
lastName: string;
1818
village: string;
19+
center?: string;
1920
checked: boolean;
2021
setChecked: (checked: boolean) => void;
2122
reason: string;
@@ -27,6 +28,7 @@ const DeleteDetails: React.FC<DeleteDetailsProps> = ({
2728
firstName,
2829
lastName,
2930
village,
31+
center,
3032
checked,
3133
setChecked,
3234
reason,
@@ -45,9 +47,9 @@ const DeleteDetails: React.FC<DeleteDetailsProps> = ({
4547
}}
4648
>
4749
<Typography fontWeight="bold">
48-
{ firstName } { lastName } {t("FORM.TEST_BELONG_TO")}
50+
{ firstName } { lastName } {center? t("FORM.BELONG_TO"): t("FORM.WAS_BELONG_TO")}
4951
</Typography>
50-
<TextField fullWidth value={village} disabled sx={{ mt: 1 }} />
52+
<TextField fullWidth value={center? center: village} disabled sx={{ mt: 1 }} />
5153
</Box>
5254

5355
<FormControlLabel

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

Lines changed: 63 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ import FacilitatorForm from '@/components/DynamicForm/FacilitatorForm/Facilitato
6565
import CenterLabel from '@/components/Centerlabel';
6666
import ResetFiltersButton from '@/components/ResetFiltersButton/ResetFiltersButton';
6767
import { showToastMessage } from '@/components/Toastify';
68+
import { getOverallStatus } from '@shared-lib-v2/utils/helper';
6869

6970
const Facilitator = () => {
7071
const theme = useTheme<any>();
@@ -100,6 +101,7 @@ const Facilitator = () => {
100101
firstName: '',
101102
lastName: '',
102103
village: '',
104+
center: '',
103105
});
104106

105107
const { t, i18n } = useTranslation();
@@ -310,7 +312,7 @@ const Facilitator = () => {
310312
// )}
311313
// </>
312314
// );
313-
const centers =
315+
let centers =
314316
row.cohortData
315317
?.filter(
316318
(c: any) =>
@@ -319,7 +321,17 @@ const Facilitator = () => {
319321
)
320322
.map((c: any) => transformLabel(c.centerName))
321323
.filter(Boolean) || [];
322-
324+
if (centers.length === 0) {
325+
centers =
326+
row.cohortData
327+
?.filter(
328+
(c: any) =>
329+
c.centerStatus === 'active' &&
330+
c.cohortMember?.status === 'archived'
331+
)
332+
.map((c: any) => transformLabel(c.centerName))
333+
.filter(Boolean) || [];
334+
}
323335
return centers.join(', ');
324336
},
325337
},
@@ -328,7 +340,7 @@ const Facilitator = () => {
328340
label: 'Batch',
329341
render: (row) => {
330342
// console.log('BacthRow', row?.cohortData)
331-
const batches =
343+
let batches =
332344
row.cohortData
333345
?.filter(
334346
(c: any) =>
@@ -338,7 +350,18 @@ const Facilitator = () => {
338350
.map((c: any) => transformLabel(c.batchName))
339351
.filter(Boolean) || [];
340352

341-
return batches.join(', ');
353+
if (batches.length === 0) {
354+
batches =
355+
row.cohortData
356+
?.filter(
357+
(c: any) =>
358+
c.batchStatus === 'active' &&
359+
c.cohortMember?.status === 'archived'
360+
)
361+
.map((c: any) => transformLabel(c.batchName))
362+
.filter(Boolean) || [];
363+
}
364+
return batches.join(', ');
342365
},
343366
},
344367
{
@@ -354,8 +377,8 @@ const Facilitator = () => {
354377
{
355378
key: 'status',
356379
label: 'Status',
357-
render: (row: any) => transformLabel(row.status),
358-
getStyle: (row) => ({ color: row.status === 'active' ? 'green' : 'red' }),
380+
render: (row: any) => transformLabel(getOverallStatus(row?.cohortData)),
381+
getStyle: (row) => ({ color: getOverallStatus(row?.cohortData) === 'active' ? 'green' : 'red' }),
359382
},
360383
];
361384

@@ -367,9 +390,9 @@ const Facilitator = () => {
367390
try {
368391
const userCohortResp = await getCohortList(userID);
369392
if (userCohortResp?.result?.length) {
370-
membershipIds = userCohortResp?.result?.map(
371-
(item) => item.cohortMembershipId
372-
);
393+
membershipIds = userCohortResp?.result
394+
?.filter((c: any) => c.cohortMemberStatus === 'active')
395+
?.map((c: any) => c.cohortMembershipId) || [];
373396
} else {
374397
console.warn('No cohort data found for the user.');
375398
}
@@ -443,9 +466,9 @@ const Facilitator = () => {
443466
try {
444467
const userCohortResp = await getCohortList(userID);
445468
if (userCohortResp?.result?.length) {
446-
membershipIds = userCohortResp?.result?.map(
447-
(item) => item.cohortMembershipId
448-
);
469+
membershipIds = userCohortResp?.result
470+
?.filter((c: any) => c.cohortMemberStatus === 'archived')
471+
?.map((c: any) => c.cohortMembershipId) || [];
449472
} else {
450473
console.warn('No cohort data found for the user.');
451474
}
@@ -560,7 +583,10 @@ console.log('response?.result?.getUserDetails',response?.result?.getUserDetails)
560583
setEditableUserId(row?.userId);
561584
handleOpenModal();
562585
},
563-
show: (row) => row.status !== 'archived',
586+
show: (row) => row.cohortData?.some(
587+
(cohort) =>
588+
cohort?.cohortMember?.status === 'active'
589+
),
564590
},
565591
{
566592
icon: (
@@ -605,6 +631,11 @@ console.log('response?.result?.getUserDetails',response?.result?.getUserDetails)
605631
firstName: row?.firstName || '',
606632
lastName: row?.lastName || '',
607633
village: centerNames.length!==0 ?centerNames :"-" ,
634+
center:
635+
row?.cohortData
636+
?.filter((cohort) => cohort?.cohortMember?.status === 'archived')
637+
?.map((cohort) => cohort?.centerName)
638+
?.join(', ') || '',
608639
});
609640
setOpen(true);
610641
setUserId(row?.userId);
@@ -624,7 +655,10 @@ console.log('response?.result?.getUserDetails',response?.result?.getUserDetails)
624655
// setPrefilledFormData({});
625656
// searchData(prefilledFormData, currentPage);
626657
},
627-
show: (row) => row.status !== 'archived',
658+
show: (row) => row.cohortData?.some(
659+
(cohort) =>
660+
cohort?.cohortMember?.status === 'active'
661+
),
628662
},
629663
{
630664
icon: (
@@ -669,7 +703,10 @@ console.log('response?.result?.getUserDetails',response?.result?.getUserDetails)
669703
setEditableUserId(row?.userId);
670704
handleOpenModal();
671705
},
672-
show: (row) => row.status !== 'archived',
706+
show: (row) => row.cohortData?.some(
707+
(cohort) =>
708+
cohort?.cohortMember?.status === 'active'
709+
),
673710
},
674711
{
675712
icon: (
@@ -712,11 +749,18 @@ console.log('response?.result?.getUserDetails',response?.result?.getUserDetails)
712749
firstName: row?.firstName || '',
713750
lastName: row?.lastName || '',
714751
village: findVillage?.selectedValues?.[0]?.value || '',
752+
center:
753+
row?.cohortData
754+
?.filter((cohort) => cohort?.cohortMember?.status === 'archived')
755+
?.map((cohort) => cohort?.centerName)
756+
?.join(', ') || '',
715757
});
716758
// setReason('');
717759
// setChecked(false);
718760
},
719-
show: (row) => row.status !== 'active',
761+
show: (row) => row.cohortData?.some(
762+
(cohort) =>
763+
cohort?.cohortMember?.status === 'archived')
720764
},
721765
];
722766

@@ -934,6 +978,7 @@ console.log('response?.result?.getUserDetails',response?.result?.getUserDetails)
934978
firstName={userData.firstName}
935979
lastName={userData.lastName}
936980
village={userData.village}
981+
center={userData.center}
937982
checked={checked}
938983
setChecked={setChecked}
939984
reason={reason}
@@ -960,11 +1005,11 @@ console.log('response?.result?.getUserDetails',response?.result?.getUserDetails)
9601005
}}
9611006
>
9621007
<Typography>
963-
{userData.firstName} {userData.lastName} {t('FORM.WAS_BELONG_TO')}
1008+
{userData.firstName} {userData.lastName} {t('FORM.BELONG_TO')}
9641009
</Typography>
9651010
<TextField
9661011
fullWidth
967-
value={userData.village}
1012+
value={userData.center}
9681013
disabled
9691014
sx={{ mt: 1 }}
9701015
/>

0 commit comments

Comments
 (0)