diff --git a/package-lock.json b/package-lock.json index e392542f..06c35e7c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,6 +8,7 @@ "name": "dynamites-ecomm-fe", "version": "0.0.0", "dependencies": { + "@mui/material": "^5.16.4", "@react-jvectormap/core": "^1.0.4", "@react-jvectormap/world": "^1.1.2", "@reduxjs/toolkit": "^2.2.5", @@ -747,6 +748,28 @@ "statuses": "^2.0.1" } }, + "node_modules/@emotion/cache": { + "version": "11.13.0", + "resolved": "https://registry.npmjs.org/@emotion/cache/-/cache-11.13.0.tgz", + "integrity": "sha512-hPV345J/tH0Cwk2wnU/3PBzORQ9HeX+kQSbwI+jslzpRCHE6fSGTohswksA/Ensr8znPzwfzKZCmAM9Lmlhp7g==", + "dependencies": { + "@emotion/memoize": "^0.9.0", + "@emotion/sheet": "^1.4.0", + "@emotion/utils": "^1.4.0", + "@emotion/weak-memoize": "^0.4.0", + "stylis": "4.2.0" + } + }, + "node_modules/@emotion/cache/node_modules/@emotion/memoize": { + "version": "0.9.0", + "resolved": "https://registry.npmjs.org/@emotion/memoize/-/memoize-0.9.0.tgz", + "integrity": "sha512-30FAj7/EoJ5mwVPOWhAyCX+FPfMDrVecJAM+Iw9NRoSl4BBAQeqj4cApHHUXOVvIPgLVDsCFoz/hGD+5QQD1GQ==" + }, + "node_modules/@emotion/cache/node_modules/stylis": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/stylis/-/stylis-4.2.0.tgz", + "integrity": "sha512-Orov6g6BB1sDfYgzWfTHDOxamtX1bE/zo104Dh9e6fqJ3PooipYyfJ0pUmrZO2wAvO8YbEyeFrkV91XTsGMSrw==" + }, "node_modules/@emotion/is-prop-valid": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/@emotion/is-prop-valid/-/is-prop-valid-1.2.2.tgz", @@ -760,11 +783,26 @@ "resolved": "https://registry.npmjs.org/@emotion/memoize/-/memoize-0.8.1.tgz", "integrity": "sha512-W2P2c/VRW1/1tLox0mVUalvnWXxavmv/Oum2aPsRcoDJuob75FC3Y8FbpfLwUegRcxINtGUMPq0tFCvYNTBXNA==" }, + "node_modules/@emotion/sheet": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/@emotion/sheet/-/sheet-1.4.0.tgz", + "integrity": "sha512-fTBW9/8r2w3dXWYM4HCB1Rdp8NLibOw2+XELH5m5+AkWiL/KqYX6dc0kKYlaYyKjrQ6ds33MCdMPEwgs2z1rqg==" + }, "node_modules/@emotion/unitless": { "version": "0.8.1", "resolved": "https://registry.npmjs.org/@emotion/unitless/-/unitless-0.8.1.tgz", "integrity": "sha512-KOEGMu6dmJZtpadb476IsZBclKvILjopjUii3V+7MnXIQCYh8W3NgNcgwo21n9LXZX6EDIKvqfjYxXebDwxKmQ==" }, + "node_modules/@emotion/utils": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/@emotion/utils/-/utils-1.4.0.tgz", + "integrity": "sha512-spEnrA1b6hDR/C68lC2M7m6ALPUHZC0lIY7jAS/B/9DuuO1ZP04eov8SMv/6fwRd8pzmsn2AuJEznRREWlQrlQ==" + }, + "node_modules/@emotion/weak-memoize": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/@emotion/weak-memoize/-/weak-memoize-0.4.0.tgz", + "integrity": "sha512-snKqtPW01tN0ui7yu9rGv69aJXr/a/Ywvl11sUjNtEcRc+ng/mQriFL0wLXMef74iHa/EkftbDzU9F8iFbH+zg==" + }, "node_modules/@esbuild/aix-ppc64": { "version": "0.21.5", "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.21.5.tgz", @@ -2017,6 +2055,206 @@ "node": ">=18" } }, + "node_modules/@mui/core-downloads-tracker": { + "version": "5.16.4", + "resolved": "https://registry.npmjs.org/@mui/core-downloads-tracker/-/core-downloads-tracker-5.16.4.tgz", + "integrity": "sha512-rNdHXhclwjEZnK+//3SR43YRx0VtjdHnUFhMSGYmAMJve+KiwEja/41EYh8V3pZKqF2geKyfcFUenTfDTYUR4w==", + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/mui-org" + } + }, + "node_modules/@mui/material": { + "version": "5.16.4", + "resolved": "https://registry.npmjs.org/@mui/material/-/material-5.16.4.tgz", + "integrity": "sha512-dBnh3/zRYgEVIS3OE4oTbujse3gifA0qLMmuUk13ywsDCbngJsdgwW5LuYeiT5pfA8PGPGSqM7mxNytYXgiMCw==", + "dependencies": { + "@babel/runtime": "^7.23.9", + "@mui/core-downloads-tracker": "^5.16.4", + "@mui/system": "^5.16.4", + "@mui/types": "^7.2.15", + "@mui/utils": "^5.16.4", + "@popperjs/core": "^2.11.8", + "@types/react-transition-group": "^4.4.10", + "clsx": "^2.1.0", + "csstype": "^3.1.3", + "prop-types": "^15.8.1", + "react-is": "^18.3.1", + "react-transition-group": "^4.4.5" + }, + "engines": { + "node": ">=12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/mui-org" + }, + "peerDependencies": { + "@emotion/react": "^11.5.0", + "@emotion/styled": "^11.3.0", + "@types/react": "^17.0.0 || ^18.0.0", + "react": "^17.0.0 || ^18.0.0", + "react-dom": "^17.0.0 || ^18.0.0" + }, + "peerDependenciesMeta": { + "@emotion/react": { + "optional": true + }, + "@emotion/styled": { + "optional": true + }, + "@types/react": { + "optional": true + } + } + }, + "node_modules/@mui/material/node_modules/react-is": { + "version": "18.3.1", + "resolved": "https://registry.npmjs.org/react-is/-/react-is-18.3.1.tgz", + "integrity": "sha512-/LLMVyas0ljjAtoYiPqYiL8VWXzUUdThrmU5+n20DZv+a+ClRoevUzw5JxU+Ieh5/c87ytoTBV9G1FiKfNJdmg==" + }, + "node_modules/@mui/private-theming": { + "version": "5.16.4", + "resolved": "https://registry.npmjs.org/@mui/private-theming/-/private-theming-5.16.4.tgz", + "integrity": "sha512-ZsAm8cq31SJ37SVWLRlu02v9SRthxnfQofaiv14L5Bht51B0dz6yQEoVU/V8UduZDCCIrWkBHuReVfKhE/UuXA==", + "dependencies": { + "@babel/runtime": "^7.23.9", + "@mui/utils": "^5.16.4", + "prop-types": "^15.8.1" + }, + "engines": { + "node": ">=12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/mui-org" + }, + "peerDependencies": { + "@types/react": "^17.0.0 || ^18.0.0", + "react": "^17.0.0 || ^18.0.0" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, + "node_modules/@mui/styled-engine": { + "version": "5.16.4", + "resolved": "https://registry.npmjs.org/@mui/styled-engine/-/styled-engine-5.16.4.tgz", + "integrity": "sha512-0+mnkf+UiAmTVB8PZFqOhqf729Yh0Cxq29/5cA3VAyDVTRIUUQ8FXQhiAhUIbijFmM72rY80ahFPXIm4WDbzcA==", + "dependencies": { + "@babel/runtime": "^7.23.9", + "@emotion/cache": "^11.11.0", + "csstype": "^3.1.3", + "prop-types": "^15.8.1" + }, + "engines": { + "node": ">=12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/mui-org" + }, + "peerDependencies": { + "@emotion/react": "^11.4.1", + "@emotion/styled": "^11.3.0", + "react": "^17.0.0 || ^18.0.0" + }, + "peerDependenciesMeta": { + "@emotion/react": { + "optional": true + }, + "@emotion/styled": { + "optional": true + } + } + }, + "node_modules/@mui/system": { + "version": "5.16.4", + "resolved": "https://registry.npmjs.org/@mui/system/-/system-5.16.4.tgz", + "integrity": "sha512-ET1Ujl2/8hbsD611/mqUuNArMCGv/fIWO/f8B3ZqF5iyPHM2aS74vhTNyjytncc4i6dYwGxNk+tLa7GwjNS0/w==", + "dependencies": { + "@babel/runtime": "^7.23.9", + "@mui/private-theming": "^5.16.4", + "@mui/styled-engine": "^5.16.4", + "@mui/types": "^7.2.15", + "@mui/utils": "^5.16.4", + "clsx": "^2.1.0", + "csstype": "^3.1.3", + "prop-types": "^15.8.1" + }, + "engines": { + "node": ">=12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/mui-org" + }, + "peerDependencies": { + "@emotion/react": "^11.5.0", + "@emotion/styled": "^11.3.0", + "@types/react": "^17.0.0 || ^18.0.0", + "react": "^17.0.0 || ^18.0.0" + }, + "peerDependenciesMeta": { + "@emotion/react": { + "optional": true + }, + "@emotion/styled": { + "optional": true + }, + "@types/react": { + "optional": true + } + } + }, + "node_modules/@mui/types": { + "version": "7.2.15", + "resolved": "https://registry.npmjs.org/@mui/types/-/types-7.2.15.tgz", + "integrity": "sha512-nbo7yPhtKJkdf9kcVOF8JZHPZTmqXjJ/tI0bdWgHg5tp9AnIN4Y7f7wm9T+0SyGYJk76+GYZ8Q5XaTYAsUHN0Q==", + "peerDependencies": { + "@types/react": "^17.0.0 || ^18.0.0" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, + "node_modules/@mui/utils": { + "version": "5.16.4", + "resolved": "https://registry.npmjs.org/@mui/utils/-/utils-5.16.4.tgz", + "integrity": "sha512-nlppYwq10TBIFqp7qxY0SvbACOXeOjeVL3pOcDsK0FT8XjrEXh9/+lkg8AEIzD16z7YfiJDQjaJG2OLkE7BxNg==", + "dependencies": { + "@babel/runtime": "^7.23.9", + "@types/prop-types": "^15.7.12", + "clsx": "^2.1.1", + "prop-types": "^15.8.1", + "react-is": "^18.3.1" + }, + "engines": { + "node": ">=12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/mui-org" + }, + "peerDependencies": { + "@types/react": "^17.0.0 || ^18.0.0", + "react": "^17.0.0 || ^18.0.0" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, + "node_modules/@mui/utils/node_modules/react-is": { + "version": "18.3.1", + "resolved": "https://registry.npmjs.org/react-is/-/react-is-18.3.1.tgz", + "integrity": "sha512-/LLMVyas0ljjAtoYiPqYiL8VWXzUUdThrmU5+n20DZv+a+ClRoevUzw5JxU+Ieh5/c87ytoTBV9G1FiKfNJdmg==" + }, "node_modules/@nodelib/fs.scandir": { "version": "2.1.5", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", @@ -2096,6 +2334,15 @@ "url": "https://opencollective.com/unts" } }, + "node_modules/@popperjs/core": { + "version": "2.11.8", + "resolved": "https://registry.npmjs.org/@popperjs/core/-/core-2.11.8.tgz", + "integrity": "sha512-P1st0aksCrn9sGZhp8GMYwBnQsbvAWsZAX44oXNNvLHGqAOcoVxmjZiohstwQ7SqKnbR47akdNi+uleWD8+g6A==", + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/popperjs" + } + }, "node_modules/@react-jvectormap/core": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/@react-jvectormap/core/-/core-1.0.4.tgz", @@ -2854,6 +3101,14 @@ "@types/react": "*" } }, + "node_modules/@types/react-transition-group": { + "version": "4.4.10", + "resolved": "https://registry.npmjs.org/@types/react-transition-group/-/react-transition-group-4.4.10.tgz", + "integrity": "sha512-hT/+s0VQs2ojCX823m60m5f0sL5idt9SO6Tj6Dg+rdphGPIeJbJ6CxvBYkgkGKrYeDjvIpKTR38UzmtHJOGW3Q==", + "dependencies": { + "@types/react": "*" + } + }, "node_modules/@types/reactcss": { "version": "1.2.12", "resolved": "https://registry.npmjs.org/@types/reactcss/-/reactcss-1.2.12.tgz", @@ -4872,6 +5127,15 @@ "integrity": "sha512-X7BJ2yElsnOJ30pZF4uIIDfBEVgF4XEBxL9Bxhy6dnrm5hkzqmsWHGTiHqRiITNhMyFLyAiWndIJP7Z1NTteDg==", "peer": true }, + "node_modules/dom-helpers": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/dom-helpers/-/dom-helpers-5.2.1.tgz", + "integrity": "sha512-nRCa7CK3VTrM2NmGkIy4cbK7IZlgBE/PYMn55rrXefr5xXDP0LdtfPnblFDoVdcAfslJ7or6iqAUnx0CCGIWQA==", + "dependencies": { + "@babel/runtime": "^7.8.7", + "csstype": "^3.0.2" + } + }, "node_modules/dotenv": { "version": "16.4.5", "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.5.tgz", @@ -10024,6 +10288,21 @@ "react-dom": ">=18" } }, + "node_modules/react-transition-group": { + "version": "4.4.5", + "resolved": "https://registry.npmjs.org/react-transition-group/-/react-transition-group-4.4.5.tgz", + "integrity": "sha512-pZcd1MCJoiKiBR2NRxeCRg13uCXbydPnmB4EOeRrY7480qNWO8IIgQG6zlDkm6uRMsURXPuKq0GWtiM59a5Q6g==", + "dependencies": { + "@babel/runtime": "^7.5.5", + "dom-helpers": "^5.0.1", + "loose-envify": "^1.4.0", + "prop-types": "^15.6.2" + }, + "peerDependencies": { + "react": ">=16.6.0", + "react-dom": ">=16.6.0" + } + }, "node_modules/reactcss": { "version": "1.2.3", "resolved": "https://registry.npmjs.org/reactcss/-/reactcss-1.2.3.tgz", diff --git a/package.json b/package.json index 0d92c666..d2e52ca0 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "pre-commit": "npm run lint:fix && npm run format" }, "dependencies": { + "@mui/material": "^5.16.4", "@react-jvectormap/core": "^1.0.4", "@react-jvectormap/world": "^1.1.2", "@reduxjs/toolkit": "^2.2.5", @@ -26,8 +27,6 @@ "axios": "^1.7.2", "axios-mock-adapter": "^1.22.0", "chart.js": "^4.4.3", - "chart.js": "^4.4.3", - "date-fns": "^3.6.0", "cloudinary": "^2.2.0", "cloudinary-core": "^2.13.1", "date-fns": "^3.6.0", @@ -88,6 +87,7 @@ "eslint-plugin-react": "^7.34.2", "eslint-plugin-react-hooks": "^4.6.0", "eslint-plugin-react-refresh": "^0.4.6", + "husky": "^8.0.0", "jest": "^29.7.0", "jsdom": "^24.1.0", "lint-staged": "^15.2.5", @@ -99,7 +99,6 @@ "tailwindcss": "^3.4.3", "typescript": "^5.2.2", "vite": "^5.2.0", - "vitest": "^1.6.0", - "husky": "^8.0.0" + "vitest": "^1.6.0" } } diff --git a/src/assets/icons/Airtel.png b/src/assets/icons/Airtel.png new file mode 100644 index 00000000..895e2935 Binary files /dev/null and b/src/assets/icons/Airtel.png differ diff --git a/src/assets/icons/MemberDiscount.png b/src/assets/icons/MemberDiscount.png new file mode 100644 index 00000000..6f74e16b Binary files /dev/null and b/src/assets/icons/MemberDiscount.png differ diff --git a/src/assets/icons/add.svg b/src/assets/icons/add.svg new file mode 100644 index 00000000..331b67e2 --- /dev/null +++ b/src/assets/icons/add.svg @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/src/assets/icons/discount.svg b/src/assets/icons/discount.svg new file mode 100644 index 00000000..b95b79d5 --- /dev/null +++ b/src/assets/icons/discount.svg @@ -0,0 +1,4 @@ + + + + diff --git a/src/assets/icons/masterCARD.svg b/src/assets/icons/masterCARD.svg new file mode 100644 index 00000000..56d537c3 --- /dev/null +++ b/src/assets/icons/masterCARD.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/src/assets/icons/moneyReturn.png b/src/assets/icons/moneyReturn.png new file mode 100644 index 00000000..efd7cd9f Binary files /dev/null and b/src/assets/icons/moneyReturn.png differ diff --git a/src/assets/icons/moneyReturn.svg b/src/assets/icons/moneyReturn.svg new file mode 100644 index 00000000..0ea7fe08 --- /dev/null +++ b/src/assets/icons/moneyReturn.svg @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/src/assets/icons/mtn-momo.jpg b/src/assets/icons/mtn-momo.jpg new file mode 100644 index 00000000..606a810e Binary files /dev/null and b/src/assets/icons/mtn-momo.jpg differ diff --git a/src/assets/icons/mtn_momo.png b/src/assets/icons/mtn_momo.png new file mode 100644 index 00000000..bfbef758 Binary files /dev/null and b/src/assets/icons/mtn_momo.png differ diff --git a/src/assets/icons/support.svg b/src/assets/icons/support.svg new file mode 100644 index 00000000..4c2b7bcc --- /dev/null +++ b/src/assets/icons/support.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/src/assets/icons/supportIcon.png b/src/assets/icons/supportIcon.png new file mode 100644 index 00000000..be0b0e9d Binary files /dev/null and b/src/assets/icons/supportIcon.png differ diff --git a/src/assets/icons/truck.png b/src/assets/icons/truck.png new file mode 100644 index 00000000..816173db Binary files /dev/null and b/src/assets/icons/truck.png differ diff --git a/src/assets/icons/truck.svg b/src/assets/icons/truck.svg new file mode 100644 index 00000000..34fa8375 --- /dev/null +++ b/src/assets/icons/truck.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/src/assets/icons/visaIcon.svg b/src/assets/icons/visaIcon.svg new file mode 100644 index 00000000..16f4c63c --- /dev/null +++ b/src/assets/icons/visaIcon.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/src/components/Cart/CartCollection.tsx b/src/components/Cart/CartCollection.tsx new file mode 100644 index 00000000..5e48d5c9 --- /dev/null +++ b/src/components/Cart/CartCollection.tsx @@ -0,0 +1,26 @@ +import React from 'react'; + +// interface CartProps { +// id: number; +// name: string; +// } + +function CartCollection() { + + return ( +
+
+ Item 1 + Item 1 + Item 1 + Item 1 +
+
+

Cart Collection

+

My saved collection for summer sales

+
+
+ ); +} + +export default CartCollection; diff --git a/src/features/Payments/paymentSlice.ts b/src/features/Payments/paymentSlice.ts new file mode 100644 index 00000000..b75fd431 --- /dev/null +++ b/src/features/Payments/paymentSlice.ts @@ -0,0 +1,122 @@ +import { createAsyncThunk, createSlice, PayloadAction } from '@reduxjs/toolkit'; +import axios from 'axios'; +import { showErrorToast, showSuccessToast } from '@/utils/ToastConfig'; + +interface PaymentState { + loading: boolean; + error: string | null; +} + +const initialState: PaymentState = { + loading: false, + error: null, +}; + +interface MomoPaymentParams { + momoNumber: string; + orderId: number; +} + +export const makeMomoPayment = createAsyncThunk( + 'payment/momoPayment', + async ({ momoNumber, orderId }: MomoPaymentParams, { rejectWithValue }) => { + try { + const tokenFromStorage = localStorage.getItem('token') || ''; + const response = await axios.post( + `${import.meta.env.VITE_BASE_URL}/buyer/momoPay`, + { + momoNumber, + orderId, + }, + { + headers: { + Authorization: `Bearer ${tokenFromStorage}`, + }, + } + ); + showSuccessToast(response.data.message); + return response.data; + } catch (error) { + if (axios.isAxiosError(error)) { + console.error('Error response:', error.response); + const errorMessage = error.response?.data?.message || 'Payment failed'; + showErrorToast(errorMessage); + return rejectWithValue(error.response?.data || 'Payment failed'); + } + console.error('Unexpected error:', error); + showErrorToast('Payment failed'); + return rejectWithValue('Payment failed'); + } + } +); + +interface StripePaymentParams { + token: string; + orderId: number; +} + +export const makeStripePayment = createAsyncThunk( + 'payment/stripePayment', + async ({ token, orderId }: StripePaymentParams, { rejectWithValue }) => { + try { + const tokenFromStorage = localStorage.getItem('token') || ''; + const response = await axios.post( + `${import.meta.env.VITE_BASE_URL}/buyer/payment`, + { + token, + orderId, + }, + { + headers: { + Authorization: `Bearer ${tokenFromStorage}`, + }, + } + ); + showSuccessToast(response.data.message); + return response.data; + } catch (error) { + if (axios.isAxiosError(error)) { + console.error('Error response:', error.response); + const errorMessage = error.response?.data?.message || 'Payment failed'; + showErrorToast(errorMessage); + return rejectWithValue(error.response?.data || 'Payment failed'); + } + console.error('Unexpected error:', error); + showErrorToast('Payment failed'); + return rejectWithValue('Payment failed'); + } + } +); + +const paymentSlice = createSlice({ + name: 'payment', + initialState, + reducers: {}, + extraReducers: (builder) => { + builder + .addCase(makeMomoPayment.pending, (state) => { + state.loading = true; + state.error = null; + }) + .addCase(makeMomoPayment.fulfilled, (state) => { + state.loading = false; + }) + .addCase(makeMomoPayment.rejected, (state, action) => { + state.loading = false; + state.error = action.error.message || 'Payment failed'; + }) + .addCase(makeStripePayment.pending, (state) => { + state.loading = true; + state.error = null; + }) + .addCase(makeStripePayment.fulfilled, (state) => { + state.loading = false; + }) + .addCase(makeStripePayment.rejected, (state, action) => { + state.loading = false; + state.error = action.error.message || 'Payment failed'; + }); + }, +}); + +export default paymentSlice.reducer; diff --git a/src/pages/OrderCompletion.tsx b/src/pages/OrderCompletion.tsx new file mode 100644 index 00000000..e713b7fd --- /dev/null +++ b/src/pages/OrderCompletion.tsx @@ -0,0 +1,197 @@ +import React, { useState } from 'react'; +import { useDispatch, useSelector } from 'react-redux'; +import { Select, MenuItem, FormControl } from '@mui/material'; +import { AppDispatch, RootState } from '@/app/store'; // Adjust the path as necessary +import { makeMomoPayment, makeStripePayment } from '@/features/Payments/paymentSlice'; +import truck from '@/assets/icons/truck.svg'; +import moneyReturn from '@/assets/icons/moneyReturn.svg'; +import supportIcon from '@/assets/icons/support.svg'; +import discountIcon from '@/assets/icons/discount.svg'; +import visaIcon from '@/assets/icons/visaIcon.svg'; +import masterCardIcon from '@/assets/icons/masterCARD.svg'; +import airtel from '@/assets/icons/Airtel.png'; +import momo from '@/assets/icons/mtn_momo.png'; +import add from '@/assets/icons/add.svg'; +import CartCollection from '@/components/Cart/CartCollection'; +import HSButton from '@/components/form/HSButton'; + +const OrderCompletion = () => { + const [selectedPaymentMethod, setSelectedPaymentMethod] = useState('Debit Card'); + const [selectedCard, setSelectedCard] = useState('BK Bank'); + const [selectedMomoOption, setSelectedMomoOption] = useState('MTN Mobile Money'); + const dispatch = useDispatch(); + + const handlePaymentMethodChange = (event: { target: any }) => { + setSelectedPaymentMethod(event.target.value); + }; + + const handleCardChange = (event: { target: { value: React.SetStateAction } }) => { + setSelectedCard(event.target.value); + }; + + const handleMomoOptionChange = (event: { target: { value: React.SetStateAction } }) => { + setSelectedMomoOption(event.target.value); + }; + + const handlePayment = () => { + const orderId = 48; + if (selectedPaymentMethod === 'Momo Payment') { + const momoNumber = '0780609878'; + dispatch(makeMomoPayment({ momoNumber, orderId })); + } else if (selectedPaymentMethod === 'Debit Card Payment') { + const token = 'tok_visa'; + dispatch(makeStripePayment({ token, orderId })); + } + }; + + const momoOptions = [ + { value: 'MTN Mobile Money', label: 'MTN Mobile Money', icon: momo }, + { value: 'Airtel Money', label: 'Airtel Money', icon: airtel }, + ]; + + const cardOptions = [ + { value: 'BK Bank', label: 'BK Bank **** **** **** 1234', icon: visaIcon }, + { value: 'Equity Bank', label: 'Equity Bank **** **** **** 1234', icon: masterCardIcon }, + ]; + + return ( +
+
+
+

Complete your Order

+

+ You are just a few steps away to finish your order.. +

+
+ +
+
+ +
+

Free Delivery

+

Free shipping on all order

+
+
+
+ +
+

Money Return

+

Back guarantee under 7 days

+
+
+
+ +
+

Online Support 24/7

+

Support Online 24 hours a day

+
+
+
+ +
+

Member Discount

+

On every order over $ 20.00

+
+
+
+
+ +
+
+

Payment Methods

+
+ + +
+ {selectedPaymentMethod === 'Momo Payment' && ( +
+

Momo Options

+ + + +
+ )} + {selectedPaymentMethod === 'Debit Card Payment' && ( +
+

My Cards

+ + + +
+ + +
+
+ )} +
+ + +
+
+
+ +
+

Promo code

+
+ + +
+
+

Total

+

$ 200.00

+
+
+

Shipping

+

$ 200.00

+
+
+

Total Cost

+

$ 400.00

+
+ +
+
+
+
+ ); +}; + +export default OrderCompletion; diff --git a/src/routes/AppRoutes.tsx b/src/routes/AppRoutes.tsx index d95608b8..4c6dc335 100644 --- a/src/routes/AppRoutes.tsx +++ b/src/routes/AppRoutes.tsx @@ -23,6 +23,7 @@ import Cart from '@/components/Cart/Cart'; import Seller from '@/pages/Seller'; import CheckoutPage from '@/pages/Checkout'; import Aboutus from '@/components/home/Aboutus'; +import OrderCompletion from '@/pages/OrderCompletion'; function AppRoutes() { return ( @@ -44,6 +45,7 @@ function AppRoutes() { } /> } /> } /> + } /> } /> } />