3 Commits

  1. 11
      src/app/layout.tsx
  2. 8
      src/components/Componentes/token-switcher.tsx

11
src/app/layout.tsx

@ -60,7 +60,11 @@ export default async function RootLayout({
headerLocale && isLocale(headerLocale) ? headerLocale : defaultLocale; headerLocale && isLocale(headerLocale) ? headerLocale : defaultLocale;
return ( return (
<html lang={locale} dir={localeDirections[locale] ?? "ltr"}>
<html
lang={locale}
dir={localeDirections[locale] ?? "ltr"}
suppressHydrationWarning
>
<head> <head>
<link rel="preconnect" href="https://habibapp.com" /> <link rel="preconnect" href="https://habibapp.com" />
<link rel="dns-prefetch" href="https://habibapp.com" /> <link rel="dns-prefetch" href="https://habibapp.com" />
@ -310,7 +314,10 @@ export default async function RootLayout({
}} }}
/> />
</head> </head>
<body className={`${faminela.variable} ${amiri.variable}`}>
<body
className={`${faminela.variable} ${amiri.variable}`}
suppressHydrationWarning
>
<Providers> <Providers>
{isDevelopment ? <TokenSwitcher /> : null} {isDevelopment ? <TokenSwitcher /> : null}
<div className="app-shell">{children}</div> <div className="app-shell">{children}</div>

8
src/components/Componentes/token-switcher.tsx

@ -3,6 +3,7 @@
import { useEffect, useState } from "react"; import { useEffect, useState } from "react";
import { IoClose, IoKeyOutline, IoTrashOutline } from "react-icons/io5"; import { IoClose, IoKeyOutline, IoTrashOutline } from "react-icons/io5";
import { MdOutlineSwitchAccount } from "react-icons/md"; import { MdOutlineSwitchAccount } from "react-icons/md";
import { IoClose, IoKeyOutline, IoTrashOutline } from "react-icons/io5";
import { getClientCookie, setClientCookie } from "@/lib/cookies"; import { getClientCookie, setClientCookie } from "@/lib/cookies";
import { setCachedMarriageEntryPath } from "@/lib/entry-route-cache"; import { setCachedMarriageEntryPath } from "@/lib/entry-route-cache";
@ -32,6 +33,7 @@ export function TokenSwitcher({
const [isCustomInputOpen, setIsCustomInputOpen] = useState(false); const [isCustomInputOpen, setIsCustomInputOpen] = useState(false);
useEffect(() => { useEffect(() => {
setMounted(true);
if (typeof window !== "undefined") { if (typeof window !== "undefined") {
const token = const token =
(window as any).HABIB_TOKEN ?? (window as any).HABIB_TOKEN ??
@ -43,6 +45,10 @@ export function TokenSwitcher({
} }
}, []); }, []);
if (!mounted) {
return null;
}
const isMale = currentToken === MALE_TOKEN; const isMale = currentToken === MALE_TOKEN;
const isMale2 = currentToken === MALE_2_TOKEN; const isMale2 = currentToken === MALE_2_TOKEN;
const isFemale = currentToken === FEMALE_TOKEN; const isFemale = currentToken === FEMALE_TOKEN;
@ -179,7 +185,7 @@ export function TokenSwitcher({
aria-label="تغییر توکن کاربر (تست)" aria-label="تغییر توکن کاربر (تست)"
title="تغییر توکن (آقا / خانم)" title="تغییر توکن (آقا / خانم)"
className={[ className={[
"inline-flex items-center gap-1.5 rounded-[15px] px-3 py-2 text-xs font-bold transition-all active:scale-95 shadow-md border border-slate-200/80 dark:border-slate-700/80 backdrop-blur-md",
"fixed top-4 left-4 z-[99999] inline-flex items-center gap-1.5 rounded-[15px] px-3 py-2 text-xs font-bold transition-all active:scale-95 shadow-md border border-slate-200/80 dark:border-slate-700/80 backdrop-blur-md",
variant === "transparent" variant === "transparent"
? "bg-black/40 text-white hover:bg-black/50" ? "bg-black/40 text-white hover:bg-black/50"
: "bg-white/95 text-slate-800 hover:bg-white dark:bg-slate-900/95 dark:text-slate-100", : "bg-white/95 text-slate-800 hover:bg-white dark:bg-slate-900/95 dark:text-slate-100",

Loading…
Cancel
Save