en replaced with defalutLocale cookie

This commit is contained in:
parsa aghaei committed 2024-10-23 19:05:31 +03:30
1 parent fb89647a32
commit 80016bc39a
3 files changed
+6 -5

No files matched your search

@@ -6,7 +6,7 @@ import "react-loading-skeleton/dist/skeleton.css";
export default async function AboutMe() {
const aboutMeData: AboutMeDataType = await fetch(
`${process.env.NEXT_PUBLIC_API_URL}/website/about-me/1/translation/${cookies().get("selectedLocale")?.value}`,
`${process.env.NEXT_PUBLIC_API_URL}/website/about-me/1/translation/${cookies().get("selectedLocale")?.value ? cookies().get("selectedLocale")?.value : cookies().get("defaultLocale")?.value}`,
).then((res) => res.json());
return (
@@ -24,11 +24,12 @@ export default function Services({ dict }: ServicesProps) {
const [loading, setLoading] = useState(true);
const [error, setError] = useState<string | null>(null);
useEffect(() => {
const fetchServices = async () => {
setLoading(true);
setLoading(true);
const response = await fetch(
`${process.env.NEXT_PUBLIC_API_URL}/website/services/${getCookie("selectedLocale")}`,
`${process.env.NEXT_PUBLIC_API_URL}/website/services/${getCookie("selectedLocale") !== undefined ? getCookie("selectedLocale") : getCookie("defaultLocale")}`,
).then((res) => res.json());
setServices(response);
+2 -2
View File
@@ -45,12 +45,12 @@ export function middleware(request: NextRequest) {
if (selectedLocale && selectedLocale.value !== "") {
response.cookies.set("defaultLocale", selectedLocale.value, {
path: "/",
httpOnly: true,
httpOnly: false,
});
} else {
response.cookies.set("defaultLocale", defaultLocale, {
path: "/",
httpOnly: true,
httpOnly: false,
});
}