diff --git a/client/ecommerce/package.json b/client/ecommerce/package.json
index 08580f4..d14108b 100644
--- a/client/ecommerce/package.json
+++ b/client/ecommerce/package.json
@@ -5,7 +5,7 @@
"type": "module",
"scripts": {
"dev": "vite",
- "build": "tsc && vite build",
+ "build": "vite build",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview"
},
diff --git a/client/ecommerce/src/api/axios.tsx b/client/ecommerce/src/api/axios.tsx
index 5f38932..ce56acf 100644
--- a/client/ecommerce/src/api/axios.tsx
+++ b/client/ecommerce/src/api/axios.tsx
@@ -22,10 +22,15 @@ import {
import { RequestAccessTokenInterceptor } from "./request-access-token.interceptor";
import { ResponseOAuthInterceptor } from "./response-auth.interceptor";
const LIMIT = 5;
-const BASE_URL = "http://localhost:3000";
+let baseUrl;
+if (import.meta.env.VITE_PRODU == "false") {
+ baseUrl = "http://localhost:3000";
+} else {
+ baseUrl = "https://ecommerce-mtkw.onrender.com";
+}
export const axiosApi = axios.create({
- baseURL: BASE_URL,
+ baseURL: baseUrl,
withCredentials: true,
});
RequestAccessTokenInterceptor(axiosApi);
diff --git a/client/ecommerce/src/components/Navbar.tsx b/client/ecommerce/src/components/Navbar.tsx
index 3b83df5..b282aeb 100644
--- a/client/ecommerce/src/components/Navbar.tsx
+++ b/client/ecommerce/src/components/Navbar.tsx
@@ -31,7 +31,6 @@ import { useNotifications } from "../hooks/useNotifications";
import { useProductNotifications } from "../hooks/useProductNotifications";
import { useMarkProductNotificationAsRead } from "../hooks/useMarkProductNotificationAsRead";
import PopoverPopupState from "./PopoverPopupState";
-import { useUserInfo } from "../hooks/useUserInfo";
import { useFetchUserInfo } from "../hooks/useFetchUserInfo";
import { isAdmin } from "../utils/isAdmin";
@@ -159,7 +158,7 @@ export const Navbar = () => {
useNotifications(user.id);
if (!user.username && !user.id) {
- return;
+ return ;
}
if (isNotificationsLoading) {
return "isNotificationsLoading...";
diff --git a/client/ecommerce/src/components/PaginatedProducts.tsx b/client/ecommerce/src/components/PaginatedProducts.tsx
index 1e26584..7741c3d 100644
--- a/client/ecommerce/src/components/PaginatedProducts.tsx
+++ b/client/ecommerce/src/components/PaginatedProducts.tsx
@@ -48,7 +48,13 @@ export const PaginatedProducts = () => {
lg={below1200 ? 3 : 12 / 5}
md={below1200 ? 3 : 3}
xs={below700 ? 6 : 4}
- xl={12 / 5}
+ xl={
+ page.data.length == 2 || page.data.length == 1
+ ? 6
+ : page.data.length >= 4
+ ? 3
+ : 4
+ }
>
{
const { user, setUser } = useUserContext();
const formDataToBackend = new FormData();
const [, setLocation] = useLocation();
+ const queryClient = useQueryClient();
const [selectedFile, setSelectedFile] = useState("");
const below960 = useMediaQuery(960);
const [formData, setFormData] = useState({
@@ -44,12 +46,17 @@ export const EditProfile = () => {
const file = uploadedFiles[0];
setSelectedFile(file);
};
+ const { refetch } = useFetchUserInfo(user.id);
const mutation = useMutation({
mutationKey: ["profile", "update"],
mutationFn: updateProfile,
- onSuccess: (user: User) => {
- setUser(user);
+
+ onSuccess: (userAvatar: string) => {
+ if (typeof userAvatar === "string") {
+ setUser((prevUser) => ({ ...prevUser, avatar: userAvatar }));
+ }
toast.success("Profile updated");
+ refetch();
setLocation("/");
},
onError: (err) => {
@@ -120,7 +127,12 @@ export const EditProfile = () => {
alignItems: "center",
}}
>
- {user.avatar ? (
+ {selectedFile ? (
+
+ ) : user.avatar ? (
{
height: "64px",
}}
/>
- ) : selectedFile ? (
-
) : (
{
}}
/>
)}
+