reduce accounts
This commit is contained in:
parent
e95cba0ace
commit
71a8049a35
10 changed files with 23 additions and 37 deletions
|
@ -2,6 +2,7 @@ import { CustomHead } from "@/next/components/Head";
|
||||||
import { setupI18n } from "@/next/i18n";
|
import { setupI18n } from "@/next/i18n";
|
||||||
import { logUnhandledErrorsAndRejections } from "@/next/log-web";
|
import { logUnhandledErrorsAndRejections } from "@/next/log-web";
|
||||||
import type { AppName, BaseAppContextT } from "@/next/types/app";
|
import type { AppName, BaseAppContextT } from "@/next/types/app";
|
||||||
|
import { ensure } from "@/utils/ensure";
|
||||||
import { PAGES } from "@ente/accounts/constants/pages";
|
import { PAGES } from "@ente/accounts/constants/pages";
|
||||||
import { accountLogout } from "@ente/accounts/services/logout";
|
import { accountLogout } from "@ente/accounts/services/logout";
|
||||||
import { APPS, APP_TITLES } from "@ente/shared/apps/constants";
|
import { APPS, APP_TITLES } from "@ente/shared/apps/constants";
|
||||||
|
@ -20,7 +21,7 @@ import { ThemeProvider } from "@mui/material/styles";
|
||||||
import { t } from "i18next";
|
import { t } from "i18next";
|
||||||
import { AppProps } from "next/app";
|
import { AppProps } from "next/app";
|
||||||
import { useRouter } from "next/router";
|
import { useRouter } from "next/router";
|
||||||
import { createContext, useEffect, useState } from "react";
|
import { createContext, useContext, useEffect, useState } from "react";
|
||||||
import "styles/global.css";
|
import "styles/global.css";
|
||||||
|
|
||||||
/** The accounts app has no extra properties on top of the base context. */
|
/** The accounts app has no extra properties on top of the base context. */
|
||||||
|
@ -29,6 +30,9 @@ type AppContextT = BaseAppContextT;
|
||||||
/** The React {@link Context} available to all pages. */
|
/** The React {@link Context} available to all pages. */
|
||||||
export const AppContext = createContext<AppContextT | undefined>(undefined);
|
export const AppContext = createContext<AppContextT | undefined>(undefined);
|
||||||
|
|
||||||
|
/** Utility hook to reduce amount of boilerplate in account related pages. */
|
||||||
|
export const useAppContext = () => ensure(useContext(AppContext));
|
||||||
|
|
||||||
export default function App({ Component, pageProps }: AppProps) {
|
export default function App({ Component, pageProps }: AppProps) {
|
||||||
const appName: AppName = "account";
|
const appName: AppName = "account";
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
import { ensure } from "@/utils/ensure";
|
|
||||||
import Page_ from "@ente/accounts/pages/credentials";
|
import Page_ from "@ente/accounts/pages/credentials";
|
||||||
import { useContext } from "react";
|
import { useAppContext } from "./_app";
|
||||||
import { AppContext } from "./_app";
|
|
||||||
|
|
||||||
const Page = () => <Page_ appContext={ensure(useContext(AppContext))} />;
|
const Page = () => <Page_ appContext={useAppContext()} />;
|
||||||
|
|
||||||
export default Page;
|
export default Page;
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
import { ensure } from "@/utils/ensure";
|
|
||||||
import Page_ from "@ente/accounts/pages/generate";
|
import Page_ from "@ente/accounts/pages/generate";
|
||||||
import { useContext } from "react";
|
import { useAppContext } from "./_app";
|
||||||
import { AppContext } from "./_app";
|
|
||||||
|
|
||||||
const Page = () => <Page_ appContext={ensure(useContext(AppContext))} />;
|
const Page = () => <Page_ appContext={useAppContext()} />;
|
||||||
|
|
||||||
export default Page;
|
export default Page;
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
import { ensure } from "@/utils/ensure";
|
|
||||||
import Page_ from "@ente/accounts/pages/login";
|
import Page_ from "@ente/accounts/pages/login";
|
||||||
import { useContext } from "react";
|
import { useAppContext } from "./_app";
|
||||||
import { AppContext } from "./_app";
|
|
||||||
|
|
||||||
const Page = () => <Page_ appContext={ensure(useContext(AppContext))} />;
|
const Page = () => <Page_ appContext={useAppContext()} />;
|
||||||
|
|
||||||
export default Page;
|
export default Page;
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
import { ensure } from "@/utils/ensure";
|
|
||||||
import Page_ from "@ente/accounts/pages/recover";
|
import Page_ from "@ente/accounts/pages/recover";
|
||||||
import { useContext } from "react";
|
import { useAppContext } from "./_app";
|
||||||
import { AppContext } from "./_app";
|
|
||||||
|
|
||||||
const Page = () => <Page_ appContext={ensure(useContext(AppContext))} />;
|
const Page = () => <Page_ appContext={useAppContext()} />;
|
||||||
|
|
||||||
export default Page;
|
export default Page;
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
import { ensure } from "@/utils/ensure";
|
|
||||||
import Page_ from "@ente/accounts/pages/signup";
|
import Page_ from "@ente/accounts/pages/signup";
|
||||||
import { useContext } from "react";
|
import { useAppContext } from "./_app";
|
||||||
import { AppContext } from "./_app";
|
|
||||||
|
|
||||||
const Page = () => <Page_ appContext={ensure(useContext(AppContext))} />;
|
const Page = () => <Page_ appContext={useAppContext()} />;
|
||||||
|
|
||||||
export default Page;
|
export default Page;
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
import { ensure } from "@/utils/ensure";
|
|
||||||
import Page_ from "@ente/accounts/pages/two-factor/recover";
|
import Page_ from "@ente/accounts/pages/two-factor/recover";
|
||||||
import { useContext } from "react";
|
import { useAppContext } from "../_app";
|
||||||
import { AppContext } from "../_app";
|
|
||||||
|
|
||||||
const Page = () => <Page_ appContext={ensure(useContext(AppContext))} />;
|
const Page = () => <Page_ appContext={useAppContext()} />;
|
||||||
|
|
||||||
export default Page;
|
export default Page;
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
import { ensure } from "@/utils/ensure";
|
|
||||||
import Page_ from "@ente/accounts/pages/two-factor/setup";
|
import Page_ from "@ente/accounts/pages/two-factor/setup";
|
||||||
import { useContext } from "react";
|
import { useAppContext } from "../_app";
|
||||||
import { AppContext } from "../_app";
|
|
||||||
|
|
||||||
const Page = () => <Page_ appContext={ensure(useContext(AppContext))} />;
|
const Page = () => <Page_ appContext={useAppContext()} />;
|
||||||
|
|
||||||
export default Page;
|
export default Page;
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
import { ensure } from "@/utils/ensure";
|
|
||||||
import Page_ from "@ente/accounts/pages/two-factor/verify";
|
import Page_ from "@ente/accounts/pages/two-factor/verify";
|
||||||
import { useContext } from "react";
|
import { useAppContext } from "../_app";
|
||||||
import { AppContext } from "../_app";
|
|
||||||
|
|
||||||
const Page = () => <Page_ appContext={ensure(useContext(AppContext))} />;
|
const Page = () => <Page_ appContext={useAppContext()} />;
|
||||||
|
|
||||||
export default Page;
|
export default Page;
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
import { ensure } from "@/utils/ensure";
|
|
||||||
import Page_ from "@ente/accounts/pages/verify";
|
import Page_ from "@ente/accounts/pages/verify";
|
||||||
import { useContext } from "react";
|
import { useAppContext } from "./_app";
|
||||||
import { AppContext } from "./_app";
|
|
||||||
|
|
||||||
const Page = () => <Page_ appContext={ensure(useContext(AppContext))} />;
|
const Page = () => <Page_ appContext={useAppContext()} />;
|
||||||
|
|
||||||
export default Page;
|
export default Page;
|
||||||
|
|
Loading…
Reference in a new issue