Ends the war between tRPC and next-i18next (#939)
* Ends the war between tRPC and next-i18next * Locale fixes * Linting * Linting * trpc i18n (not working) (#942) * simplify i18n handler and remove redundant(?) fn check * split up viewer to a "logged in only" and "public" * wip -- skip first render Co-authored-by: Omar López <[email protected]> * Linting * I18n fixes * We don't need serverSideTranslations in every page anymore Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> Co-authored-by: Alex Johansson <[email protected]>
This commit is contained in:
28 files changed
+243
-401
No files matched your search
@@ -11,14 +11,31 @@ import { ALL_INTEGRATIONS } from "@lib/integrations/getIntegrations";
|
||||
import slugify from "@lib/slugify";
|
||||
|
||||
import { getCalendarAdapterOrNull } from "../../lib/calendarClient";
|
||||
import { createProtectedRouter } from "../createRouter";
|
||||
import { createProtectedRouter, createRouter } from "../createRouter";
|
||||
import { resizeBase64Image } from "../lib/resizeBase64Image";
|
||||
|
||||
const checkUsername =
|
||||
process.env.NEXT_PUBLIC_APP_URL === "https://cal.com" ? checkPremiumUsername : checkRegularUsername;
|
||||
|
||||
// things that unauthenticated users can query about themselves
|
||||
const publicViewerRouter = createRouter()
|
||||
.query("session", {
|
||||
resolve({ ctx }) {
|
||||
return ctx.session;
|
||||
},
|
||||
})
|
||||
.query("i18n", {
|
||||
async resolve({ ctx }) {
|
||||
const { locale, i18n } = ctx;
|
||||
return {
|
||||
i18n,
|
||||
locale,
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
// routes only available to authenticated users
|
||||
export const viewerRouter = createProtectedRouter()
|
||||
const loggedInViewerRouter = createProtectedRouter()
|
||||
.query("me", {
|
||||
resolve({ ctx }) {
|
||||
const {
|
||||
@@ -34,6 +51,7 @@ export const viewerRouter = createProtectedRouter()
|
||||
avatar,
|
||||
createdDate,
|
||||
completedOnboarding,
|
||||
twoFactorEnabled,
|
||||
} = ctx.user;
|
||||
const me = {
|
||||
id,
|
||||
@@ -47,6 +65,7 @@ export const viewerRouter = createProtectedRouter()
|
||||
avatar,
|
||||
createdDate,
|
||||
completedOnboarding,
|
||||
twoFactorEnabled,
|
||||
};
|
||||
return me;
|
||||
},
|
||||
@@ -251,3 +270,5 @@ export const viewerRouter = createProtectedRouter()
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
export const viewerRouter = createRouter().merge(publicViewerRouter).merge(loggedInViewerRouter);
|
||||
Reference in new issue
Block a user