Skip to content

Commit dc25c64

Browse files
authored
Merge pull request #2525 from tekdi/feat-direct-enroll
Feat direct enroll to prod register
2 parents e8d4f7b + d3f7b9b commit dc25c64

File tree

6 files changed

+189
-93
lines changed

6 files changed

+189
-93
lines changed

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import React from 'react';
44
import { Box, Typography, Paper, Stack, Button, Divider } from '@mui/material';
55
import ArrowForwardIcon from '@mui/icons-material/ArrowForward';
66
import ErrorOutlineIcon from '@mui/icons-material/ErrorOutline';
7+
import { useTranslation } from '@shared-lib';
78

89
type AccountExistsCardProps = {
910
fullName: string;
@@ -16,6 +17,8 @@ const AccountExistsCard: React.FC<AccountExistsCardProps> = ({
1617
usernames,
1718
onLoginClick,
1819
}) => {
20+
const { t } = useTranslation();
21+
1922
return (
2023
<Box
2124
display="flex"
@@ -41,8 +44,7 @@ const AccountExistsCard: React.FC<AccountExistsCardProps> = ({
4144
verticalAlign: 'middle', // ensures vertical alignment
4245
}}
4346
>
44-
One or more accounts with this name, email ID, and/or phone number
45-
already exist, as listed below
47+
{t('NAVAPATHAM.ACCOUNT_ALREADY_EXISTS_MESSAGE')}
4648
</Typography>
4749

4850
<Typography
@@ -98,7 +100,7 @@ const AccountExistsCard: React.FC<AccountExistsCardProps> = ({
98100
lineHeight: 1.4,
99101
}}
100102
>
101-
Login with this username
103+
{t('NAVAPATHAM.LOGIN_WITH_USERNAME')}
102104
</Typography>
103105
</Box>
104106

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

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -172,14 +172,14 @@ const CreateAccountForm = ({
172172
textAlign: 'center',
173173
}}
174174
>
175-
Already signed up?{' '}
175+
{t('NAVAPATHAM.ALREADY_SIGNED_UP')} ?{' '}
176176
<Link
177177
href="/login"
178178
underline="hover"
179179
color="secondary"
180180
sx={{ fontWeight: '500' }}
181181
>
182-
Click here to login
182+
{t('NAVAPATHAM.CLICK_HERE_TO_LOGIN')}
183183
</Link>
184184
</Typography>
185185
</Box>
@@ -198,7 +198,7 @@ const CreateAccountForm = ({
198198
<Box display="flex" alignItems="center" gap={1} mb={2}>
199199
<Image src={face} alt="Step Icon" />
200200
<Typography fontWeight={600}>
201-
2/2 Create your username & password
201+
2/2 {t('NAVAPATHAM.CREATE_USERNAME_PASSWORD')}
202202
</Typography>
203203
</Box>
204204

@@ -213,12 +213,12 @@ const CreateAccountForm = ({
213213
mb: 3,
214214
}}
215215
>
216-
Tip: Note down your credentials somewhere safe so you have it handy!
216+
{t('NAVAPATHAM.CREDENTIALS_TIP')}
217217
</Alert>
218218

219219
{/* Username */}
220220
<TextField
221-
label="Username"
221+
label={t('NAVAPATHAM.USERNAME')}
222222
value={username}
223223
onChange={(e) => handleUsernameChange(e.target.value)}
224224
onBlur={(e) => handleUsernameBlur(e.target.value)}
@@ -227,13 +227,13 @@ const CreateAccountForm = ({
227227
error={!!usernameError}
228228
helperText={
229229
usernameError ||
230-
'Make it unique! Customise it with your birth date or lucky number'
230+
t('NAVAPATHAM.USERNAME_HELPER')
231231
}
232232
/>
233233

234234
{/* Password */}
235235
<TextField
236-
label="Password"
236+
label={t('NAVAPATHAM.PASSWORD')}
237237
type={showPassword ? 'text' : 'password'}
238238
value={password}
239239
onChange={(e) => onPasswordChange(e.target.value)}
@@ -244,7 +244,7 @@ const CreateAccountForm = ({
244244
<InputAdornment position="end">
245245
<IconButton onClick={togglePassword} edge="end">
246246
{showPassword ? <Visibility /> : <VisibilityOff />}
247-
</IconButton>
247+
</IconButton>
248248
</InputAdornment>
249249
),
250250
}}
@@ -261,7 +261,7 @@ const CreateAccountForm = ({
261261

262262
{/* Confirm Password */}
263263
<TextField
264-
label="Confirm Password"
264+
label={t('NAVAPATHAM.CONFIRM_PASSWORD')}
265265
type={showConfirm ? 'text' : 'password'}
266266
value={confirmPassword}
267267
onChange={(e) => onConfirmPasswordChange(e.target.value)}
@@ -305,7 +305,7 @@ const CreateAccountForm = ({
305305
color="#0071E3"
306306
onClick={handleConsentform}
307307
>
308-
Consent Form
308+
{t('NAVAPATHAM.CONSENT_FORM')}
309309
</Typography>
310310
.
311311
</Typography>
@@ -323,8 +323,7 @@ const CreateAccountForm = ({
323323
}
324324
label={
325325
<Typography variant="h3">
326-
I confirm this checkbox is filled out by the parent/guardian of
327-
the learner.
326+
{t('NAVAPATHAM.PARENT_GUARDIAN_CONFIRMATION')}
328327
</Typography>
329328
}
330329
/>
@@ -364,10 +363,10 @@ const CreateAccountForm = ({
364363
{isSubmitDisabled ? (
365364
<Box display="flex" alignItems="center" gap={1}>
366365
<CircularProgress size={20} sx={{ color: '#9E9E9E' }} />
367-
<span>Creating Account...</span>
366+
<span>{t('NAVAPATHAM.CREATING_ACCOUNT')}</span>
368367
</Box>
369368
) : (
370-
'Create Account'
369+
t('NAVAPATHAM.CREATE_ACCOUNT')
371370
)}
372371
</Button>
373372
</Box>

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

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ const EditProfile = ({ completeProfile, enrolledProgram, uponEnrollCompletion }:
9797
const [parentDataAddUiSchema, setParentDataAddUiSchema] = useState({});
9898
const [parentDataSchema, setParentDataSchema] = useState({});
9999

100-
101100
console.log('addSchema', addSchema);
102101

103102
// const [schema, setSchema] = useState(facilitatorSearchSchema);
@@ -127,7 +126,6 @@ const EditProfile = ({ completeProfile, enrolledProgram, uponEnrollCompletion }:
127126
]);
128127

129128
const responseFormForEnroll: any = await fetchForm([
130-
131129
{
132130
fetchUrl: `${process.env.NEXT_PUBLIC_MIDDLEWARE_URL}/form/read?context=${FormContext.learner.context}&contextType=${FormContext.learner.contextType}`,
133131
header: {
@@ -210,6 +208,10 @@ const EditProfile = ({ completeProfile, enrolledProgram, uponEnrollCompletion }:
210208

211209
//set 2 grid layout
212210
alterUISchema = enhanceUiSchemaWithGrid(alterUISchema);
211+
212+
// Add helper text to all CustomTextFieldWidget fields if isForNavaPatham is true
213+
alterUISchema = addHelperTextToTextFieldWidgets(alterUISchema);
214+
213215
console.log('alterUISchema', alterUISchema);
214216
if (!completeProfile) {
215217
alterUISchema = {
@@ -266,6 +268,47 @@ const EditProfile = ({ completeProfile, enrolledProgram, uponEnrollCompletion }:
266268
return enhancedSchema;
267269
};
268270

271+
const addHelperTextToTextFieldWidgets = (uiSchema: any): any => {
272+
// Check if isForNavaPatham is true in localStorage
273+
const isForNavaPatham =
274+
typeof window !== 'undefined'
275+
? localStorage.getItem('isForNavaPatham') === 'true'
276+
: false;
277+
278+
// If isForNavaPatham is not true, return the schema without modifications
279+
if (!isForNavaPatham) {
280+
return uiSchema;
281+
}
282+
283+
const enhancedSchema = { ...uiSchema };
284+
285+
Object.keys(enhancedSchema).forEach((fieldKey) => {
286+
// Skip ui:order and other non-field keys
287+
if (fieldKey === 'ui:order') return;
288+
289+
if (
290+
typeof enhancedSchema[fieldKey] === 'object' &&
291+
enhancedSchema[fieldKey] !== null
292+
) {
293+
// Check if this field uses CustomTextFieldWidget
294+
if (enhancedSchema[fieldKey]['ui:widget'] === 'CustomTextFieldWidget') {
295+
// Ensure ui:options exists
296+
if (!enhancedSchema[fieldKey]['ui:options']) {
297+
enhancedSchema[fieldKey]['ui:options'] = {};
298+
}
299+
300+
// Add helperText if it doesn't already exist
301+
if (!enhancedSchema[fieldKey]['ui:options'].helperText) {
302+
enhancedSchema[fieldKey]['ui:options'].helperText =
303+
'దయచేసి ఈ సమాచారాన్ని ఇంగ్లీష్ భాషలో మాత్రమే నమోదు చేయండి';
304+
}
305+
}
306+
}
307+
});
308+
309+
return enhancedSchema;
310+
};
311+
269312
// formData.mobile = '8793607919';
270313
// formData.firstName = 'karan';
271314
// formData.lastName = 'patil';
@@ -369,9 +412,6 @@ if(enrolledProgram && userTenantStatus){
369412
router.push('/content');
370413
}
371414
}
372-
373-
374-
375415
}
376416

377417
console.log(payload);

0 commit comments

Comments
 (0)