diff --git a/src/Hooks/useAxiosSecure.tsx b/src/Hooks/useAxiosSecure.tsx index 1252919..09dd040 100644 --- a/src/Hooks/useAxiosSecure.tsx +++ b/src/Hooks/useAxiosSecure.tsx @@ -4,7 +4,7 @@ import { useNavigate } from "react-router-dom"; import useAuth from "../Provider/useAuth"; export const axiosSecure: AxiosInstance = axios.create({ - baseURL: import.meta.env.VITE_API_URL as string, + baseURL: import.meta.env.VITE_SERVER_URL, withCredentials: true, }); @@ -12,6 +12,7 @@ const useAxiosSecure = (): AxiosInstance => { const { logOut } = useAuth()??{}; const navigate = useNavigate(); + useEffect(() => { const responseInterceptor = axiosSecure.interceptors.response.use( (response: AxiosResponse) => response, diff --git a/src/pages/acount/ProfileInfo.tsx b/src/pages/acount/ProfileInfo.tsx index 0de413c..39b052d 100644 --- a/src/pages/acount/ProfileInfo.tsx +++ b/src/pages/acount/ProfileInfo.tsx @@ -16,7 +16,7 @@ const ProfileInfo = () => { const [isOpenPass, setIsOpenPass] = useState(false); const [isLoading, setIsLoading] = useState(false); - const { user, loading, updateUserProfile, resetPassword } = useAuth() || {}; + const { user, loading, updateUserProfile, resetPassword ,setUser } = useAuth() || {}; // console.log(user?.email); // console.log(email); @@ -70,11 +70,11 @@ const [imageFile, setImageFile] = React.useState(null); country, }, }; - // return console.log(updateData); const res = await axiosSecure.put(`/users/${user?._id}`, updateData); - console.log(res); if (res?.data) { - window.location.reload(); + console.log(res?.data.data); + setUser?.(res?.data.data); + // window.location.reload(); } setIsLoading?.(false) } else { @@ -94,12 +94,13 @@ const [imageFile, setImageFile] = React.useState(null); country, }, }; - // return console.log(updateData); // console.log(updateData); const res = await axiosSecure.put(`/users/${user?._id}`, updateData); - console.log(res); + // console.log(res); if (res?.data) { - window.location.reload(); + console.log(res?.data.data); + + setUser?.(res?.data.data); } } setIsOpen(false);