change product and razorpay
This commit is contained in:
parent
63aecdaaa3
commit
a26ce0df5c
@ -32,8 +32,15 @@ const InternetConnectionPopUp = () => {
|
|||||||
title: "Warning",
|
title: "Warning",
|
||||||
text: "Internet connection is lost. Please check your connection.",
|
text: "Internet connection is lost. Please check your connection.",
|
||||||
icon: "warning",
|
icon: "warning",
|
||||||
button: "Retry",
|
button: {
|
||||||
|
text: "Retry",
|
||||||
|
value: "retry",
|
||||||
|
},
|
||||||
dangerMode: true,
|
dangerMode: true,
|
||||||
|
}).then((value) => {
|
||||||
|
if (value === "retry") {
|
||||||
|
window.location.reload(); // Reload the page
|
||||||
|
}
|
||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
@ -41,6 +41,8 @@ const AddProduct = () => {
|
|||||||
// sku: "",
|
// sku: "",
|
||||||
description: "",
|
description: "",
|
||||||
master_price: "",
|
master_price: "",
|
||||||
|
master_GST: "",
|
||||||
|
|
||||||
// discontinue_on: "",
|
// discontinue_on: "",
|
||||||
// hsn_code: "",
|
// hsn_code: "",
|
||||||
product_Status: "",
|
product_Status: "",
|
||||||
@ -215,6 +217,7 @@ const AddProduct = () => {
|
|||||||
<ProductDetails
|
<ProductDetails
|
||||||
data={{ data, setData }}
|
data={{ data, setData }}
|
||||||
categories={categories}
|
categories={categories}
|
||||||
|
taxes={taxes}
|
||||||
ProductId={{ productId, setProductId }}
|
ProductId={{ productId, setProductId }}
|
||||||
loading={{ loading, setLoading }}
|
loading={{ loading, setLoading }}
|
||||||
/>
|
/>
|
||||||
|
@ -43,6 +43,7 @@ const EditProduct = () => {
|
|||||||
// sku: "",
|
// sku: "",
|
||||||
description: "",
|
description: "",
|
||||||
master_price: "",
|
master_price: "",
|
||||||
|
master_GST: "",
|
||||||
// discontinue_on: "",
|
// discontinue_on: "",
|
||||||
// hsn_code: "",
|
// hsn_code: "",
|
||||||
product_Status: "",
|
product_Status: "",
|
||||||
@ -89,11 +90,12 @@ const EditProduct = () => {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
|
|
||||||
setData((prev) => ({
|
setData((prev) => ({
|
||||||
...prev,
|
...prev,
|
||||||
...res.data?.data,
|
...res.data?.data,
|
||||||
category: res.data?.data?.category?._id,
|
category: res.data?.data?.category?._id,
|
||||||
|
master_GST: res.data?.data?.master_GST?._id,
|
||||||
|
product_Status: res.data?.data?.product_Status,
|
||||||
// discontinue_on: res.data?.data?.discontinue_on?.slice(0, 10),
|
// discontinue_on: res.data?.data?.discontinue_on?.slice(0, 10),
|
||||||
}));
|
}));
|
||||||
setProductId(res.data?.data?._id);
|
setProductId(res.data?.data?._id);
|
||||||
@ -243,6 +245,7 @@ const EditProduct = () => {
|
|||||||
<ProductDetails
|
<ProductDetails
|
||||||
data={{ data, setData }}
|
data={{ data, setData }}
|
||||||
categories={categories}
|
categories={categories}
|
||||||
|
taxes={taxes}
|
||||||
ProductId={{ productId, setProductId }}
|
ProductId={{ productId, setProductId }}
|
||||||
loading={{ loading, setLoading }}
|
loading={{ loading, setLoading }}
|
||||||
/>
|
/>
|
||||||
|
@ -8,6 +8,8 @@ const ProductDetails = (props) => {
|
|||||||
const { data, setData } = props.data;
|
const { data, setData } = props.data;
|
||||||
const { productId, setProductId } = props.ProductId;
|
const { productId, setProductId } = props.ProductId;
|
||||||
const { loading, setLoading } = props.loading;
|
const { loading, setLoading } = props.loading;
|
||||||
|
const taxes = props.taxes;
|
||||||
|
|
||||||
const categories = props?.categories || [];
|
const categories = props?.categories || [];
|
||||||
|
|
||||||
const handleChange = (e) => {
|
const handleChange = (e) => {
|
||||||
@ -26,7 +28,8 @@ const ProductDetails = (props) => {
|
|||||||
const handleSubmit = () => {
|
const handleSubmit = () => {
|
||||||
if (
|
if (
|
||||||
data.name.trim() === "" ||
|
data.name.trim() === "" ||
|
||||||
// data.master_price.trim() === "" ||
|
data.master_price === "" ||
|
||||||
|
data.master_GST === "" ||
|
||||||
data.category === "" ||
|
data.category === "" ||
|
||||||
data.description === "" ||
|
data.description === "" ||
|
||||||
data.product_Status === ""
|
data.product_Status === ""
|
||||||
@ -102,19 +105,6 @@ const ProductDetails = (props) => {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="mb-3 row">
|
<div className="mb-3 row">
|
||||||
{/* <div className="col-lg-6">
|
|
||||||
<label htmlFor="product" className="form-label">
|
|
||||||
SKU*
|
|
||||||
</label>
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
className="form-control"
|
|
||||||
id="sku"
|
|
||||||
value={data.sku}
|
|
||||||
maxLength="50"
|
|
||||||
onChange={(e) => handleChange(e)}
|
|
||||||
/>
|
|
||||||
</div> */}
|
|
||||||
<div className="col-lg-6 ">
|
<div className="col-lg-6 ">
|
||||||
<label htmlFor="product" className="form-label">
|
<label htmlFor="product" className="form-label">
|
||||||
Category *
|
Category *
|
||||||
@ -139,18 +129,8 @@ const ProductDetails = (props) => {
|
|||||||
)}
|
)}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="col-lg-6">
|
<div className="col-lg-6">
|
||||||
{/* <label htmlFor="product" className="form-label">
|
|
||||||
Master Price*
|
|
||||||
</label>
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
className="form-control"
|
|
||||||
id="master_price"
|
|
||||||
value={data.master_price}
|
|
||||||
maxLength="6"
|
|
||||||
onChange={(e) => handleChange(e)}
|
|
||||||
/> */}
|
|
||||||
<label htmlFor="title" className="form-label">
|
<label htmlFor="title" className="form-label">
|
||||||
Product Status *
|
Product Status *
|
||||||
</label>{" "}
|
</label>{" "}
|
||||||
@ -167,6 +147,44 @@ const ProductDetails = (props) => {
|
|||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div className="mb-3 row">
|
||||||
|
<div className="col-lg-6">
|
||||||
|
<label htmlFor="product" className="form-label">
|
||||||
|
Master Price*
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
className="form-control"
|
||||||
|
placeholder="₹"
|
||||||
|
id="master_price"
|
||||||
|
name="master_price"
|
||||||
|
value={data.master_price}
|
||||||
|
maxLength="6"
|
||||||
|
onChange={(e) => handleChange(e)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className="col-lg-6 ">
|
||||||
|
<label htmlFor="product" className="form-label">
|
||||||
|
Master GST *
|
||||||
|
</label>
|
||||||
|
<select
|
||||||
|
name="master_GST"
|
||||||
|
// value={r.gst_Id?._id ? r.gst_Id?._id : r.gst_Id}
|
||||||
|
value={data?.master_GST}
|
||||||
|
onChange={(e) => handleChange(e)}
|
||||||
|
id="master_GST"
|
||||||
|
className="form-control"
|
||||||
|
>
|
||||||
|
<option value="">---select---</option>
|
||||||
|
{taxes &&
|
||||||
|
taxes.map((item, index) => (
|
||||||
|
<option value={item._id} key={index}>
|
||||||
|
{item.tax} %{item.name}
|
||||||
|
</option>
|
||||||
|
))}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div className="mb-3">
|
<div className="mb-3">
|
||||||
<label htmlFor="product" className="form-label">
|
<label htmlFor="product" className="form-label">
|
||||||
Description*
|
Description*
|
||||||
@ -174,6 +192,7 @@ const ProductDetails = (props) => {
|
|||||||
<textarea
|
<textarea
|
||||||
className="form-control"
|
className="form-control"
|
||||||
id="description"
|
id="description"
|
||||||
|
placeholder="Text..."
|
||||||
value={data.description}
|
value={data.description}
|
||||||
onChange={(e) => handleChange(e)}
|
onChange={(e) => handleChange(e)}
|
||||||
/>
|
/>
|
||||||
@ -199,6 +218,7 @@ const ProductDetails = (props) => {
|
|||||||
</label>
|
</label>
|
||||||
<textarea
|
<textarea
|
||||||
className="form-control"
|
className="form-control"
|
||||||
|
placeholder="Text..."
|
||||||
style={{
|
style={{
|
||||||
whiteSpace: "pre-wrap",
|
whiteSpace: "pre-wrap",
|
||||||
minHeight: "100px",
|
minHeight: "100px",
|
||||||
|
@ -1,731 +1,3 @@
|
|||||||
// import React, { useState, useEffect } from "react";
|
|
||||||
// import { Link } from "react-router-dom";
|
|
||||||
// import Button from "@material-ui/core/Button";
|
|
||||||
// import { useNavigate } from "react-router-dom";
|
|
||||||
// import axios from "axios";
|
|
||||||
// import { isAutheticated } from "src/auth";
|
|
||||||
// import swal from "sweetalert";
|
|
||||||
// import {
|
|
||||||
// Box,
|
|
||||||
// FormControl,
|
|
||||||
// IconButton,
|
|
||||||
// InputLabel,
|
|
||||||
// MenuItem,
|
|
||||||
// Select,
|
|
||||||
// TextField,
|
|
||||||
// } from "@mui/material";
|
|
||||||
// import SearchIcon from "@mui/icons-material/Search";
|
|
||||||
// import Fuse from "fuse.js";
|
|
||||||
// import { Typography } from "@material-ui/core";
|
|
||||||
// const Products = () => {
|
|
||||||
// const token = isAutheticated();
|
|
||||||
// const [query, setQuery] = useState("");
|
|
||||||
// const navigate = useNavigate();
|
|
||||||
// const [loading, setLoading] = useState(true);
|
|
||||||
// const [success, setSuccess] = useState(true);
|
|
||||||
// const [productsData, setProductsData] = useState([]);
|
|
||||||
// const [filterData, setFilterData] = useState([]);
|
|
||||||
// const [queryData, setQueryData] = useState([]);
|
|
||||||
|
|
||||||
// const [currentPage, setCurrentPage] = useState(1);
|
|
||||||
// const [itemPerPage, setItemPerPage] = useState(10);
|
|
||||||
// const [showData, setShowData] = useState(productsData);
|
|
||||||
|
|
||||||
// const handleShowEntries = (e) => {
|
|
||||||
// setCurrentPage(1);
|
|
||||||
// setItemPerPage(e.target.value);
|
|
||||||
// };
|
|
||||||
|
|
||||||
// const getProductsData = async () => {
|
|
||||||
// axios
|
|
||||||
// .get(`/api/product/getAll/`, {
|
|
||||||
// headers: {
|
|
||||||
// Authorization: `Bearer ${token}`,
|
|
||||||
// },
|
|
||||||
// })
|
|
||||||
// .then((res) => {
|
|
||||||
// setProductsData(res.data?.product);
|
|
||||||
// setLoading(false);
|
|
||||||
// })
|
|
||||||
// .catch((error) => {
|
|
||||||
// const msg = error?.response?.data?.message || "Something went wrong!";
|
|
||||||
|
|
||||||
// swal({
|
|
||||||
// title: error,
|
|
||||||
// text: msg,
|
|
||||||
// icon: "error",
|
|
||||||
// button: "Retry",
|
|
||||||
// dangerMode: true,
|
|
||||||
// });
|
|
||||||
// setLoading(false);
|
|
||||||
// });
|
|
||||||
// };
|
|
||||||
|
|
||||||
// useEffect(() => {
|
|
||||||
// getProductsData();
|
|
||||||
// }, [success]);
|
|
||||||
|
|
||||||
// useEffect(() => {
|
|
||||||
// const loadData = () => {
|
|
||||||
// const indexOfLastPost = currentPage * itemPerPage;
|
|
||||||
// const indexOfFirstPost = indexOfLastPost - itemPerPage;
|
|
||||||
// setShowData(productsData.slice(indexOfFirstPost, indexOfLastPost));
|
|
||||||
// };
|
|
||||||
// loadData();
|
|
||||||
// }, [currentPage, itemPerPage, productsData]);
|
|
||||||
|
|
||||||
// const handleDelete = (id) => {
|
|
||||||
// swal({
|
|
||||||
// title: "Are you sure?",
|
|
||||||
// icon: "error",
|
|
||||||
// buttons: {
|
|
||||||
// Yes: { text: "Yes", value: true },
|
|
||||||
// Cancel: { text: "Cancel", value: "cancel" },
|
|
||||||
// },
|
|
||||||
// }).then((value) => {
|
|
||||||
// if (value === true) {
|
|
||||||
// axios
|
|
||||||
// .delete(`/api/product/delete/${id}`, {
|
|
||||||
// headers: {
|
|
||||||
// "Access-Control-Allow-Origin": "*",
|
|
||||||
// Authorization: `Bearer ${token}`,
|
|
||||||
// },
|
|
||||||
// })
|
|
||||||
// .then((res) => {
|
|
||||||
// swal({
|
|
||||||
// title: "Deleted",
|
|
||||||
// text: "Product Deleted successfully!",
|
|
||||||
// icon: "success",
|
|
||||||
// button: "ok",
|
|
||||||
// });
|
|
||||||
// setSuccess((prev) => !prev);
|
|
||||||
// })
|
|
||||||
// .catch((err) => {
|
|
||||||
// const msg = err?.response?.data?.message || "Something went wrong!";
|
|
||||||
|
|
||||||
// swal({
|
|
||||||
// title: "Warning",
|
|
||||||
// text: msg,
|
|
||||||
// icon: "error",
|
|
||||||
// button: "Retry",
|
|
||||||
// dangerMode: true,
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// };
|
|
||||||
// const [filterCategory, setFilterCategory] = useState("");
|
|
||||||
|
|
||||||
// const handleSearchClick = (query) => {
|
|
||||||
// const option = {
|
|
||||||
// isCaseSensitive: true,
|
|
||||||
// includeScore: false,
|
|
||||||
// shouldSort: true,
|
|
||||||
// includeMatches: false,
|
|
||||||
// findAllMatches: false,
|
|
||||||
// minMatchCharLength: 1,
|
|
||||||
// location: 0,
|
|
||||||
// threshold: 0.6,
|
|
||||||
// distance: 100,
|
|
||||||
// useExtendedSearch: true,
|
|
||||||
// ignoreLocation: false,
|
|
||||||
// ignoreFieldNorm: false,
|
|
||||||
// fieldNormWeight: 1,
|
|
||||||
// keys: ["name"],
|
|
||||||
// };
|
|
||||||
|
|
||||||
// const fuse = new Fuse(productsData, option);
|
|
||||||
// const result = fuse.search(query);
|
|
||||||
|
|
||||||
// const searchedResult = result.map((result) => result.item);
|
|
||||||
// console.log(searchedResult);
|
|
||||||
// setQueryData(searchedResult);
|
|
||||||
// };
|
|
||||||
// useEffect(() => {
|
|
||||||
// if (query !== "") {
|
|
||||||
// setFilterCategory("");
|
|
||||||
// }
|
|
||||||
// setTimeout(() => handleSearchClick(query), 100);
|
|
||||||
// }, [query]);
|
|
||||||
// const uniqueCategoryNames = [
|
|
||||||
// ...new Set(showData?.map((product) => product?.category?.categoryName)),
|
|
||||||
// ];
|
|
||||||
// useEffect(() => {
|
|
||||||
// setTimeout(() => {
|
|
||||||
// if (filterCategory !== "") {
|
|
||||||
// const filteredProducts = productsData.filter(
|
|
||||||
// (product) => product.category?.categoryName === filterCategory
|
|
||||||
// );
|
|
||||||
|
|
||||||
// setFilterData(filteredProducts);
|
|
||||||
// } else {
|
|
||||||
// // If no category is selected, show all products
|
|
||||||
// setShowData(productsData);
|
|
||||||
// // setFilterData(filteredProducts);
|
|
||||||
// }
|
|
||||||
// }, 100);
|
|
||||||
// }, [filterCategory, productsData]);
|
|
||||||
// return (
|
|
||||||
// <div className="main-content">
|
|
||||||
// <div className="page-content">
|
|
||||||
// <div className="container-fluid">
|
|
||||||
// <div className="row">
|
|
||||||
// <div className="col-12">
|
|
||||||
// <div
|
|
||||||
// className="
|
|
||||||
// page-title-box
|
|
||||||
// d-flex
|
|
||||||
// align-items-center
|
|
||||||
// justify-content-between
|
|
||||||
// "
|
|
||||||
// >
|
|
||||||
// <div style={{ fontSize: "22px" }} className="fw-bold">
|
|
||||||
// Products
|
|
||||||
// </div>
|
|
||||||
|
|
||||||
// <div className="page-title-right">
|
|
||||||
// <Button
|
|
||||||
// variant="contained"
|
|
||||||
// color="primary"
|
|
||||||
// style={{
|
|
||||||
// fontWeight: "bold",
|
|
||||||
// marginBottom: "1rem",
|
|
||||||
// textTransform: "capitalize",
|
|
||||||
// }}
|
|
||||||
// onClick={() => {
|
|
||||||
// navigate("/product/add", { replace: true });
|
|
||||||
// }}
|
|
||||||
// >
|
|
||||||
// Add Product
|
|
||||||
// </Button>
|
|
||||||
// </div>
|
|
||||||
// </div>
|
|
||||||
// </div>
|
|
||||||
// </div>
|
|
||||||
|
|
||||||
// <div className="row">
|
|
||||||
// <div className="col-lg-12">
|
|
||||||
// <div className="card">
|
|
||||||
// <div className="card-body">
|
|
||||||
// <div className="row ml-0 mr-0 mb-10">
|
|
||||||
// <div className="col-lg-1">
|
|
||||||
// <div className="dataTables_length">
|
|
||||||
// <label className="w-100">
|
|
||||||
// Show
|
|
||||||
// <select
|
|
||||||
// onChange={(e) => {
|
|
||||||
// setItemPerPage(e.target.value);
|
|
||||||
// setCurrentPage(1);
|
|
||||||
// }}
|
|
||||||
// className="form-control"
|
|
||||||
// disabled={loading}
|
|
||||||
// >
|
|
||||||
// <option value="10">10</option>
|
|
||||||
// <option value="25">25</option>
|
|
||||||
// <option value="50">50</option>
|
|
||||||
// <option value="100">100</option>
|
|
||||||
// </select>
|
|
||||||
// entries
|
|
||||||
// </label>
|
|
||||||
// </div>
|
|
||||||
// </div>
|
|
||||||
// <div className="col-lg-3">
|
|
||||||
// <label>Product Name:</label>
|
|
||||||
// <input
|
|
||||||
// type="text"
|
|
||||||
// placeholder="product name"
|
|
||||||
// className="form-control"
|
|
||||||
// ref={nameRef}
|
|
||||||
// disabled={loading}
|
|
||||||
// />
|
|
||||||
// </div>
|
|
||||||
// <div className="col-lg-3">
|
|
||||||
// <label>Filter by Category:</label>
|
|
||||||
// <select
|
|
||||||
// className="form-control"
|
|
||||||
// ref={categoryRef}
|
|
||||||
// disabled={loading}
|
|
||||||
// >
|
|
||||||
// <option value="">All</option>
|
|
||||||
// {categories?.map((e, i) => (
|
|
||||||
// <option key={i} value={e._id}>
|
|
||||||
// {e?.name}
|
|
||||||
// </option>
|
|
||||||
// ))}
|
|
||||||
// </select>
|
|
||||||
// </div>
|
|
||||||
// <div className="col-lg-2">
|
|
||||||
// <button
|
|
||||||
// className="btn btn-primary ms-1 mt-4"
|
|
||||||
// onClick={() => {
|
|
||||||
// getProductsData();
|
|
||||||
// setCurrentPage(1);
|
|
||||||
// }}
|
|
||||||
// disabled={loading}
|
|
||||||
// >
|
|
||||||
// Filter
|
|
||||||
// </button>
|
|
||||||
// </div>
|
|
||||||
// </div>
|
|
||||||
|
|
||||||
// <div className="table-responsive table-shoot mt-3">
|
|
||||||
// <table
|
|
||||||
// className="table table-centered table-nowrap"
|
|
||||||
// style={{ border: "1px solid" }}
|
|
||||||
// >
|
|
||||||
// <thead
|
|
||||||
// className="thead-info"
|
|
||||||
// style={{ background: "rgb(140, 213, 213)" }}
|
|
||||||
// >
|
|
||||||
// <tr>
|
|
||||||
// <th className="text-start">Image</th>
|
|
||||||
// <th className="text-start">Product</th>
|
|
||||||
// <th className="text-start">Category</th>
|
|
||||||
|
|
||||||
// <th className="text-start">Price</th>
|
|
||||||
// <th className="text-start">Added On</th>
|
|
||||||
// <th className="text-start">Actions</th>
|
|
||||||
// </tr>
|
|
||||||
// </thead>
|
|
||||||
// <tbody>
|
|
||||||
// {!loading && showData.length === 0 && (
|
|
||||||
// <tr className="text-center">
|
|
||||||
// <td colSpan="6">
|
|
||||||
// <h5>No Data Available</h5>
|
|
||||||
// </td>
|
|
||||||
// </tr>
|
|
||||||
// )}
|
|
||||||
// {loading ? (
|
|
||||||
// <tr>
|
|
||||||
// <td className="text-center" colSpan="6">
|
|
||||||
// Loading...
|
|
||||||
// </td>
|
|
||||||
// </tr>
|
|
||||||
// ) : query === "" && filterCategory == "" ? (
|
|
||||||
// showData.map((product, i) => {
|
|
||||||
// return (
|
|
||||||
// <tr key={i}>
|
|
||||||
// <th>
|
|
||||||
// {product.image &&
|
|
||||||
// product.image.map((i, j) => (
|
|
||||||
// <img
|
|
||||||
// key={j}
|
|
||||||
// className="me-2"
|
|
||||||
// src={`${i?.url}`}
|
|
||||||
// width="40"
|
|
||||||
// alt=""
|
|
||||||
// />
|
|
||||||
// ))}
|
|
||||||
// </th>
|
|
||||||
// <td className="text-start">{product.name}</td>
|
|
||||||
// <td className="text-start">
|
|
||||||
// {product.category?.categoryName !== ""
|
|
||||||
// ? product.category?.categoryName
|
|
||||||
// : "Category Not selected "}
|
|
||||||
// </td>
|
|
||||||
// <th className="text-start">
|
|
||||||
// ₹
|
|
||||||
// {product?.total_amount
|
|
||||||
// ? product?.total_amount
|
|
||||||
// : product?.variants[0]?.price}
|
|
||||||
// </th>
|
|
||||||
// <td className="text-start">
|
|
||||||
// {new Date(product.createdAt).toLocaleString(
|
|
||||||
// "en-IN",
|
|
||||||
// {
|
|
||||||
// weekday: "short",
|
|
||||||
// month: "short",
|
|
||||||
// day: "numeric",
|
|
||||||
// year: "numeric",
|
|
||||||
// hour: "numeric",
|
|
||||||
// minute: "numeric",
|
|
||||||
// hour12: true,
|
|
||||||
// }
|
|
||||||
// )}
|
|
||||||
// </td>
|
|
||||||
// <td className="text-start">
|
|
||||||
// <Link to={`/product/view/${product._id}`}>
|
|
||||||
// <button
|
|
||||||
// style={{
|
|
||||||
// color: "white",
|
|
||||||
// marginRight: "1rem",
|
|
||||||
// }}
|
|
||||||
// type="button"
|
|
||||||
// className="
|
|
||||||
// btn btn-primary btn-sm
|
|
||||||
// waves-effect waves-light
|
|
||||||
// btn-table
|
|
||||||
// mx-1
|
|
||||||
// mt-1
|
|
||||||
// "
|
|
||||||
// >
|
|
||||||
// View
|
|
||||||
// </button>
|
|
||||||
// </Link>
|
|
||||||
// <Link to={`/product/edit/${product._id}`}>
|
|
||||||
// <button
|
|
||||||
// style={{
|
|
||||||
// color: "white",
|
|
||||||
// marginRight: "1rem",
|
|
||||||
// }}
|
|
||||||
// type="button"
|
|
||||||
// className="
|
|
||||||
// btn btn-info btn-sm
|
|
||||||
// waves-effect waves-light
|
|
||||||
// btn-table
|
|
||||||
// mt-1
|
|
||||||
// mx-1
|
|
||||||
// "
|
|
||||||
// >
|
|
||||||
// Edit
|
|
||||||
// </button>
|
|
||||||
// </Link>
|
|
||||||
// <Link
|
|
||||||
// to={"#"}
|
|
||||||
// style={{
|
|
||||||
// marginRight: "1rem",
|
|
||||||
// }}
|
|
||||||
// >
|
|
||||||
// <button
|
|
||||||
// style={{ color: "white" }}
|
|
||||||
// type="button"
|
|
||||||
// className="
|
|
||||||
// btn btn-danger btn-sm
|
|
||||||
// waves-effect waves-light
|
|
||||||
// btn-table
|
|
||||||
// mt-1
|
|
||||||
// mx-1
|
|
||||||
|
|
||||||
// "
|
|
||||||
// onClick={() => {
|
|
||||||
// handleDelete(product._id);
|
|
||||||
// }}
|
|
||||||
// >
|
|
||||||
// Delete
|
|
||||||
// </button>
|
|
||||||
// </Link>
|
|
||||||
// </td>
|
|
||||||
// </tr>
|
|
||||||
// );
|
|
||||||
// })
|
|
||||||
// ) : query !== "" ? (
|
|
||||||
// queryData.map((product, i) => {
|
|
||||||
// return (
|
|
||||||
// <tr key={i}>
|
|
||||||
// <th>
|
|
||||||
// {product.image &&
|
|
||||||
// product.image.map((i, j) => (
|
|
||||||
// <img
|
|
||||||
// key={j}
|
|
||||||
// className="me-2"
|
|
||||||
// src={`${i?.url}`}
|
|
||||||
// width="40"
|
|
||||||
// alt=""
|
|
||||||
// />
|
|
||||||
// ))}
|
|
||||||
// </th>
|
|
||||||
// <td className="text-start">{product.name}</td>
|
|
||||||
// <td className="text-start">
|
|
||||||
// {product.category !== ""
|
|
||||||
// ? product.category?.categoryName
|
|
||||||
// : "Category Not selected "}
|
|
||||||
// </td>
|
|
||||||
// <th className="text-start">₹{product.price}</th>
|
|
||||||
// <td className="text-start">
|
|
||||||
// {new Date(product.createdAt).toLocaleString(
|
|
||||||
// "en-IN",
|
|
||||||
// {
|
|
||||||
// weekday: "short",
|
|
||||||
// month: "short",
|
|
||||||
// day: "numeric",
|
|
||||||
// year: "numeric",
|
|
||||||
// hour: "numeric",
|
|
||||||
// minute: "numeric",
|
|
||||||
// hour12: true,
|
|
||||||
// }
|
|
||||||
// )}
|
|
||||||
// </td>
|
|
||||||
// <td className="text-start">
|
|
||||||
// <Link to={`/product/view/${product._id}`}>
|
|
||||||
// <button
|
|
||||||
// style={{
|
|
||||||
// color: "white",
|
|
||||||
// marginRight: "1rem",
|
|
||||||
// }}
|
|
||||||
// type="button"
|
|
||||||
// className="
|
|
||||||
// btn btn-primary btn-sm
|
|
||||||
// waves-effect waves-light
|
|
||||||
// btn-table
|
|
||||||
// mx-1
|
|
||||||
// mt-1
|
|
||||||
// "
|
|
||||||
// >
|
|
||||||
// View
|
|
||||||
// </button>
|
|
||||||
// </Link>
|
|
||||||
// <Link to={`/product/edit/${product._id}`}>
|
|
||||||
// <button
|
|
||||||
// style={{
|
|
||||||
// color: "white",
|
|
||||||
// marginRight: "1rem",
|
|
||||||
// }}
|
|
||||||
// type="button"
|
|
||||||
// className="
|
|
||||||
// btn btn-info btn-sm
|
|
||||||
// waves-effect waves-light
|
|
||||||
// btn-table
|
|
||||||
// mt-1
|
|
||||||
// mx-1
|
|
||||||
// "
|
|
||||||
// >
|
|
||||||
// Edit
|
|
||||||
// </button>
|
|
||||||
// </Link>
|
|
||||||
// <Link
|
|
||||||
// to={"#"}
|
|
||||||
// style={{
|
|
||||||
// marginRight: "1rem",
|
|
||||||
// }}
|
|
||||||
// >
|
|
||||||
// <button
|
|
||||||
// style={{ color: "white" }}
|
|
||||||
// type="button"
|
|
||||||
// className="
|
|
||||||
// btn btn-danger btn-sm
|
|
||||||
// waves-effect waves-light
|
|
||||||
// btn-table
|
|
||||||
// mt-1
|
|
||||||
// mx-1
|
|
||||||
|
|
||||||
// "
|
|
||||||
// onClick={() => {
|
|
||||||
// handleDelete(product._id);
|
|
||||||
// }}
|
|
||||||
// >
|
|
||||||
// Delete
|
|
||||||
// </button>
|
|
||||||
// </Link>
|
|
||||||
// </td>
|
|
||||||
// </tr>
|
|
||||||
// );
|
|
||||||
// })
|
|
||||||
// ) : (
|
|
||||||
// query == "" &&
|
|
||||||
// filterData.map((product, i) => {
|
|
||||||
// return (
|
|
||||||
// <tr key={i}>
|
|
||||||
// <th>
|
|
||||||
// {product.image &&
|
|
||||||
// product.image.map((i, j) => (
|
|
||||||
// <img
|
|
||||||
// key={j}
|
|
||||||
// className="me-2"
|
|
||||||
// src={`${i?.url}`}
|
|
||||||
// width="40"
|
|
||||||
// alt=""
|
|
||||||
// />
|
|
||||||
// ))}
|
|
||||||
// </th>
|
|
||||||
// <td className="text-start">{product.name}</td>
|
|
||||||
// <td className="text-start">
|
|
||||||
// {product.category?.categoryName}
|
|
||||||
// </td>
|
|
||||||
// <th className="text-start">₹{product.price}</th>
|
|
||||||
// <td className="text-start">
|
|
||||||
// {new Date(product.createdAt).toLocaleString(
|
|
||||||
// "en-IN",
|
|
||||||
// {
|
|
||||||
// weekday: "short",
|
|
||||||
// month: "short",
|
|
||||||
// day: "numeric",
|
|
||||||
// year: "numeric",
|
|
||||||
// hour: "numeric",
|
|
||||||
// minute: "numeric",
|
|
||||||
// hour12: true,
|
|
||||||
// }
|
|
||||||
// )}
|
|
||||||
// </td>
|
|
||||||
// <td className="text-start">
|
|
||||||
// <Link to={`/product/view/${product._id}`}>
|
|
||||||
// <button
|
|
||||||
// style={{
|
|
||||||
// color: "white",
|
|
||||||
// marginRight: "1rem",
|
|
||||||
// }}
|
|
||||||
// type="button"
|
|
||||||
// className="
|
|
||||||
// btn btn-primary btn-sm
|
|
||||||
// waves-effect waves-light
|
|
||||||
// btn-table
|
|
||||||
// mx-1
|
|
||||||
// mt-1
|
|
||||||
// "
|
|
||||||
// >
|
|
||||||
// View
|
|
||||||
// </button>
|
|
||||||
// </Link>
|
|
||||||
// <Link to={`/product/edit/${product._id}`}>
|
|
||||||
// <button
|
|
||||||
// style={{
|
|
||||||
// color: "white",
|
|
||||||
// marginRight: "1rem",
|
|
||||||
// }}
|
|
||||||
// type="button"
|
|
||||||
// className="
|
|
||||||
// btn btn-info btn-sm
|
|
||||||
// waves-effect waves-light
|
|
||||||
// btn-table
|
|
||||||
// mt-1
|
|
||||||
// mx-1
|
|
||||||
// "
|
|
||||||
// >
|
|
||||||
// Edit
|
|
||||||
// </button>
|
|
||||||
// </Link>
|
|
||||||
// <Link
|
|
||||||
// to={"#"}
|
|
||||||
// style={{
|
|
||||||
// marginRight: "1rem",
|
|
||||||
// }}
|
|
||||||
// >
|
|
||||||
// <button
|
|
||||||
// style={{ color: "white" }}
|
|
||||||
// type="button"
|
|
||||||
// className="
|
|
||||||
// btn btn-danger btn-sm
|
|
||||||
// waves-effect waves-light
|
|
||||||
// btn-table
|
|
||||||
// mt-1
|
|
||||||
// mx-1
|
|
||||||
|
|
||||||
// "
|
|
||||||
// onClick={() => {
|
|
||||||
// handleDelete(product._id);
|
|
||||||
// }}
|
|
||||||
// >
|
|
||||||
// Delete
|
|
||||||
// </button>
|
|
||||||
// </Link>
|
|
||||||
// </td>
|
|
||||||
// </tr>
|
|
||||||
// );
|
|
||||||
// })
|
|
||||||
// )}
|
|
||||||
// </tbody>
|
|
||||||
// </table>
|
|
||||||
// </div>
|
|
||||||
|
|
||||||
// <div className="row mt-20">
|
|
||||||
// <div className="col-sm-12 col-md-6 mb-20">
|
|
||||||
// <div
|
|
||||||
// className="dataTables_info"
|
|
||||||
// id="datatable_info"
|
|
||||||
// role="status"
|
|
||||||
// aria-live="polite"
|
|
||||||
// >
|
|
||||||
// Showing {currentPage * itemPerPage - itemPerPage + 1} to{" "}
|
|
||||||
// {Math.min(
|
|
||||||
// currentPage * itemPerPage,
|
|
||||||
// productsData.length
|
|
||||||
// )}{" "}
|
|
||||||
// of {productsData.length} entries
|
|
||||||
// </div>
|
|
||||||
// </div>
|
|
||||||
|
|
||||||
// <div className="col-sm-12 col-md-6">
|
|
||||||
// <div className="d-flex">
|
|
||||||
// <ul className="pagination ms-auto">
|
|
||||||
// <li
|
|
||||||
// className={
|
|
||||||
// currentPage === 1
|
|
||||||
// ? "paginate_button page-item previous disabled"
|
|
||||||
// : "paginate_button page-item previous"
|
|
||||||
// }
|
|
||||||
// >
|
|
||||||
// <span
|
|
||||||
// className="page-link"
|
|
||||||
// style={{ cursor: "pointer" }}
|
|
||||||
// onClick={() => setCurrentPage((prev) => prev - 1)}
|
|
||||||
// >
|
|
||||||
// Previous
|
|
||||||
// </span>
|
|
||||||
// </li>
|
|
||||||
|
|
||||||
// {!(currentPage - 1 < 1) && (
|
|
||||||
// <li className="paginate_button page-item">
|
|
||||||
// <span
|
|
||||||
// className="page-link"
|
|
||||||
// style={{ cursor: "pointer" }}
|
|
||||||
// onClick={(e) =>
|
|
||||||
// setCurrentPage((prev) => prev - 1)
|
|
||||||
// }
|
|
||||||
// >
|
|
||||||
// {currentPage - 1}
|
|
||||||
// </span>
|
|
||||||
// </li>
|
|
||||||
// )}
|
|
||||||
|
|
||||||
// <li className="paginate_button page-item active">
|
|
||||||
// <span
|
|
||||||
// className="page-link"
|
|
||||||
// style={{ cursor: "pointer" }}
|
|
||||||
// >
|
|
||||||
// {currentPage}
|
|
||||||
// </span>
|
|
||||||
// </li>
|
|
||||||
|
|
||||||
// {!(
|
|
||||||
// (currentPage + 1) * itemPerPage - itemPerPage >
|
|
||||||
// productsData.length - 1
|
|
||||||
// ) && (
|
|
||||||
// <li className="paginate_button page-item ">
|
|
||||||
// <span
|
|
||||||
// className="page-link"
|
|
||||||
// style={{ cursor: "pointer" }}
|
|
||||||
// onClick={() => {
|
|
||||||
// setCurrentPage((prev) => prev + 1);
|
|
||||||
// }}
|
|
||||||
// >
|
|
||||||
// {currentPage + 1}
|
|
||||||
// </span>
|
|
||||||
// </li>
|
|
||||||
// )}
|
|
||||||
|
|
||||||
// <li
|
|
||||||
// className={
|
|
||||||
// !(
|
|
||||||
// (currentPage + 1) * itemPerPage - itemPerPage >
|
|
||||||
// productsData.length - 1
|
|
||||||
// )
|
|
||||||
// ? "paginate_button page-item next"
|
|
||||||
// : "paginate_button page-item next disabled"
|
|
||||||
// }
|
|
||||||
// >
|
|
||||||
// <span
|
|
||||||
// className="page-link"
|
|
||||||
// style={{ cursor: "pointer" }}
|
|
||||||
// onClick={() => setCurrentPage((prev) => prev + 1)}
|
|
||||||
// >
|
|
||||||
// Next
|
|
||||||
// </span>
|
|
||||||
// </li>
|
|
||||||
// </ul>
|
|
||||||
// </div>
|
|
||||||
// </div>
|
|
||||||
// </div>
|
|
||||||
// </div>
|
|
||||||
// </div>
|
|
||||||
// </div>
|
|
||||||
// </div>
|
|
||||||
// </div>
|
|
||||||
// </div>
|
|
||||||
// </div>
|
|
||||||
// );
|
|
||||||
// };
|
|
||||||
|
|
||||||
// export default Products;
|
|
||||||
|
|
||||||
import React, { useState, useEffect, useRef } from "react";
|
import React, { useState, useEffect, useRef } from "react";
|
||||||
import { Link } from "react-router-dom";
|
import { Link } from "react-router-dom";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
@ -755,8 +27,7 @@ const Products = () => {
|
|||||||
// } = checkPermission("Product Master");
|
// } = checkPermission("Product Master");
|
||||||
const getProductsData = async () => {
|
const getProductsData = async () => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
|
await axios
|
||||||
axios
|
|
||||||
.get(`/api/product/getAll/admin/`, {
|
.get(`/api/product/getAll/admin/`, {
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bearer ${token}`,
|
Authorization: `Bearer ${token}`,
|
||||||
@ -1067,21 +338,15 @@ const Products = () => {
|
|||||||
<th className="text-start">Actions</th>
|
<th className="text-start">Actions</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
|
||||||
<tbody>
|
<tbody>
|
||||||
{!loading && productsData?.length === 0 && (
|
|
||||||
<tr className="text-center">
|
|
||||||
<td colSpan="6">
|
|
||||||
<h5>No Data Available</h5>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
)}
|
|
||||||
{loading ? (
|
{loading ? (
|
||||||
<tr>
|
<tr>
|
||||||
<td className="text-center" colSpan="6">
|
<td className="text-center" colSpan="6">
|
||||||
Loading...
|
Loading...
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
) : (
|
) : productsData?.length > 0 ? (
|
||||||
productsData?.map((product, i) => {
|
productsData?.map((product, i) => {
|
||||||
return (
|
return (
|
||||||
<tr key={i}>
|
<tr key={i}>
|
||||||
@ -1131,9 +396,9 @@ const Products = () => {
|
|||||||
</td>
|
</td>
|
||||||
<th className="text-start">
|
<th className="text-start">
|
||||||
₹
|
₹
|
||||||
{product?.total_amount
|
{product?.variants?.length > 0
|
||||||
? product?.total_amount
|
? product?.variants[0]?.price
|
||||||
: product?.variants[0]?.price}
|
: product?.master_price}
|
||||||
</th>
|
</th>
|
||||||
<td className="text-start">
|
<td className="text-start">
|
||||||
<span className=""></span>
|
<span className=""></span>
|
||||||
@ -1247,6 +512,15 @@ const Products = () => {
|
|||||||
</tr>
|
</tr>
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
|
) : (
|
||||||
|
!loading &&
|
||||||
|
productsData?.length === 0 && (
|
||||||
|
<tr className="text-center">
|
||||||
|
<td colSpan="6">
|
||||||
|
<h5>No Product Available...</h5>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
)
|
||||||
)}
|
)}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
@ -76,7 +76,6 @@ const ViewProduct = () => {
|
|||||||
<th>Name</th>
|
<th>Name</th>
|
||||||
<td>{productData?.name}</td>
|
<td>{productData?.name}</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<th>Product Group</th>
|
<th>Product Group</th>
|
||||||
<td>{productData?.category?.categoryName}</td>
|
<td>{productData?.category?.categoryName}</td>
|
||||||
@ -99,15 +98,50 @@ const ViewProduct = () => {
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
|
{productData?.master_price && (
|
||||||
|
<tr>
|
||||||
|
<th>Master Price</th>
|
||||||
|
<td>₹{productData?.master_price}</td>
|
||||||
|
</tr>
|
||||||
|
)}
|
||||||
|
{productData?.master_GST && (
|
||||||
|
<tr>
|
||||||
|
<th>Master GST</th>
|
||||||
|
<td>
|
||||||
|
{productData?.master_GST?.tax}%{" "}
|
||||||
|
{productData?.master_GST?.name}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
)}
|
||||||
|
{productData?.master_GST && (
|
||||||
|
<tr>
|
||||||
|
<th>Master GST Price</th>
|
||||||
|
<td>
|
||||||
|
₹
|
||||||
|
{(
|
||||||
|
(Number(productData?.master_price) *
|
||||||
|
Number(productData?.master_GST?.tax)) /
|
||||||
|
100
|
||||||
|
)?.toFixed(2)}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
)}
|
||||||
<tr>
|
<tr>
|
||||||
<th>Description</th>
|
<th>Description</th>
|
||||||
<td>{productData?.description}</td>
|
<td>{productData?.description}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Product Status</th>
|
<th>Product Status</th>
|
||||||
<td>{productData?.product_Status}</td>
|
<td
|
||||||
|
className={`badge m-1 ${
|
||||||
|
productData?.product_Status === "Active"
|
||||||
|
? "text-bg-success"
|
||||||
|
: "text-bg-danger"
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
{productData?.product_Status}
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<th>Special Instructions</th>
|
<th>Special Instructions</th>
|
||||||
<td>
|
<td>
|
||||||
|
@ -506,34 +506,64 @@ function ViewOrders() {
|
|||||||
<div className="row">
|
<div className="row">
|
||||||
<div className="col-sm-6">
|
<div className="col-sm-6">
|
||||||
<div
|
<div
|
||||||
className="d-flex justify-content-center mt-3 me-3 "
|
className="d-flex justify-content-center mt-2 me-3 "
|
||||||
style={{
|
style={{
|
||||||
width: "6rem",
|
width: "6rem",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<span
|
<span className=" mt-1" style={{}}>
|
||||||
className="px-2 mt-1"
|
|
||||||
style={{}}
|
|
||||||
>
|
|
||||||
{" "}
|
{" "}
|
||||||
Quantity:{" "}
|
Quantity:{" "}
|
||||||
{productDetails?.quantity}
|
{productDetails?.quantity}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
{productDetails?.variant_Name ? (
|
||||||
<p className="m-0 mt-3 ms-3">
|
<p className="m-0 mt-1 ms-3">
|
||||||
|
<small>Variant :</small> ₹
|
||||||
|
<small>
|
||||||
|
{productDetails?.variant_Name}
|
||||||
|
</small>
|
||||||
|
</p>
|
||||||
|
) : (
|
||||||
|
<p className="m-0 mt-1 ms-3">
|
||||||
|
<small>It`s Device</small>
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
<p className="m-0 mt-1 ms-3">
|
||||||
<stong> Subtotal:</stong> ₹
|
<stong> Subtotal:</stong> ₹
|
||||||
{productDetails?.product_Subtotal}
|
{productDetails?.product_Subtotal}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div className="col-sm-6">
|
<div className="col-sm-6">
|
||||||
<p className="m-0 mt-3">
|
<p className="m-0 mt-1">
|
||||||
<stong> Price:</stong> ₹
|
<stong>
|
||||||
{productDetails?.price}
|
{productDetails?.variant_Name
|
||||||
|
? "Price:"
|
||||||
|
: "Master Price"}
|
||||||
|
</stong>{" "}
|
||||||
|
₹{productDetails?.price}
|
||||||
</p>
|
</p>
|
||||||
<p className="m-0 mt-3">
|
{productDetails?.gst_rate && (
|
||||||
<stong> GST:</stong> ₹
|
<p className="m-0 mt-1">
|
||||||
{productDetails?.gst_amount}
|
<small>
|
||||||
|
{productDetails?.variant_Name
|
||||||
|
? "GST Rate:"
|
||||||
|
: "Master GST Rate:"}{" "}
|
||||||
|
</small>
|
||||||
|
<small>
|
||||||
|
{productDetails?.gst_rate} %
|
||||||
|
</small>
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
<p className="m-0 mt-1">
|
||||||
|
<small>
|
||||||
|
{productDetails?.variant_Name
|
||||||
|
? "GST:"
|
||||||
|
: "Master GST:"}{" "}
|
||||||
|
</small>{" "}
|
||||||
|
<small>
|
||||||
|
₹{productDetails?.gst_amount}
|
||||||
|
</small>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -547,8 +577,10 @@ function ViewOrders() {
|
|||||||
<small className="mb-4">Shipping Charge: </small> ₹
|
<small className="mb-4">Shipping Charge: </small> ₹
|
||||||
{orderDetails?.shipping_charge}
|
{orderDetails?.shipping_charge}
|
||||||
<br />
|
<br />
|
||||||
<span className="mt-2"> Total Order Value: </span> ₹
|
<h6 className="mt-2">
|
||||||
{orderDetails?.total_amount}
|
{" "}
|
||||||
|
Total Order Value: ₹{orderDetails?.total_amount}
|
||||||
|
</h6>{" "}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user