Skip to content

Commit c562cb8

Browse files
Merge remote-tracking branch 'upstream/release-1.15.0' into release-1.15.0
2 parents d54012f + e1a5086 commit c562cb8

File tree

11 files changed

+895
-13
lines changed

11 files changed

+895
-13
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@
184184
"REMEMBER_ME": "Remember Me",
185185
"CONFIRM_PASSWORD": "Confirm password",
186186
"RESET_PASSWORD": "Reset Password",
187+
"SET_PASSWORD": "Set Password",
187188
"CREATE_NEW": "Create a new, strong password that you don't use for other websites",
188189
"NOT_MATCH": "Passwords do not match",
189190
"CHARACTERS_LONG": "Passwords must be at least 8 characters long",

apps/teachers/src/pages/login.tsx

Lines changed: 68 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -126,16 +126,43 @@ const LoginComponent = () => {
126126
: '';
127127
const userId = receivedToken?.userId;
128128

129+
// Find the tenant data for the selected tenant
130+
const tenantData = receivedToken?.tenantData?.find(
131+
(tenant: any) => tenant.tenantId === tenantId
132+
);
133+
129134
if (receivedToken.tenantData && receivedToken.tenantData.length > 0) {
130135
localStorage.setItem('tenantName', tenantName);
131136
localStorage.setItem('tenantId', tenantId);
137+
138+
// Set templateId from tenant data
139+
localStorage.setItem('templtateId', tenantData?.templateId || '');
140+
141+
// Set channelId
142+
if (tenantData?.channelId) {
143+
localStorage.setItem('channelId', tenantData.channelId);
144+
}
145+
146+
// Set collectionFramework
147+
if (tenantData?.collectionFramework) {
148+
localStorage.setItem('collectionFramework', tenantData.collectionFramework);
149+
}
150+
151+
// Set uiConfig
152+
const uiConfig = tenantData?.params?.uiConfig;
153+
localStorage.setItem('uiConfig', JSON.stringify(uiConfig || {}));
154+
155+
// Set userProgram
156+
localStorage.setItem('userProgram', tenantName);
132157
} else {
133158
console.error('Tenant data not found in user response.');
134159
}
135160
localStorage.setItem('userId', userId);
136161
setUserId(userId);
137162

138163
if (token && userId) {
164+
// Set token cookie
165+
document.cookie = `token=${token}; path=/; secure; SameSite=Strict`;
139166
document.cookie = `authToken=${token}; path=/; secure; SameSite=Strict`;
140167
document.cookie = `userId=${userId}; path=/; secure; SameSite=Strict`;
141168

@@ -166,9 +193,11 @@ const LoginComponent = () => {
166193
}
167194

168195
localStorage.setItem('role', roleName);
196+
localStorage.setItem('roleName', roleName);
169197
localStorage.setItem('roleId', roleId || '');
170198
localStorage.setItem('userEmail', receivedToken?.email);
171199
localStorage.setItem('userName', receivedToken?.firstName);
200+
localStorage.setItem('firstName', receivedToken?.firstName || '');
172201
localStorage.setItem('userIdName', receivedToken?.username);
173202
localStorage.setItem(
174203
'temporaryPassword',
@@ -183,7 +212,8 @@ const LoginComponent = () => {
183212
tenant?.toLocaleLowerCase() ===
184213
TENANT_DATA?.SECOND_CHANCE_PROGRAM?.toLowerCase() ||
185214
tenant?.toLocaleLowerCase() === TENANT_DATA?.PRATHAM_SCP?.toLowerCase() ||
186-
tenant?.toLocaleLowerCase() === TENANT_DATA?.YOUTHNET?.toLowerCase()
215+
tenant?.toLocaleLowerCase() === TENANT_DATA?.YOUTHNET?.toLowerCase() ||
216+
tenant?.toLocaleLowerCase() === TENANT_DATA?.PRAGYANPATH?.toLowerCase()
187217
) {
188218
const userDetails = await getUserDetails(userId, true);
189219
console.log(userDetails);
@@ -193,12 +223,14 @@ const LoginComponent = () => {
193223
const customFields = userDetails?.result?.userData?.customFields;
194224
if (customFields?.length) {
195225
// set customFields in userData
196-
let userDataString = localStorage.getItem('userData');
197-
let userData: any = userDataString
226+
const userDataString = localStorage.getItem('userData');
227+
const userData: any = userDataString
198228
? JSON.parse(userDataString)
199229
: null;
200-
userData.customFields = customFields;
201-
localStorage.setItem('userData', JSON.stringify(userData));
230+
if (userData) {
231+
userData.customFields = customFields;
232+
localStorage.setItem('userData', JSON.stringify(userData));
233+
}
202234
const state = customFields.find(
203235
(field: any) => field?.label === 'STATE'
204236
);
@@ -232,10 +264,38 @@ const LoginComponent = () => {
232264
}
233265
}
234266

267+
// Check for temporary password first
268+
235269
if (activeSessionId && tenant?.toLocaleLowerCase() === TENANT_DATA?.SECOND_CHANCE_PROGRAM?.toLowerCase()) {
236-
router.push('/teacher');
237-
}else if (tenant?.toLocaleLowerCase() === TENANT_DATA?.YOUTHNET?.toLowerCase()){
270+
{
271+
router.push('/teacher');
272+
}
273+
} else if (tenant?.toLocaleLowerCase() === TENANT_DATA?.YOUTHNET?.toLowerCase()) {
238274
router.push('/youth');
275+
276+
} else if (tenant?.toLocaleLowerCase() === TENANT_DATA?.PRAGYANPATH?.toLowerCase()) {
277+
278+
if (activeSessionId) {
279+
localStorage.setItem('academicYearId', activeSessionId);
280+
}
281+
282+
// Check if user has Lead role for PRAGYANPATH
283+
const hasLead = receivedToken?.tenantData?.some((tenant: any) =>
284+
tenant.roles.some((role: any) => role.roleName.toLowerCase().includes("lead"))
285+
);
286+
287+
if (hasLead && roleName.toLowerCase().includes('lead')) {
288+
// For Lead role, set managrUserId for manager dashboard
289+
localStorage.setItem('managrUserId', userId);
290+
291+
// Redirect to manager dashboard in youthNet MFE
292+
{
293+
router.push('/youthnet/manager-dashboard');
294+
}
295+
} else {
296+
// For other roles, redirect to youthNet MFE
297+
router.push('/youthnet');
298+
}
239299
}
240300
console.log('userDetails', userDetails);
241301
}
@@ -247,7 +307,7 @@ const LoginComponent = () => {
247307
localStorage.getItem('role') === RoleNames.TEACHER ||
248308
localStorage.getItem('role') === RoleNames.TEAM_LEADER
249309
)
250-
router.push('/youth');
310+
router.push('/youthnet');
251311
else router.push('/unauthorized');
252312
}
253313
}

mfes/workspace/src/components/KaTableComponent.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ const KaTableComponent: React.FC<CustomTableProps> = ({
127127
mode =
128128
content?.status === 'Draft' || content?.status === 'Live'
129129
? 'edit'
130-
: getLocalStoredUserRole() === Role.CCTA ? 'read' : 'review';
130+
: getLocalStoredUserRole() === Role.SCTA ? 'read' : 'review';
131131
break;
132132

133133
default:

mfes/youthNet/public/locales/en/common.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@
184184
"REMEMBER_ME": "Remember Me",
185185
"CONFIRM_PASSWORD": "Confirm password",
186186
"RESET_PASSWORD": "Reset Password",
187+
"SET_PASSWORD": "Set Password",
187188
"CREATE_NEW": "Create a new, strong password that you don't use for other websites",
188189
"NOT_MATCH": "Passwords do not match",
189190
"CHARACTERS_LONG": "Passwords must be at least 8 characters long",
Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
import * as React from 'react';
2+
import Box from '@mui/material/Box';
3+
import Button from '@mui/material/Button';
4+
import Modal from '@mui/material/Modal';
5+
import { Divider } from '@mui/material';
6+
import { useTheme } from '@mui/material/styles';
7+
import CheckCircleOutlineIcon from '@mui/icons-material/CheckCircleOutline';
8+
export interface CentralizedModalProps {
9+
title?: string;
10+
subTitle?: string;
11+
secondary?: string;
12+
primary?: string;
13+
modalOpen?: boolean;
14+
handlePrimaryButton?: () => void;
15+
handleSkipButton?: () => void;
16+
icon?: boolean;
17+
}
18+
export const modalStyles = (theme: any, width?: string) => ({
19+
width: width ?? '85%',
20+
position: 'absolute',
21+
top: '50%',
22+
left: '50%',
23+
transform: 'translate(-50%, -50%)',
24+
backgroundColor: theme.palette.warning.A400,
25+
borderRadius: '8px',
26+
zIndex: '9999',
27+
outline: 'none',
28+
boxShadow: '0px 4px 10px rgba(0, 0, 0, 0.1)',
29+
'@media (min-width: 600px)': {
30+
width: '450px',
31+
},
32+
});
33+
const CentralizedModal: React.FC<CentralizedModalProps> = ({
34+
title,
35+
subTitle,
36+
secondary,
37+
primary,
38+
modalOpen = false,
39+
handlePrimaryButton,
40+
handleSkipButton,
41+
icon,
42+
}) => {
43+
const [open, setOpen] = React.useState(modalOpen);
44+
45+
React.useEffect(() => {
46+
setOpen(modalOpen);
47+
}, [modalOpen]);
48+
49+
const theme = useTheme<any>();
50+
const handleClose = () => setOpen(false);
51+
52+
return (
53+
<Modal
54+
open={open}
55+
// onClose={handleClose}
56+
aria-labelledby="modal-modal-title"
57+
aria-describedby="modal-modal-description"
58+
>
59+
<Box sx={modalStyles}>
60+
<Box sx={{ padding: '16px' }}>
61+
<Box
62+
sx={{
63+
fontSize: '22px',
64+
color: theme.palette.warning['A200'],
65+
fontWeight: '400',
66+
textAlign: 'center',
67+
}}
68+
>
69+
{title}
70+
</Box>
71+
{icon && (
72+
<Box sx={{ display: 'flex', justifyContent: 'center' }}>
73+
<CheckCircleOutlineIcon
74+
sx={{ color: theme.palette.success.main, fontSize: '33px' }}
75+
/>
76+
</Box>
77+
)}
78+
<Box
79+
sx={{
80+
fontSize: '16px',
81+
fontWeight: '400',
82+
color: theme,
83+
textAlign: 'center',
84+
pt: '12px',
85+
}}
86+
>
87+
{subTitle}
88+
</Box>
89+
</Box>
90+
<Box sx={{ my: 1.2 }}>
91+
<Divider sx={{ color: theme.palette.warning['A100'] }} />
92+
</Box>
93+
94+
<Box
95+
sx={{
96+
display: 'flex',
97+
justifyContent: 'center',
98+
gap: '12px',
99+
my: 2,
100+
}}
101+
>
102+
{secondary && (
103+
<Button
104+
className="one-line-text"
105+
sx={{
106+
width: 'auto',
107+
height: '40px',
108+
fontSize: '14px',
109+
fontWeight: '500',
110+
border: 'none',
111+
color: theme.palette.secondary.main,
112+
'&:hover': {
113+
border: 'none',
114+
backgroundColor: 'transparent',
115+
},
116+
}}
117+
variant="outlined"
118+
color="primary"
119+
onClick={() => {
120+
handleClose();
121+
if (handleSkipButton) {
122+
handleSkipButton();
123+
}
124+
}}
125+
>
126+
{secondary}
127+
</Button>
128+
)}
129+
{primary && (
130+
<Button
131+
className="one-line-text"
132+
sx={{
133+
width: '151px',
134+
height: '40px',
135+
fontSize: '14px',
136+
fontWeight: '500',
137+
}}
138+
variant="contained"
139+
color="primary"
140+
onClick={handlePrimaryButton}
141+
>
142+
{primary}
143+
</Button>
144+
)}
145+
</Box>
146+
</Box>
147+
</Modal>
148+
);
149+
};
150+
151+
export default CentralizedModal;

0 commit comments

Comments
 (0)