fix server action response

This commit is contained in:
peintnermax
2024-10-09 10:47:18 +02:00
parent faf38c7f6f
commit 93b2ebf75e
3 changed files with 7 additions and 10 deletions

View File

@@ -54,7 +54,7 @@ export default async function RootLayout({
<GlobalNav />
) : (
<div className="absolute bottom-0 right-0 flex flex-row p-4 items-center space-x-4">
{locale && <LanguageSwitcher locale={locale} />}
<LanguageSwitcher />
<Theme />
</div>
)}

View File

@@ -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) {
>
<ListboxOptions
anchor="bottom"
className="absolute mt-1 max-h-60 w-[var(--button-width)] w-full overflow-auto rounded-md text-text-light-500 dark:text-text-dark-500 bg-background-light-500 dark:bg-background-dark-500 py-1 text-base shadow-lg ring-1 ring-black/5 focus:outline-none sm:text-sm"
className="absolute mt-1 max-h-60 w-52 w-full overflow-auto rounded-md text-text-light-500 dark:text-text-dark-500 bg-background-light-500 dark:bg-background-dark-500 py-1 text-base shadow-lg ring-1 ring-black/5 focus:outline-none sm:text-sm"
>
{LANGS.map((lang, index) => (
<ListboxOption

View File

@@ -28,8 +28,8 @@ function setSessionHttpOnlyCookie<T>(sessions: SessionCookie<T>[]) {
export async function setLanguageCookie(language: string) {
const cookiesList = cookies();
// @ts-ignore
return cookiesList.set({
await cookiesList.set({
name: "NEXT_LOCALE",
value: language,
httpOnly: true,