import { Box, Container, Grid, Paper, Table, TableBody, TableCell, TableContainer, TableHead, TableRow, Typography, } from '@mui/material' 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/rd-get-me`, { // headers: { // Authorization: `Bearer ${token}`, // }, // }) // if (res.data.success) { // setOwnerDetails({ ...res.data.user }) // } // } // Calculate total GST for the entire cart const totalGST = cartItem.reduce((acc, item) => { // console.log(item) const gstAmount = (item.price * item.GST) / 100 return acc + gstAmount * item.count }, 0) return ( OrderId : {orderId} Bill Address {billTo} Ship Address {shipTo} Payment mode : {paymentMode} SBU: {ownerDetails?.SBU} Product Category Brand SKU Quantity Price GST Subtotal {cartItem.map((row, index) => { const gstAmount = (row.price * row.GST) / 100 return ( {/* {row.product.name} */} {row.name} {row.category.categoryName} {row.brand.brandName} {row.SKU} {row.count} ₹{row.price} ₹{gstAmount} ₹{row.price * row.count} ) })} Subtotal: ₹ {subtotal} Total GST: ₹ {totalGST} Grand Total: ₹ {subtotal + totalGST}
) } export default OrderConfirmation