Skip to content

Commit 6ab7060

Browse files
authored
Merge pull request #2484 from tekdi/release-1.13.0-qa-feat
Release 1.13.0 qa feat to teacher qa
2 parents 15b1521 + 4c4640a commit 6ab7060

File tree

7 files changed

+72
-8
lines changed

7 files changed

+72
-8
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,9 @@
424424
"BATCH_CREATED_SUCCESSFULLY": "Batch Created successfully",
425425
"BATCH_UPDATE_FAILED": "Something went wrong while updating batch",
426426
"YOU_CANT_DELETE_BATCH_HAS_ACTIVE_LEARNERS": "You can't delete the batch because it has {{activeMembers}} Active Learners",
427-
"NO_BATCH_FOUND": "No Batch Found"
427+
"NO_BATCH_FOUND": "No Batch Found",
428+
"TYPE_OF_BATCH": "Type of Batch",
429+
"BATCH_CREATE_FAILED": "Something went wrong while creating batch"
428430
},
429431
"FORM": {
430432
"FULL_NAME": "Full Name",
@@ -488,6 +490,7 @@
488490
"DESIGNATION": "Designation",
489491
"REGULAR": "Regular",
490492
"REMOTE": "Remote",
493+
"CONTACT": "Contact",
491494
"NOTE_THIS_WILL_BE_CENTER_NAME": "Note : This will be center name",
492495
"STATE": "State",
493496
"DISTRICT": "District",
@@ -721,6 +724,7 @@
721724
"email": "Email",
722725
"UNIT_NAME": "Unit Name",
723726
"TYPE_OF_CENTER": "Type of Center",
727+
"TYPE_OF_BATCH": "Type of Batch",
724728
"MY_MAIN_SUBJECTS": "Main subjects",
725729
"LIFE_SKILLS": "Life Skills",
726730
"ENGLISH": "English",

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

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,15 @@ interface BatchFlowProps {
4444
centerBoards?: string[];
4545
centerMediums?: string[];
4646
centerGrades?: string[];
47+
centerType?: string | null;
4748
}
4849

4950
const BatchFlow: React.FC<BatchFlowProps> = ({
5051
initialParentId,
5152
centerBoards = [],
5253
centerMediums = [],
5354
centerGrades = [],
55+
centerType = null,
5456
}) => {
5557
const theme = useTheme<any>();
5658
const [isLoading, setIsLoading] = useState(false);
@@ -144,6 +146,24 @@ const BatchFlow: React.FC<BatchFlowProps> = ({
144146
overrideEnum('medium', centerMediums);
145147
overrideEnum('grade', centerGrades);
146148

149+
// Modify batch_type based on centerType
150+
if (centerType && alterSchema?.properties?.batch_type) {
151+
if (centerType === 'remote') {
152+
// For remote center: set default to "remote" and disable the field
153+
alterSchema.properties.batch_type.default = 'remote';
154+
if (alterUiSchema?.batch_type) {
155+
alterUiSchema.batch_type['ui:disabled'] = true;
156+
}
157+
} else if (centerType === 'regular') {
158+
// For regular center: show only "regular" and "contact" options
159+
alterSchema.properties.batch_type.enum = ['regular', 'contact'];
160+
alterSchema.properties.batch_type.enumNames = ['REGULAR', 'CONTACT'];
161+
if (alterUiSchema?.batch_type?.['ui:disabled']) {
162+
delete alterUiSchema.batch_type['ui:disabled'];
163+
}
164+
}
165+
}
166+
147167
if (!isEditMode) {
148168
if (centerBoards?.length === 1 && alterUiSchema?.board) {
149169
alterUiSchema.board['ui:disabled'] = true;
@@ -188,7 +208,7 @@ const BatchFlow: React.FC<BatchFlowProps> = ({
188208
);
189209
setPrefilledFormData(withParent);
190210
fetchData();
191-
}, [initialParentId]);
211+
}, [initialParentId, centerType, centerBoards, centerMediums, centerGrades]);
192212

193213
const updatedUiSchema = {
194214
...uiSchema,
@@ -351,6 +371,10 @@ const BatchFlow: React.FC<BatchFlowProps> = ({
351371
};
352372
buildSchemaAndUi(true, existingValues);
353373
let tempFormData = extractMatchingKeys(row, addSchema);
374+
// Force batch_type to "remote" if centerType is "remote"
375+
if (centerType === 'remote') {
376+
tempFormData.batch_type = 'remote';
377+
}
354378
setPrefilledAddFormData(tempFormData);
355379
setIsEdit(true);
356380
setEditableUserId(row?.cohortId);
@@ -419,7 +443,7 @@ const BatchFlow: React.FC<BatchFlowProps> = ({
419443
const failureUpdateMessage = 'BATCH.BATCH_UPDATE_FAILED';
420444
const successCreateMessage = 'BATCH.BATCH_CREATED_SUCCESSFULLY';
421445
const telemetryCreateKey = 'batch-created-successfully';
422-
const failureCreateMessage = 'BATCH.BATCH_UPDATE_FAILED';
446+
const failureCreateMessage = 'BATCH.BATCH_CREATE_FAILED';
423447

424448
return (
425449
<>
@@ -461,6 +485,11 @@ const BatchFlow: React.FC<BatchFlowProps> = ({
461485
if (centerGrades?.length === 1)
462486
prefillWithBMGS.grade = [centerGrades[0]];
463487

488+
// Prefill batch_type for remote center
489+
if (centerType === 'remote') {
490+
prefillWithBMGS.batch_type = 'remote';
491+
}
492+
464493
buildSchemaAndUi(false);
465494

466495
setPrefilledAddFormData(prefillWithBMGS);

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

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,30 @@ export const BatchCreateSchema = {
108108
field_type: 'text',
109109
pattern: '^[a-zA-Z][a-zA-Z ]*[a-zA-Z]$',
110110
},
111+
batch_type: {
112+
type: 'string',
113+
title: 'Type of Batch',
114+
coreField: 0,
115+
fieldId: '0417d8fd-47ae-4ec4-9b3b-3f8fdca31625',
116+
field_type: 'radio',
117+
isRequired: true,
118+
enum: [
119+
'remote',
120+
'regular',
121+
'contact',
122+
],
123+
enumNames: [
124+
'REMOTE',
125+
'REGULAR',
126+
'CONTACT',
127+
],
128+
},
111129
},
112-
required: ['board', 'medium', 'grade', 'name'],
130+
required: ['board', 'medium', 'grade', 'name', 'batch_type'],
113131
};
114132

115133
export const BatchCreateUISchema = {
116-
'ui:order': ['board', 'medium', 'grade', 'name'],
134+
'ui:order': ['board', 'medium', 'grade', 'name', 'batch_type'],
117135
board: {
118136
'ui:widget': 'AutoCompleteMultiSelectWidget',
119137
'ui:options': {
@@ -145,4 +163,10 @@ export const BatchCreateUISchema = {
145163
hideError: true,
146164
},
147165
},
166+
batch_type: {
167+
'ui:widget': 'CustomRadioWidget',
168+
'ui:options': {
169+
hideError: true,
170+
},
171+
},
148172
};

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ const Batch = () => {
391391
const failureUpdateMessage = 'BATCH.BATCH_UPDATE_FAILED';
392392
const successCreateMessage = 'BATCH.BATCH_CREATED_SUCCESSFULLY';
393393
const telemetryCreateKey = 'batch-created-successfully';
394-
const failureCreateMessage = 'BATCH.BATCH_UPDATE_FAILED';
394+
const failureCreateMessage = 'BATCH.BATCH_CREATE_FAILED';
395395

396396
return (
397397
<>

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,7 @@ const Centers = () => {
471471
callback: async (row: any) => {
472472
setSelectedCenter(row);
473473
setOpenBatchModal(true);
474+
// console.log('row in view batch', row);
474475
},
475476
show: (row) => row.status !== 'archived',
476477
},
@@ -732,6 +733,11 @@ const Centers = () => {
732733
(field: any) => field.label === 'GRADE'
733734
)?.selectedValues || []
734735
}
736+
centerType={
737+
selectedCenter?.customFields?.find(
738+
(field: any) => field.label === 'TYPE_OF_CENTER'
739+
)?.selectedValues?.[0]?.value || null
740+
}
735741
/>
736742
) : null}
737743
</SimpleModal>

mfes/scp-teacher-repo/public/locales/en/common.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -993,7 +993,8 @@
993993
"BATCH_CREATED_SUCCESSFULLY": "Batch Created successfully",
994994
"BATCH_UPDATE_FAILED": "Something went wrong while updating batch",
995995
"YOU_CANT_DELETE_BATCH_HAS_ACTIVE_LEARNERS": "You can't delete the batch because it has {{activeMembers}} Active Learners",
996-
"NO_BATCH_FOUND": "No Batch Found"
996+
"NO_BATCH_FOUND": "No Batch Found",
997+
"BATCH_CREATE_FAILED": "Something went wrong while creating batch"
997998
},
998999
"WHAT_IS_YOUR_PRIMARY_WORK": "What is Your Primary Work?",
9991000
"STATE": "State",

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,7 @@ const CentersPage = () => {
768768
extraFieldsUpdate={{}}
769769
successCreateMessage="BATCH.BATCH_CREATED_SUCCESSFULLY"
770770
telemetryCreateKey="batch-created-successfully"
771-
failureCreateMessage="BATCH.BATCH_CREATION_FAILED"
771+
failureCreateMessage="BATCH.BATCH_CREATE_FAILED"
772772
successUpdateMessage="BATCH.BATCH_UPDATED_SUCCESSFULLY"
773773
telemetryUpdateKey="batch-updated-successfully"
774774
failureUpdateMessage="BATCH.BATCH_UPDATE_FAILED"

0 commit comments

Comments
 (0)