Skip to content

Commit

Permalink
Merge pull request #45 from Rushikesh-Sonawane99/release-1.0.0
Browse files Browse the repository at this point in the history
Issue #PS-1255 chore: Modified user-profile as per UI and modified data mapping for TL and FL profile to display details as per figma
  • Loading branch information
itsvick authored Jul 26, 2024
2 parents a56e4dc + 8f39146 commit a6e3f09
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 47 deletions.
1 change: 1 addition & 0 deletions src/components/CohortFacilitatorList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ const CohortLearnerList: React.FC<CohortLearnerListProp> = ({
statusReason={data.statusReason}
reloadState={reloadState}
setReloadState={setReloadState}
showMiniProfile={false}
/>
);
})}
Expand Down
1 change: 1 addition & 0 deletions src/components/CohortLearnerList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ const CohortLearnerList: React.FC<CohortLearnerListProp> = ({
statusReason={data.statusReason}
reloadState={reloadState}
setReloadState={setReloadState}
showMiniProfile= {true}
/>
);
})}
Expand Down
23 changes: 12 additions & 11 deletions src/components/LearnerModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import PropTypes from 'prop-types';
import { useRouter } from 'next/router';
import { useTheme } from '@mui/material/styles';
import { useTranslation } from 'next-i18next';
import { toPascalCase } from '@/utils/Helper';

const LearnerModal = ({
userId,
Expand Down Expand Up @@ -46,16 +47,16 @@ const LearnerModal = ({
(field.type === 'radio' && field.options && field.value.length)
) {
const selectedOption = field?.options?.find(
(option: any) => option.value === field.value[0]
(option: any) => option.value === field.value
);
return {
...field,
displayValue: selectedOption ? selectedOption?.label : field.value[0],
displayValue: selectedOption ? selectedOption?.label : field.value,
};
}
return {
...field,
displayValue: field.value[0],
displayValue: field.value,
};
});

Expand Down Expand Up @@ -131,7 +132,7 @@ const LearnerModal = ({
margin={0}
color={theme.palette.warning['A200']}
>
{userName}
{userName ? toPascalCase(userName) : ''}
</Typography>
</Box>
</Grid>
Expand All @@ -145,14 +146,12 @@ const LearnerModal = ({
fontWeight={'600'}
color={theme.palette.warning['500']}
>
{item?.label && item.name
{item?.label
? t(
`FIELDS.${item.name.toUpperCase()}`,
`FIELDS.${item.label.toUpperCase()}`,
item.label
)
: item.label}

{/* {item.label} */}
</Typography>
{/* <Box display="flex"> */}
<Typography
Expand All @@ -168,8 +167,10 @@ const LearnerModal = ({
// noWrap
>
{Array.isArray(item.displayValue)
? item.displayValue.join(', ')
: item?.displayValue}
? toPascalCase(item.displayValue.join(', '))
: item?.displayValue
? toPascalCase(item.displayValue)
: t('ATTENDANCE.N/A')}
</Typography>
{/* </Box> */}
</Grid>
Expand Down Expand Up @@ -197,7 +198,7 @@ const LearnerModal = ({
whiteSpace: 'normal',
}}
>
{contactNumber ? contactNumber : ''}
{contactNumber ? contactNumber : t('ATTENDANCE.N/A')}
</Typography>
</Box>
</Grid>
Expand Down
13 changes: 9 additions & 4 deletions src/components/LearnersListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const LearnersListItem: React.FC<LearnerListProps> = ({
setReloadState,
block,
center,
showMiniProfile
}) => {
const [state, setState] = React.useState({
bottom: false,
Expand Down Expand Up @@ -256,6 +257,10 @@ const LearnersListItem: React.FC<LearnerListProps> = ({
setIsModalOpenLearner(false);
};

const handleTeacherFullProfile = (userId: string) => {
router.push(`/user-profile/${userId}`);
};

const fetchUserDetails = async (userId: string) => {
try {
if (userId) {
Expand Down Expand Up @@ -388,10 +393,10 @@ const LearnersListItem: React.FC<LearnerListProps> = ({
<CustomLink className="word-break" href="#">
<Typography
onClick={() => {
handleOpenModalLearner(userId!);
ReactGA.event('learner-details-link-clicked', {
userId: userId,
});
showMiniProfile ? handleOpenModalLearner(userId!) : handleTeacherFullProfile(userId!);
// ReactGA.event('teacher-details-link-clicked', {
// userId: userId,
// });
}}
sx={{
textAlign: 'left',
Expand Down
12 changes: 7 additions & 5 deletions src/components/ManageUser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -442,9 +442,8 @@ const manageUsers: React.FC<ManageUsersProps> = ({
setReassignBlockRequestModalOpen(false);
};

const handleLearnerFullProfile = (userId: string) => {
// router.push(`/learner/${userId}`);
// router.push(`/profile/${userId}`);
const handleTeacherFullProfile = (userId: string) => {
router.push(`/user-profile/${userId}`);
};
const noop = () => {};

Expand Down Expand Up @@ -612,7 +611,10 @@ const manageUsers: React.FC<ManageUsersProps> = ({
<CustomLink className="word-break" href="#">
<Typography
onClick={() => {
handleLearnerFullProfile(user.userId!);
handleTeacherFullProfile(user.userId!);
// ReactGA.event('teacher-details-link-clicked', {
// userId: userId,
// });
}}
sx={{
textAlign: 'left',
Expand All @@ -638,7 +640,7 @@ const manageUsers: React.FC<ManageUsersProps> = ({
>
{user?.cohortNames
? `${user.cohortNames}`
: 'N/a'}
: t('ATTENDANCE.N/A')}
</Box>
</Box>
</Box>
Expand Down
37 changes: 11 additions & 26 deletions src/pages/user-profile/[userId].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import Modal from '@mui/material/Modal';
import PlaceOutlinedIcon from '@mui/icons-material/PlaceOutlined';
import ReactGA from 'react-ga4';
import { accessControl } from '../../../app.config';
import { getLabelForValue } from '@/utils/Helper';
import { getLabelForValue, toPascalCase } from '@/utils/Helper';
import { logEvent } from '@/utils/googleAnalytics';
import { serverSideTranslations } from 'next-i18next/serverSideTranslations';
import { showToastMessage } from '@/components/Toastify';
Expand Down Expand Up @@ -544,7 +544,7 @@ const TeacherProfile = () => {
className="text-dark-grey two-line-text"
mr={'40px'}
>
{userData?.name}
{toPascalCase(userData?.name)}
</Typography>
</Box>
</Box>
Expand Down Expand Up @@ -660,13 +660,8 @@ const TeacherProfile = () => {
sx={{ wordBreak: 'break-word' }}
color={theme.palette.warning['500']}
>
{item?.label && item.name
? t(
`FIELDS.${item.name.toUpperCase()}`,
item.label
)
: item.label}
{/* {item?.label} */}
{item?.label &&
t(`FIELDS.${item.label}`, item.label)}
</Typography>
<Box
mt={2}
Expand Down Expand Up @@ -719,21 +714,16 @@ const TeacherProfile = () => {
letterSpacing={'0.5px'}
color={theme.palette.warning['500']}
>
{item?.label && item.name
? t(
`FIELDS.${item.name.toUpperCase()}`,
item.label
)
: item.label}
{/* {item.label} */}
</Typography>
{item?.label &&
t(`FIELDS.${item.label}`, item.label)}
</Typography> {/* No of cluster */}
<Typography
variant="h4"
margin={0}
color={theme.palette.warning.A200}
sx={{ wordBreak: 'break-word' }}
>
{item.value}
{item.value ? toPascalCase(item.value): t('ATTENDANCE.N/A')}
</Typography>
</Grid>
);
Expand All @@ -749,21 +739,16 @@ const TeacherProfile = () => {
letterSpacing={'0.5px'}
color={theme.palette.warning['500']}
>
{item?.label && item.name
? t(
`FIELDS.${item.name.toUpperCase()}`,
item.label
)
: item.label}
{/* {item.label} */}
{item?.label && t(`FIELDS.${item.label}`, item.label)}
</Typography>
<Typography
variant="h4"
margin={0}
color={theme.palette.warning.A200}
sx={{ wordBreak: 'break-word' }}
>
{getLabelForValue(item, item.value[0])}
{item.value? toPascalCase(getLabelForValue(item, item.value)): t('ATTENDANCE.N/A')}{' '}
{/* apply elipses/ truncating here */}
</Typography>
</Grid>
);
Expand Down
2 changes: 1 addition & 1 deletion src/utils/Helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export const getDayMonthYearFormat = (dateString: string) => {
export const truncateURL = (
url: string,
maxLength: number,
isMobile: boolean
isMobile?: boolean
) => {
if (isMobile) {
return url.length > maxLength ? `${url.substring(0, maxLength)} ...` : url;
Expand Down
1 change: 1 addition & 0 deletions src/utils/Interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ export interface LearnerListProps {
setReloadState: React.Dispatch<React.SetStateAction<boolean>>;
block?: string;
center?: string;
showMiniProfile?: boolean;
}
export interface FacilitatorListParam {
limit: number;
Expand Down

0 comments on commit a6e3f09

Please sign in to comment.