diff --git a/src/index.js b/src/index.js index 0ab534a..8a829f2 100644 --- a/src/index.js +++ b/src/index.js @@ -15,9 +15,9 @@ import { cibGmail } from "@coreui/icons"; import { createRoot } from "react-dom/client"; const setupAxios = () => { - // axios.defaults.baseURL = "http://localhost:5000"; + axios.defaults.baseURL = "http://localhost:5000"; // axios.defaults.baseURL = "https://cheminova-api-2.onrender.com"; - axios.defaults.baseURL = "https://api.cnapp.co.in"; + // axios.defaults.baseURL = "https://api.cnapp.co.in"; axios.defaults.headers = { "Cache-Control": "no-cache,no-store", diff --git a/src/views/orders/ViewOrders.js b/src/views/orders/ViewOrders.js index 2cf1c15..af7eeeb 100644 --- a/src/views/orders/ViewOrders.js +++ b/src/views/orders/ViewOrders.js @@ -27,6 +27,7 @@ import { isAutheticated } from "src/auth"; import Swal from "sweetalert2"; import OrderDetailsDialog from "./partialOrderModal"; import InvoiceTable from "./invoiceTable"; +import PendingOrderTable from "./pendingOrderTable"; const ViewOrders = () => { const [order, setOrder] = useState(null); // State to store order details @@ -297,12 +298,12 @@ const ViewOrders = () => { - {onvoicesData.length > 0 && ( + {order.invoices?.length > 0 && ( <> Invoices - + )} @@ -361,6 +362,15 @@ const ViewOrders = () => { + {order.invoices?.length > 0 && ( + <> + {" "} + + Order Itmes to processed + + + + )} @@ -387,7 +397,7 @@ const ViewOrders = () => { - + {/* { "-" )} - {/* {row.date} */} + ))} - + */} diff --git a/src/views/orders/invoiceTable.js b/src/views/orders/invoiceTable.js index f0c4220..356687d 100644 --- a/src/views/orders/invoiceTable.js +++ b/src/views/orders/invoiceTable.js @@ -43,7 +43,7 @@ const InvoiceTable = ({ invoices }) => { {invoice.items.map((item) => (
- {item.name} ({item.SKU}) x {item.processquantity} + {item.name} ({item.SKU}) x {item.processquantity}
))}
diff --git a/src/views/orders/partialOrderModal.js b/src/views/orders/partialOrderModal.js index 9f8f68f..b1b7b0b 100644 --- a/src/views/orders/partialOrderModal.js +++ b/src/views/orders/partialOrderModal.js @@ -22,7 +22,7 @@ const OrderDetailsDialog = ({ open, onClose, order, onSubmit }) => { const [availability, setAvailability] = useState( order?.orderItem.map((item) => ({ ...item, // Keep all original properties from orderItem - processquantity: item.quantity, // Add availability field with default value equal to quantity + processquantity: item.remainingQuantity, // Add availability field with default value equal to quantity })) ); @@ -31,7 +31,7 @@ const OrderDetailsDialog = ({ open, onClose, order, onSubmit }) => { const updatedAvailability = [...availability]; const newValue = Math.max( 0, - Math.min(value, updatedAvailability[index].quantity) + Math.min(value, updatedAvailability[index].remainingQuantity) ); // Ensure value is between 0 and available quantity updatedAvailability[index].processquantity = newValue; setAvailability(updatedAvailability); @@ -65,9 +65,9 @@ const OrderDetailsDialog = ({ open, onClose, order, onSubmit }) => { {order?.orderItem.map((item, index) => { - const subtotal = item.price * item.quantity; + const subtotal = item.price * item.remainingQuantity; const gstAmount = - ((item.GST * item.price) / 100) * item.quantity; + ((item.GST * item.price) / 100) * item.remainingQuantity; const totalWithGST = subtotal + gstAmount; return ( @@ -83,7 +83,9 @@ const OrderDetailsDialog = ({ open, onClose, order, onSubmit }) => { ₹{item.price} - {item.quantity} + + {item.remainingQuantity} + { } inputProps={{ min: 0, - max: item.quantity, + max: item.remainingQuantity, }} style={{ width: "60px", textAlign: "center" }} /> diff --git a/src/views/orders/pendingOrderTable.js b/src/views/orders/pendingOrderTable.js new file mode 100644 index 0000000..87bef79 --- /dev/null +++ b/src/views/orders/pendingOrderTable.js @@ -0,0 +1,81 @@ +import { + Box, + Grid, + TableContainer, + Paper, + Table, + TableHead, + TableRow, + TableCell, + TableBody, + Typography, +} from "@mui/material"; +import React from "react"; + +const PendingOrderTable = ({ order }) => { + return ( + + + + + + + + Product + Price (₹) + Quantity + Subtotal (₹) + GST (%) + GST Amount (₹) + Total with GST (₹) + + + + {order?.orderItem.map((item, index) => { + // Check if remainingQuantity is greater than 0 + if (item.remainingQuantity > 0) { + const subtotal = item.price * item.remainingQuantity; + const gstAmount = + ((item.GST * item.price) / 100) * item.remainingQuantity; + const totalWithGST = subtotal + gstAmount; + + return ( + + + {item.productId.name} + + {item.productId.name} + + + ₹{item.price} + + {item.remainingQuantity} + + ₹{subtotal} + {item.GST}% + ₹{gstAmount} + ₹{totalWithGST} + + ); + } + // Return null if remainingQuantity is 0 + return null; + })} + +
+
+
+
+
+ ); +}; + +export default PendingOrderTable;