en replaced with defalutLocale cookie
This commit is contained in:
parent
fb89647a32
commit
80016bc39a
@ -6,7 +6,7 @@ import "react-loading-skeleton/dist/skeleton.css";
|
|||||||
|
|
||||||
export default async function AboutMe() {
|
export default async function AboutMe() {
|
||||||
const aboutMeData: AboutMeDataType = await fetch(
|
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());
|
).then((res) => res.json());
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@ -24,11 +24,12 @@ export default function Services({ dict }: ServicesProps) {
|
|||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
const [error, setError] = useState<string | null>(null);
|
const [error, setError] = useState<string | null>(null);
|
||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const fetchServices = async () => {
|
const fetchServices = async () => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
const response = await fetch(
|
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());
|
).then((res) => res.json());
|
||||||
|
|
||||||
setServices(response);
|
setServices(response);
|
||||||
|
|||||||
@ -45,12 +45,12 @@ export function middleware(request: NextRequest) {
|
|||||||
if (selectedLocale && selectedLocale.value !== "") {
|
if (selectedLocale && selectedLocale.value !== "") {
|
||||||
response.cookies.set("defaultLocale", selectedLocale.value, {
|
response.cookies.set("defaultLocale", selectedLocale.value, {
|
||||||
path: "/",
|
path: "/",
|
||||||
httpOnly: true,
|
httpOnly: false,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
response.cookies.set("defaultLocale", defaultLocale, {
|
response.cookies.set("defaultLocale", defaultLocale, {
|
||||||
path: "/",
|
path: "/",
|
||||||
httpOnly: true,
|
httpOnly: false,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user