diff --git a/front/routes.d.ts b/front/routes.d.ts index 103b2b71..4904a9fc 100644 --- a/front/routes.d.ts +++ b/front/routes.d.ts @@ -6,7 +6,7 @@ import type { OneRouter } from 'one' declare module 'one' { export namespace OneRouter { export interface __routes extends Record { - StaticRoutes: `/` | `/(app)` | `/_sitemap` + StaticRoutes: `/` | `/(app)` | `/(app)/` | `/_sitemap` DynamicRoutes: never DynamicRouteTemplate: never IsTyped: true diff --git a/front/src/primitives/links.tsx b/front/src/primitives/links.tsx index 0520ec90..7073f19d 100644 --- a/front/src/primitives/links.tsx +++ b/front/src/primitives/links.tsx @@ -18,18 +18,16 @@ * along with Kyoo. If not, see . */ -import type { UrlObject } from "node:url"; +import { useLinkTo } from "one"; import { type ReactNode, forwardRef } from "react"; import { - Linking, Platform, Pressable, type PressableProps, + Text, type TextProps, type View, } from "react-native"; -// import { TextLink, useLink } from "solito/link"; -// import { parseNextPath } from "solito/router"; import { useTheme, useYoshiki } from "yoshiki/native"; import { alpha } from "./theme"; @@ -37,47 +35,30 @@ export const A = ({ href, replace, children, - target, ...props }: TextProps & { - href?: string | UrlObject | null; + href?: string | null; target?: string; replace?: boolean; children: ReactNode; }) => { const { css, theme } = useYoshiki(); + const linkProps = useLinkTo({ href: href ?? "#", replace }); return ( - {children} - + ); }; @@ -102,20 +83,19 @@ export const PressableFeedback = forwardRef(function Feedb }); export const Link = ({ - href: link, + href, replace, - target, children, ...props -}: { href?: string | UrlObject | null; target?: string; replace?: boolean } & PressableProps) => { - const href = link && typeof link === "object" ? parseNextPath(link) : link; - const linkProps = useLink({ - href: href ?? "#", - replace, - experimental: { nativeBehavior: "stack-replace", isNestedNavigator: true }, - }); - // @ts-ignore Missing hrefAttrs type definition. - linkProps.hrefAttrs = { ...linkProps.hrefAttrs, target }; +}: { + href?: string | null; + replace?: boolean; + download?: boolean; + target?: string; +} & PressableProps) => { + const linkProps = useLinkTo({ href: href ?? "#", replace }); + + console.warn(children); return ( { props?.onPress?.(e); if (e?.defaultPrevented) return; - if (Platform.OS !== "web" && href?.includes("://")) Linking.openURL(href); else linkProps.onPress(e); }} > diff --git a/front/src/ui/errors/unauthorized.tsx b/front/src/ui/errors/unauthorized.tsx index a7d4737c..e65a2fa4 100644 --- a/front/src/ui/errors/unauthorized.tsx +++ b/front/src/ui/errors/unauthorized.tsx @@ -20,7 +20,7 @@ export const Unauthorized = ({ missing }: { missing: string[] }) => { as={Link} href={"/register"} text={t("login.register")} - licon={} + // licon={} /> ); @@ -45,7 +45,7 @@ export const Unauthorized = ({ missing }: { missing: string[] }) => { alignItems: "center", })} > -

{t("errors.unauthorized", { permission: missing?.join(", ") })}

+

{t("errors.unauthorized", { permission: missing?.join(", ") ?? "" })}

); };