42 lines
1.0 KiB
TypeScript
42 lines
1.0 KiB
TypeScript
"use server";
|
|
|
|
import ProfileAvatar from "@/features/ProfileAvatar/ProfileAvatar";
|
|
import { apiInstance } from "@/shared/config/apiConfig";
|
|
import { authConfig } from "@/shared/config/authConfig";
|
|
import { IProfile } from "@/shared/types/profile-type";
|
|
import { AxiosError } from "axios";
|
|
import { getServerSession } from "next-auth";
|
|
import React from "react";
|
|
|
|
const Personal = async () => {
|
|
const session = await getServerSession(authConfig);
|
|
const getProfile = async () => {
|
|
const Authorization = `Bearer ${session?.access_token}`;
|
|
const config = {
|
|
headers: {
|
|
Authorization,
|
|
},
|
|
};
|
|
try {
|
|
const response = await apiInstance.get<IProfile>(
|
|
"/users/profile/",
|
|
config
|
|
);
|
|
|
|
return response.data;
|
|
} catch (error: unknown) {
|
|
if (error instanceof AxiosError) console.log(error.message);
|
|
}
|
|
};
|
|
|
|
const data = await getProfile();
|
|
|
|
return (
|
|
<div className="personal">
|
|
<ProfileAvatar img={data?.image as string} />
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default Personal;
|