diff --git a/front/apps/web/src/pages/_app.tsx b/front/apps/web/src/pages/_app.tsx index b553e409..1744cd7c 100755 --- a/front/apps/web/src/pages/_app.tsx +++ b/front/apps/web/src/pages/_app.tsx @@ -55,7 +55,7 @@ import arrayShuffle from "array-shuffle"; import { Tooltip } from "react-tooltip"; import { getCurrentAccount, readCookie, updateAccount } from "@kyoo/models/src/account-internal"; import { PortalProvider } from "@gorhom/portal"; -import { ConnectionError, ErrorContext } from "@kyoo/ui"; +import { ConnectionError } from "@kyoo/ui"; const font = Poppins({ weight: ["300", "400", "900"], subsets: ["latin"], display: "swap" }); @@ -136,17 +136,7 @@ const WithLayout = ({ Component, ...props }: { Component: ComponentType }) => { const layoutInfo = (Component as QueryPage).getLayout ?? (({ page }) => page); const { Layout, props: layoutProps } = typeof layoutInfo === "function" ? { Layout: layoutInfo, props: {} } : layoutInfo; - return ( - - - - } - randomItems={[]} - {...layoutProps} - /> - ); + return } randomItems={[]} {...layoutProps} />; }; const App = ({ Component, pageProps }: AppProps) => { diff --git a/front/packages/models/src/accounts.tsx b/front/packages/models/src/accounts.tsx index b9f93d45..64c58ed8 100644 --- a/front/packages/models/src/accounts.tsx +++ b/front/packages/models/src/accounts.tsx @@ -18,7 +18,7 @@ * along with Kyoo. If not, see . */ -import { ReactNode, createContext, useContext, useEffect, useMemo, useRef } from "react"; +import { ReactNode, createContext, useContext, useEffect, useMemo, useRef, useState } from "react"; import { ServerInfoP, User, UserP } from "./resources"; import { z } from "zod"; import { zdate } from "./utils"; @@ -69,7 +69,8 @@ export const ConnectionErrorContext = createContext<{ error: KyooErrors | null; loading: boolean; retry?: () => void; -}>({ error: null, loading: true }); + setError: (error: KyooErrors) => void; +}>({ error: null, loading: true, setError: () => {} }); /* eslint-disable react-hooks/rules-of-hooks */ export const AccountProvider = ({ @@ -96,6 +97,7 @@ export const AccountProvider = ({ retry: () => { queryClient.resetQueries({ queryKey: ["auth", "me"] }); }, + setError: () => {}, }} > {children} @@ -156,15 +158,18 @@ export const AccountProvider = ({ } }, [selected, queryClient]); + const [permissionError, setPermissionError] = useState(null); + return ( { queryClient.invalidateQueries({ queryKey: ["auth", "me"] }); }, + setError: setPermissionError, }} > {children} diff --git a/front/packages/ui/src/errors/connection.tsx b/front/packages/ui/src/errors/connection.tsx index 2218dd78..b1b17c9c 100644 --- a/front/packages/ui/src/errors/connection.tsx +++ b/front/packages/ui/src/errors/connection.tsx @@ -18,21 +18,49 @@ * along with Kyoo. If not, see . */ -import { ConnectionErrorContext } from "@kyoo/models"; -import { Button, H1, P, ts } from "@kyoo/primitives"; +import { ConnectionErrorContext, useAccount } from "@kyoo/models"; +import { Button, H1, Icon, Link, P, ts } from "@kyoo/primitives"; import { useRouter } from "solito/router"; import { useContext } from "react"; import { useTranslation } from "react-i18next"; import { View } from "react-native"; import { useYoshiki } from "yoshiki/native"; import { DefaultLayout } from "../layout"; +import { ErrorView } from "./error"; +import Register from "@material-symbols/svg-400/rounded/app_registration.svg"; export const ConnectionError = () => { const { css } = useYoshiki(); const { t } = useTranslation(); const router = useRouter(); const { error, retry } = useContext(ConnectionErrorContext); + const account = useAccount(); + if (error && (error.status === 401 || error.status == 403)) { + if (!account) { + return ( + +

{t("errors.needAccount")}

+