[WIP] Move Privacy Policy onto its own Next.js page
The first page moved over! Note that this broke navigation on the rest of the app, so don't deploy this until we're done! The reason it broke was that we had to migrate GlobalHeader and GlobalFooter to the Next.js link & router stuff too, or else it crashed because it wasn't in a react-router-dom context.
This commit is contained in:
parent
4cd847f6ba
commit
eb8a0cf2a9
6 changed files with 119 additions and 100 deletions
|
@ -1,3 +1,5 @@
|
||||||
|
import React from "react";
|
||||||
|
import type { NextPageWithLayout } from "./_app";
|
||||||
// import App from '../src'
|
// import App from '../src'
|
||||||
|
|
||||||
// next/dynamic is used to prevent breaking incompatibilities
|
// next/dynamic is used to prevent breaking incompatibilities
|
||||||
|
@ -10,6 +12,13 @@ import dynamic from "next/dynamic";
|
||||||
// below removed
|
// below removed
|
||||||
const App = dynamic(() => import("../src/app/App"), { ssr: false });
|
const App = dynamic(() => import("../src/app/App"), { ssr: false });
|
||||||
|
|
||||||
export default function Page(props: any) {
|
const FallbackPage: NextPageWithLayout = () => {
|
||||||
return <App {...props} />;
|
return <App />;
|
||||||
}
|
};
|
||||||
|
|
||||||
|
// This old fallback page uses App, which already has PageLayout built-in.
|
||||||
|
FallbackPage.layoutComponent = ({ children }: { children: JSX.Element }) => {
|
||||||
|
return children;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default FallbackPage;
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import Head from "next/head";
|
import Head from "next/head";
|
||||||
import type { AppProps } from "next/app";
|
import type { AppProps } from "next/app";
|
||||||
|
import type { NextPage } from "next";
|
||||||
import * as Sentry from "@sentry/react";
|
import * as Sentry from "@sentry/react";
|
||||||
import { Integrations } from "@sentry/tracing";
|
import { Integrations } from "@sentry/tracing";
|
||||||
import { Auth0Provider } from "@auth0/auth0-react";
|
import { Auth0Provider } from "@auth0/auth0-react";
|
||||||
|
@ -10,6 +11,11 @@ import { useAuth0 } from "@auth0/auth0-react";
|
||||||
import { mode } from "@chakra-ui/theme-tools";
|
import { mode } from "@chakra-ui/theme-tools";
|
||||||
|
|
||||||
import buildApolloClient from "../src/app/apolloClient";
|
import buildApolloClient from "../src/app/apolloClient";
|
||||||
|
import PageLayout from "../src/app/PageLayout";
|
||||||
|
|
||||||
|
export type NextPageWithLayout<P = {}, IP = P> = NextPage<P, IP> & {
|
||||||
|
layoutComponent?: (props: { children: JSX.Element }) => JSX.Element;
|
||||||
|
};
|
||||||
|
|
||||||
const theme = extendTheme({
|
const theme = extendTheme({
|
||||||
styles: {
|
styles: {
|
||||||
|
@ -29,7 +35,11 @@ const theme = extendTheme({
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export default function DTIApp({ Component, pageProps }: AppProps) {
|
type AppPropsWithLayout = AppProps & { Component: NextPageWithLayout };
|
||||||
|
|
||||||
|
export default function DTIApp({ Component, pageProps }: AppPropsWithLayout) {
|
||||||
|
const LayoutComponent = Component.layoutComponent ?? PageLayout;
|
||||||
|
|
||||||
React.useEffect(() => setupLogging(), []);
|
React.useEffect(() => setupLogging(), []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -53,7 +63,9 @@ export default function DTIApp({ Component, pageProps }: AppProps) {
|
||||||
<ApolloProviderWithAuth0>
|
<ApolloProviderWithAuth0>
|
||||||
<ChakraProvider theme={theme}>
|
<ChakraProvider theme={theme}>
|
||||||
<CSSReset />
|
<CSSReset />
|
||||||
|
<LayoutComponent>
|
||||||
<Component {...pageProps} />
|
<Component {...pageProps} />
|
||||||
|
</LayoutComponent>
|
||||||
</ChakraProvider>
|
</ChakraProvider>
|
||||||
</ApolloProviderWithAuth0>
|
</ApolloProviderWithAuth0>
|
||||||
</Auth0Provider>
|
</Auth0Provider>
|
||||||
|
|
5
pages/privacy.tsx
Normal file
5
pages/privacy.tsx
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
import PrivacyPolicyPage from "../src/app/PrivacyPolicyPage";
|
||||||
|
|
||||||
|
export default function PrivacyPolicyPageWrapper() {
|
||||||
|
return <PrivacyPolicyPage />;
|
||||||
|
}
|
|
@ -25,7 +25,6 @@ const ItemTradesSeekingPage = loadable(() =>
|
||||||
import("./ItemTradesPage").then((m) => m.ItemTradesSeekingPage)
|
import("./ItemTradesPage").then((m) => m.ItemTradesSeekingPage)
|
||||||
);
|
);
|
||||||
const ModelingPage = loadable(() => import("./ModelingPage"));
|
const ModelingPage = loadable(() => import("./ModelingPage"));
|
||||||
const PrivacyPolicyPage = loadable(() => import("./PrivacyPolicyPage"));
|
|
||||||
const SupportPetAppearancesPage = loadable(() =>
|
const SupportPetAppearancesPage = loadable(() =>
|
||||||
import("./SupportPetAppearancesPage")
|
import("./SupportPetAppearancesPage")
|
||||||
);
|
);
|
||||||
|
@ -109,11 +108,6 @@ function App() {
|
||||||
<ModelingPage />
|
<ModelingPage />
|
||||||
</PageLayout>
|
</PageLayout>
|
||||||
</Route>
|
</Route>
|
||||||
<Route path="/privacy">
|
|
||||||
<PageLayout>
|
|
||||||
<PrivacyPolicyPage />
|
|
||||||
</PageLayout>
|
|
||||||
</Route>
|
|
||||||
<Route path="/conversion">
|
<Route path="/conversion">
|
||||||
<PageLayout>
|
<PageLayout>
|
||||||
<ConversionPage />
|
<ConversionPage />
|
||||||
|
|
|
@ -10,7 +10,8 @@ import {
|
||||||
} from "@chakra-ui/react";
|
} from "@chakra-ui/react";
|
||||||
import { EmailIcon, MoonIcon, SunIcon } from "@chakra-ui/icons";
|
import { EmailIcon, MoonIcon, SunIcon } from "@chakra-ui/icons";
|
||||||
import { SiGithub, SiTwitter } from "react-icons/si";
|
import { SiGithub, SiTwitter } from "react-icons/si";
|
||||||
import { Link as RouterLink, useRouteMatch } from "react-router-dom";
|
import { useRouter } from "next/router";
|
||||||
|
import Link from "next/link";
|
||||||
|
|
||||||
function GlobalFooter() {
|
function GlobalFooter() {
|
||||||
const classicDTIUrl = useClassicDTIUrl();
|
const classicDTIUrl = useClassicDTIUrl();
|
||||||
|
@ -27,9 +28,9 @@ function GlobalFooter() {
|
||||||
<ChakraLink href="https://impress.openneo.net/terms">
|
<ChakraLink href="https://impress.openneo.net/terms">
|
||||||
Terms of Use
|
Terms of Use
|
||||||
</ChakraLink>
|
</ChakraLink>
|
||||||
<ChakraLink as={RouterLink} to="/privacy">
|
<Link href="/privacy" passHref>
|
||||||
Privacy Policy
|
<ChakraLink>Privacy Policy</ChakraLink>
|
||||||
</ChakraLink>
|
</Link>
|
||||||
<ChakraLink href={classicDTIUrl}>Classic DTI</ChakraLink>
|
<ChakraLink href={classicDTIUrl}>Classic DTI</ChakraLink>
|
||||||
</HStack>
|
</HStack>
|
||||||
<Box as="p" opacity="0.75">
|
<Box as="p" opacity="0.75">
|
||||||
|
@ -111,21 +112,17 @@ function ColorModeButton() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function useClassicDTIUrl() {
|
function useClassicDTIUrl() {
|
||||||
const itemPageMatch = useRouteMatch("/items/:itemId");
|
const { pathname, query } = useRouter();
|
||||||
const userItemListsIndexPageMatch = useRouteMatch("/user/:userId/lists");
|
|
||||||
const modelingPageMatch = useRouteMatch("/modeling");
|
|
||||||
|
|
||||||
if (itemPageMatch) {
|
if (pathname === "/items/:itemId") {
|
||||||
const { itemId } = itemPageMatch.params;
|
return `https://impress.openneo.net/items/${query.itemId}`;
|
||||||
return `https://impress.openneo.net/items/${itemId}`;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (userItemListsIndexPageMatch) {
|
if (pathname === "/user/:userId/lists") {
|
||||||
const { userId } = userItemListsIndexPageMatch.params;
|
return `https://impress.openneo.net/user/${query.userId}/closet`;
|
||||||
return `https://impress.openneo.net/user/${userId}/closet`;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (modelingPageMatch) {
|
if (pathname === "/modeling") {
|
||||||
return "https://impress.openneo.net/modeling";
|
return "https://impress.openneo.net/modeling";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,9 +12,10 @@ import {
|
||||||
useToast,
|
useToast,
|
||||||
} from "@chakra-ui/react";
|
} from "@chakra-ui/react";
|
||||||
import { HamburgerIcon } from "@chakra-ui/icons";
|
import { HamburgerIcon } from "@chakra-ui/icons";
|
||||||
import { Link, useLocation } from "react-router-dom";
|
|
||||||
import { ChevronLeftIcon } from "@chakra-ui/icons";
|
import { ChevronLeftIcon } from "@chakra-ui/icons";
|
||||||
import Image from "next/image";
|
import Image from "next/image";
|
||||||
|
import Link from "next/link";
|
||||||
|
import { useRouter } from "next/router";
|
||||||
|
|
||||||
import useCurrentUser, {
|
import useCurrentUser, {
|
||||||
useAuthModeFeatureFlag,
|
useAuthModeFeatureFlag,
|
||||||
|
@ -35,13 +36,13 @@ function GlobalHeader() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function HomeLink(props) {
|
function HomeLink(props) {
|
||||||
const { pathname } = useLocation();
|
const { pathname } = useRouter();
|
||||||
const isHomePage = pathname === "/";
|
const isHomePage = pathname === "";
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
<Link href="/" passHref>
|
||||||
<Box
|
<Box
|
||||||
as={Link}
|
as="a"
|
||||||
to="/"
|
|
||||||
display="flex"
|
display="flex"
|
||||||
alignItems="center"
|
alignItems="center"
|
||||||
role="group"
|
role="group"
|
||||||
|
@ -110,6 +111,7 @@ function HomeLink(props) {
|
||||||
Dress to Impress
|
Dress to Impress
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
|
</Link>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,16 +132,16 @@ function UserNavBarSection() {
|
||||||
)}
|
)}
|
||||||
<NavLinksList>
|
<NavLinksList>
|
||||||
{id && (
|
{id && (
|
||||||
<NavLinkItem as={Link} to={`/user/${id}/lists`}>
|
<Link href={`/user/${id}/lists`} passHref>
|
||||||
Lists
|
<NavLinkItem as="a">Lists</NavLinkItem>
|
||||||
</NavLinkItem>
|
</Link>
|
||||||
)}
|
)}
|
||||||
<NavLinkItem as={Link} to={`/your-outfits`}>
|
<Link href={`/your-outfits`} passHref>
|
||||||
Outfits
|
<NavLinkItem as="a">Outfits</NavLinkItem>
|
||||||
</NavLinkItem>
|
</Link>
|
||||||
<NavLinkItem as={Link} to="/modeling">
|
<Link href="/modeling" passHref>
|
||||||
Modeling
|
<NavLinkItem as="a">Modeling</NavLinkItem>
|
||||||
</NavLinkItem>
|
</Link>
|
||||||
<LogoutButton />
|
<LogoutButton />
|
||||||
</NavLinksList>
|
</NavLinksList>
|
||||||
</HStack>
|
</HStack>
|
||||||
|
@ -147,9 +149,9 @@ function UserNavBarSection() {
|
||||||
} else {
|
} else {
|
||||||
return (
|
return (
|
||||||
<HStack align="center" spacing="2">
|
<HStack align="center" spacing="2">
|
||||||
<NavButton as={Link} to="/modeling">
|
<Link href="/modeling" passHref>
|
||||||
Modeling
|
<NavButton as="a">Modeling</NavButton>
|
||||||
</NavButton>
|
</Link>
|
||||||
<LoginButton />
|
<LoginButton />
|
||||||
</HStack>
|
</HStack>
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue