Add profile page

This commit is contained in:
anime committed 2024-09-10 15:02:17 +06:00
1 parent a106044047
commit 95674a489c
7 files changed
+150 -26

No files matched your search

+1 -3
View File
@@ -1,8 +1,6 @@
/* eslint-disable @next/next/no-img-element */
import { apiInstance } from "@/shared/config/apiConfig";
import { INews, INewsData, NewsDataResponse } from "@/shared/types/news-type";
import Image from "next/image";
import calendar from "./icons/calendar.svg";
import { INews, NewsDataResponse } from "@/shared/types/news-type";
import { Metadata } from "next";
import { Container, Title } from "@/shared/ui";
+45
View File
@@ -0,0 +1,45 @@
import { AxiosError } from "axios";
import { apiInstance } from "@/shared/config/apiConfig";
import { getServerSession } from "next-auth";
import { authConfig } from "@/shared/config/authConfig";
import { Title } from "@/shared/ui";
import ProfileNav from "@/widgets/ProfileNav/ProfileNav";
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="flex flex-col">
<Title text="Личный кабинет" className="mb-[50px]" />
<ProfileNav report_count={data?.report_count as number} />
{children}
</div>
);
};
export default Profile;
+13
View File
@@ -0,0 +1,13 @@
"use client";
import { useRouter } from "@/shared/config/navigation";
import { useEffect } from "react";
const Profile = () => {
const router = useRouter();
useEffect(() => {
router.push("/profile/personal");
}, []);
return <></>;
};
export default Profile;