[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'
|
||||
|
||||
// next/dynamic is used to prevent breaking incompatibilities
|
||||
|
@ -10,6 +12,13 @@ import dynamic from "next/dynamic";
|
|||
// below removed
|
||||
const App = dynamic(() => import("../src/app/App"), { ssr: false });
|
||||
|
||||
export default function Page(props: any) {
|
||||
return <App {...props} />;
|
||||
}
|
||||
const FallbackPage: NextPageWithLayout = () => {
|
||||
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 Head from "next/head";
|
||||
import type { AppProps } from "next/app";
|
||||
import type { NextPage } from "next";
|
||||
import * as Sentry from "@sentry/react";
|
||||
import { Integrations } from "@sentry/tracing";
|
||||
import { Auth0Provider } from "@auth0/auth0-react";
|
||||
|
@ -10,6 +11,11 @@ import { useAuth0 } from "@auth0/auth0-react";
|
|||
import { mode } from "@chakra-ui/theme-tools";
|
||||
|
||||
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({
|
||||
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(), []);
|
||||
|
||||
return (
|
||||
|
@ -53,7 +63,9 @@ export default function DTIApp({ Component, pageProps }: AppProps) {
|
|||
<ApolloProviderWithAuth0>
|
||||
<ChakraProvider theme={theme}>
|
||||
<CSSReset />
|
||||
<LayoutComponent>
|
||||
<Component {...pageProps} />
|
||||
</LayoutComponent>
|
||||
</ChakraProvider>
|
||||
</ApolloProviderWithAuth0>
|
||||
</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)
|
||||
);
|
||||
const ModelingPage = loadable(() => import("./ModelingPage"));
|
||||
const PrivacyPolicyPage = loadable(() => import("./PrivacyPolicyPage"));
|
||||
const SupportPetAppearancesPage = loadable(() =>
|
||||
import("./SupportPetAppearancesPage")
|
||||
);
|
||||
|
@ -109,11 +108,6 @@ function App() {
|
|||
<ModelingPage />
|
||||
</PageLayout>
|
||||
</Route>
|
||||
<Route path="/privacy">
|
||||
<PageLayout>
|
||||
<PrivacyPolicyPage />
|
||||
</PageLayout>
|
||||
</Route>
|
||||
<Route path="/conversion">
|
||||
<PageLayout>
|
||||
<ConversionPage />
|
||||
|
|
|
@ -10,7 +10,8 @@ import {
|
|||
} from "@chakra-ui/react";
|
||||
import { EmailIcon, MoonIcon, SunIcon } from "@chakra-ui/icons";
|
||||
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() {
|
||||
const classicDTIUrl = useClassicDTIUrl();
|
||||
|
@ -27,9 +28,9 @@ function GlobalFooter() {
|
|||
<ChakraLink href="https://impress.openneo.net/terms">
|
||||
Terms of Use
|
||||
</ChakraLink>
|
||||
<ChakraLink as={RouterLink} to="/privacy">
|
||||
Privacy Policy
|
||||
</ChakraLink>
|
||||
<Link href="/privacy" passHref>
|
||||
<ChakraLink>Privacy Policy</ChakraLink>
|
||||
</Link>
|
||||
<ChakraLink href={classicDTIUrl}>Classic DTI</ChakraLink>
|
||||
</HStack>
|
||||
<Box as="p" opacity="0.75">
|
||||
|
@ -111,21 +112,17 @@ function ColorModeButton() {
|
|||
}
|
||||
|
||||
function useClassicDTIUrl() {
|
||||
const itemPageMatch = useRouteMatch("/items/:itemId");
|
||||
const userItemListsIndexPageMatch = useRouteMatch("/user/:userId/lists");
|
||||
const modelingPageMatch = useRouteMatch("/modeling");
|
||||
const { pathname, query } = useRouter();
|
||||
|
||||
if (itemPageMatch) {
|
||||
const { itemId } = itemPageMatch.params;
|
||||
return `https://impress.openneo.net/items/${itemId}`;
|
||||
if (pathname === "/items/:itemId") {
|
||||
return `https://impress.openneo.net/items/${query.itemId}`;
|
||||
}
|
||||
|
||||
if (userItemListsIndexPageMatch) {
|
||||
const { userId } = userItemListsIndexPageMatch.params;
|
||||
return `https://impress.openneo.net/user/${userId}/closet`;
|
||||
if (pathname === "/user/:userId/lists") {
|
||||
return `https://impress.openneo.net/user/${query.userId}/closet`;
|
||||
}
|
||||
|
||||
if (modelingPageMatch) {
|
||||
if (pathname === "/modeling") {
|
||||
return "https://impress.openneo.net/modeling";
|
||||
}
|
||||
|
||||
|
|
|
@ -12,9 +12,10 @@ import {
|
|||
useToast,
|
||||
} from "@chakra-ui/react";
|
||||
import { HamburgerIcon } from "@chakra-ui/icons";
|
||||
import { Link, useLocation } from "react-router-dom";
|
||||
import { ChevronLeftIcon } from "@chakra-ui/icons";
|
||||
import Image from "next/image";
|
||||
import Link from "next/link";
|
||||
import { useRouter } from "next/router";
|
||||
|
||||
import useCurrentUser, {
|
||||
useAuthModeFeatureFlag,
|
||||
|
@ -35,13 +36,13 @@ function GlobalHeader() {
|
|||
}
|
||||
|
||||
function HomeLink(props) {
|
||||
const { pathname } = useLocation();
|
||||
const isHomePage = pathname === "/";
|
||||
const { pathname } = useRouter();
|
||||
const isHomePage = pathname === "";
|
||||
|
||||
return (
|
||||
<Link href="/" passHref>
|
||||
<Box
|
||||
as={Link}
|
||||
to="/"
|
||||
as="a"
|
||||
display="flex"
|
||||
alignItems="center"
|
||||
role="group"
|
||||
|
@ -110,6 +111,7 @@ function HomeLink(props) {
|
|||
Dress to Impress
|
||||
</Box>
|
||||
</Box>
|
||||
</Link>
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -130,16 +132,16 @@ function UserNavBarSection() {
|
|||
)}
|
||||
<NavLinksList>
|
||||
{id && (
|
||||
<NavLinkItem as={Link} to={`/user/${id}/lists`}>
|
||||
Lists
|
||||
</NavLinkItem>
|
||||
<Link href={`/user/${id}/lists`} passHref>
|
||||
<NavLinkItem as="a">Lists</NavLinkItem>
|
||||
</Link>
|
||||
)}
|
||||
<NavLinkItem as={Link} to={`/your-outfits`}>
|
||||
Outfits
|
||||
</NavLinkItem>
|
||||
<NavLinkItem as={Link} to="/modeling">
|
||||
Modeling
|
||||
</NavLinkItem>
|
||||
<Link href={`/your-outfits`} passHref>
|
||||
<NavLinkItem as="a">Outfits</NavLinkItem>
|
||||
</Link>
|
||||
<Link href="/modeling" passHref>
|
||||
<NavLinkItem as="a">Modeling</NavLinkItem>
|
||||
</Link>
|
||||
<LogoutButton />
|
||||
</NavLinksList>
|
||||
</HStack>
|
||||
|
@ -147,9 +149,9 @@ function UserNavBarSection() {
|
|||
} else {
|
||||
return (
|
||||
<HStack align="center" spacing="2">
|
||||
<NavButton as={Link} to="/modeling">
|
||||
Modeling
|
||||
</NavButton>
|
||||
<Link href="/modeling" passHref>
|
||||
<NavButton as="a">Modeling</NavButton>
|
||||
</Link>
|
||||
<LoginButton />
|
||||
</HStack>
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue