-
Order details
+ {isCheckoutSuccess ? (
+
+
Order details
- {arrayOfProduct.products.map((product, index) => (
-
-
{product.name}:
-
${product.price}
+ {arrayOfProduct.products.map((product, index) => (
+
+
{product.name}:
+
${product.price}
+
+ ))}
+
+
Total Discount:
+
+ ${(totalProductPrice - checkoutData).toFixed(2)}
+
- ))}
-
-
Total Discount:
-
- ${(totalProductPrice - checkoutData).toFixed(2)}
+
+
Total amount:
+
${checkoutData.toFixed(2)}
+
-
-
Total amount:
-
${checkoutData.toFixed(2)}
-
-
-
- ) : null}
-
+ ) : null}
+
+
>
diff --git a/src/pages/admin/Dashboard.tsx b/src/pages/admin/Dashboard.tsx
index 745e438d..895d384a 100644
--- a/src/pages/admin/Dashboard.tsx
+++ b/src/pages/admin/Dashboard.tsx
@@ -34,7 +34,7 @@ export const AdminDashboard = () => {
dispatch(logout());
setTimeout(() => {
navigate("/");
- }, 1000);
+ }, 2000);
};
useEffect(() => {
diff --git a/src/pages/admin/Users.tsx b/src/pages/admin/Users.tsx
index 4539f3d5..0326bc31 100644
--- a/src/pages/admin/Users.tsx
+++ b/src/pages/admin/Users.tsx
@@ -73,7 +73,6 @@ export default function Users() {
};
const handleStatusChange = (userId:string, isEnabled:boolean) => {
- console.log("userID:" ,userId,"status:",isEnabled)
setLocalUserState((prevState) =>
prevState.map((user) =>
user.id === userId? {...user, newStatus: isEnabled ? "enabled" : "disabled" } : user
diff --git a/src/pages/seller/SellerDashboard.tsx b/src/pages/seller/SellerDashboard.tsx
index 20cc2082..5ddd2535 100644
--- a/src/pages/seller/SellerDashboard.tsx
+++ b/src/pages/seller/SellerDashboard.tsx
@@ -1,10 +1,14 @@
/* eslint-disable */
-import React from 'react'
+import React from "react";
+import LiveChat from "../../components/live-chat/LiveChat";
const SellerDashboard = () => {
return (
-
SellerDashboard
- )
-}
+ <>
+
SellerDashboard
+ {/*
*/}
+ >
+ );
+};
-export default SellerDashboard
\ No newline at end of file
+export default SellerDashboard;
diff --git a/src/store/actions/resetAction.ts b/src/store/actions/resetAction.ts
index 25dd1515..f3e1476d 100644
--- a/src/store/actions/resetAction.ts
+++ b/src/store/actions/resetAction.ts
@@ -1,4 +1,9 @@
export const RESET_STATE = 'RESET_STATE';
+export const CLEAR_IMAGES = 'CLEAR_IMAGES';
+
+export const clearImages = () => ({
+ type: CLEAR_IMAGES,
+});
export const resetState = () => ({
type: RESET_STATE,
diff --git a/src/store/features/auth/authSlice.tsx b/src/store/features/auth/authSlice.tsx
index 51b78c0c..a2239327 100644
--- a/src/store/features/auth/authSlice.tsx
+++ b/src/store/features/auth/authSlice.tsx
@@ -7,7 +7,7 @@ import { toast } from "react-toastify";
import { resetState, RESET_STATE } from "../../actions/resetAction";
const initialState: AuthService = {
- user: undefined,
+ user: null,
isError: false,
isLoading: false,
isSuccess: false,
@@ -325,7 +325,7 @@ const userSlice = createSlice({
state.isSuccess = false;
state.isAuthenticated = false;
})
- .addCase( getUserDetails.fulfilled, (state, action: PayloadAction
) => {
+ .addCase( getUserDetails.fulfilled, (state, action: PayloadAction) => {
state.isError = false;
state.isSuccess = true;
state.isAuthenticated = true;
diff --git a/src/store/features/carts/cartSlice.tsx b/src/store/features/carts/cartSlice.tsx
index 03149494..b643bc63 100644
--- a/src/store/features/carts/cartSlice.tsx
+++ b/src/store/features/carts/cartSlice.tsx
@@ -212,6 +212,7 @@ const cartSlice = createSlice({
state.isError = false;
state.isSuccess = true;
state.carts = action.payload.data.carts;
+ console.log(state.carts)
let cartProductsTotal = 0;
let cartTotalAmount = 0;
let cartsProductsList = [];
diff --git a/src/store/features/chat/chatSlice.tsx b/src/store/features/chat/chatSlice.tsx
new file mode 100644
index 00000000..7d6a4843
--- /dev/null
+++ b/src/store/features/chat/chatSlice.tsx
@@ -0,0 +1,52 @@
+/* eslint-disable */
+import { createSlice, createAsyncThunk } from '@reduxjs/toolkit';
+import axios from 'axios';
+
+export const uploadImage = createAsyncThunk(
+ 'chat/uploadImage',
+ async (file:File, thunkAPI) => {
+ console.log(file)
+ const formData = new FormData();
+ formData.append("file",file);
+ formData.append("upload_preset", "pbyvho95");
+
+ try {
+ const response = await axios.post("https://api.cloudinary.com/v1_1/du0vvcuiz/image/upload",formData)
+ return response.data.secure_url;
+ } catch (error) {
+ return thunkAPI.rejectWithValue(error.message);
+ }
+ }
+);
+
+const chatSlice = createSlice({
+ name: 'chat',
+ initialState: {
+ images: [],
+ loading: false,
+ error: null,
+ },
+ reducers: {
+ addMessage: (state, action) => {
+ state.images.push(action.payload);
+ },
+ },
+ extraReducers: (builder) => {
+ builder
+ .addCase(uploadImage.pending, (state) => {
+ state.loading = true;
+ state.error = null;
+ })
+ .addCase(uploadImage.fulfilled, (state, action) => {
+ state.loading = false;
+ state.images.push(action.payload);
+ localStorage.setItem("uploadedImages", JSON.stringify(state.images));
+ })
+ .addCase(uploadImage.rejected, (state, action) => {
+ state.loading = false;
+ state.error = action.payload;
+ });
+ },
+});
+
+export default chatSlice.reducer;
diff --git a/src/store/reducers/index.ts b/src/store/reducers/index.ts
index 2dbdf13f..f53fa139 100644
--- a/src/store/reducers/index.ts
+++ b/src/store/reducers/index.ts
@@ -10,8 +10,9 @@ import singleSellerProductReducer from '../features/product/sellerProductSlice';
import sellerCollectionProducts from '../features/product/sellerCollectionProductsSlice';
import adminReducer from '../features/admin/adminSlice';
import cartReducer from "../features/carts/cartSlice";
+import chatReducer from '../features/chat/chatSlice';
import userReducer from "../features/user/userSlice"
-import { RESET_STATE } from '../actions/resetAction';
+import { CLEAR_IMAGES, RESET_STATE } from '../actions/resetAction';
const appReducer = combineReducers({
initialMessage: welcomeReducer,
@@ -24,6 +25,7 @@ const appReducer = combineReducers({
sellerCollectionProducts: sellerCollectionProducts,
admin: adminReducer,
cart: cartReducer,
+ chat: chatReducer,
user: userReducer
});
@@ -31,6 +33,12 @@ const rootReducer = (state, action) => {
if (action.type === RESET_STATE) {
state = undefined;
}
+ if(action.type === CLEAR_IMAGES) {
+ return {
+ ...state,
+ images: []
+ };
+ }
return appReducer(state, action);
};
diff --git a/src/utils/protectRoute/ProtectedRoute.tsx b/src/utils/protectRoute/ProtectedRoute.tsx
index ab0679d5..c32eb66e 100644
--- a/src/utils/protectRoute/ProtectedRoute.tsx
+++ b/src/utils/protectRoute/ProtectedRoute.tsx
@@ -50,7 +50,7 @@ const ProtectedRoute = ({ redirectPath = '/', children }) => {
}
if (!isAuthenticated) {
- toast.info('You need to be logged in to access this page');
+ toast.info('Please log in to access this page.');
return ;
}
if (isError && message === 'Not authorized') {
diff --git a/src/utils/types/custom.d.ts b/src/utils/types/custom.d.ts
index 6e51fb2c..5de1f303 100644
--- a/src/utils/types/custom.d.ts
+++ b/src/utils/types/custom.d.ts
@@ -19,3 +19,8 @@ declare module '*.gif' {
const value: string;
export default value;
}
+
+declare module '*.mp3' {
+ const value: string;
+ export default value;
+}
diff --git a/src/utils/types/store.d.ts b/src/utils/types/store.d.ts
index a910f1e9..ee294f32 100644
--- a/src/utils/types/store.d.ts
+++ b/src/utils/types/store.d.ts
@@ -34,8 +34,8 @@ export interface IUser {
id?: string;
firstName?: string;
lastName?: string;
- email: string;
- password: string;
+ email?: string;
+ password?: string;
phone?: number;
profilePicture?: string;
gender?: string;
@@ -53,12 +53,12 @@ export interface IUser {
}
export interface IUserData {
- data: object;
+ data: {user:IUser};
message: string;
}
export interface IUserDataState {
- user: IUserData | undefined;
+ user: IUserData | null;
}
export interface IVerification {
diff --git a/webpack.dev.config.ts b/webpack.dev.config.ts
index 551be173..a681488c 100644
--- a/webpack.dev.config.ts
+++ b/webpack.dev.config.ts
@@ -30,7 +30,7 @@ const config: Configuration = {
'@babel/preset-react',
'@babel/preset-typescript',
],
- cacheDirectory: true, // Enable Babel caching
+ cacheDirectory: true,
},
},
},
@@ -56,6 +56,19 @@ const config: Configuration = {
},
],
},
+ {
+ test: /\.(mp3)$/,
+ use: [
+ {
+ loader: 'file-loader',
+ options: {
+ name: '[name].[ext]',
+ outputPath: 'assets/',
+ publicPath: 'assets/',
+ },
+ },
+ ],
+ },
],
},
resolve: {
@@ -78,7 +91,7 @@ const config: Configuration = {
],
}),
],
- devtool: 'eval-cheap-module-source-map', // Use a faster devtool setting
+ devtool: 'eval-cheap-module-source-map',
devServer: {
static: path.join(__dirname, 'dist'),
historyApiFallback: {
@@ -89,10 +102,10 @@ const config: Configuration = {
hot: true,
},
cache: {
- type: 'filesystem', // Enable filesystem caching
+ type: 'filesystem',
},
optimization: {
- usedExports: true, // Enable tree shaking
+ usedExports: true,
},
};
diff --git a/webpack.prod.config.ts b/webpack.prod.config.ts
index dc38539b..6e00f5ec 100644
--- a/webpack.prod.config.ts
+++ b/webpack.prod.config.ts
@@ -76,6 +76,19 @@ const config: Configuration = {
}
],
},
+ {
+ test: /\.(mp3)$/,
+ use: [
+ {
+ loader: 'file-loader',
+ options: {
+ name: '[name].[ext]',
+ outputPath: 'assets/',
+ publicPath: 'assets/',
+ },
+ },
+ ],
+ },
],
},
resolve: {