From 93b2ebf75ece89e975edaadca38882540481aa7e Mon Sep 17 00:00:00 2001 From: peintnermax Date: Wed, 9 Oct 2024 10:47:18 +0200 Subject: [PATCH] fix server action response --- apps/login/src/app/(login)/layout.tsx | 2 +- apps/login/src/components/language-switcher.tsx | 11 ++++------- apps/login/src/lib/cookies.ts | 4 ++-- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/apps/login/src/app/(login)/layout.tsx b/apps/login/src/app/(login)/layout.tsx index 700de5561ac..50ea287a1c7 100644 --- a/apps/login/src/app/(login)/layout.tsx +++ b/apps/login/src/app/(login)/layout.tsx @@ -54,7 +54,7 @@ export default async function RootLayout({ ) : (
- {locale && } +
)} diff --git a/apps/login/src/components/language-switcher.tsx b/apps/login/src/components/language-switcher.tsx index 92f097998f8..dd2fa8b74b1 100644 --- a/apps/login/src/components/language-switcher.tsx +++ b/apps/login/src/components/language-switcher.tsx @@ -9,6 +9,7 @@ import { Transition, } from "@headlessui/react"; import { CheckIcon, ChevronUpDownIcon } from "@heroicons/react/24/outline"; +import { useLocale } from "next-intl"; import { useRouter } from "next/navigation"; import { Fragment, useState } from "react"; @@ -40,12 +41,8 @@ const LANGS: Lang[] = [ }, ]; -type Props = { - locale: string; -}; - -export function LanguageSwitcher({ locale }: Props) { - const currentLocale = locale || "en"; +export function LanguageSwitcher() { + const currentLocale = useLocale(); const [selected, setSelected] = useState( LANGS.find((l) => l.code === currentLocale) || LANGS[0], @@ -83,7 +80,7 @@ export function LanguageSwitcher({ locale }: Props) { > {LANGS.map((lang, index) => ( (sessions: SessionCookie[]) { export async function setLanguageCookie(language: string) { const cookiesList = cookies(); - // @ts-ignore - return cookiesList.set({ + + await cookiesList.set({ name: "NEXT_LOCALE", value: language, httpOnly: true,