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

+7 -13
View File
@@ -3,9 +3,9 @@
import Image from "next/image";
import "./ProfileAvatar.scss";
import pen from "./icons/pen.svg";
import { apiInstance } from "@/shared/config/apiConfig";
import { useSession } from "next-auth/react";
import { authInstanse } from "@/shared/config/apiConfig";
import { useRouter } from "next/navigation";
import { useSession } from "next-auth/react";
interface IProfileAvatarProps {
img: string;
@@ -19,24 +19,18 @@ const ProfileAvatar: React.FC<IProfileAvatarProps> = ({
const changeImage: React.ChangeEventHandler<
HTMLInputElement
> = async (e) => {
const Authorization = `Bearer ${session.data?.access_token}`;
const config = {
headers: {
Authorization,
},
};
const formData = new FormData();
if (e.target.files) {
const image = Array.from(e.target.files);
formData.append("image", image[0]);
}
if (session.status === "unauthenticated") return;
try {
const res = await apiInstance.patch(
"/users/update_image/",
formData,
config
);
const res = await authInstanse(
session.data?.access_token as string
).patch("/users/update_image/", formData);
router.refresh();
} catch (error) {
console.log(error);