Skip to content

Commit 52ed601

Browse files
authored
Merge pull request #2438 from tekdi/release-1.13.0-prod-register
Release 1.13.0 prod register to admin qa
2 parents 3989b2a + cd774f4 commit 52ed601

File tree

5 files changed

+65
-103
lines changed

5 files changed

+65
-103
lines changed

apps/learner-web-app/src/app/profile/page.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ const ProfilePage = () => {
2525

2626
const [filters] = useState<FilterDetails>({
2727
status: [ 'viewCertificate'],
28-
tenantId:
29-
(typeof window !== 'undefined' && localStorage.getItem('tenantId')) || '',
28+
3029
userId:
3130
(typeof window !== 'undefined' && localStorage.getItem('userId')) || '',
3231
});

apps/learner-web-app/src/components/Content/Player.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,15 @@ const App = ({
7575
const fetch = async () => {
7676
const response = await fetchContent(identifier);
7777
const rt = (await hierarchyAPI(courseId as string)) as any;
78+
console.log('rt=======>', rt);
7879
const currentPath =
7980
typeof window !== 'undefined' ? window.location.pathname : '';
8081
const isThematicPath = currentPath.includes('/themantic');
8182
const isPosPath = currentPath.includes('/pos');
8283

8384
if (!isThematicPath && !isPosPath && rt?.program) {
8485
console.log('response=======>', rt?.program);
86+
if(localStorage.getItem('channelId')==="pos-channel"){
8587
if (
8688
!rt?.program?.includes(localStorage.getItem('userProgram')) &&
8789
!rt.program.includes('Open School')
@@ -90,6 +92,12 @@ const App = ({
9092
return;
9193
}
9294
}
95+
}
96+
if(localStorage.getItem('channelId')!==rt.channel)
97+
{
98+
router.push('/unauthorized');
99+
return;
100+
}
93101

94102
const response2 = await ContentSearch({
95103
filters: {

libs/shared-lib-v2/src/DynamicForm/components/DynamicForm.tsx

Lines changed: 36 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -299,25 +299,14 @@ const DynamicForm = ({
299299

300300
if (formData?.dob) {
301301
let age = calculateAgeFromDate(formData?.dob);
302-
let oldFormSchema = (createNew && !isCompleteProfile)
303-
? { ...schemaa, properties: { ...schemaa.properties }, required: [...(schemaa.required || [])] }
304-
: schemaa;
305-
let oldFormUiSchema = (createNew && !isCompleteProfile)
306-
? { ...uischema }
307-
: uischema;
308-
let requiredArray = (createNew && !isCompleteProfile)
309-
? [...(oldFormSchema?.required || [])]
310-
: oldFormSchema?.required;
302+
let oldFormSchema = schemaa; // ✅ Use schemaa instead of formSchema
303+
let oldFormUiSchema = uischema; // ✅ Use uischema instead of formUiSchema
304+
let requiredArray = oldFormSchema?.required;
311305

312306
//if learner form then only apply
313307
if (oldFormSchema?.properties?.guardian_relation || isCompleteProfile) {
314308
if (age < 18) {
315-
if (createNew && !isCompleteProfile) {
316-
// Avoid direct mutation of formData
317-
} else {
318-
delete formData?.mobile;
319-
}
320-
309+
delete formData?.mobile;
321310
// Merge only missing items from required2 into required1 guardian details
322311
requiredKeys.forEach((item) => {
323312
if (!requiredArray.includes(item)) {
@@ -343,7 +332,7 @@ const DynamicForm = ({
343332

344333
// Clone each key's config and set widget to 'CustomTextFieldWidget' with full width
345334
requiredKeys.forEach((key) => {
346-
if (Object.prototype.hasOwnProperty.call(updatedUiSchema, key)) {
335+
if (updatedUiSchema.hasOwnProperty(key)) {
347336
updatedUiSchema[key] = {
348337
...updatedUiSchema[key],
349338
'ui:widget': 'CustomTextFieldWidget',
@@ -355,20 +344,11 @@ const DynamicForm = ({
355344
}
356345
});
357346

358-
//hide mobile
347+
//hide mobile - remove from schema completely
359348
requiredKeys2.forEach((key) => {
360-
if (createNew && !isCompleteProfile) {
361-
// hide mobile - keep in schema to preserve value
362-
updatedUiSchema[key] = {
363-
...updatedUiSchema[key],
364-
'ui:widget': 'hidden'
365-
};
366-
} else {
367-
// remove from schema completely (legacy behavior)
368-
delete updatedUiSchema[key];
369-
if (oldFormSchema.properties && oldFormSchema.properties[key]) {
370-
delete oldFormSchema.properties[key];
371-
}
349+
delete updatedUiSchema[key];
350+
if (oldFormSchema.properties && oldFormSchema.properties[key]) {
351+
delete oldFormSchema.properties[key];
372352
}
373353
});
374354

@@ -403,13 +383,9 @@ const DynamicForm = ({
403383

404384
oldFormUiSchema = reorderedUiSchema;
405385
} else {
406-
if (createNew && !isCompleteProfile) {
407-
// Avoid direct mutation of formData
408-
} else {
409-
delete formData?.parent_phone;
410-
delete formData?.guardian_relation;
411-
delete formData?.guardian_name;
412-
}
386+
delete formData?.parent_phone;
387+
delete formData?.guardian_relation;
388+
delete formData?.guardian_name;
413389

414390
// remove from required
415391
requiredArray = requiredArray.filter(
@@ -427,7 +403,7 @@ const DynamicForm = ({
427403
const updatedUiSchema = { ...oldFormUiSchema };
428404
// Clone each key's config and set widget to 'hidden'
429405
requiredKeys.forEach((key) => {
430-
if (Object.prototype.hasOwnProperty.call(updatedUiSchema, key)) {
406+
if (updatedUiSchema.hasOwnProperty(key)) {
431407
updatedUiSchema[key] = {
432408
...updatedUiSchema[key],
433409
'ui:widget': 'hidden',
@@ -474,13 +450,7 @@ const DynamicForm = ({
474450
// Remove guardian info note from schema and UI schema
475451
delete updatedUiSchema['guardian_info_note'];
476452
if (oldFormSchema.properties && oldFormSchema.properties.guardian_info_note) {
477-
if (createNew && !isCompleteProfile) {
478-
const newProps = { ...oldFormSchema.properties };
479-
delete newProps.guardian_info_note;
480-
oldFormSchema.properties = newProps;
481-
} else {
482-
delete oldFormSchema.properties.guardian_info_note;
483-
}
453+
delete oldFormSchema.properties.guardian_info_note;
484454
}
485455
oldFormUiSchema = updatedUiSchema;
486456
}
@@ -491,66 +461,39 @@ const DynamicForm = ({
491461
}
492462
} else {
493463
//initially hide all
494-
let oldFormSchema = (createNew && !isCompleteProfile)
495-
? { ...schemaa, properties: { ...schemaa.properties }, required: [...(schemaa.required || [])] }
496-
: formSchema;
497-
let oldFormUiSchema = (createNew && !isCompleteProfile)
498-
? { ...uischema }
499-
: formUiSchema;
464+
let oldFormSchema = formSchema;
465+
let oldFormUiSchema = formUiSchema;
500466
let requiredArray = oldFormSchema?.required;
501467

502468
// remove from required
503469
requiredArray = requiredArray.filter(
504470
(key) => !requiredKeys.includes(key)
505471
);
506-
507-
if (createNew && !isCompleteProfile) {
508-
// keep mobile in schema but hide in UI initially
509-
} else {
510-
requiredArray = requiredArray.filter(
511-
(key) => !requiredKeys2.includes(key)
512-
);
513-
}
472+
requiredArray = requiredArray.filter(
473+
(key) => !requiredKeys2.includes(key)
474+
);
514475

515476
//set ui schema hide
516477
const updatedUiSchema = { ...oldFormUiSchema };
517478
// Clone each key's config and set widget to 'hidden'
518479
requiredKeys.forEach((key) => {
519-
if (Object.prototype.hasOwnProperty.call(updatedUiSchema, key)) {
480+
if (updatedUiSchema.hasOwnProperty(key)) {
520481
updatedUiSchema[key] = {
521482
...updatedUiSchema[key],
522483
'ui:widget': 'hidden',
523484
};
524485
}
525486
});
526-
527487
requiredKeys2.forEach((key) => {
528-
if (createNew && !isCompleteProfile) {
529-
// hide mobile but keep in schema
530-
if (updatedUiSchema[key]) {
531-
updatedUiSchema[key] = {
532-
...updatedUiSchema[key],
533-
'ui:widget': 'CustomTextFieldWidget',
534-
};
535-
}
536-
} else {
537-
delete updatedUiSchema[key];
538-
if (oldFormSchema.properties && oldFormSchema.properties[key]) {
539-
delete oldFormSchema.properties[key];
540-
}
488+
delete updatedUiSchema[key];
489+
if (oldFormSchema.properties && oldFormSchema.properties[key]) {
490+
delete oldFormSchema.properties[key];
541491
}
542492
});
543-
544493
// Remove guardian info note from schema and UI schema initially
545494
delete updatedUiSchema['guardian_info_note'];
546495
if (oldFormSchema.properties && oldFormSchema.properties.guardian_info_note) {
547-
if (createNew && !isCompleteProfile) {
548-
const newProps = { ...oldFormSchema.properties };
549-
delete newProps.guardian_info_note;
550-
oldFormSchema.properties = newProps;
551-
} else {
552-
delete oldFormSchema.properties.guardian_info_note;
553-
}
496+
delete oldFormSchema.properties.guardian_info_note;
554497
}
555498
oldFormUiSchema = updatedUiSchema;
556499
oldFormSchema.required = requiredArray;
@@ -1540,24 +1483,18 @@ const customFields = {
15401483

15411484
if (hasObjectChanged(prevFormData.current, formData)) {
15421485
console.log('hasObjectChanged in 1 formData', formData);
1543-
const updatedFormData = (createNew && !isCompleteProfile) ? { ...formData } : formData;
1544-
15451486
if (changedField) {
15461487
//error set
15471488
console.log('errors', errors);
15481489
setSubmitted(false);
15491490
//find out all dependent keys
15501491
const dependentKeyArray = getDependentKeys(schema, changedField);
1551-
console.log('hasObjectChanged in 2 formData', updatedFormData);
1492+
console.log('hasObjectChanged in 2 formData', formData);
15521493
// console.log('hasObjectChanged dependent keys:', dependentKeyArray);
15531494
dependentKeyArray.forEach((key) => {
1554-
if (createNew && !isCompleteProfile) {
1555-
delete updatedFormData[key]; // Remove the key from cloned formData
1556-
} else {
1557-
delete formData[key]; // Remove the key from formData
1558-
}
1495+
delete formData[key]; // Remove the key from formData
15591496
});
1560-
// console.log('hasObjectChanged formData', updatedFormData);
1497+
// console.log('hasObjectChanged formData', formData);
15611498

15621499
setFormSchema((prevSchema) => {
15631500
const updatedProperties = { ...prevSchema.properties };
@@ -1586,14 +1523,14 @@ const customFields = {
15861523
return { ...prevSchema, properties: updatedProperties };
15871524
});
15881525

1589-
// // console.log(`Field changed: ${changedField}, New Value: ${updatedFormData[changedField]}`);
1526+
// // console.log(`Field changed: ${changedField}, New Value: ${formData[changedField]}`);
15901527
// // console.log('dependentSchema', dependentSchema);
15911528
const workingSchema = dependentSchema?.filter(
15921529
(item) => item.api && item.api.dependent === changedField
15931530
);
15941531
// // console.log('workingSchema', workingSchema);
15951532
if (workingSchema.length > 0) {
1596-
const changedFieldValue = updatedFormData[changedField];
1533+
const changedFieldValue = formData[changedField];
15971534

15981535
const getNestedValue = (obj, path) => {
15991536
if (path === '') {
@@ -1743,13 +1680,13 @@ const customFields = {
17431680
const isUsernameDisabled = formUiSchema?.username?.['ui:disabled'] === true;
17441681
if (isUsernameDisabled && prevFormData.current?.username) {
17451682
// Keep the existing username value when username field is disabled
1746-
updatedFormData.username = prevFormData.current.username;
1683+
formData.username = prevFormData.current.username;
17471684
}
17481685

1749-
prevFormData.current = updatedFormData;
1750-
// console.log('Form data changed:', updatedFormData);
1686+
prevFormData.current = formData;
1687+
// console.log('Form data changed:', formData);
17511688
// live error
1752-
setFormData(updatedFormData);
1689+
setFormData(formData);
17531690

17541691
function getSkipKeys(skipHideObject, formData) {
17551692
let skipKeys = [];
@@ -1763,7 +1700,7 @@ const customFields = {
17631700
return skipKeys;
17641701
}
17651702

1766-
const skipKeys = getSkipKeys(hideAndSkipFields, updatedFormData);
1703+
const skipKeys = getSkipKeys(hideAndSkipFields, formData);
17671704
// console.log('skipKeys', skipKeys);
17681705
let updatedUISchema = formUiSchemaOriginal;
17691706
function hideFieldsInUISchema(uiSchema, fieldsToHide) {
@@ -1917,7 +1854,7 @@ const customFields = {
19171854

19181855
const transformedFormData = transformFormData(
19191856
cleanedData,
1920-
(createNew && !isCompleteProfile) ? formSchema : schema,
1857+
schema,
19211858
extraFields
19221859
);
19231860

@@ -2381,4 +2318,4 @@ const uiSchema = {
23812318
phoneDetails: { 'ui:widget': 'select' },
23822319
district: { 'ui:widget': 'select' },
23832320
};
2384-
*/
2321+
*/

mfes/content/src/components/Content/ContentEnroll.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ const ContentDetails = (props: ContentDetailsProps) => {
5454
const fetchContentDetails = async () => {
5555
try {
5656
const result = await hierarchyAPI(identifier as string)as any;
57+
console.log('rt=======>', result);
5758

5859
console.log('result=======>', result?.program);
5960
const currentPath = typeof window !== 'undefined' ? window.location.pathname : '';
@@ -63,13 +64,19 @@ const isPosPath = currentPath.includes('/pos');
6364
console.log('isThematicPath=======>', isThematicPath);
6465

6566
if(!isThematicPath && !isPosPath && result?.program) {
67+
if(localStorage.getItem('channelId')==="pos-channel"){
6668

6769
if (!result?.program?.includes(localStorage.getItem('userProgram')) && !result.program.includes('Open School'))
6870
{
6971
router.push('/unauthorized');
7072
return;
7173
}
72-
}
74+
}}
75+
if(localStorage.getItem('channelId')!==result.channel)
76+
{
77+
router.push('/unauthorized');
78+
return;
79+
}
7380
const userId = getUserId(props?._config?.userIdLocalstorageName);
7481
setCheckLocalAuth(checkAuth(Boolean(userId)));
7582
if (props?._config?.isEnrollmentRequired !== false) {

mfes/content/src/components/Content/CourseUnitDetails.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,24 @@ export default function Details(props: DetailsProps) {
8080
const isThematicPath = currentPath.includes('/themantic');
8181
const isPosPath = currentPath.includes('/pos');
8282
if(!isThematicPath && !isPosPath && resultHierarchyCourse?.program) {
83-
console.log('resultHierarchyCourse=======>', resultHierarchyCourse?.program);
83+
console.log('rt=======>', resultHierarchyCourse);
84+
if(localStorage.getItem('channelId')==="pos-channel"){
8485
if (!resultHierarchyCourse?.program?.includes(localStorage.getItem('userProgram')) && !resultHierarchyCourse.program.includes('Open School'))
8586
{
8687
router.push('/unauthorized');
8788
return;
8889
}
8990
}
91+
92+
if(localStorage.getItem('channelId')!==resultHierarchyCourse.channel)
93+
{
94+
router.push('/unauthorized');
95+
return;
96+
}
97+
98+
99+
100+
}
90101
let resultHierarchy = resultHierarchyCourse;
91102
console.log('resultHierarchyCourse', resultHierarchyCourse);
92103

0 commit comments

Comments
 (0)