diff --git a/src/views/orders/OrderDetails.js b/src/views/orders/OrderDetails.js
index f01c948..2663442 100644
--- a/src/views/orders/OrderDetails.js
+++ b/src/views/orders/OrderDetails.js
@@ -15,18 +15,36 @@ import {
import axios from 'axios' // Make sure you have axios installed
import { useNavigate, useParams } from 'react-router-dom'
import Axios from '../../axios'
+import { isAutheticated } from '../../auth'
const OrderDetails = () => {
const [order, setOrder] = useState(null)
const [loading, setLoading] = useState(true)
const [error, setError] = useState(null)
+ const token = isAutheticated()
const navigate = useNavigate()
const { id } = useParams() // Assuming order ID is passed as a route parameter
+ const [ownerDetails, setOwnerDetails] = useState()
+ const getData = async () => {
+ let res = await Axios.get(`/api/v1/user/details`, {
+ headers: {
+ Authorization: `Bearer ${token}`,
+ },
+ })
+ if (res.data.success) {
+ setOwnerDetails({ ...res.data.user })
+ }
+ }
+ console.log('order', order)
useEffect(() => {
const fetchOrderDetails = async () => {
try {
- const response = await Axios.get(`/api/get-single-placed-order-pd/${id}`) // Adjust API endpoint as needed
+ const response = await Axios.get(`/api/get-single-placed-order-pd/${id}`, {
+ headers: {
+ Authorization: `Bearer ${token}`,
+ },
+ }) // Adjust API endpoint as needed
setOrder(response.data.singleOrder)
console.log(response)
setLoading(false)
@@ -35,7 +53,7 @@ const OrderDetails = () => {
setLoading(false)
}
}
-
+ getData()
fetchOrderDetails()
}, [id])
@@ -96,6 +114,11 @@ const OrderDetails = () => {
Payment Mode: {paymentMode}
+
+
+ SBU: {ownerDetails?.SBU}
+
+
@@ -113,6 +136,8 @@ const OrderDetails = () => {
Product
+ Category
+ Brand
SKU
Quantity
Price
@@ -122,7 +147,7 @@ const OrderDetails = () => {
{order.orderItem.map((row, index) => {
- const gstAmount = (row.productId.price * row.productId.GST) / 100
+ const gstAmount = (row.price * row.GST) / 100
return (
{
- {row.productId.name}
+ {row.name}
- {row.productId.SKU}
+ {row.categoryName}
+ {row.brandName}
+ {row.SKU}
{row.quantity}
- ₹{row.productId.price}
+ ₹{row.price}
₹{gstAmount}
- ₹{row.productId.price * row.quantity}
+ ₹{row.price * row.quantity}
)
})}
-
+
Subtotal: ₹ {subtotal}
-
+
Total GST: ₹ {gstTotal}
-
+
Grand Total: ₹ {grandTotal}
diff --git a/src/views/pages/cart/orderConfirmation.js b/src/views/pages/cart/orderConfirmation.js
index bcda06f..1a42d24 100644
--- a/src/views/pages/cart/orderConfirmation.js
+++ b/src/views/pages/cart/orderConfirmation.js
@@ -11,13 +11,29 @@ import {
TableRow,
Typography,
} from '@mui/material'
-import React from 'react'
+import React, { useEffect, useState } from 'react'
import { useSelector } from 'react-redux'
import { selectCartSubtotal } from '../../../redux-store/CartStore/ducs'
+import { isAutheticated } from '../../../auth'
+import Axios from '../../../axios'
const OrderConfirmation = ({ orderId, billTo, shipTo, paymentMode, cartItem }) => {
const subtotal = useSelector(selectCartSubtotal)
-
+ const [ownerDetails, setOwnerDetails] = useState()
+ const token = isAutheticated()
+ const getData = async () => {
+ let res = await Axios.get(`/api/v1/user/details`, {
+ headers: {
+ Authorization: `Bearer ${token}`,
+ },
+ })
+ if (res.data.success) {
+ setOwnerDetails({ ...res.data.user })
+ }
+ }
+ useEffect(() => {
+ getData()
+ }, [])
// Calculate total GST for the entire cart
const totalGST = cartItem.reduce((acc, item) => {
// console.log(item)
@@ -49,6 +65,11 @@ const OrderConfirmation = ({ orderId, billTo, shipTo, paymentMode, cartItem }) =
Payment mode : {paymentMode}
+
+
+ SBU: {ownerDetails?.SBU}
+
+
@@ -65,6 +86,8 @@ const OrderConfirmation = ({ orderId, billTo, shipTo, paymentMode, cartItem }) =
Product
+ Category
+ Brand
SKU
Quantity
Price
@@ -93,6 +116,8 @@ const OrderConfirmation = ({ orderId, billTo, shipTo, paymentMode, cartItem }) =
+ {row.category.categoryName}
+ {row.brand.brandName}
{row.SKU}
{row.count}
₹{row.price}
@@ -102,20 +127,20 @@ const OrderConfirmation = ({ orderId, billTo, shipTo, paymentMode, cartItem }) =
)
})}
-
+
Subtotal: ₹ {subtotal}
-
+
Total GST: ₹ {totalGST}
-
+
Grand Total: ₹ {subtotal + totalGST}
diff --git a/src/views/pages/cart/reviewOrder.js b/src/views/pages/cart/reviewOrder.js
index 9b2c6d5..4ec0243 100644
--- a/src/views/pages/cart/reviewOrder.js
+++ b/src/views/pages/cart/reviewOrder.js
@@ -77,6 +77,7 @@ const ReviewOrder = ({
Swal.fire('Something went wrong', error.message, 'error')
}
}
+ console.log('cartitems', cartItem)
return (
@@ -114,6 +115,8 @@ const ReviewOrder = ({
Product
+ Category
+ Brand
SKU
Quantity
Price
@@ -142,6 +145,8 @@ const ReviewOrder = ({
+ {row.category.categoryName}
+ {row.brand.brandName}
{row.SKU}
{row.count}
₹{row.price}
@@ -151,20 +156,20 @@ const ReviewOrder = ({
)
})}
-
+
Subtotal: ₹ {subtotal}
-
+
Total GST: ₹ {totalGST}
-
+
Grand Total: ₹ {subtotal + totalGST}