Skip to content

Commit

Permalink
Merge pull request #648 from Aar-if/subzero
Browse files Browse the repository at this point in the history
Issue #PS-3374 feat:  Generic Profile Component (YouthNet)
  • Loading branch information
itsvick authored Jan 28, 2025
2 parents 0093b4b + 265a175 commit c262be9
Show file tree
Hide file tree
Showing 11 changed files with 381 additions and 17 deletions.
14 changes: 14 additions & 0 deletions public/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,20 @@
"ENTRIES": "Entries",
"VOLUNTEERS_ASSIGNED": "Volunteers assigned"
},
"YOUTHNET_PROFILE": {
"MY_PROFILE": "My Profile",
"ACTIVITIES_CONDUCTED": "Activities conducted",
"PROFILE_DETAILS": "Profile Details",
"FULL_NAME": "Full Name",
"EMAIL_ID": "Email ID",
"STATE_DISTRICT_BLOCK": "State District Block",
"DESIGNATION": "Designation",
"JOINED_ON": "Joined on",
"PHONE_NUMBER": "Phone Number",
"MENTOR_ID": "Mentor ID",
"GENDER": "Gender",
"AGE": "Age"
},
"YOUTHNET_CAMP_DETAILS": {
"SUBMISSION": "Submission",
"SUMMARY": "Summary"
Expand Down
15 changes: 15 additions & 0 deletions public/locales/hi/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,21 @@
"ENTRIES": "प्रविष्टियाँ",
"VOLUNTEERS_ASSIGNED": "स्वयंसेवक सौंपे गए"
},
"YOUTHNET_PROFILE": {
"MY_PROFILE": "मेरा प्रोफाइल",
"ACTIVITIES_CONDUCTED": "संचालित गतिविधियाँ",
"PROFILE_DETAILS": "प्रोफाइल विवरण",
"FULL_NAME": "पूरा नाम",
"EMAIL_ID": "ईमेल आईडी",
"STATE_DISTRICT_BLOCK": "राज्य जिला ब्लॉक",
"DESIGNATION": "पद",
"JOINED_ON": "जुड़े दिनांक",
"PHONE_NUMBER": "फोन नंबर",
"MENTOR_ID": "मेंटोर आईडी",
"GENDER": "लिंग",
"AGE": "आयु"
},

"YOUTHNET_CAMP_DETAILS": {
"SUBMISSION": "प्रस्तुत करना",
"SUMMARY": "सारांश"
Expand Down
15 changes: 15 additions & 0 deletions public/locales/mr/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,21 @@
"BELOW_18": "18 वर्षांखालील नोंदणी",
"VLLAGE_18": "आजची नवीन नोंदणी"
},
"YOUTHNET_PROFILE": {
"MY_PROFILE": "माझा प्रोफाइल",
"ACTIVITIES_CONDUCTED": "संचालित क्रियाकलाप",
"PROFILE_DETAILS": "प्रोफाइल तपशील",
"FULL_NAME": "पूर्ण नाव",
"EMAIL_ID": "ईमेल आयडी",
"STATE_DISTRICT_BLOCK": "राज्य जिल्हा ब्लॉक",
"DESIGNATION": "पद",
"JOINED_ON": "जोडलेले",
"PHONE_NUMBER": "फोन नंबर",
"MENTOR_ID": "मेंटर आयडी",
"GENDER": "लिंग",
"AGE": "वय"
},

"YOUTHNET_VOLUNTEERLIST": {
"ENTRIES": "नोंदी",
"VOLUNTEERS_ASSIGNED": "स्वयंसेवक नियुक्त"
Expand Down
26 changes: 15 additions & 11 deletions src/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { useDirection } from '../hooks/useDirection';
import useStore from '../store/store';
import ConfirmationModal from './ConfirmationModal';
import StyledMenu from './StyledMenu';
import { TENANT_DATA } from '../../app.config';

interface HeaderProps {
toggleDrawer?: (newOpen: boolean) => () => void;
Expand Down Expand Up @@ -63,8 +64,16 @@ const Header: React.FC<HeaderProps> = ({ toggleDrawer, openDrawer }) => {
}, []);

const handleProfileClick = () => {
const tenant = localStorage.getItem('tenantName');
if (pathname !== `/user-profile/${userId}`) {
router.push(`/user-profile/${userId}`);
if (tenant?.toLowerCase() === TENANT_DATA.YOUTHNET?.toLowerCase()) {
router.push(`youthboard/user-profile/${userId}`);
} else if (
tenant?.toLowerCase() ===
TENANT_DATA.SECOND_CHANCE_PROGRAM?.toLowerCase()
) {
router.push(`/user-profile/${userId}`);
}
logEvent({
action: 'my-profile-clicked-header',
category: 'Dashboard',
Expand All @@ -73,7 +82,7 @@ const Header: React.FC<HeaderProps> = ({ toggleDrawer, openDrawer }) => {
}
};

const handleLogoutClick = async() => {
const handleLogoutClick = async () => {
router.replace('/logout');
logEvent({
action: 'logout-clicked-header',
Expand All @@ -82,11 +91,11 @@ const Header: React.FC<HeaderProps> = ({ toggleDrawer, openDrawer }) => {
});
const token = localStorage.getItem('token');

const tenantid = localStorage.getItem('tenantId')
const tenantid = localStorage.getItem('tenantId');
const deviceID = localStorage.getItem('deviceID');
const windowUrl = window.location.pathname;
const cleanedUrl = windowUrl.replace(/^\//, '');
const env = cleanedUrl.split("/")[0];
const env = cleanedUrl.split('/')[0];
const telemetryInteract = {
context: {
env: env,
Expand All @@ -103,7 +112,6 @@ const Header: React.FC<HeaderProps> = ({ toggleDrawer, openDrawer }) => {
telemetryFactory.interact(telemetryInteract);
if (deviceID) {
try {

const tenantId = tenantid;

const headers = {
Expand All @@ -117,10 +125,7 @@ const Header: React.FC<HeaderProps> = ({ toggleDrawer, openDrawer }) => {
headers
);
} catch (updateError) {
console.error(
'Error updating device notification:',
updateError
);
console.error('Error updating device notification:', updateError);
}
}
};
Expand Down Expand Up @@ -299,9 +304,8 @@ const Header: React.FC<HeaderProps> = ({ toggleDrawer, openDrawer }) => {
setLanguage={setLanguage}
/>
</Box>
<Box sx={{marginTop:'10px'}}></Box>
<Box sx={{ marginTop: '10px' }}></Box>
</>

);
};

Expand Down
1 change: 1 addition & 0 deletions src/components/youthNet/MonthlyRegistrationsChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const MonthlyRegistrationsChart: React.FC = () => {
marginBottom: '10px',
marginTop: 0,
}}
suppressHydrationWarning
>
{t('YOUTHNET_DASHBOARD.MONTHLY_REGISTRATIONS_OVERVIEW')}
</h3>
Expand Down
178 changes: 178 additions & 0 deletions src/components/youthNet/Profile.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
import React from 'react';
import { Card, CardContent, Typography, Grid } from '@mui/material';
import { useTheme } from '@mui/material/styles';
import { useTranslation } from 'react-i18next';

interface ProfileDetailsProps {
fullName: string;
emailId: string;
state?: string;
district?: string;
block?: string;
designation?: string;
joinedOn?: string;
phoneNumber?: string;
mentorId?: string;
gender?: string;
age?: number;
}

const Profile: React.FC<ProfileDetailsProps> = ({
fullName,
emailId,
state,
district,
block,
designation,
joinedOn,
phoneNumber,
mentorId,
gender,
age,
}) => {
const { t } = useTranslation();
const theme = useTheme<any>();
return (
<Card
sx={{
borderRadius: '16px',
boxShadow: 0,
border: `1px solid ${theme.palette.warning['A100']}`,
mt: 2,
}}
>
<CardContent>
<Typography
color={theme.palette.warning['500']}
sx={{ fontSize: '12px', fontWeight: 600 }}
>
{t('YOUTHNET_PROFILE.FULL_NAME')}
</Typography>
<Typography
color={theme.palette.warning['A200']}
sx={{ fontSize: '16px', fontWeight: 400 }}
gutterBottom
>
{fullName}
</Typography>

<Typography
color={theme.palette.warning['500']}
sx={{ fontSize: '12px', fontWeight: 600, mt: 2 }}
>
{t('YOUTHNET_PROFILE.EMAIL_ID')}
</Typography>
<Typography
color={theme.palette.warning['A200']}
sx={{ fontSize: '16px', fontWeight: 400 }}
gutterBottom
>
{emailId}
</Typography>

<Typography
color={theme.palette.warning['500']}
sx={{ fontSize: '12px', fontWeight: 600, mt: 2 }}
>
{t('YOUTHNET_PROFILE.STATE_DISTRICT_BLOCK')}
</Typography>
<Typography
color={theme.palette.warning['A200']}
sx={{ fontSize: '16px', fontWeight: 400 }}
gutterBottom
>
{state}, {district}, {block}
</Typography>

<Grid container spacing={2}>
<Grid item xs={6}>
<Typography
color={theme.palette.warning['500']}
sx={{ fontSize: '12px', fontWeight: 600, mt: 2 }}
>
{t('YOUTHNET_PROFILE.DESIGNATION')}
</Typography>
<Typography
color={theme.palette.warning['A200']}
sx={{ fontSize: '16px', fontWeight: 400 }}
>
{designation}
</Typography>
</Grid>
<Grid item xs={6}>
<Typography
color={theme.palette.warning['500']}
sx={{ fontSize: '12px', fontWeight: 600, mt: 2 }}
>
{t('YOUTHNET_PROFILE.JOINED_ON')}
</Typography>
<Typography
color={theme.palette.warning['A200']}
sx={{ fontSize: '16px', fontWeight: 400 }}
>
{joinedOn}
</Typography>
</Grid>
</Grid>

<Grid container spacing={2}>
<Grid item xs={6}>
<Typography
color={theme.palette.warning['500']}
sx={{ fontSize: '12px', fontWeight: 600, mt: 2 }}
>
{t('YOUTHNET_PROFILE.PHONE_NUMBER')}
</Typography>
<Typography
color={theme.palette.warning['A200']}
sx={{ fontSize: '16px', fontWeight: 400 }}
>
{phoneNumber}
</Typography>
</Grid>
<Grid item xs={6}>
<Typography
color={theme.palette.warning['500']}
sx={{ fontSize: '12px', fontWeight: 600, mt: 2 }}
>
{t('YOUTHNET_PROFILE.MENTOR_ID')}
</Typography>
<Typography
color={theme.palette.warning['A200']}
sx={{ fontSize: '16px', fontWeight: 400 }}
>
{mentorId}
</Typography>
</Grid>
</Grid>

<Grid container spacing={2}>
<Grid item xs={6}>
<Typography
color={theme.palette.warning['500']}
sx={{ fontSize: '12px', fontWeight: 600, mt: 2 }}
>
{t('YOUTHNET_PROFILE.GENDER')}
</Typography>
<Typography color={theme.palette.warning['A200']}>
{gender}
</Typography>
</Grid>
<Grid item xs={6}>
<Typography
color={theme.palette.warning['500']}
sx={{ fontSize: '12px', fontWeight: 600, mt: 2 }}
>
{t('YOUTHNET_PROFILE.AGE')}
</Typography>
<Typography sx={{ fontSize: '16px', fontWeight: 400 }}>
{age}
</Typography>
</Grid>
</Grid>
</CardContent>
</Card>
);
};

export default Profile;
5 changes: 2 additions & 3 deletions src/components/youthNet/VillageDetailCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const VillageDetailCard: React.FC<VillageDetailProps> = ({
border: `1px solid ${theme.palette.warning['A100']}`,
bgcolor: theme.palette.warning['800'],
padding: '12px',

margin: '20px',
borderRadius: '16px',
height: '64px',
Expand All @@ -39,7 +40,7 @@ const VillageDetailCard: React.FC<VillageDetailProps> = ({
<Image src={imageSrc} alt="Icon" width={40} height={40} />
)}

<Box display="flex" flexDirection="column" justifyContent="center">
<Box display="flex" flexDirection="column" minHeight="40px" mt={2.5}>
{title && (
<Typography
variant="subtitle1"
Expand All @@ -62,8 +63,6 @@ const VillageDetailCard: React.FC<VillageDetailProps> = ({
variant="body2"
sx={{
fontSize: '12px',
fontWeight: 400,
lineHeight: '1.2',
color: '#635E57',
overflow: 'hidden',
textOverflow: 'ellipsis',
Expand Down
4 changes: 3 additions & 1 deletion src/pages/youthboard/campDetails/[surveyCamp].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import { useTheme } from '@mui/material/styles';
import { useTranslation } from 'next-i18next';
import EntrySlider from '@/components/youthNet/EntrySlider';
import EntryContent from '@/components/youthNet/EntryContent';
import withRole from '@/components/withRole';
import { TENANT_DATA } from '../../../../app.config';

const SurveyClassDetails = () => {
const { t } = useTranslation();
Expand Down Expand Up @@ -127,4 +129,4 @@ const SurveyClassDetails = () => {
);
};

export default SurveyClassDetails;
export default withRole(TENANT_DATA.YOUTHNET)(SurveyClassDetails);
Loading

0 comments on commit c262be9

Please sign in to comment.