order related things done
This commit is contained in:
parent
0bf978357d
commit
05c9d902ff
@ -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",
|
||||
|
@ -33,15 +33,19 @@ const ProcessingOrders = () => {
|
||||
const [searchText, setSearchText] = useState("");
|
||||
const navigate = useNavigate();
|
||||
const token = isAutheticated();
|
||||
const searchRef = useRef();
|
||||
const searchRef = useRef();
|
||||
const fetchOrdersDebounced = useRef(
|
||||
debounce((page, limit, searchField, searchText) => {
|
||||
fetchOrders(page, limit, searchField, searchText);
|
||||
}, 500)
|
||||
).current;
|
||||
|
||||
|
||||
const fetchOrders = async (page, limit, searchField = "", searchText = "") => {
|
||||
const fetchOrders = async (
|
||||
page,
|
||||
limit,
|
||||
searchField = "",
|
||||
searchText = ""
|
||||
) => {
|
||||
setLoading(true);
|
||||
try {
|
||||
const response = await axios.get("/api/get-delivered-invoice-admin", {
|
||||
@ -50,8 +54,9 @@ const ProcessingOrders = () => {
|
||||
},
|
||||
params: {
|
||||
limit,
|
||||
page: page + 1,
|
||||
[searchField === "Order ID" ? "orderId" : "invoiceId"]: searchText || "",
|
||||
page: page + 1,
|
||||
[searchField === "Order ID" ? "orderId" : "invoiceId"]:
|
||||
searchText || "",
|
||||
},
|
||||
});
|
||||
setOrders(response?.data?.invoices);
|
||||
@ -65,7 +70,7 @@ const ProcessingOrders = () => {
|
||||
|
||||
useEffect(() => {
|
||||
fetchOrdersDebounced(page, rowsPerPage, searchField, searchText);
|
||||
}, [page, rowsPerPage, searchField, searchText]);
|
||||
}, [page, rowsPerPage, searchField, searchText]);
|
||||
|
||||
const handleSearchChange = (event) => {
|
||||
const value = event.target.value;
|
||||
@ -78,12 +83,12 @@ const ProcessingOrders = () => {
|
||||
};
|
||||
|
||||
const handleChangePage = (event, newPage) => {
|
||||
setPage(newPage);
|
||||
setPage(newPage);
|
||||
};
|
||||
|
||||
const handleChangeRowsPerPage = (event) => {
|
||||
setRowsPerPage(parseInt(event.target.value, 10));
|
||||
setPage(0);
|
||||
setPage(0);
|
||||
};
|
||||
|
||||
return (
|
||||
@ -141,8 +146,12 @@ const ProcessingOrders = () => {
|
||||
<TableCell>{invoice.orderId.uniqueId}</TableCell>
|
||||
<TableCell>{invoice.invoiceId}</TableCell>
|
||||
<TableCell>
|
||||
{new Date(invoice.courierstatus_timeline.delivered).toDateString()}
|
||||
<span>, {formatAMPM(invoice.courierstatus_timeline.delivered)}</span>
|
||||
{new Date(
|
||||
invoice.courierstatus_timeline.delivered
|
||||
).toDateString()}
|
||||
<span>
|
||||
, {formatAMPM(invoice.courierstatus_timeline.delivered)}
|
||||
</span>
|
||||
</TableCell>
|
||||
<TableCell>{invoice.items.length}</TableCell>
|
||||
<TableCell>{invoice.invoiceAmount}</TableCell>
|
||||
@ -152,7 +161,9 @@ const ProcessingOrders = () => {
|
||||
variant="contained"
|
||||
color="primary"
|
||||
onClick={() =>
|
||||
navigate(`/orders/${invoice.courierStatus}/${invoice._id}`)
|
||||
navigate(
|
||||
`/orders/invoice/${invoice.courierStatus}/${invoice._id}`
|
||||
)
|
||||
}
|
||||
>
|
||||
View
|
||||
@ -174,7 +185,7 @@ const ProcessingOrders = () => {
|
||||
component="div"
|
||||
count={totalOrders}
|
||||
rowsPerPage={rowsPerPage}
|
||||
page={page}
|
||||
page={page}
|
||||
onPageChange={handleChangePage}
|
||||
onRowsPerPageChange={handleChangeRowsPerPage}
|
||||
/>
|
||||
|
@ -33,15 +33,19 @@ const ProcessingOrders = () => {
|
||||
const [searchText, setSearchText] = useState("");
|
||||
const navigate = useNavigate();
|
||||
const token = isAutheticated();
|
||||
const searchRef = useRef();
|
||||
const searchRef = useRef();
|
||||
const fetchOrdersDebounced = useRef(
|
||||
debounce((page, limit, searchField, searchText) => {
|
||||
fetchOrders(page, limit, searchField, searchText);
|
||||
}, 500)
|
||||
).current;
|
||||
|
||||
|
||||
const fetchOrders = async (page, limit, searchField = "", searchText = "") => {
|
||||
const fetchOrders = async (
|
||||
page,
|
||||
limit,
|
||||
searchField = "",
|
||||
searchText = ""
|
||||
) => {
|
||||
setLoading(true);
|
||||
try {
|
||||
const response = await axios.get("/api/get-dispatched-invoice-admin", {
|
||||
@ -50,8 +54,9 @@ const ProcessingOrders = () => {
|
||||
},
|
||||
params: {
|
||||
limit,
|
||||
page: page + 1,
|
||||
[searchField === "Order ID" ? "orderId" : "invoiceId"]: searchText || "",
|
||||
page: page + 1,
|
||||
[searchField === "Order ID" ? "orderId" : "invoiceId"]:
|
||||
searchText || "",
|
||||
},
|
||||
});
|
||||
setOrders(response?.data?.invoices);
|
||||
@ -65,7 +70,7 @@ const ProcessingOrders = () => {
|
||||
|
||||
useEffect(() => {
|
||||
fetchOrdersDebounced(page, rowsPerPage, searchField, searchText);
|
||||
}, [page, rowsPerPage, searchField, searchText]);
|
||||
}, [page, rowsPerPage, searchField, searchText]);
|
||||
|
||||
const handleSearchChange = (event) => {
|
||||
const value = event.target.value;
|
||||
@ -78,12 +83,12 @@ const ProcessingOrders = () => {
|
||||
};
|
||||
|
||||
const handleChangePage = (event, newPage) => {
|
||||
setPage(newPage);
|
||||
setPage(newPage);
|
||||
};
|
||||
|
||||
const handleChangeRowsPerPage = (event) => {
|
||||
setRowsPerPage(parseInt(event.target.value, 10));
|
||||
setPage(0);
|
||||
setPage(0);
|
||||
};
|
||||
|
||||
return (
|
||||
@ -141,8 +146,12 @@ const ProcessingOrders = () => {
|
||||
<TableCell>{invoice.orderId.uniqueId}</TableCell>
|
||||
<TableCell>{invoice.invoiceId}</TableCell>
|
||||
<TableCell>
|
||||
{new Date(invoice.courierstatus_timeline.dispatched).toDateString()}
|
||||
<span>, {formatAMPM(invoice.courierstatus_timeline.dispatched)}</span>
|
||||
{new Date(
|
||||
invoice.courierstatus_timeline.dispatched
|
||||
).toDateString()}
|
||||
<span>
|
||||
, {formatAMPM(invoice.courierstatus_timeline.dispatched)}
|
||||
</span>
|
||||
</TableCell>
|
||||
<TableCell>{invoice.items.length}</TableCell>
|
||||
<TableCell>{invoice.invoiceAmount}</TableCell>
|
||||
@ -152,7 +161,9 @@ const ProcessingOrders = () => {
|
||||
variant="contained"
|
||||
color="primary"
|
||||
onClick={() =>
|
||||
navigate(`/orders/${invoice.courierStatus}/${invoice._id}`)
|
||||
navigate(
|
||||
`/orders/invoice/${invoice.courierStatus}/${invoice._id}`
|
||||
)
|
||||
}
|
||||
>
|
||||
View
|
||||
@ -174,7 +185,7 @@ const ProcessingOrders = () => {
|
||||
component="div"
|
||||
count={totalOrders}
|
||||
rowsPerPage={rowsPerPage}
|
||||
page={page}
|
||||
page={page}
|
||||
onPageChange={handleChangePage}
|
||||
onRowsPerPageChange={handleChangeRowsPerPage}
|
||||
/>
|
||||
|
@ -33,15 +33,19 @@ const ProcessingOrders = () => {
|
||||
const [searchText, setSearchText] = useState("");
|
||||
const navigate = useNavigate();
|
||||
const token = isAutheticated();
|
||||
const searchRef = useRef();
|
||||
const searchRef = useRef();
|
||||
const fetchOrdersDebounced = useRef(
|
||||
debounce((page, limit, searchField, searchText) => {
|
||||
fetchOrders(page, limit, searchField, searchText);
|
||||
}, 500)
|
||||
).current;
|
||||
|
||||
|
||||
const fetchOrders = async (page, limit, searchField = "", searchText = "") => {
|
||||
const fetchOrders = async (
|
||||
page,
|
||||
limit,
|
||||
searchField = "",
|
||||
searchText = ""
|
||||
) => {
|
||||
setLoading(true);
|
||||
try {
|
||||
const response = await axios.get("/api/get-processing-invoice-admin", {
|
||||
@ -50,8 +54,9 @@ const ProcessingOrders = () => {
|
||||
},
|
||||
params: {
|
||||
limit,
|
||||
page: page + 1,
|
||||
[searchField === "Order ID" ? "orderId" : "invoiceId"]: searchText || "",
|
||||
page: page + 1,
|
||||
[searchField === "Order ID" ? "orderId" : "invoiceId"]:
|
||||
searchText || "",
|
||||
},
|
||||
});
|
||||
setOrders(response?.data?.invoices);
|
||||
@ -65,7 +70,7 @@ const ProcessingOrders = () => {
|
||||
|
||||
useEffect(() => {
|
||||
fetchOrdersDebounced(page, rowsPerPage, searchField, searchText);
|
||||
}, [page, rowsPerPage, searchField, searchText]);
|
||||
}, [page, rowsPerPage, searchField, searchText]);
|
||||
|
||||
const handleSearchChange = (event) => {
|
||||
const value = event.target.value;
|
||||
@ -78,12 +83,12 @@ const ProcessingOrders = () => {
|
||||
};
|
||||
|
||||
const handleChangePage = (event, newPage) => {
|
||||
setPage(newPage);
|
||||
setPage(newPage);
|
||||
};
|
||||
|
||||
const handleChangeRowsPerPage = (event) => {
|
||||
setRowsPerPage(parseInt(event.target.value, 10));
|
||||
setPage(0);
|
||||
setPage(0);
|
||||
};
|
||||
|
||||
return (
|
||||
@ -141,8 +146,12 @@ const ProcessingOrders = () => {
|
||||
<TableCell>{invoice.orderId.uniqueId}</TableCell>
|
||||
<TableCell>{invoice.invoiceId}</TableCell>
|
||||
<TableCell>
|
||||
{new Date(invoice.courierstatus_timeline.processing).toDateString()}
|
||||
<span>, {formatAMPM(invoice.courierstatus_timeline.processing)}</span>
|
||||
{new Date(
|
||||
invoice.courierstatus_timeline.processing
|
||||
).toDateString()}
|
||||
<span>
|
||||
, {formatAMPM(invoice.courierstatus_timeline.processing)}
|
||||
</span>
|
||||
</TableCell>
|
||||
<TableCell>{invoice.items.length}</TableCell>
|
||||
<TableCell>{invoice.invoiceAmount}</TableCell>
|
||||
@ -152,7 +161,9 @@ const ProcessingOrders = () => {
|
||||
variant="contained"
|
||||
color="primary"
|
||||
onClick={() =>
|
||||
navigate(`/orders/${invoice.courierStatus}/${invoice._id}`)
|
||||
navigate(
|
||||
`/orders/invoice/${invoice.courierStatus}/${invoice._id}`
|
||||
)
|
||||
}
|
||||
>
|
||||
View
|
||||
@ -174,7 +185,7 @@ const ProcessingOrders = () => {
|
||||
component="div"
|
||||
count={totalOrders}
|
||||
rowsPerPage={rowsPerPage}
|
||||
page={page}
|
||||
page={page}
|
||||
onPageChange={handleChangePage}
|
||||
onRowsPerPageChange={handleChangeRowsPerPage}
|
||||
/>
|
||||
|
@ -18,6 +18,7 @@ import {
|
||||
DialogTitle,
|
||||
TextField,
|
||||
Divider,
|
||||
Chip,
|
||||
} from "@mui/material";
|
||||
import onvoicesData from "../../assets/incoicedata.json";
|
||||
import { useNavigate, useParams } from "react-router-dom";
|
||||
@ -52,20 +53,18 @@ const ViewInvoices = () => {
|
||||
useEffect(() => {
|
||||
const fetchOrderDetails = async () => {
|
||||
try {
|
||||
const response = await axios.get(
|
||||
`/api/get-single-placed-order-pd/${id}`,
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
}
|
||||
);
|
||||
const response = await axios.get(`/api/invoice/details/${id}`, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
});
|
||||
console.log(response);
|
||||
setOrder(response.data.singleOrder);
|
||||
setStatus(response.data.singleOrder?.status);
|
||||
setInvoice(response.data);
|
||||
setStatus(response.data.courierStatus);
|
||||
|
||||
setLoading(false);
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
setError("Failed to fetch order details");
|
||||
setLoading(false);
|
||||
}
|
||||
@ -79,53 +78,40 @@ const ViewInvoices = () => {
|
||||
};
|
||||
|
||||
const handleUpdateClick = () => {
|
||||
if (orderStatus === "dispatched") {
|
||||
if (invoiceStatus === "dispatched") {
|
||||
setOpenDispatchDialog(true);
|
||||
} else if (orderStatus === "partial-processing") {
|
||||
setOpnePartialModal(true);
|
||||
} else if (orderStatus === "cancelled") {
|
||||
setOpenCancelDialog(true);
|
||||
} else if (orderStatus === "delivered") {
|
||||
} else if (invoiceStatus === "delivered") {
|
||||
setOpenDeliveredDialog(true);
|
||||
} else {
|
||||
}
|
||||
};
|
||||
|
||||
const handleConfirmUpdate = async (e) => {
|
||||
e.preventDefault();
|
||||
try {
|
||||
if (orderStatus === "cancelled") {
|
||||
if (!cancellationReason) {
|
||||
Swal.fire("Please give the order cancellation reason");
|
||||
}
|
||||
const cancellationRes = await axios.put(
|
||||
`/api/cancel-order/${id}`,
|
||||
if (invoiceStatus === "dispatched") {
|
||||
const res = await axios.put(
|
||||
`/api/invoice/dispatched/${id}`,
|
||||
{
|
||||
cancellationReason: cancellationReason,
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
"Access-Control-Allow-Origin": "*",
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
}
|
||||
);
|
||||
if (cancellationRes.status === 200) {
|
||||
Swal.fire(
|
||||
"Order Status updated",
|
||||
`Order got cancelled due to${cancellationReason}`,
|
||||
"success"
|
||||
);
|
||||
navigate(`/orders/${orderStatus}`);
|
||||
}
|
||||
} else if (orderStatus === "dispatched") {
|
||||
const cancellationRes = await axios.patch(
|
||||
`/api/change/status/${id}`,
|
||||
{
|
||||
status: orderStatus,
|
||||
courierName,
|
||||
TrackingID: couriertrackingId,
|
||||
couriertrackingId,
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
console.log(res);
|
||||
if (res.status === 200) {
|
||||
Swal.fire("Invoice Status updated", "Invoice Dispatched", "success");
|
||||
navigate(`/orders/dispatched`);
|
||||
}
|
||||
} else if (invoiceStatus === "delivered") {
|
||||
const deli = await axios.put(
|
||||
`/api/invoice/delivered/${id}`,
|
||||
{},
|
||||
|
||||
{
|
||||
headers: {
|
||||
"Access-Control-Allow-Origin": "*",
|
||||
@ -133,65 +119,16 @@ const ViewInvoices = () => {
|
||||
},
|
||||
}
|
||||
);
|
||||
if (cancellationRes.status === 200) {
|
||||
|
||||
if (deli.status === 200) {
|
||||
Swal.fire("Order Status updated", `Order Dispatched`, "success");
|
||||
|
||||
navigate(`/orders/${orderStatus}`);
|
||||
}
|
||||
} else if (orderStatus === "delivered") {
|
||||
if (!deliveryDate) {
|
||||
Swal.fire("Please enter the Delivery Date");
|
||||
setOpenDeliveredDialog(false);
|
||||
return;
|
||||
}
|
||||
const cancellationRes = await axios.patch(
|
||||
`/api/change/status/${id}`,
|
||||
{
|
||||
status: orderStatus,
|
||||
DDate: deliveryDate,
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
"Access-Control-Allow-Origin": "*",
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
}
|
||||
);
|
||||
if (cancellationRes.status === 200) {
|
||||
Swal.fire("Order Status updated", `Order in processing`, "success");
|
||||
navigate(`/orders/${orderStatus}`);
|
||||
}
|
||||
} else if (orderStatus === "processing") {
|
||||
const processingOrderInvoice = order?.orderItem
|
||||
.filter((item) => item.remainingQuantity > 0) // Only include items with remainingQuantity > 0
|
||||
.map((item) => ({
|
||||
...item,
|
||||
productId: item.productId._id,
|
||||
processquantity: item.remainingQuantity, // Add processquantity only for items with remainingQuantity > 0
|
||||
}));
|
||||
console.log(processingOrderInvoice);
|
||||
const cancellationRes = await axios.post(
|
||||
`/api/processing-order`,
|
||||
{
|
||||
invoiceItems: processingOrderInvoice,
|
||||
orderId: order._id,
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
"Access-Control-Allow-Origin": "*",
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
}
|
||||
);
|
||||
if (cancellationRes.status === 200) {
|
||||
Swal.fire("Order Status updated", `Order in processing`, "success");
|
||||
navigate(`/orders/${orderStatus}`);
|
||||
navigate(`/orders/delivered`);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
Swal.fire("Something went wrong ", error.message, "error");
|
||||
}
|
||||
// Perform update logic here
|
||||
|
||||
setOpenDispatchDialog(false);
|
||||
|
||||
@ -220,7 +157,7 @@ const ViewInvoices = () => {
|
||||
mb={5}
|
||||
>
|
||||
<Typography variant="h4" sx={{ flexGrow: 1, textAlign: "center" }}>
|
||||
Invoice Id : {order?.uniqueId}
|
||||
Invoice Id : {invoice?.invoiceId}
|
||||
</Typography>
|
||||
<Button
|
||||
color="primary"
|
||||
@ -236,9 +173,53 @@ const ViewInvoices = () => {
|
||||
<Typography variant="h4" gutterBottom>
|
||||
Invoice
|
||||
</Typography>
|
||||
<InvoiceTable invoices={invoice} />
|
||||
{/* <InvoiceTable invoices={invoice} /> */}
|
||||
<TableContainer component={Paper}>
|
||||
<Table>
|
||||
<TableHead>
|
||||
<TableRow>
|
||||
<TableCell>Invoice ID</TableCell>
|
||||
|
||||
<Typography variant="h4" my={3} gutterBottom>
|
||||
<TableCell>Items</TableCell>
|
||||
<TableCell>Subtotal</TableCell>
|
||||
<TableCell>GST Total</TableCell>
|
||||
<TableCell>Invoice Amount</TableCell>
|
||||
<TableCell>Courier Status</TableCell>
|
||||
</TableRow>
|
||||
</TableHead>
|
||||
<TableBody>
|
||||
<TableRow key={invoice.invoiceId}>
|
||||
<TableCell>{invoice.invoiceId}</TableCell>
|
||||
|
||||
<TableCell>
|
||||
{invoice.items.map((item) => (
|
||||
<div key={item.productId}>
|
||||
{item.name} ({item.SKU}) x{" "}
|
||||
<b>{item.processquantity}</b>
|
||||
</div>
|
||||
))}
|
||||
</TableCell>
|
||||
<TableCell>{invoice.subtotal}</TableCell>
|
||||
<TableCell>{invoice.gstTotal}</TableCell>
|
||||
<TableCell>{invoice.invoiceAmount}</TableCell>
|
||||
<TableCell>
|
||||
<Chip
|
||||
label={invoice.courierStatus}
|
||||
color={
|
||||
invoice.courierStatus === "delivered"
|
||||
? "success"
|
||||
: invoice.courierStatus === "dispatched"
|
||||
? "primary"
|
||||
: "warning"
|
||||
}
|
||||
/>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
</TableBody>
|
||||
</Table>
|
||||
</TableContainer>
|
||||
|
||||
{/* <Typography variant="h4" my={3} gutterBottom>
|
||||
Order Summary
|
||||
</Typography>
|
||||
|
||||
@ -258,7 +239,7 @@ const ViewInvoices = () => {
|
||||
</TableRow>
|
||||
</TableHead>
|
||||
<TableBody>
|
||||
{order?.orderItem.map((item, index) => {
|
||||
{invoice?.orderId?.orderItem.map((item, index) => {
|
||||
const subtotal = item.price * item.quantity;
|
||||
const gstAmount =
|
||||
((item.GST * item.price) / 100) * item.quantity;
|
||||
@ -293,7 +274,7 @@ const ViewInvoices = () => {
|
||||
</Table>
|
||||
</TableContainer>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid> */}
|
||||
|
||||
<Grid container spacing={2}>
|
||||
<Grid item sm={6} md={6} xl={6}>
|
||||
@ -306,17 +287,15 @@ const ViewInvoices = () => {
|
||||
}}
|
||||
>
|
||||
<Typography variant="h5" gutterBottom>
|
||||
Order Summary
|
||||
Invoice Summary
|
||||
</Typography>
|
||||
<Divider sx={{ marginBottom: 2 }} />
|
||||
<Typography>
|
||||
Total Items: {order?.orderItem.length}
|
||||
</Typography>
|
||||
<Typography>Total Items: {invoice?.items.length}</Typography>
|
||||
|
||||
<Typography>Total Subtotal: ₹{order?.subtotal}</Typography>
|
||||
<Typography>Total GST: ₹{order?.gstTotal}</Typography>
|
||||
<Typography>Total Subtotal: ₹{invoice?.subtotal}</Typography>
|
||||
<Typography>Total GST: ₹{invoice?.gstTotal}</Typography>
|
||||
<Typography variant="h5" sx={{ marginTop: 2 }}>
|
||||
Grand Total: ₹{order?.grandTotal}
|
||||
Grand Total: ₹{invoice?.invoiceAmount}
|
||||
</Typography>
|
||||
</Box>
|
||||
</Grid>
|
||||
@ -337,50 +316,54 @@ const ViewInvoices = () => {
|
||||
Customer Details
|
||||
</Typography>
|
||||
<Typography sx={{ mb: "0.5rem" }}>
|
||||
<strong>SBU:</strong> {order?.addedBy.SBU}
|
||||
<strong>SBU:</strong> {invoice?.orderId?.addedBy.SBU}
|
||||
</Typography>
|
||||
<Typography sx={{ mb: "0.5rem" }}>
|
||||
<strong>Name:</strong> {order?.addedBy.name}
|
||||
<strong>Name:</strong> {invoice?.orderId?.addedBy.name}
|
||||
</Typography>
|
||||
<Typography sx={{ mb: "0.5rem" }}>
|
||||
<strong>Email id:</strong> {order?.addedBy.email}
|
||||
<strong>Email id:</strong> {invoice?.orderId?.addedBy.email}
|
||||
</Typography>
|
||||
<Typography sx={{ mb: "0.5rem" }}>
|
||||
<strong>Number:</strong> {order?.addedBy.phone}
|
||||
<strong>Number:</strong> {invoice?.orderId?.addedBy.phone}
|
||||
</Typography>
|
||||
</Grid>
|
||||
<Grid item sm={6} md={6} lg={6}>
|
||||
<Typography variant="h5" sx={{ mb: "0.5rem" }}>
|
||||
Bill Address
|
||||
</Typography>
|
||||
<Typography sx={{ mb: "0.5rem" }}>{order?.billTo}</Typography>
|
||||
<Typography sx={{ mb: "0.5rem" }}>
|
||||
{invoice?.orderId?.billTo}
|
||||
</Typography>
|
||||
</Grid>
|
||||
<Grid item sm={6} md={6} lg={6}>
|
||||
<Typography variant="h5" sx={{ mb: "0.5rem" }}>
|
||||
Ship Address
|
||||
</Typography>
|
||||
<Typography sx={{ mb: "0.5rem" }}>{order?.shipTo}</Typography>
|
||||
<Typography sx={{ mb: "0.5rem" }}>
|
||||
{invoice?.orderId?.shipTo}
|
||||
</Typography>
|
||||
</Grid>
|
||||
<Grid item sm={6} md={6} lg={6}>
|
||||
<Typography variant="h5" sx={{ mb: "0.5rem" }}>
|
||||
Payment mode
|
||||
</Typography>
|
||||
<Typography sx={{ mb: "0.5rem" }}>
|
||||
{order?.paymentMode}
|
||||
{invoice?.orderId?.paymentMode}
|
||||
</Typography>
|
||||
</Grid>
|
||||
|
||||
<Grid item sm={12} md={12} lg={12}>
|
||||
{/* <Grid item sm={12} md={12} lg={12}>
|
||||
<Typography variant="h5" sx={{ mb: "0.5rem" }}>
|
||||
Order Status
|
||||
</Typography>
|
||||
<Typography sx={{ mb: "0.5rem" }}>{order?.status}</Typography>
|
||||
{order?.status === "cancelled" && (
|
||||
{invoice?.courierStatus === "cancelled" && (
|
||||
<Typography sx={{ mb: "0.5rem", color: "red" }}>
|
||||
{order?.order_Cancelled_Reason}
|
||||
</Typography>
|
||||
)}
|
||||
</Grid>
|
||||
</Grid> */}
|
||||
</Grid>
|
||||
</Box>
|
||||
{invoice?.status !== "delivered" && (
|
||||
@ -388,7 +371,7 @@ const ViewInvoices = () => {
|
||||
<select
|
||||
className="form-control"
|
||||
onChange={handleStatusChange}
|
||||
value={orderStatus}
|
||||
value={invoiceStatus}
|
||||
>
|
||||
{status === "processing" && (
|
||||
<>
|
||||
@ -406,7 +389,7 @@ const ViewInvoices = () => {
|
||||
</FormControl>
|
||||
)}
|
||||
|
||||
{orderStatus && (
|
||||
{invoiceStatus && (
|
||||
<Button
|
||||
variant="contained"
|
||||
color="primary"
|
||||
@ -424,7 +407,7 @@ const ViewInvoices = () => {
|
||||
<DialogTitle>Update Order Status</DialogTitle>
|
||||
<DialogContent>
|
||||
<DialogContentText>
|
||||
Are you sure you want to update the status to {orderStatus}?
|
||||
Are you sure you want to update the status to {invoiceStatus}?
|
||||
</DialogContentText>
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
@ -482,37 +465,6 @@ const ViewInvoices = () => {
|
||||
</form>
|
||||
</Dialog>
|
||||
|
||||
{/* Dialog for cancellation reason */}
|
||||
<Dialog open={openCancelDialog} onClose={handleCancel}>
|
||||
<DialogTitle>Cancellation Reason</DialogTitle>
|
||||
<form onSubmit={handleConfirmUpdate}>
|
||||
<DialogContent>
|
||||
<DialogContentText>
|
||||
Please provide a reason for cancelling the order:
|
||||
</DialogContentText>
|
||||
<TextField
|
||||
autoFocus
|
||||
required
|
||||
margin="dense"
|
||||
label="Cancellation Reason"
|
||||
fullWidth
|
||||
variant="outlined"
|
||||
value={cancellationReason}
|
||||
onChange={(e) => setCancellationReason(e.target.value)}
|
||||
/>
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<Button onClick={handleCancel} color="primary">
|
||||
Cancel
|
||||
</Button>
|
||||
<Button type="submit" variant="contained" color="success" autoFocus>
|
||||
Confirm
|
||||
</Button>
|
||||
</DialogActions>
|
||||
</form>
|
||||
</Dialog>
|
||||
|
||||
{/* Dialog for delivery confirmation */}
|
||||
<Dialog open={openDeliveredDialog} onClose={handleCancel}>
|
||||
<DialogTitle>Confirm Delivery</DialogTitle>
|
||||
<form onSubmit={handleConfirmUpdate}>
|
||||
@ -552,14 +504,6 @@ const ViewInvoices = () => {
|
||||
</DialogActions>
|
||||
</form>
|
||||
</Dialog>
|
||||
|
||||
{/* partial processing */}
|
||||
<OrderDetailsDialog
|
||||
open={parialModal}
|
||||
onClose={handlePartialOrderClose}
|
||||
order={order}
|
||||
onSubmit={handlePartialProcess}
|
||||
/>
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user