added next-intl, composed next-auth and next-intl in middleware, fixed some bugs, completed details page, added google auth

This commit is contained in:
Alibek committed 2024-02-29 14:09:37 +06:00
1 parent 9cd7b2a67d
commit 6637ab4eae
172 files changed
+1772 -502

No files matched your search

+54
View File
@@ -0,0 +1,54 @@
import Typography from "@/shared/ui/components/Typography/Typography";
import "./Profile.scss";
import ProfileNav from "@/widgets/ProfileNav/ProfileNav";
import AuthGuard from "./AuthGuard";
import { AxiosError } from "axios";
import { apiInstance } from "@/shared/config/apiConfig";
import { getServerSession } from "next-auth";
import { authConfig } from "@/shared/config/authConfig";
import { Metadata } from "next";
export const metadata: Metadata = {
title: "KG ROAD | Профиль",
description:
"Страница профиля Kyrgyzstan Transperency International",
};
const Profile = async ({
children,
}: Readonly<{
children: React.ReactNode;
}>) => {
const session = await getServerSession(authConfig);
const getProfile = async () => {
const Authorization = `Bearer ${session?.access_token}`;
const config = {
headers: {
Authorization,
},
};
try {
const response = await apiInstance.get<{
report_count: number;
}>("/users/profile/", config);
return response.data;
} catch (error: unknown) {
if (error instanceof AxiosError) console.log(error.message);
}
};
const data = await getProfile();
return (
<div className="profile page-padding">
<Typography element="h2">Личный кабинет</Typography>
<ProfileNav report_count={data?.report_count as number} />
<AuthGuard>{children}</AuthGuard>
</div>
);
};
export default Profile;