Skip to content

Commit 3714ed5

Browse files
authored
Merge pull request #2684 from tekdi/release-1.15.0
Release 1.15.0 to learner dev
2 parents 45efb73 + 569ec3e commit 3714ed5

File tree

5 files changed

+118
-34
lines changed

5 files changed

+118
-34
lines changed

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

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -149,20 +149,21 @@ const BatchFlow: React.FC<BatchFlowProps> = ({
149149
// Modify batch_type based on centerType
150150
if (centerType && alterSchema?.properties?.batch_type) {
151151
if (centerType === 'remote') {
152-
// For remote center: show only "remote" option
153-
alterSchema.properties.batch_type.enum = ['remote'];
154-
alterSchema.properties.batch_type.enumNames = ['REMOTE'];
152+
// For remote center: show "remote" and "hybrid" options
153+
alterSchema.properties.batch_type.enum = ['remote', 'hybrid'];
154+
alterSchema.properties.batch_type.enumNames = ['REMOTE', 'HYBRID'];
155155
alterSchema.properties.batch_type.default = 'remote';
156-
if (alterUiSchema?.batch_type) {
157-
alterUiSchema.batch_type['ui:disabled'] = true;
158-
}
159-
} else if (centerType === 'regular') {
160-
// For regular center: show only "regular" and "contact" options
161-
alterSchema.properties.batch_type.enum = ['regular', 'contact'];
162-
alterSchema.properties.batch_type.enumNames = ['REGULAR', 'CONTACT'];
163156
if (alterUiSchema?.batch_type?.['ui:disabled']) {
164157
delete alterUiSchema.batch_type['ui:disabled'];
165158
}
159+
} else if (centerType === 'regular') {
160+
// For regular center: show only "regular" option (disabled)
161+
alterSchema.properties.batch_type.enum = ['regular'];
162+
alterSchema.properties.batch_type.enumNames = ['REGULAR'];
163+
alterSchema.properties.batch_type.default = 'regular';
164+
if (alterUiSchema?.batch_type) {
165+
alterUiSchema.batch_type['ui:disabled'] = true;
166+
}
166167
}
167168
}
168169

@@ -374,8 +375,8 @@ const BatchFlow: React.FC<BatchFlowProps> = ({
374375
buildSchemaAndUi(true, existingValues);
375376
let tempFormData = extractMatchingKeys(row, addSchema);
376377
// Force batch_type to "remote" if centerType is "remote"
377-
if (centerType === 'remote') {
378-
tempFormData.batch_type = 'remote';
378+
if (centerType === 'regular') {
379+
tempFormData.batch_type = 'regular';
379380
}
380381
setPrefilledAddFormData(tempFormData);
381382
setIsEdit(true);

apps/admin-app-repo/src/constant/Forms/BatchCreate.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,12 @@ export const BatchCreateSchema = {
118118
enum: [
119119
'remote',
120120
'regular',
121-
'contact',
121+
'hybrid',
122122
],
123123
enumNames: [
124124
'REMOTE',
125125
'REGULAR',
126-
'CONTACT',
126+
'HYBRID',
127127
],
128128
},
129129
},

apps/learner-web-app/src/components/UserProfileCard/UserProfileCard.tsx

Lines changed: 92 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import Image from 'next/image';
2121
import ChevronRightIcon from '@mui/icons-material/ChevronRight';
2222
import VisibilityIcon from '@mui/icons-material/Visibility';
2323
import { useRouter } from 'next/navigation';
24-
import { getUserDetails } from '@learner/utils/API/userService';
24+
import { getUserDetails, getMentorList } from '@learner/utils/API/userService';
2525
import { Loader, useTranslation } from '@shared-lib';
2626
import { isUnderEighteen, toPascalCase } from '@learner/utils/helper';
2727
import { fetchForm } from '@shared-lib-v2/DynamicForm/components/DynamicFormCallback';
@@ -114,6 +114,8 @@ const UserProfileCard = ({ maxWidth = '600px' }) => {
114114
const [previewUrl, setPreviewUrl] = useState<string | null>(null);
115115
const [isPreviewOpen, setIsPreviewOpen] = useState(false);
116116
const [previewTitle, setPreviewTitle] = useState<string>('');
117+
const [villageId, setVillageId] = useState<number | null>(null);
118+
const [mentorData, setMentorData] = useState<Record<string, unknown> | null>(null);
117119

118120
const storedConfig =
119121
typeof window !== 'undefined'
@@ -177,6 +179,13 @@ const UserProfileCard = ({ maxWidth = '600px' }) => {
177179
console.log('useInfo', userInfoResponse?.result?.userData);
178180
console.log('responseForm', formResponse);
179181

182+
// Extract village ID for mentor lookup
183+
const extractedVillageId =
184+
userInfoResponse?.result?.userData?.customFields?.find(
185+
(f: Record<string, unknown>) => f.label === 'VILLAGE'
186+
)?.selectedValues?.[0]?.id ?? null;
187+
setVillageId(extractedVillageId);
188+
180189
setUserData(userInfoResponse?.result?.userData);
181190
setFormSchema(formResponse);
182191
} catch (error) {
@@ -186,6 +195,45 @@ const UserProfileCard = ({ maxWidth = '600px' }) => {
186195

187196
fetchData();
188197
}, []);
198+
199+
// Fetch mentor data based on village ID
200+
useEffect(() => {
201+
const fetchMentorData = async () => {
202+
try {
203+
if (villageId) {
204+
const mentorResponse = await getMentorList({
205+
limit: 100,
206+
filters: {
207+
working_village: [String(villageId)],
208+
role: 'Mobilizer',
209+
},
210+
sort: ['createdAt', 'asc'],
211+
offset: 0,
212+
});
213+
214+
// Handle different possible response structures
215+
const mentorList =
216+
mentorResponse?.getUserDetails ||
217+
mentorResponse?.userDetails ||
218+
mentorResponse?.results ||
219+
[];
220+
221+
// Get the first mentor from the list if available
222+
if (Array.isArray(mentorList) && mentorList.length > 0) {
223+
setMentorData(mentorList[0] as Record<string, unknown>);
224+
} else {
225+
setMentorData(null);
226+
}
227+
}
228+
} catch (error) {
229+
console.error('Error fetching mentor data:', error);
230+
setMentorData(null);
231+
}
232+
};
233+
234+
fetchMentorData();
235+
}, [villageId]);
236+
189237
const handleSettingsClick = (event: React.MouseEvent<HTMLElement>) => {
190238
setAnchorEl(event.currentTarget);
191239
};
@@ -676,6 +724,49 @@ const UserProfileCard = ({ maxWidth = '600px' }) => {
676724
</Box>
677725
</>
678726
)}
727+
728+
{/* My Mentor Details Section */}
729+
{mentorData && (
730+
<>
731+
<Typography sx={sectionTitleStyle}>
732+
{t('LEARNER_APP.USER_PROFILE_CARD.MY_MENTOR_DETAILS')}
733+
</Typography>
734+
<Box sx={sectionCardStyle}>
735+
<Grid container spacing={1.5}>
736+
{(mentorData.firstName || mentorData.lastName) ? (
737+
<Grid item xs={6}>
738+
<Typography sx={labelStyle}>
739+
{t('LEARNER_APP.USER_PROFILE_CARD.MENTOR_NAME')}
740+
</Typography>
741+
<Typography sx={valueStyle}>
742+
{toPascalCase(
743+
[String(mentorData.firstName || ''), String(mentorData.lastName || '')]
744+
.filter(Boolean)
745+
.join(' ')
746+
)}
747+
</Typography>
748+
</Grid>
749+
) : null}
750+
{mentorData.email ? (
751+
<Grid item xs={6}>
752+
<Typography sx={labelStyle}>
753+
{t('LEARNER_APP.USER_PROFILE_CARD.MENTOR_EMAIL')}
754+
</Typography>
755+
<Typography sx={valueStyle}>{String(mentorData.email)}</Typography>
756+
</Grid>
757+
) : null}
758+
{mentorData.mobile ? (
759+
<Grid item xs={6}>
760+
<Typography sx={labelStyle}>
761+
{t('LEARNER_APP.USER_PROFILE_CARD.PHONE_NUMBER')}
762+
</Typography>
763+
<Typography sx={valueStyle}>{String(mentorData.mobile)}</Typography>
764+
</Grid>
765+
) : null}
766+
</Grid>
767+
</Box>
768+
</>
769+
)}
679770
</Box>
680771

681772
<Menu

libs/shared-lib-v2/src/lib/context/locales/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -688,6 +688,7 @@
688688
"DESIGNATION": "Designation",
689689
"REGULAR": "Regular",
690690
"REMOTE": "Remote",
691+
"HYBRID": "Hybrid",
691692
"NOTE_THIS_WILL_BE_CENTER_NAME": "Note : This will be center name",
692693
"STATE": "State",
693694
"DISTRICT": "District",

mfes/scp-teacher-repo/src/pages/centers/index.tsx

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -587,31 +587,22 @@ const CentersPage = () => {
587587
const ct = (params.centerType || '').toLowerCase();
588588
if (schema?.properties?.batch_type) {
589589
if (ct === 'remote') {
590-
schema.properties.batch_type.enum = ['remote'];
591-
schema.properties.batch_type.enumNames = ['REMOTE'];
590+
// For remote center: show "remote" and "hybrid" options
591+
schema.properties.batch_type.enum = ['remote', 'hybrid'];
592+
schema.properties.batch_type.enumNames = ['Remote', 'Hybrid'];
592593
schema.properties.batch_type.default = 'remote';
593594
prefill.batch_type = 'remote';
595+
ensureEnabled('batch_type');
596+
} else if (ct === 'regular') {
597+
// For regular center: show only "regular" option (disabled)
598+
schema.properties.batch_type.enum = ['regular'];
599+
schema.properties.batch_type.enumNames = ['Regular'];
600+
schema.properties.batch_type.default = 'regular';
601+
prefill.batch_type = 'regular';
594602
uiSchema.batch_type = {
595603
...(uiSchema?.batch_type || {}),
596604
'ui:disabled': true,
597605
};
598-
} else if (ct === 'regular') {
599-
// Only restrict if enum exists; otherwise leave as-is.
600-
const existingEnum = Array.isArray(schema.properties.batch_type.enum)
601-
? schema.properties.batch_type.enum
602-
: null;
603-
if (existingEnum) {
604-
const allowed = ['regular', 'contact'].filter((v) =>
605-
existingEnum.includes(v)
606-
);
607-
if (allowed.length) {
608-
schema.properties.batch_type.enum = allowed;
609-
schema.properties.batch_type.enumNames = allowed.map((v) =>
610-
v.toUpperCase()
611-
);
612-
}
613-
}
614-
ensureEnabled('batch_type');
615606
}
616607
}
617608

0 commit comments

Comments
 (0)