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
+1
-1
@@ -66,7 +66,7 @@ export function QueryCell<TData, TError extends ErrorLike>(
|
||||
return opts.loading?.(query) ?? <Loader />;
|
||||
}
|
||||
if (query.status === "idle") {
|
||||
return null;
|
||||
return opts.idle?.(query) ?? <Loader />;
|
||||
}
|
||||
// impossible state
|
||||
return null;
|
||||
|
||||
+20
-2
@@ -1,18 +1,36 @@
|
||||
import { IdProvider } from "@radix-ui/react-id";
|
||||
import { Provider } from "next-auth/client";
|
||||
import { appWithTranslation } from "next-i18next";
|
||||
import { AppProps } from "next/dist/shared/lib/router/router";
|
||||
import React from "react";
|
||||
import React, { ComponentProps, ReactNode } from "react";
|
||||
|
||||
import DynamicIntercomProvider from "@ee/lib/intercom/providerDynamic";
|
||||
|
||||
import { createTelemetryClient, TelemetryProvider } from "@lib/telemetry";
|
||||
|
||||
import { trpc } from "./trpc";
|
||||
|
||||
const I18nextAdapter = appWithTranslation(({ children }: { children?: ReactNode }) => <>{children}</>);
|
||||
|
||||
const CustomI18nextProvider = (props: { children: ReactNode }) => {
|
||||
const { i18n, locale } = trpc.useQuery(["viewer.i18n"]).data ?? {};
|
||||
const passedProps = {
|
||||
...props,
|
||||
pageProps: { ...i18n },
|
||||
router: { locale },
|
||||
} as unknown as ComponentProps<typeof I18nextAdapter>;
|
||||
return <I18nextAdapter {...passedProps} />;
|
||||
};
|
||||
|
||||
const AppProviders = (props: AppProps) => {
|
||||
const session = trpc.useQuery(["viewer.session"]).data;
|
||||
return (
|
||||
<TelemetryProvider value={createTelemetryClient()}>
|
||||
<IdProvider>
|
||||
<DynamicIntercomProvider>
|
||||
<Provider session={props.pageProps.session}>{props.children}</Provider>
|
||||
<Provider session={session || undefined}>
|
||||
<CustomI18nextProvider>{props.children}</CustomI18nextProvider>
|
||||
</Provider>
|
||||
</DynamicIntercomProvider>
|
||||
</IdProvider>
|
||||
</TelemetryProvider>
|
||||
|
||||
Reference in new issue
Block a user