Skip to content

Commit

Permalink
Feature/cookie consent (#482)
Browse files Browse the repository at this point in the history
* cookie consent

* typescript types

* Add cookie plocity page, add cookie settings to footer

* Update cookie list styles

* clear google analytics

* cookie policy table

* Update middleware

* link consent modal to policy

* remove link

* Add footer to outer pages, update cookie policy link

* Update eslint rules

* remove typescript parser from eslint

* update context default value, coderabbit suggestion fix

---------

Co-authored-by: rushil95 <rushild95@gmail.com>
  • Loading branch information
Nithishprem and rushil95 authored Jan 3, 2025
1 parent 06627b3 commit 3b6f353
Show file tree
Hide file tree
Showing 40 changed files with 1,183 additions and 179 deletions.
1 change: 1 addition & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"globals": {
"React": true
},

"rules": {
"no-use-before-define": [
"warn",
Expand Down
2 changes: 1 addition & 1 deletion middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,6 @@ export async function middleware(request) {

export const config = {
matcher: [
"/((?!api/action|api/signup|api/signin|api/reset-password|api/provider-details|idp-auth|api/sign-in-with-idp|privacy-policy|terms-of-use|favicon.ico|_next/image|_next/static|static|validate-token).*)",
"/((?!api/action|api/signup|api/signin|api/reset-password|api/provider-details|idp-auth|api/sign-in-with-idp|privacy-policy|cookie-policy|terms-of-use|favicon.ico|_next/image|_next/static|static|validate-token).*)",
],
};
32 changes: 30 additions & 2 deletions pages/_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ import EnvironmentTypeProvider from "src/context/EnvironmentTypeProvider";
import { ENVIRONMENT_TYPES } from "src/constants/environmentTypes";
import { PAGE_TITLE_MAP } from "src/constants/pageTitleMap";
import Head from "next/head";
import CookieConsentProvider from "src/context/cookieConsentContext";
import { getProviderOrgDetails } from "src/server/api/customer-user";
import OrgDetailsProvider from "src/context/OrgDetailsProvider";

NProgress.configure({
trickleSpeed: 50,
Expand Down Expand Up @@ -173,7 +176,15 @@ export default function App(props) {
theme={isDashboardRoute ? dashboardTheme : nonDashboardTheme}
>
<EnvironmentTypeProvider envType={props.envType}>
<Component {...pageProps} />
<OrgDetailsProvider
orgLogoURL={props.orgLogoURL}
orgName={props.orgName}
orgSupportEmail={props.orgSupportEmail}
>
<CookieConsentProvider>
<Component {...pageProps} />
</CookieConsentProvider>
</OrgDetailsProvider>
</EnvironmentTypeProvider>
</ThemeProvider>
</NotificationBarProvider>
Expand All @@ -196,6 +207,23 @@ export default function App(props) {
}

App.getInitialProps = async () => {
let orgName = "";
let orgLogoURL = "";
let orgSupportEmail = "";

try {
await getProviderOrgDetails().then((response) => {
orgName = response.data.orgName;
orgLogoURL = response.data.orgLogoURL;
orgSupportEmail = response.data.orgSupportEmail || response.data.email;
});
} catch (err) {}

//check for environment type in environment variables, default to prod
return { envType: process.env.ENVIRONMENT_TYPE || ENVIRONMENT_TYPES.PROD };
return {
envType: process.env.ENVIRONMENT_TYPE || ENVIRONMENT_TYPES.PROD,
orgName,
orgLogoURL,
orgSupportEmail,
};
};
6 changes: 3 additions & 3 deletions pages/_document.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import * as React from "react";
import Document, { Html, Head, Main, NextScript } from "next/document";
import createEmotionServer from "@emotion/server/create-instance";
import createEmotionCache from "../src/createEmotionCache";
import Script from "next/script";
// import Script from "next/script";
export default class MyDocument extends Document {
render() {
return (
<Html lang="en">
<Head>
{process.env.GOOGLE_ANALYTICS_TAG_ID && (
{/* {process.env.GOOGLE_ANALYTICS_TAG_ID && (
<Script
src={`https://www.googletagmanager.com/gtag/js?id=${process.env.GOOGLE_ANALYTICS_TAG_ID}`}
strategy="afterInteractive"
Expand All @@ -25,7 +25,7 @@ export default class MyDocument extends Document {
gtag('config', '${process.env.GOOGLE_ANALYTICS_TAG_ID}');
`}
</Script>
)}
)} */}
{/* PWA primary color */}
<link rel="icon" href="" id="provider-favicon" />
<meta httpEquiv="cache-control" content="no-cache" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,6 @@ function ResourceInstance() {
<DashboardLayout
setSupportDrawerOpen={setSupportDrawerOpen}
setCurrentTabValue={setCurrentTabValue}
isNotShow
marketplacePage={currentSource === "access" ? false : true}
accessPage
currentSubscription={subscriptionData}
Expand Down Expand Up @@ -279,7 +278,6 @@ function ResourceInstance() {
<DashboardLayout
setSupportDrawerOpen={setSupportDrawerOpen}
setCurrentTabValue={setCurrentTabValue}
isNotShow
marketplacePage={currentSource === "access" ? false : true}
accessPage
currentSubscription={subscriptionData}
Expand Down Expand Up @@ -335,7 +333,6 @@ function ResourceInstance() {
apiDocsurl={serviceAPIDocsLink}
serviceId={serviceId}
serviceApiId={serviceOffering?.serviceAPIID}
isNotShow
SidebarUI={
<MarketplaceServiceSidebar
serviceId={serviceId}
Expand Down
4 changes: 0 additions & 4 deletions pages/access/[serviceId]/[environmentId]/access-control.js
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,6 @@ function AccessControl() {
<DashboardLayout
setSupportDrawerOpen={setSupportDrawerOpen}
setCurrentTabValue={setCurrentTabValue}
isNotShow
marketplacePage={currentSource === "access" ? false : true}
apiDocsurl={serviceAPIDocsLink}
serviceId={serviceId}
Expand Down Expand Up @@ -400,7 +399,6 @@ function AccessControl() {
<DashboardLayout
setSupportDrawerOpen={setSupportDrawerOpen}
setCurrentTabValue={setCurrentTabValue}
isNotShow
marketplacePage={currentSource === "access" ? false : true}
apiDocsurl={serviceAPIDocsLink}
serviceId={serviceId}
Expand Down Expand Up @@ -440,7 +438,6 @@ function AccessControl() {
<DashboardLayout
setSupportDrawerOpen={setSupportDrawerOpen}
setCurrentTabValue={setCurrentTabValue}
isNotShow
serviceId={serviceId}
serviceApiId={service?.serviceAPIID}
marketplacePage
Expand Down Expand Up @@ -470,7 +467,6 @@ function AccessControl() {
enableConsumptionLinks
servicePlanUrlLink={servicePlanUrlLink}
environmentId={environmentId}
isNotShow
SidebarUI={
<MarketplaceServiceSidebar
serviceId={serviceId}
Expand Down
4 changes: 0 additions & 4 deletions pages/access/[serviceId]/[environmentId]/audit-logs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ function Events() {
setSupportDrawerOpen={setSupportDrawerOpen}
setCurrentTabValue={setCurrentTabValue}
accessPage
isNotShow
customLogo
serviceId={serviceId}
environmentId={environmentId}
Expand Down Expand Up @@ -138,7 +137,6 @@ function Events() {
setSupportDrawerOpen={setSupportDrawerOpen}
setCurrentTabValue={setCurrentTabValue}
accessPage
isNotShow
customLogo
serviceId={serviceId}
environmentId={environmentId}
Expand Down Expand Up @@ -185,7 +183,6 @@ function Events() {
<DashboardLayout
setSupportDrawerOpen={setSupportDrawerOpen}
setCurrentTabValue={setCurrentTabValue}
isNotShow
serviceId={serviceId}
serviceApiId={serviceOffering?.serviceAPIID}
marketplacePage
Expand All @@ -207,7 +204,6 @@ function Events() {
setCurrentTabValue={setCurrentTabValue}
accessPage
currentSubscription={subscriptionData}
isNotShow
enableConsumptionLinks
apiDocsurl={serviceAPIDocsLink}
servicePlanUrlLink={servicePlanUrlLink}
Expand Down
4 changes: 0 additions & 4 deletions pages/access/[serviceId]/[environmentId]/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ function Dashboard() {
<DashboardLayout
setSupportDrawerOpen={setSupportDrawerOpen}
setCurrentTabValue={setCurrentTabValue}
isNotShow
marketplacePage={currentSource === "access" ? false : true}
accessPage
customLogo
Expand Down Expand Up @@ -134,7 +133,6 @@ function Dashboard() {
<DashboardLayout
setSupportDrawerOpen={setSupportDrawerOpen}
setCurrentTabValue={setCurrentTabValue}
isNotShow
marketplacePage={currentSource === "access" ? false : true}
accessPage
customLogo
Expand Down Expand Up @@ -187,7 +185,6 @@ function Dashboard() {
<DashboardLayout
setSupportDrawerOpen={setSupportDrawerOpen}
setCurrentTabValue={setCurrentTabValue}
isNotShow
serviceId={serviceId}
serviceApiId={serviceOffering?.serviceAPIID}
marketplacePage
Expand All @@ -214,7 +211,6 @@ function Dashboard() {
servicePlanUrlLink={servicePlanUrlLink}
serviceId={serviceId}
serviceApiId={serviceOffering?.serviceAPIID}
isNotShow
SidebarUI={
<MarketplaceServiceSidebar
serviceId={serviceId}
Expand Down
4 changes: 0 additions & 4 deletions pages/access/[serviceId]/[environmentId]/notifications.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ function Events() {
setSupportDrawerOpen={setSupportDrawerOpen}
setCurrentTabValue={setCurrentTabValue}
accessPage
isNotShow
customLogo
serviceId={serviceId}
environmentId={environmentId}
Expand Down Expand Up @@ -137,7 +136,6 @@ function Events() {
setSupportDrawerOpen={setSupportDrawerOpen}
setCurrentTabValue={setCurrentTabValue}
accessPage
isNotShow
customLogo
serviceId={serviceId}
environmentId={environmentId}
Expand Down Expand Up @@ -184,7 +182,6 @@ function Events() {
<DashboardLayout
setSupportDrawerOpen={setSupportDrawerOpen}
setCurrentTabValue={setCurrentTabValue}
isNotShow
serviceId={serviceId}
environmentId={environmentId}
serviceApiId={serviceOffering?.serviceAPIID}
Expand All @@ -206,7 +203,6 @@ function Events() {
setCurrentTabValue={setCurrentTabValue}
accessPage
currentSubscription={subscriptionData}
isNotShow
enableConsumptionLinks
apiDocsurl={serviceAPIDocsLink}
servicePlanUrlLink={servicePlanUrlLink}
Expand Down
1 change: 0 additions & 1 deletion pages/access/api-document.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ export default function ApiDocument() {
<DashboardLayout
setSupportDrawerOpen={setSupportDrawerOpen}
setCurrentTabValue={setCurrentTabValue}
isNotShow
marketplacePage={currentSource === "access" ? false : true}
accessPage
currentSubscription={subscriptionData}
Expand Down
5 changes: 0 additions & 5 deletions pages/access/service/[serviceId].js
Original file line number Diff line number Diff line change
Expand Up @@ -1544,7 +1544,6 @@ function MarketplaceService() {
<DashboardLayout
setSupportDrawerOpen={setSupportDrawerOpen}
setCurrentTabValue={setCurrentTabValue}
isNotShow
accessPage
marketplacePage={currentSource === "access" ? false : true}
SidebarUI={""}
Expand Down Expand Up @@ -1586,7 +1585,6 @@ function MarketplaceService() {
<DashboardLayout
setSupportDrawerOpen={setSupportDrawerOpen}
setCurrentTabValue={setCurrentTabValue}
isNotShow
serviceId={serviceId}
serviceApiId={service?.serviceAPIID}
marketplacePage
Expand All @@ -1611,7 +1609,6 @@ function MarketplaceService() {
setSupportDrawerOpen={setSupportDrawerOpen}
setCurrentTabValue={setCurrentTabValue}
currentSubscription={subscriptionData}
isNotShow
serviceId={serviceId}
serviceApiId={service?.serviceAPIID}
marketplacePage={currentSource === "access" ? false : true}
Expand Down Expand Up @@ -1739,7 +1736,6 @@ function MarketplaceService() {
<DashboardLayout
setSupportDrawerOpen={setSupportDrawerOpen}
setCurrentTabValue={setCurrentTabValue}
isNotShow
serviceId={serviceId}
serviceApiId={service?.serviceAPIID}
marketplacePage
Expand All @@ -1766,7 +1762,6 @@ function MarketplaceService() {
setSupportDrawerOpen={setSupportDrawerOpen}
setCurrentTabValue={setCurrentTabValue}
currentSubscription={subscriptionData}
isNotShow
serviceId={serviceId}
serviceApiId={service?.serviceAPIID}
marketplacePage={currentSource === "access" ? false : true}
Expand Down
14 changes: 1 addition & 13 deletions pages/change-password.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,8 @@
import ChangePasswordPage from "src/features/ChangePassword/ChangePasswordPage";
import { getProviderOrgDetails } from "src/server/api/customer-user";

export const getServerSideProps = async () => {
let orgName = "";
let orgLogoURL = "";
try {
const response = await getProviderOrgDetails();
orgName = response.data.orgName;
orgLogoURL = response.data.orgLogoURL;
} catch (err) {}

return {
props: {
orgName: orgName,
orgLogoURL: orgLogoURL,
},
props: {},
};
};

Expand Down
Loading

0 comments on commit 3b6f353

Please sign in to comment.