From babe378301b7f3b384caeff783753196340ca1b3 Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Sun, 26 May 2024 16:03:16 +0530 Subject: [PATCH] Move --- web/packages/accounts/services/redirect.ts | 24 ++++++++++++++++++++++ web/packages/next/types/app.ts | 5 +++++ web/packages/shared/apps/constants.ts | 18 ---------------- 3 files changed, 29 insertions(+), 18 deletions(-) create mode 100644 web/packages/accounts/services/redirect.ts create mode 100644 web/packages/next/types/app.ts diff --git a/web/packages/accounts/services/redirect.ts b/web/packages/accounts/services/redirect.ts new file mode 100644 index 000000000..084d001ec --- /dev/null +++ b/web/packages/accounts/services/redirect.ts @@ -0,0 +1,24 @@ +import type { AppName } from "@/next/types/app"; +import { + ACCOUNTS_PAGES, + AUTH_PAGES, + PHOTOS_PAGES, +} from "@ente/shared/constants/pages"; + +/** + * The "home" route for each of our apps. + * + * This is where we redirect to after successful authentication. + */ +export const appHomeRoute = (appName: AppName): string => { + switch (appName) { + case "account": + return ACCOUNTS_PAGES.PASSKEYS; + case "albums": + return "/"; + case "auth": + return AUTH_PAGES.AUTH; + case "photos": + return PHOTOS_PAGES.GALLERY; + } +}; diff --git a/web/packages/next/types/app.ts b/web/packages/next/types/app.ts new file mode 100644 index 000000000..8818a09e5 --- /dev/null +++ b/web/packages/next/types/app.ts @@ -0,0 +1,5 @@ +/** + * Arbitrary names that we used as keys for indexing various constants + * corresponding to our apps. + */ +export type AppName = "account" | "albums" | "auth" | "photos"; diff --git a/web/packages/shared/apps/constants.ts b/web/packages/shared/apps/constants.ts index 3fcf0dcdd..b679fb912 100644 --- a/web/packages/shared/apps/constants.ts +++ b/web/packages/shared/apps/constants.ts @@ -1,23 +1,5 @@ import { ACCOUNTS_PAGES, AUTH_PAGES, PHOTOS_PAGES } from "../constants/pages"; -/** - * Arbitrary names that we used as keys for indexing various constants - * corresponding to our apps. - */ -export type AppName = "account" | "albums" | "auth" | "photos"; - -/** - * The "home" route for each of our apps. - * - * This is where we redirect to, e.g, after successful authentication. - */ -export const appHomeRoute: Record = { - account: ACCOUNTS_PAGES.PASSKEYS, - albums: "/", - auth: AUTH_PAGES.AUTH, - photos: PHOTOS_PAGES.GALLERY, -}; - export enum APPS { PHOTOS = "PHOTOS", AUTH = "AUTH",