Skip to content

Commit b305931

Browse files
committed
conflicts solved prd merge into feat
2 parents 50ce29a + 6aa4f85 commit b305931

File tree

28 files changed

+326
-163
lines changed

28 files changed

+326
-163
lines changed

apps/admin-app-repo/src/components/DeleteUserModal.tsx

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,24 @@ const DeleteUserModal: React.FC<DeleteUserModalProps> = ({
125125
overflowY: "auto",
126126
}}
127127
>
128-
{centers}
128+
{typeof centers === "string"
129+
? centers.split(", ").map((center: string, index: number) => (
130+
<Typography
131+
key={center.trim()}
132+
variant="body2"
133+
sx={{
134+
padding: "4px 6px",
135+
borderBottom:
136+
index < centers.split(", ").length - 1
137+
? "1px solid #f0f0f0"
138+
: "none",
139+
color: "#333",
140+
}}
141+
>
142+
{center.trim()}
143+
</Typography>
144+
))
145+
: centers}
129146
</Box>
130147

131148
<FormControlLabel

apps/admin-app-repo/src/pages/sso/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ const SSOContent = () => {
209209
}
210210

211211
localStorage.setItem('firstName', userResponse?.firstName);
212+
localStorage.setItem('lastName', userResponse?.lastName);
212213
localStorage.setItem(Storage.USER_DATA, JSON.stringify(userResponse));
213214

214215
setTimeout(async () => {
Lines changed: 26 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,37 @@
1-
import HeaderWrapper from '@/components/layouts/header/HeaderWrapper';
21
import { serverSideTranslations } from 'next-i18next/serverSideTranslations';
3-
import dynamic from 'next/dynamic';
42
import React, { useEffect } from 'react';
53

6-
// const index = () => {
7-
// const mfe_workspace = process.env.NEXT_PUBLIC_WORKSPACE;
8-
// if (typeof window !== "undefined" && window.localStorage) {
9-
// localStorage.setItem("showHeader" , "true")
10-
// }
11-
// console.log(mfe_workspace);
12-
13-
// return (
14-
// <>
15-
// {/* <HeaderWrapper /> */}
16-
// {/* <div
17-
// style={{
18-
// padding: 0,
19-
// height: '100vh',
20-
// width: '100vw',
21-
// overflow: 'hidden',
22-
// }}
23-
// > */}
24-
25-
// <iframe
26-
// src={mfe_workspace}
27-
// style={{
28-
// display: 'block',
29-
// // marginTop: 65,
30-
// padding: 0,
31-
// width: '100vw',
32-
// height: '100vh',
33-
// border: 'none',
34-
// }}
35-
// title="Embedded Localhost"
36-
// />
37-
// {/* </div> */}
38-
// </>
39-
// );
40-
// };
41-
42-
// export async function getStaticProps({ locale }: any) {
43-
// return {
44-
// props: {
45-
// noLayout: true,
46-
// ...(await serverSideTranslations(locale, ["common"])),
47-
// },
48-
// };
49-
// }
50-
51-
// export default index;
52-
53-
import { useRouter } from 'next/router';
54-
554
const HomePage = () => {
56-
const router = useRouter();
575
const path = process.env.NEXT_PUBLIC_WORKSPACE;
6+
587
useEffect(() => {
59-
router.push(path || '/'); // Replace with target page URL
60-
}, []);
8+
// Set showHeader flag before redirecting to workspace MFE
9+
if (typeof window !== 'undefined' && window.localStorage) {
10+
localStorage.setItem('showHeader', 'true');
11+
}
12+
13+
// Use window.location.href for external MFE URL navigation.
14+
// router.push() is only for internal Next.js routes — using it with
15+
// an external URL causes a crash/abort in the router.
16+
if (path) {
17+
if (typeof globalThis !== 'undefined' && globalThis.location) {
18+
globalThis.location.href = path;
19+
}
20+
}
21+
}, [path]);
6122

62-
if (typeof window !== 'undefined' && window.localStorage) {
63-
localStorage.setItem('showHeader', 'true');
64-
}
6523
return <div>Redirecting...</div>;
6624
};
6725

26+
// Required so next-i18next loads the 'common' namespace for this page.
27+
// Without this, the sidebar's useTranslation() has no translation data
28+
// while this page is mounted, causing raw translation keys to flash.
29+
export async function getStaticProps({ locale }: { locale: string }) {
30+
return {
31+
props: {
32+
...(await serverSideTranslations(locale, ['common'])),
33+
},
34+
};
35+
}
36+
6837
export default HomePage;

apps/learner-web-app/src/app/api/analytics/pageviews/route.ts

Lines changed: 53 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import "server-only";
22

33
import { NextRequest, NextResponse } from "next/server";
4-
import { BetaAnalyticsDataClient } from "@google-analytics/data";
4+
import { BetaAnalyticsDataClient, protos } from "@google-analytics/data";
5+
6+
type IFilterExpression = protos.google.analytics.data.v1beta.IFilterExpression;
7+
type IRunReportResponse = protos.google.analytics.data.v1beta.IRunReportResponse;
58
// import serviceAccount from "../../../../utils/service-account";
69
interface ServiceAccountConfig {
710
type?: string;
@@ -160,13 +163,6 @@ export async function GET(request: NextRequest) {
160163
const startDateParam = searchParams.get("startDate");
161164
const endDateParam = searchParams.get("endDate");
162165

163-
if (!pagePath) {
164-
return NextResponse.json(
165-
{ error: "Query parameter 'path' is required" },
166-
{ status: 400 }
167-
);
168-
}
169-
170166
const dateRegex = /^\d{4}-\d{2}-\d{2}$/;
171167
let startDate: string;
172168
let endDate: string;
@@ -196,48 +192,60 @@ export async function GET(request: NextRequest) {
196192
endDate = end;
197193
}
198194

195+
// Build dimension filter:
196+
// - If pagePath is provided: filter by BOTH pagePath AND eventName=page_view
197+
// - If no pagePath: filter only by eventName=page_view (returns total across all pages)
198+
const dimensionFilter: IFilterExpression = pagePath
199+
? {
200+
andGroup: {
201+
expressions: [
202+
{
203+
filter: {
204+
fieldName: "pagePath",
205+
stringFilter: { matchType: "EXACT" as const, value: pagePath },
206+
},
207+
},
208+
{
209+
filter: {
210+
fieldName: "eventName",
211+
stringFilter: { matchType: "EXACT" as const, value: "page_view" },
212+
},
213+
},
214+
],
215+
},
216+
}
217+
: {
218+
filter: {
219+
fieldName: "eventName",
220+
stringFilter: { matchType: "EXACT" as const, value: "page_view" },
221+
},
222+
};
223+
199224
const analyticsDataClient = getAnalyticsClient();
200-
const [report] = await analyticsDataClient.runReport({
225+
const reportResponse = await analyticsDataClient.runReport({
201226
property: `properties/${PROPERTY_ID}`,
202-
//dimensions: [{ name: "pagePath" }],
203-
dimensions: [
204-
{ name: "pagePath" },
205-
{ name: "eventName" },
206-
],
207-
// metrics: [{ name: "screenPageViews" }],
208-
metrics: [{ name: "eventCount" }],
209-
210-
dimensionFilter: {
211-
andGroup: {
212-
expressions: [
213-
{
214-
filter: {
215-
fieldName: "pagePath",
216-
stringFilter: { matchType: "EXACT", value: pagePath },
217-
},
218-
},
219-
{
220-
filter: {
221-
fieldName: "eventName",
222-
stringFilter: { matchType: "EXACT", value: "page_view" },
223-
},
224-
},
225-
],
226-
},
227-
},
228-
229-
// dimensionFilter: {
230-
// filter: {
231-
// fieldName: "pagePath",
232-
// stringFilter: { matchType: "EXACT", value: pagePath },
233-
// },
234-
// },
227+
dimensions: pagePath
228+
? [{ name: "pagePath" }, { name: "eventName" }]
229+
: [{ name: "eventName" }],
230+
metrics: [{ name: "eventCount" }],
231+
dimensionFilter,
235232
dateRanges: [{ startDate, endDate }],
236-
limit: 1,
233+
limit: pagePath ? 1 : undefined,
237234
});
235+
const report = (reportResponse as unknown as [IRunReportResponse])[0];
238236

239-
const rawValue = report.rows?.[0]?.metricValues?.[0]?.value ?? "0";
240-
const pageViews = Number.parseInt(rawValue, 10) || 0;
237+
// When pagePath is provided, take the single matched row.
238+
// When no pagePath, sum all rows to get the total page_view count across all pages.
239+
let pageViews: number;
240+
if (pagePath) {
241+
const rawValue = report.rows?.[0]?.metricValues?.[0]?.value ?? "0";
242+
pageViews = Number.parseInt(rawValue, 10) || 0;
243+
} else {
244+
pageViews = (report.rows ?? []).reduce((sum: number, row: protos.google.analytics.data.v1beta.IRow) => {
245+
const val = Number.parseInt(row.metricValues?.[0]?.value ?? "0", 10) || 0;
246+
return sum + val;
247+
}, 0);
248+
}
241249

242250
return NextResponse.json({ pageViews });
243251
} catch (error) {

apps/learner-web-app/src/app/enroll-profile-completion/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ const EnrollProfileCompletionInner = () => {
8989
localStorage.setItem('templtateId', tenantData?.templateId);
9090
localStorage.setItem('userIdName', userResponse?.result?.userData?.username);
9191
localStorage.setItem('firstName', userResponse?.result?.userData?.firstName || '');
92-
92+
localStorage.setItem('lastName', userResponse?.result?.userData?.lastName || '');
9393
const tenantId = tenantData?.tenantId;
9494
const tenantName = tenantData?.tenantName;
9595
const uiConfig = tenantData?.params?.uiConfig;

apps/learner-web-app/src/app/login/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ const LoginPage = () => {
397397
localStorage.setItem('templtateId', tenantData?.templateId);
398398
localStorage.setItem('userIdName', userResponse?.username);
399399
localStorage.setItem('firstName', userResponse?.firstName || '');
400-
400+
localStorage.setItem('lastName', userResponse?.lastName || '');
401401
const uiConfig = tenantData?.params?.uiConfig;
402402
const landingPage = tenantData?.params?.uiConfig?.landingPage;
403403
localStorage.setItem('landingPage', landingPage);

apps/learner-web-app/src/app/registration/RegisterUser.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ const RegisterUser = () => {
519519
localStorage.setItem('userIdName', userResponse?.username);
520520
localStorage.setItem('name', userResponse?.firstName);
521521
localStorage.setItem('firstName', userResponse?.firstName || '');
522-
522+
localStorage.setItem('lastName', userResponse?.lastName || '');
523523
// Persist selected tenant/role
524524
localStorage.setItem('tenantName', selectedTenantName);
525525
localStorage.setItem('roleId', selectedRoleId);

apps/learner-web-app/src/app/registration/RegisterationFlow.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,7 @@ const RegisterationFlow = () => {
773773
localStorage.setItem('userIdName', userResponse?.username);
774774
localStorage.setItem('name', userResponse?.firstName);
775775
localStorage.setItem('firstName', userResponse?.firstName || '');
776-
776+
localStorage.setItem('lastName', userResponse?.lastName || '');
777777
// Persist selected tenant/role
778778
localStorage.setItem('tenantName', selectedTenantName);
779779
localStorage.setItem('roleId', selectedRoleId);

apps/learner-web-app/src/app/sso/page.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ const SSOContent = () => {
208208
(tenant: any) => tenant.tenantName === "Pragyanpath"
209209
)?.templateId);
210210
localStorage.setItem('firstName', userResponse?.firstName);
211+
localStorage.setItem('lastName', userResponse?.lastName);
211212
setTimeout(async () => {
212213
const res = await getUserDetails(userResponse?.userId, true);
213214
console.log('response=========>', res?.result);
@@ -314,7 +315,7 @@ const SSOContent = () => {
314315
)?.templateId);
315316
localStorage.setItem('userIdName', userResponse?.username);
316317
localStorage.setItem('firstName', userResponse?.firstName || '');
317-
318+
localStorage.setItem('lastName', userResponse?.lastName || '');
318319
const uiConfig = tenantData?.find(
319320
(tenant: any) => tenant.tenantName === "Pragyanpath"
320321
)?.params?.uiConfig;

apps/learner-web-app/src/components/Content/Player.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,7 @@ const PlayerBox = ({
772772
userIdLocalstorageName
773773
? `&userId=${localStorage.getItem(userIdLocalstorageName)}`
774774
: ''
775-
}${typeof window !== 'undefined' ? `&firstName=${localStorage.getItem('firstName')}` : ''}`}
775+
}${typeof window !== 'undefined' ? `&firstName=${localStorage.getItem('firstName')}&lastName=${localStorage.getItem('lastName')}` : ''}`}
776776
style={{
777777
border: 'none',
778778
objectFit: 'contain',

0 commit comments

Comments
 (0)