diff --git a/src/app/[locale]/profile/personal/page.tsx b/src/app/[locale]/profile/personal/page.tsx
index f92910e..ee85649 100644
--- a/src/app/[locale]/profile/personal/page.tsx
+++ b/src/app/[locale]/profile/personal/page.tsx
@@ -4,12 +4,14 @@ 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 ProfileForm from "@/widgets/forms/ProfileForm/ProfileForm";
import { AxiosError } from "axios";
import { getServerSession } from "next-auth";
import React from "react";
const Personal = async () => {
const session = await getServerSession(authConfig);
+ console.log(session?.access_token);
const getProfile = async () => {
const Authorization = `Bearer ${session?.access_token}`;
const config = {
@@ -22,7 +24,6 @@ const Personal = async () => {
"/users/profile/",
config
);
-
return response.data;
} catch (error: unknown) {
if (error instanceof AxiosError) console.log(error.message);
@@ -33,7 +34,13 @@ const Personal = async () => {
return (
);
};
diff --git a/src/entities/TenderCard.tsx b/src/entities/TenderCard.tsx
index d5ad394..19c5701 100644
--- a/src/entities/TenderCard.tsx
+++ b/src/entities/TenderCard.tsx
@@ -57,7 +57,7 @@ const TenderCard: React.FC = ({
Планируемая сумма
diff --git a/src/widgets/forms/ProfileForm/ProfileForm.tsx b/src/widgets/forms/ProfileForm/ProfileForm.tsx
new file mode 100644
index 0000000..35c995a
--- /dev/null
+++ b/src/widgets/forms/ProfileForm/ProfileForm.tsx
@@ -0,0 +1,171 @@
+"use client";
+
+import Image from "next/image";
+import pen from "./icons/pen.svg";
+import { useState } from "react";
+import { apiInstance } from "@/shared/config/apiConfig";
+import { AxiosError } from "axios";
+import { useSession } from "next-auth/react";
+import { useRouter } from "@/shared/config/navigation";
+import Loader from "@/shared/ui/Loader/Loader";
+import LogoutButton from "@/features/LogoutButton";
+
+interface IProfileFormProps {
+ id: number;
+ email: string;
+ first_name: string;
+ last_name: string;
+}
+
+const ProfileForm: React.FC
= ({
+ id,
+ email,
+ first_name,
+ last_name,
+}: IProfileFormProps) => {
+ const session = useSession();
+ const router = useRouter();
+ const [error, setError] = useState("");
+ const [loader, setLoader] = useState(false);
+
+ const [editFirstName, setEditFirstName] = useState(true);
+ const [editLastName, setEditLastName] = useState(true);
+
+ const [firstName, setFirstName] = useState(first_name);
+ const [lastName, setLastName] = useState(last_name);
+
+ const [openPopup, setOpenPopup] = useState(false);
+
+ const thereAreChanges = () => {
+ if (firstName !== first_name || lastName !== last_name) return false;
+
+ return true;
+ };
+
+ const updateProfile: React.MouseEventHandler = async (e) => {
+ e.preventDefault();
+
+ const data = {
+ first_name: firstName,
+ last_name: lastName,
+ };
+
+ const Authorization = `Bearer ${session.data?.access_token}`;
+ const config = {
+ headers: {
+ Authorization,
+ },
+ };
+
+ try {
+ setLoader(true);
+ const res = await apiInstance.patch(
+ "/users/profile/update/",
+ data,
+ config
+ );
+ if ([200, 201].includes(res.status)) {
+ router.refresh();
+ }
+ } catch (error: unknown) {
+ if (error instanceof AxiosError) {
+ if (error.response?.status === 400) {
+ setError("Были введены неккоректные данные");
+ } else {
+ setError("Ошибка на стороне сервера");
+ }
+ } else {
+ setError("Возникла непредвиденная ошибка");
+ }
+ } finally {
+ setLoader(false);
+ }
+ };
+ return (
+ <>
+
+ >
+ );
+};
+
+export default ProfileForm;
diff --git a/src/widgets/forms/ProfileForm/icons/pen.svg b/src/widgets/forms/ProfileForm/icons/pen.svg
new file mode 100644
index 0000000..202f2c8
--- /dev/null
+++ b/src/widgets/forms/ProfileForm/icons/pen.svg
@@ -0,0 +1,8 @@
+