Skip to content

Commit

Permalink
Merge pull request #50 from Rushikesh-Sonawane99/release-1.0.0
Browse files Browse the repository at this point in the history
Issue #PS-1271 chore: Mapped api response to display learner profile and added translations
  • Loading branch information
itsvick authored Jul 26, 2024
2 parents 9e0fc0d + f66f821 commit e72f86f
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 57 deletions.
29 changes: 23 additions & 6 deletions public/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -350,8 +350,6 @@
"SECOND_CHANCE_ALUMNI": "Second Chance Alumni",
"PRATHAM_TEAM_MEMBER": "Pratham Team Member",
"OTHER": "Other",
"AGE": "Age",
"GENDER": "Gender",
"MALE": "Male",
"FEMALE": "Female",
"LEARNERS_PRIMARY_WORK": "Learner's Primary Work",
Expand All @@ -363,7 +361,6 @@
"SELF_EMPLOYMENT": "Self-employment",
"UNEMPLOYED": "Unemployed",
"INVOLVED_IN_DOMESTIC_WORK": "Involved in domestic work",
"FATHER_NAME": "Father’s Name",
"ENTER_YOUR_FATHER_NAME": "Enter Your Father Name",
"CLASS_OR_LAST_PASSED_GRADE": "Class (Last passed grade)",
"NO_SCHOOLING": "No Schooling",
Expand All @@ -379,11 +376,9 @@
"STARTED_VOCATIONAL_COURSE": "Started vocational course",
"STARTED_A_JOB": "Started a job",
"SCHOOL_CLOSURE_DUE_TO_COVID": "School closure due to covid",
"MARITAL_STATUS": "Marital Status",
"UNMARRIED": "Unmarried",
"MARRIED": "Married",
"DIVORCED": "Divorced",
"PHONE_TYPE_AVAILABLE": "Type of Phone Available",
"SMARTPHONE": "Smartphone",
"KEYPAD": "Keypad",
"NO_PHONE": "No Phone",
Expand All @@ -393,10 +388,32 @@
"TYPE_OF_PHONE_AVAILABLE": "Type of Phone Available",
"REASON_FOR_DROP_OUT_FROM_SCHOOL": "Reason for drop out from School",
"EMAIL": "Email",
"DESIGNATION": "Designation",
"NO_OF_CLUSTERS": "Number of Clusters I Teach",
"YEAR_OF_JOINING_SCP": "Year of joining SCP",
"MAIN_SUBJECT": "My Main Subjects",
"SUBJECT_TAUGHT": "Subjects I Teach",
"GENDER": "Gender",
"UNIT_NAME": "Unit Name",
"UNIT_CODE": "Unit Code",
"ENROLLMENT_NUMBER": "Enrollment Number",
"BLOCK_NAME": "Block Name",
"STUDENT_TYPE": "Type of Learner",
"STATE_NAME": "State Name",
"SUPPORT_NEEDED": "Support needed",
"CLASS": "Class (Last passed grade)",
"FATHER_NAME": "Father’s Name",
"MARITAL_STATUS": "Marital Status",
"OWN_PHONE_CHECK": "Does the Learner Own the Phone?",
"PHONE_TYPE_AVAILABLE": "Type of Phone Available",
"DISTRICT_NAME": "District Name",
"AGE": "Age",
"PRIMARY_WORK": "Learner's Primary Work",
"MOBILISATION_METHOD": "How Was the Learner Mobilized?",
"MONTH_MOBILISATION": "Month of Mobilisation",
"DROP_OUT_REASON": "Reason for Drop Out From School",
"ASSIGN_CENTERS": "Assign Centers",
"TYPE_OF_COHORT": "Type of cohort",
"UNIT_NAME": "Unit name",
"NOTE_THIS_WILL_BE_CENTER_NAME": "Note this will be Center name"
},
"FORM_ERROR_MESSAGES": {
Expand Down
4 changes: 2 additions & 2 deletions src/components/LearnerModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ const LearnerModal = ({
? toPascalCase(item.displayValue.join(', '))
: item?.displayValue
? toPascalCase(item.displayValue)
: t('ATTENDANCE.N/A')}
: "-"}
</Typography>
{/* </Box> */}
</Grid>
Expand Down Expand Up @@ -198,7 +198,7 @@ const LearnerModal = ({
whiteSpace: 'normal',
}}
>
{contactNumber ? contactNumber : t('ATTENDANCE.N/A')}
{contactNumber ? contactNumber : "-"}
</Typography>
</Box>
</Grid>
Expand Down
66 changes: 33 additions & 33 deletions src/pages/learner/[userId].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import {
getCohortAttendance,
} from '@/services/AttendanceService';
import { editEditUser, getUserDetails } from '@/services/ProfileService';
import { formatSelectedDate, getTodayDate } from '@/utils/Helper';
import { formatSelectedDate, getTodayDate, toPascalCase } from '@/utils/Helper';

import CloseIcon from '@mui/icons-material/Close';
import CreateOutlinedIcon from '@mui/icons-material/CreateOutlined';
Expand Down Expand Up @@ -316,12 +316,18 @@ const LearnerProfile: React.FC = () => {
);
return {
...field,
displayValue: selectedOption ? selectedOption?.label : field.value[0],
displayValue: selectedOption
? selectedOption.label
: field.value
? toPascalCase(field.value)
: "-",
};
}
return {
...field,
displayValue: field.value[0],
displayValue: field.value
? toPascalCase(field.value)
: "-",
};
});

Expand Down Expand Up @@ -664,8 +670,8 @@ const LearnerProfile: React.FC = () => {
const userDetails = data;
try {
if (userId) {
console.log("HELLO");
console.log('HELLO');

const response = await editEditUser(user_id, userDetails);
ReactGA.event('edit-learner-profile-successful', { userId: userId });

Expand Down Expand Up @@ -1153,8 +1159,8 @@ const LearnerProfile: React.FC = () => {
}}
margin={0}
>
{item?.label && item.name
? t(`FIELDS.${item.name.toUpperCase()}`, item.label)
{item?.label
? t(`FORM.${item.label.toUpperCase()}`, item.label)
: item.label}
</Typography>

Expand Down Expand Up @@ -1426,11 +1432,10 @@ const LearnerProfile: React.FC = () => {
type="text"
sx={{ marginTop: '20px' }}
fullWidth
name={field.name}
name={field.label}
label={
field?.label && field.name
? t(`FIELDS.${field.name.toUpperCase()}`, field.label)
: field.label
field?.label &&
t(`FORM.${field.label.toUpperCase()}`, field.label)
}
variant="outlined"
inputProps={{
Expand All @@ -1451,11 +1456,10 @@ const LearnerProfile: React.FC = () => {
type="number"
sx={{ marginTop: '20px' }}
fullWidth
name={field.name}
name={field.label}
label={
field?.label && field.name
? t(`FIELDS.${field.name.toUpperCase()}`, field.label)
: field.label
field?.label &&
t(`FORM.${field.label.toUpperCase()}`, field.label)
}
variant="outlined"
value={fieldValue}
Expand Down Expand Up @@ -1491,9 +1495,8 @@ const LearnerProfile: React.FC = () => {
margin={0}
color={theme.palette.warning.A200}
>
{field?.label && field.name
? t(`FIELDS.${field.name.toUpperCase()}`, field.label)
: field.label}
{field?.label &&
t(`FORM.${field.label.toUpperCase()}`, field.label)}
</Typography>
{field.options?.map((option: any) => (
<FormGroup key={option.value}>
Expand Down Expand Up @@ -1526,25 +1529,23 @@ const LearnerProfile: React.FC = () => {
<Box marginTop={3} textAlign={'start'}>
<FormControl fullWidth>
<InputLabel id={`select-label-${field.fieldId}`}>
{field?.label && field.name
? t(
`FIELDS.${field.name.toUpperCase()}`,
field.label
)
: field.label}
{field?.label &&
t(
`FORM.${field.label.toUpperCase()}`,
field.label
)}
</InputLabel>
<Select
error={isError}
labelId={`select-label-${field.fieldId}`}
id={`select-${field.fieldId}`}
value={fieldValue}
label={
field?.label && field.name
? t(
`FIELDS.${field.name.toUpperCase()}`,
field.label
)
: field.label
field?.label &&
t(
`FORM.${field.label.toUpperCase()}`,
field.label
)
}
onChange={(e) =>
handleDropdownChange(field.fieldId, e.target.value)
Expand Down Expand Up @@ -1573,9 +1574,8 @@ const LearnerProfile: React.FC = () => {
margin={0}
color={theme.palette.warning.A200}
>
{field?.label && field.name
? t(`FIELDS.${field.name.toUpperCase()}`, field.label)
: field.label}
{field?.label &&
t(`FORM.${field.label.toUpperCase()}`, field.label)}
</Typography>
<RadioGroup
name={field.fieldId}
Expand Down
32 changes: 16 additions & 16 deletions src/pages/user-profile/[userId].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -202,15 +202,15 @@ const TeacherProfile = () => {
const teachSubjectsField = customFieldsData?.find(
(field) => field.name === 'subject_taught'
);
const mainSubjectsField = customFieldsData?.find(
const mainSubjectsField: any = customFieldsData?.find(
(field) => field.name === 'main_subject'
);

const teachSubjects: string[] = Array.isArray(teachSubjectsField?.value)
? teachSubjectsField?.value
const teachSubjects: string[] = teachSubjectsField
? teachSubjectsField?.value.split(',')
: [];
const mainSubjects: string[] = Array.isArray(mainSubjectsField?.value)
? mainSubjectsField?.value
const mainSubjects: string[] = mainSubjectsField
? mainSubjectsField?.value.split(',')
: [];

// Find mutual and remaining subjects
Expand Down Expand Up @@ -661,7 +661,7 @@ const TeacherProfile = () => {
color={theme.palette.warning['500']}
>
{item?.label &&
t(`FIELDS.${item.label}`, item.label)}
t(`FORM.${item.label}`, item.label)}
</Typography>
<Box
mt={2}
Expand Down Expand Up @@ -715,15 +715,15 @@ const TeacherProfile = () => {
color={theme.palette.warning['500']}
>
{item?.label &&
t(`FIELDS.${item.label}`, item.label)}
t(`FORM.${item.label}`, item.label)}
</Typography> {/* No of cluster */}
<Typography
variant="h4"
margin={0}
color={theme.palette.warning.A200}
sx={{ wordBreak: 'break-word' }}
>
{item.value ? toPascalCase(item.value): t('ATTENDANCE.N/A')}
{item.value ? toPascalCase(item.value): "-"}
</Typography>
</Grid>
);
Expand All @@ -739,15 +739,15 @@ const TeacherProfile = () => {
letterSpacing={'0.5px'}
color={theme.palette.warning['500']}
>
{item?.label && t(`FIELDS.${item.label}`, item.label)}
{item?.label && t(`FORM.${item.label}`, item.label)}
</Typography>
<Typography
variant="h4"
margin={0}
color={theme.palette.warning.A200}
sx={{ wordBreak: 'break-word' }}
>
{item.value? toPascalCase(getLabelForValue(item, item.value)): t('ATTENDANCE.N/A')}{' '}
{item.value? toPascalCase(getLabelForValue(item, item.value)): "-"}{' '}
{/* apply elipses/ truncating here */}
</Typography>
</Grid>
Expand Down Expand Up @@ -907,7 +907,7 @@ const TeacherProfile = () => {
label={
field?.label && field.name
? t(
`FIELDS.${field.name.toUpperCase()}`,
`FORM.${field.name.toUpperCase()}`,
field.label
)
: field.label
Expand Down Expand Up @@ -936,7 +936,7 @@ const TeacherProfile = () => {
label={
field?.label && field.name
? t(
`FIELDS.${field.name.toUpperCase()}`,
`FORM.${field.name.toUpperCase()}`,
field.label
)
: field.label
Expand Down Expand Up @@ -977,7 +977,7 @@ const TeacherProfile = () => {
>
{field?.label && field.name
? t(
`FIELDS.${field.name.toUpperCase()}`,
`FORM.${field.name.toUpperCase()}`,
field.label
)
: field.label}
Expand Down Expand Up @@ -1017,7 +1017,7 @@ const TeacherProfile = () => {
>
{field?.label && field.name
? t(
`FIELDS.${field.name.toUpperCase()}`,
`FORM.${field.name.toUpperCase()}`,
field.label
)
: field.label}
Expand All @@ -1029,7 +1029,7 @@ const TeacherProfile = () => {
label={
field?.label && field.name
? t(
`FIELDS.${field.name.toUpperCase()}`,
`FORM.${field.name.toUpperCase()}`,
field.label
)
: field.label
Expand Down Expand Up @@ -1070,7 +1070,7 @@ const TeacherProfile = () => {
>
{field?.label && field.name
? t(
`FIELDS.${field.name.toUpperCase()}`,
`FORM.${field.name.toUpperCase()}`,
field.label
)
: field.label}
Expand Down

0 comments on commit e72f86f

Please sign in to comment.