product update

This commit is contained in:
Sibunnayak 2024-07-26 08:39:54 +05:30
parent ae473a0c48
commit 810d5770b5
8 changed files with 140 additions and 1705 deletions

View File

@ -60,13 +60,13 @@ const _nav = [
to: "/categories",
group: "Product Management",
},
// {
// component: CNavItem,
// name: "Products",
// icon: <CIcon icon={cilClipboard} customClassName="nav-icon" />,
// to: "/products",
// group: "Product Management",
// },
{
component: CNavItem,
name: "Products",
icon: <CIcon icon={cilClipboard} customClassName="nav-icon" />,
to: "/products",
group: "Product Management",
},
{
component: CNavItem,
name: "GST",

View File

@ -1,23 +1,11 @@
import React, { useState, useEffect } from "react";
import { Button } from "@mui/material";
import axios from "axios";
// import { API } from "src/API";
// import { isAutheticated } from "../../components/auth/authhelper";
import { Link, useNavigate } from "react-router-dom";
import {
CCard,
CCardBody,
CCardGroup,
CCol,
CContainer,
CRow,
} from "@coreui/react";
import { CCard, CCardBody, CCardGroup, CCol, CContainer, CRow } from "@coreui/react";
import ProductDetails from "./Productcomponents/ProductDetails.js";
import ProductVarients from "./Productcomponents/ProductVarients.js";
import ProductsImages from "./Productcomponents/ProductImages.js";
import { isAutheticated } from "src/auth.js";
// import ReleventProduct from "./Productcomponents/ReleventProduct";
// import ProductFabric from "./Productcomponents/ProductFabric.js";
const AddProduct = () => {
const token = isAutheticated();
@ -26,68 +14,19 @@ const AddProduct = () => {
const [images, setImages] = useState([]);
const [categories, setCategories] = useState([]);
const [taxes, setTaxes] = useState([]);
const [sizes, setSizes] = useState([]);
const [relevantProduct, setRelevantProduct] = useState([]);
const [allreleventSelectedProduct, setallReleventSelectedProduct] = useState(
[]
);
const navigate = useNavigate();
const [loading, setLoading] = useState(false);
const [data, setData] = useState({
name: "",
category: "",
// sku: "",
description: "",
master_price: "",
master_GST: "",
// discontinue_on: "",
// hsn_code: "",
price: "",
GST: "",
product_Status: "",
special_instructions: "",
// productImages.length == 0 ||
// gst_amount === "" ||
// price === "" ||
// totalAmt === "" ||
// gst_amount === "" ||
});
const [varients, setVarients] = useState([
{
variant_Name: "",
weight: "",
volume: "",
price: "",
gst_Id: "",
},
{
variant_Name: "",
weight: "",
volume: "",
price: "",
gst_Id: "",
},
{
variant_Name: "",
weight: "",
volume: "",
price: "",
gst_Id: "",
},
]);
const [allFabrics, setAllFabrics] = useState([]);
const [fabrics, setFabrics] = useState([
{ _id: "", fabric_Name: "", for_Part: "" },
{ _id: "", fabric_Name: "", for_Part: "" },
{ _id: "", fabric_Name: "", for_Part: "" },
]);
const navigate = useNavigate();
const getCategories = () => {
axios
@ -101,7 +40,7 @@ const AddProduct = () => {
setCategories(res?.data?.categories);
setLoading(false);
})
.catch((err) => {
.catch(() => {
setLoading(false);
});
};
@ -119,57 +58,11 @@ const AddProduct = () => {
});
};
// const getSizes = () => {
// axios
// .get(`/api/erp/sizemaster/size`, {
// headers: {
// "Access-Control-Allow-Origin": "*",
// Authorization: `Bearer ${token}`,
// },
// })
// .then((res) => {
// setSizes(res.data?.data);
// });
// };
// const getItemWhichcontaiNameFabric = () => {
// axios
// .get(`/api/erp/item/name_contain_fabric`, {
// headers: {
// "Access-Control-Allow-Origin": "*",
// Authorization: `Bearer ${token}`,
// },
// })
// .then((res) => {
// console.log(res?.data);
// // setSizes(res.data?.data)
// setAllFabrics(res?.data?.data);
// })
// .catch((err) => {
// console.log(err);
// });
// };
// const getProductsData = async () => {
// axios
// .get(`/api/product`, {
// headers: {
// Authorization: `Bearer ${token}`,
// },
// })
// .then((res) => {
// setRelevantProduct(res.data?.data);
// })
// .catch((err) => {
// console.log(err);
// });
// };
useEffect(() => {
getCategories();
getTaxes();
// getSizes();
// getProductsData();
// getItemWhichcontaiNameFabric();
}, []);
const handleView = (n) => {
if (viewState === n) return;
setViewState(n);
@ -179,14 +72,7 @@ const AddProduct = () => {
<CContainer>
<CRow className="mt-3">
<CCol md={12}>
<div
className="
page-title-box
d-flex
align-items-center
justify-content-between
"
>
<div className="page-title-box d-flex align-items-center justify-content-between">
<div style={{ fontSize: "22px" }} className="fw-bold">
Add Product : {data?.name && data?.name}
</div>
@ -195,11 +81,7 @@ const AddProduct = () => {
<Button
variant="contained"
color="secondary"
style={{
fontWeight: "bold",
marginBottom: "1rem",
textTransform: "capitalize",
}}
style={{ fontWeight: "bold", marginBottom: "1rem", textTransform: "capitalize" }}
>
Back
</Button>
@ -222,15 +104,6 @@ const AddProduct = () => {
loading={{ loading, setLoading }}
/>
)}
{viewState === 2 && (
<ProductVarients
productId={productId}
data={{ varients, setVarients }}
taxes={taxes}
sizes={sizes}
loading={{ loading, setLoading }}
/>
)}
{viewState === 3 && (
<ProductsImages
productId={productId}
@ -238,38 +111,6 @@ const AddProduct = () => {
loading={{ loading, setLoading }}
/>
)}
{/* {viewState === 4 && (
<ProductFabric
productId={productId}
data={{ fabrics, setFabrics }}
allFabrics={allFabrics}
loading={{ loading, setLoading }}
/>
)}
{viewState === 5 && (
<ReleventProduct
data={{ data, setData }}
ProductId={productId}
AllreleventSelectedPro={{
allreleventSelectedProduct,
setallReleventSelectedProduct,
}}
ReleventProduct={relevantProduct}
loading={{ loading, setLoading }}
/>
)} */}
{/* {viewState === 5 && (
<ProductFabric
data={{ data, setData }}
ProductId={productId}
AllreleventSelectedPro={{
allreleventSelectedProduct,
setallReleventSelectedProduct,
}}
ReleventProduct={relevantProduct}
loading={{ loading, setLoading }}
/>
)} */}
</CCardBody>
</CCard>
</CCardGroup>
@ -280,60 +121,19 @@ const AddProduct = () => {
<CCardBody>
<div className="d-grid gap-2">
<button
className={
viewState === 1
? "btn btn-light"
: "btn btn-info text-white"
}
className={viewState === 1 ? "btn btn-light" : "btn btn-info text-white"}
type="button"
onClick={() => handleView(1)}
>
Product Details
</button>
<button
className={
viewState === 2
? "btn btn-light"
: "btn btn-info text-white"
}
type="button"
onClick={() => handleView(2)}
>
Variants
</button>
<button
className={
viewState === 3
? "btn btn-light"
: "btn btn-info text-white"
}
className={viewState === 3 ? "btn btn-light" : "btn btn-info text-white"}
type="button"
onClick={() => handleView(3)}
>
Images
</button>
{/* <button
className={
viewState === 4
? "btn btn-light"
: "btn btn-info text-white"
}
type="button"
onClick={() => handleView(4)}
>
Fabric
</button> */}
{/* <button
className={
viewState === 5
? "btn btn-light"
: "btn btn-info text-white"
}
type="button"
onClick={() => handleView(5)}
>
+ Relevent Product
</button> */}
</div>
</CCardBody>
</CCard>

View File

@ -1,8 +1,6 @@
import React, { useState, useEffect } from "react";
import { Button } from "@mui/material";
import axios from "axios";
// import { API } from "src/API";
// import { isAutheticated } from "../../components/auth/authhelper";
import { Link, useNavigate, useParams } from "react-router-dom";
import {
CCard,
@ -13,26 +11,18 @@ import {
CRow,
} from "@coreui/react";
import ProductDetails from "./Productcomponents/ProductDetails.js";
import ProductVarients from "./Productcomponents/ProductVarients.js";
import ProductsImages from "./Productcomponents/ProductImages.js";
import { isAutheticated } from "src/auth.js";
// import ReleventProduct from "./Productcomponents/ReleventProduct";
// import ProductFabric from "./Productcomponents/ProductFabric.js";
const EditProduct = () => {
const id = useParams()?.id;
console.log("id", id);
// console.log("id", id);
const token = isAutheticated();
const [productId, setProductId] = useState("");
const [viewState, setViewState] = useState(1);
const [images, setImages] = useState([]);
const [categories, setCategories] = useState([]);
const [taxes, setTaxes] = useState([]);
const [sizes, setSizes] = useState([]);
const [relevantProduct, setRelevantProduct] = useState([]);
const [allreleventSelectedProduct, setallReleventSelectedProduct] = useState(
[]
);
const navigate = useNavigate();
const [loading, setLoading] = useState(false);
@ -40,46 +30,13 @@ const EditProduct = () => {
const [data, setData] = useState({
name: "",
category: "",
// sku: "",
description: "",
master_price: "",
master_GST: "",
// discontinue_on: "",
// hsn_code: "",
price: "",
GST: "",
product_Status: "",
special_instructions: "",
// productImages.length == 0 ||
// gst_amount === "" ||
// price === "" ||
// totalAmt === "" ||
// gst_amount === "" ||
});
const [varients, setVarients] = useState([
{
variant_Name: "",
weight: "",
volume: "",
price: "",
gst_Id: "",
},
{
variant_Name: "",
weight: "",
volume: "",
price: "",
gst_Id: "",
},
{
variant_Name: "",
weight: "",
volume: "",
price: "",
gst_Id: "",
},
]);
///////////////
const getProduct = () => {
axios
@ -90,31 +47,22 @@ const EditProduct = () => {
},
})
.then((res) => {
// console.log("res", res.data);
setData((prev) => ({
...prev,
...res.data?.data,
category: res.data?.data?.category?._id,
master_GST: res.data?.data?.master_GST?._id,
GST: res.data?.data?.GST?._id,
product_Status: res.data?.data?.product_Status,
// discontinue_on: res.data?.data?.discontinue_on?.slice(0, 10),
}));
setProductId(res.data?.data?._id);
setImages([...res.data?.data?.image]);
setVarients([...res.data.data?.variants]);
setLoading(false);
})
.catch((err) => {
setLoading(false);
});
};
/////////////////
const [allFabrics, setAllFabrics] = useState([]);
const [fabrics, setFabrics] = useState([
{ _id: "", fabric_Name: "", for_Part: "" },
{ _id: "", fabric_Name: "", for_Part: "" },
{ _id: "", fabric_Name: "", for_Part: "" },
]);
const getCategories = () => {
axios
.get(`/api/category/getCategories`, {
@ -141,62 +89,14 @@ const EditProduct = () => {
},
})
.then((res) => {
// console.log("tax", res.data);
setTaxes(res.data);
});
};
// const getSizes = () => {
// axios
// .get(`/api/erp/sizemaster/size`, {
// headers: {
// "Access-Control-Allow-Origin": "*",
// Authorization: `Bearer ${token}`,
// },
// })
// .then((res) => {
// setSizes(res.data?.data);
// });
// };
// const getItemWhichcontaiNameFabric = () => {
// axios
// .get(`/api/erp/item/name_contain_fabric`, {
// headers: {
// "Access-Control-Allow-Origin": "*",
// Authorization: `Bearer ${token}`,
// },
// })
// .then((res) => {
// console.log(res?.data);
// // setSizes(res.data?.data)
// setAllFabrics(res?.data?.data);
// })
// .catch((err) => {
// console.log(err);
// });
// };
// const getProductsData = async () => {
// axios
// .get(`/api/product`, {
// headers: {
// Authorization: `Bearer ${token}`,
// },
// })
// .then((res) => {
// setRelevantProduct(res.data?.data);
// })
// .catch((err) => {
// console.log(err);
// });
// };
useEffect(() => {
getProduct();
getCategories();
getTaxes();
// getSizes();
// getProductsData();
// getItemWhichcontaiNameFabric();
}, []);
const handleView = (n) => {
if (viewState === n) return;
@ -250,15 +150,6 @@ const EditProduct = () => {
loading={{ loading, setLoading }}
/>
)}
{viewState === 2 && (
<ProductVarients
productId={productId}
data={{ varients, setVarients }}
taxes={taxes}
sizes={sizes}
loading={{ loading, setLoading }}
/>
)}
{viewState === 3 && (
<ProductsImages
productId={productId}
@ -266,38 +157,6 @@ const EditProduct = () => {
loading={{ loading, setLoading }}
/>
)}
{/* {viewState === 4 && (
<ProductFabric
productId={productId}
data={{ fabrics, setFabrics }}
allFabrics={allFabrics}
loading={{ loading, setLoading }}
/>
)}
{viewState === 5 && (
<ReleventProduct
data={{ data, setData }}
ProductId={productId}
AllreleventSelectedPro={{
allreleventSelectedProduct,
setallReleventSelectedProduct,
}}
ReleventProduct={relevantProduct}
loading={{ loading, setLoading }}
/>
)} */}
{/* {viewState === 5 && (
<ProductFabric
data={{ data, setData }}
ProductId={productId}
AllreleventSelectedPro={{
allreleventSelectedProduct,
setallReleventSelectedProduct,
}}
ReleventProduct={relevantProduct}
loading={{ loading, setLoading }}
/>
)} */}
</CCardBody>
</CCard>
</CCardGroup>
@ -318,17 +177,6 @@ const EditProduct = () => {
>
Product Details
</button>
<button
className={
viewState === 2
? "btn btn-light"
: "btn btn-info text-white"
}
type="button"
onClick={() => handleView(2)}
>
Variants
</button>
<button
className={
viewState === 3
@ -340,28 +188,6 @@ const EditProduct = () => {
>
Images
</button>
{/* <button
className={
viewState === 4
? "btn btn-light"
: "btn btn-info text-white"
}
type="button"
onClick={() => handleView(4)}
>
Fabric
</button> */}
{/* <button
className={
viewState === 5
? "btn btn-light"
: "btn btn-info text-white"
}
type="button"
onClick={() => handleView(5)}
>
+ Relevent Product
</button> */}
</div>
</CCardBody>
</CCard>
@ -373,617 +199,3 @@ const EditProduct = () => {
};
export default EditProduct;
// import React, { useEffect, useState } from "react";
// import Button from "@material-ui/core/Button";
// import { Link, useNavigate, useParams } from "react-router-dom";
// import swal from "sweetalert";
// import axios from "axios";
// import { isAutheticated } from "src/auth";
// import CloudUploadIcon from "@mui/icons-material/CloudUpload";
// import DeleteSharpIcon from "@mui/icons-material/DeleteSharp";
// import {
// Box,
// FormControl,
// IconButton,
// MenuItem,
// Select,
// TextField,
// } from "@mui/material";
// // import { WebsiteURL } from '../WebsiteURL'
// const EditProduct = () => {
// const id = useParams()?.id;
// const token = isAutheticated();
// const navigate = useNavigate();
// const [loading, setLoading] = useState(false);
// const [allTax, setAllTax] = useState([]);
// const [categories, setCatgories] = useState([]);
// const [imagesPreview, setImagesPreview] = useState([]);
// const [name, setName] = useState("");
// const [description, setDescription] = useState("");
// const [productImages, setProductImages] = useState([]);
// const [price, setPrice] = useState("");
// const [category, setCategoryName] = useState("");
// const [error, setError] = useState("");
// const [initTax, setInitTax] = useState();
// const [selectedTax, setselectedTax] = useState();
// const [product_Status, setproduct_Status] = useState("");
// const [totalAmt, setTotalAmt] = useState(0);
// const [gst_amount, setGst_amount] = useState(0);
// const [newUpdatedImages, setNewUpdatedImages] = useState([]);
// //get Productdata
// const getProduct = async () => {
// axios
// .get(`/api/product/getOne/${id}`, {
// headers: {
// "Access-Control-Allow-Origin": "*",
// Authorization: `Bearer ${token}`,
// },
// })
// .then((res) => {
// setName(res?.data?.product.name);
// setDescription(res.data.product.description);
// setProductImages(res.data.product.image);
// setPrice(res.data.product.price);
// setCategoryName(res.data.product?.category?._id);
// setselectedTax(res.data.product?.gst);
// setInitTax(res.data.product?.gst?._id);
// setTotalAmt(res.data.product?.total_amount);
// setGst_amount(res.data.product?.gst_amount);
// setproduct_Status(res.data.product?.product_Status);
// })
// .catch((err) => {
// swal({
// title: error,
// text: " Can not fetch the product ",
// icon: "error",
// button: "Retry",
// dangerMode: true,
// });
// });
// };
// // console.log(selectedTax, "selectedTax");
// const getCategories = async () => {
// try {
// const response = await axios.get("/api/category/getCategories", {
// headers: {
// Authorization: `Bearer ${token}`,
// },
// });
// if (response.status === 200) {
// setCatgories(response?.data?.categories);
// }
// } catch (error) {
// swal({
// title: error,
// text: " please login to access the resource ",
// icon: "error",
// button: "Retry",
// dangerMode: true,
// });
// }
// };
// useEffect(() => {
// getProduct();
// getCategories();
// }, []);
// useEffect(() => {
// const getAllTax = async () => {
// const res = await axios.get(`/api/tax/view_tax`, {
// headers: {
// "Access-Control-Allow-Origin": "*",
// Authorization: `Bearer ${token}`,
// },
// });
// if (res.data) {
// setAllTax(res.data);
// }
// };
// getAllTax();
// }, [token]);
// const TaxRatechange = async (e) => {
// let m = JSON.parse(e.target.value);
// setInitTax("");
// if (m?.tax) {
// let totalprice = Number(price) + Number((price * m?.tax) / 100);
// setGst_amount(Number((price * m?.tax) / 100)?.toFixed(2));
// setTotalAmt(totalprice?.toFixed(2));
// setselectedTax(m?._id);
// }
// };
// // console.log(selectedTax, "inisele");
// const handlePriceChange = (e) => {
// const newPrice = e.target.value;
// setPrice(newPrice);
// const selectedTaxObj = allTax.find(
// (t) =>
// t._id ===
// (typeof selectedTax === "object" ? selectedTax._id : selectedTax)
// );
// // console.log(selectedTax);
// // console.log(selectedTaxObj, "this is ", selectedTax);
// if (selectedTaxObj && !isNaN(newPrice)) {
// const gstAmount = (newPrice * selectedTaxObj.tax) / 100;
// const totalAmount = Number(newPrice) + gstAmount;
// setGst_amount(gstAmount.toFixed(2));
// setTotalAmt(totalAmount.toFixed(2));
// }
// };
// const handleSubmit = () => {
// // console.log("selected Tax", selectedTax);
// if (
// name === "" ||
// description === "" ||
// productImages.length == 0 ||
// category === "" ||
// selectedTax === "" ||
// gst_amount === "" ||
// price === "" ||
// product_Status === "" ||
// totalAmt === "" ||
// gst_amount === "" ||
// (productImages.length == 0 && newUpdatedImages.length == 0)
// ) {
// swal({
// title: "Warning",
// text: "Fill all mandatory fields",
// icon: "error",
// button: "Close",
// dangerMode: true,
// });
// return;
// }
// setLoading(true);
// const formData = new FormData();
// formData.append("name", name);
// formData.append("description", description);
// formData.append("price", price);
// formData.append("category", category);
// formData.append("total_amount", totalAmt);
// formData.append("gst_amount", gst_amount);
// formData.append("product_Status", product_Status);
// formData.append("gst", initTax === "" ? selectedTax : initTax);
// newUpdatedImages.length > 0 &&
// newUpdatedImages.forEach((Singleimage) => {
// formData.append("newImages", Singleimage);
// });
// formData.append("image", JSON.stringify(productImages));
// axios
// .patch(`/api/product/update/${id}`, formData, {
// headers: {
// Authorization: `Bearer ${token}`,
// "Content-Type": "multipart/form-data",
// "Access-Control-Allow-Origin": "*",
// },
// })
// .then((res) => {
// swal({
// title: "Updated",
// text: "Product Updated successfully!",
// icon: "success",
// button: "ok",
// });
// setLoading(false);
// navigate("/products", { replace: true });
// })
// .catch((err) => {
// setLoading(false);
// const message = err.response?.data?.message
// ? err.response?.data?.message
// : "Something went wrong!";
// swal({
// title: "Warning",
// text: message,
// icon: "error",
// button: "Retry",
// dangerMode: true,
// });
// });
// };
// const handleFileChange = (e) => {
// const files = e.target.files;
// // Check the total number of selected files
// if (newUpdatedImages.length + files.length > 4 - productImages.length) {
// setError("You can only upload up to 4 images.");
// return;
// }
// // Check file types and append to selectedFiles
// const allowedTypes = ["image/jpeg", "image/png", "image/jpg"];
// const selected = [];
// for (let i = 0; i < files.length; i++) {
// if (
// newUpdatedImages.length + selected.length >=
// 4 - productImages.length
// ) {
// break; // Don't allow more than 4 images
// }
// if (allowedTypes.includes(files[i].type)) {
// selected.push(files[i]);
// }
// }
// if (selected.length === 0) {
// setError("Please upload only PNG, JPEG, or JPG files.");
// } else {
// setError("");
// setNewUpdatedImages([...newUpdatedImages, ...selected]);
// }
// };
// const handelDelete = async (public_id) => {
// const ary = public_id.split("/");
// const res = await axios.delete(
// `/api/product/deleteImage/jatinMor/product/${ary[2]}`,
// {
// headers: {
// "Access-Control-Allow-Origin": "*",
// Authorization: `Bearer ${token}`,
// },
// }
// );
// if (res) {
// const filtered = productImages.filter(
// (item) => item.public_id !== public_id
// );
// setProductImages(filtered);
// }
// };
// const handellocalDelete = (image) => {
// const filtered = productImages.filter((item) => item !== image);
// setProductImages(filtered);
// };
// return (
// <div className="container">
// <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">
// Edit Product
// </div>
// <div style={{ display: "flex", gap: "1rem" }}>
// <h4 className="mb-0"></h4>
// </div>
// <div className="page-title-right">
// <Button
// variant="contained"
// color="primary"
// style={{
// fontWeight: "bold",
// marginBottom: "1rem",
// textTransform: "capitalize",
// marginRight: "5px",
// }}
// onClick={() => handleSubmit()}
// disabled={loading}
// >
// {loading ? "Loading" : "Save"}
// </Button>
// <Link to="/products">
// <Button
// variant="contained"
// color="secondary"
// style={{
// fontWeight: "bold",
// marginBottom: "1rem",
// textTransform: "capitalize",
// }}
// >
// Back
// </Button>
// </Link>
// </div>
// </div>
// </div>
// </div>
// <div className="row">
// <div className="col-lg-6 col-md-6 col-sm-12 my-1">
// <div className="card h-100">
// <div className="card-body px-5">
// <div className="mb-3">
// <label htmlFor="title" className="form-label">
// Product Name*
// </label>
// <input
// type="text"
// className="form-control"
// id="name"
// value={name}
// maxLength={35}
// onChange={(e) => setName(e.target.value)}
// />
// {name ? (
// <>
// <small className="charLeft mt-4 fst-italic">
// {35 - name.length} characters left
// </small>
// </>
// ) : (
// <></>
// )}{" "}
// </div>
// <div className="mb-3">
// <label htmlFor="title" className="form-label">
// Description*
// </label>
// <textarea
// type="text"
// className="form-control"
// id="description"
// rows="8"
// value={description}
// maxLength="400"
// onChange={(e) => setDescription(e.target.value)}
// />
// {description ? (
// <>
// <small className="charLeft mt-4 fst-italic">
// {400 - description.length} characters left
// </small>
// </>
// ) : (
// <></>
// )}
// </div>
// <Box>
// <label htmlFor="upload-Image">
// <TextField
// style={{
// display: "none",
// width: "350px",
// height: "350px",
// borderRadius: "10%",
// }}
// fullWidth
// id="upload-Image"
// type="file"
// accept=".jpg , .png ,.jpeg"
// label="file"
// multiple
// variant="outlined"
// onChange={(e) => handleFileChange(e)}
// />
// <Box
// style={{ borderRadius: "10%" }}
// sx={{
// margin: "1rem 0rem",
// cursor: "pointer",
// width: "140px",
// height: "140px",
// border: "2px solid grey",
// // borderRadius: '50%',
// "&:hover": {
// background: "rgba(112,112,112,0.5)",
// },
// }}
// >
// <CloudUploadIcon
// style={{
// color: "grey",
// margin: "auto",
// fontSize: "5rem",
// }}
// fontSize="large"
// />
// </Box>
// </label>
// </Box>
// {error && <p style={{ color: "red" }}>{error}</p>}
// <div>
// <strong className="fs-6 fst-italic">
// *You cannot upload more than 4 images
// </strong>
// </div>
// <Box style={{ display: "flex" }}>
// {productImages &&
// productImages.map((image, i) => (
// <Box marginRight={"2rem"}>
// <img
// src={image.url}
// alt="profileImage"
// style={{
// width: 70,
// height: 70,
// marginBottom: "1rem",
// }}
// />
// {productImages.length + newUpdatedImages.length > 1 && (
// <DeleteSharpIcon
// onClick={() => handelDelete(image.public_id)}
// fontSize="small"
// sx={{
// color: "white",
// position: "absolute",
// cursor: "pointer",
// padding: "0.2rem",
// background: "black",
// borderRadius: "50%",
// }}
// />
// )}
// {/* </IconButton> */}
// </Box>
// ))}
// {newUpdatedImages &&
// newUpdatedImages.map((image, i) => (
// <Box marginRight={"2rem"}>
// <img
// src={URL.createObjectURL(image)}
// alt="profileImage"
// style={{
// width: 70,
// height: 70,
// marginBottom: "1rem",
// }}
// />
// {productImages.length + newUpdatedImages.length > 1 && (
// <DeleteSharpIcon
// onClick={() => handellocalDelete(image)}
// fontSize="small"
// sx={{
// color: "white",
// position: "absolute",
// cursor: "pointer",
// padding: "0.2rem",
// background: "black",
// borderRadius: "50%",
// }}
// />
// )}
// {/* </IconButton> */}
// </Box>
// ))}
// </Box>
// </div>
// </div>
// </div>
// <div className="col-lg-6 col-md-6 col-sm-12 my-1">
// <div className="card h-100">
// <div className="card-body px-5">
// <div className="mb-3 me-3">
// <label htmlFor="title" className="form-label">
// Price(Rs)*
// </label>
// <input
// type="number"
// className="form-control"
// id="price"
// value={price}
// onChange={(e) => handlePriceChange(e)}
// />
// </div>
// <div>
// <label htmlFor="categorySelect">Select a Category *:</label>
// <select
// id="category"
// className="form-control"
// style={{ width: "100%" }}
// value={category}
// onChange={(e) => setCategoryName(e.target.value)}
// >
// <option value={""}>None</option>
// {categories.map((category, index) => (
// <option key={index} value={category?._id}>
// {category.categoryName}
// </option>
// ))}
// </select>
// </div>
// {allTax.length > 0 && (
// <div className=" mb-3">
// <label htmlFor="title" className="form-label">
// GST*
// </label>{" "}
// <select
// className=" form-control"
// name=""
// id=""
// value={JSON.stringify(selectedTax?._id)}
// onChange={(e) => TaxRatechange(e)}
// >
// {selectedTax?.tax && (
// <option
// value={selectedTax && JSON.stringify(selectedTax)}
// >
// {selectedTax?.tax}% {selectedTax?.name}
// </option>
// )}
// {allTax.map((t, i) => (
// <option key={i} value={JSON.stringify(t)}>
// {t.tax}% {t.name}
// </option>
// ))}
// </select>
// </div>
// )}
// <div className="mb-3 me-3">
// <label htmlFor="title" className="form-label">
// GST Amount (Rs) *
// </label>
// <input
// disabled
// type="number"
// name="gst_amount"
// className="form-control"
// id="gst_amount"
// value={gst_amount}
// // onChange={(e) => setPrice(e.target.value)}
// />
// </div>
// <div className="mb-3 me-3">
// <label htmlFor="title" className="form-label">
// Total Amount(Rs)*
// </label>
// <input
// disabled
// type="number"
// name="total_amount"
// className="form-control"
// id="total_amount"
// value={totalAmt}
// // onChange={(e) => setPrice(e.target.value)}
// />
// </div>
// <div className=" mb-3">
// <label htmlFor="title" className="form-label">
// Product Status *
// </label>{" "}
// <select
// className="form-control"
// name="product_Status"
// id="product_Status"
// value={product_Status}
// onChange={(e) => setproduct_Status(e.target.value)}
// >
// <option value="">--Select--</option>
// <option value="Active">Active</option>
// <option value="Inactive">Inactive</option>
// </select>
// </div>
// </div>
// </div>
// </div>
// </div>
// </div>
// );
// };
// export default EditProduct;

View File

@ -33,8 +33,6 @@ const ProductDetails = (props) => {
data.category === "" ||
data.description === "" ||
data.product_Status === ""
// data.sku === "" ||
// data.hsn_code === ""
) {
swal({
title: "Warning",
@ -143,36 +141,36 @@ const ProductDetails = (props) => {
>
<option value="">--Select--</option>
<option value="Active">Active</option>
<option value="Inactive">Inactive</option>
<option value="inActive">inActive</option>
</select>
</div>
</div>
<div className="mb-3 row">
<div className="col-lg-6">
<label htmlFor="product" className="form-label">
Master Price*
Price*
</label>
<input
type="text"
className="form-control"
placeholder=""
id="master_price"
name="master_price"
value={data.master_price}
id="price"
name="price"
value={data.price}
maxLength="6"
onChange={(e) => handleChange(e)}
/>
</div>
<div className="col-lg-6 ">
<label htmlFor="product" className="form-label">
Master GST *
GST *
</label>
<select
name="master_GST"
name="GST"
// value={r.gst_Id?._id ? r.gst_Id?._id : r.gst_Id}
value={data?.master_GST}
value={data?.GST}
onChange={(e) => handleChange(e)}
id="master_GST"
id="GST"
className="form-control"
>
<option value="">---select---</option>
@ -197,21 +195,6 @@ const ProductDetails = (props) => {
onChange={(e) => handleChange(e)}
/>
</div>
{/* <div className="mb-3 row">
<div className="col-6">
<label htmlFor="hsc_code" className="form-label">
HSN Code*
</label>
<input
type="text"
className="form-control"
id="hsn_code"
value={data.hsn_code}
maxLength="50"
onChange={(e) => handleChange(e)}
/>
</div>
</div> */}
<div className="mb-3">
<label htmlFor="product" className="form-label">
Special Instructions
@ -229,34 +212,6 @@ const ProductDetails = (props) => {
id="special_instructions"
/>
</div>
{/* <div className="mb-3">
<label>Discontinue On*</label>
<input
type="date"
value={data.discontinue_on}
id="discontinue_on"
onChange={(e) => handleChange(e)}
className="form-control"
min={new Date().toISOString().slice(0, 10)}
/>
</div> */}
{/* <div className=" mb-3">
<label htmlFor="title" className="form-label">
Product Status *
</label>{" "}
<select
className="form-control"
name="product_Status"
id="product_Status"
value={data.product_Status}
onChange={(e) => handleChange(e)}
>
<option value="">--Select--</option>
<option value="Active">Active</option>
<option value="Inactive">Inactive</option>
</select>
</div> */}
</>
);
};

View File

@ -8,201 +8,88 @@ const ProductsImages = (props) => {
const productId = props.productId;
const { images, setImages } = props.data;
const { loading, setLoading } = props.loading;
const [deleting, setDeleting] = useState(false);
const [imagePreview, setImagePreview] = useState({ preview: "", image: "" });
const [imagesPreview, setImagesPreview] = useState([]);
const [allimage, setAllImage] = useState([]);
//
const [data, setData] = useState({
image: [],
imageURL: [],
});
const [imagePreview, setImagePreview] = useState([]);
const [localImages, setLocalImages] = useState([]);
const [removedImages, setRemovedImages] = useState([]);
useEffect(() => {
if (images?.length > 0) {
setData((prev) => ({
...prev,
imageURL: images?.url,
}));
setImagesPreview(images);
setImagePreview(images.map((img) => ({ url: img.url, public_id: img.public_id })));
}
}, []);
}, [images]);
const handleChange = (e) => {
if (e.target.id === "image") {
if (
e.target.files[0]?.type === "image/jpeg" ||
e.target.files[0]?.type === "image/png" ||
e.target.files[0]?.type === "image/jpg"
) {
if (imagesPreview.length > 3) {
swal({
title: "Warning",
text: "maximum Four image Upload ",
icon: "error",
button: "Close",
dangerMode: true,
});
return;
}
// only for file preview------------------------------------
const files = Array.from(e.target.files);
files.forEach((file) => {
const reader = new FileReader();
reader.onload = () => {
if (reader.readyState === 2) {
setImagesPreview((old) => [...old, reader.result]);
}
};
reader.readAsDataURL(file);
});
// -----------------------------------------------------------------------------
setData((prev) => ({
...prev,
image: [...data.image, ...e.target.files],
}));
return;
} else {
swal({
title: "Warning",
text: "Upload jpg, jpeg, png only.",
icon: "error",
button: "Close",
dangerMode: true,
});
setData((prev) => ({
...prev,
imageURL: "",
image: "",
}));
e.target.value = null;
return;
}
}
setData((prev) => ({ ...prev, [e.target.id]: e.target.value }));
};
//
// const handleChange = (e) => {
// if (
// e.target.files[0]?.type === "image/jpeg" ||
// e.target.files[0]?.type === "image/png" ||
// e.target.files[0]?.type === "image/jpg"
// ) {
// setImagePreview((prev) => ({
// ...prev,
// preview: URL.createObjectURL(e.target.files[0]),
// image: e.target.files[0],
// }));
// return;
// } else {
// swal({
// title: "Warning",
// text: "Upload jpg, jpeg, png only.",
// icon: "error",
// button: "Close",
// dangerMode: true,
// });
// setImagePreview((prev) => ({
// ...prev,
// preview: "",
// image: "",
// }));
// e.target.value = null;
// return;
// }
// };
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) {
setDeleting(true);
axios
.delete(`/api/product/image/${productId}/${id}`, {
headers: {
"Access-Control-Allow-Origin": "*",
Authorization: `Bearer ${token}`,
},
})
.then((res) => {
setDeleting(false);
const filteredImages = images.filter((e) => e._id !== id);
setImages(filteredImages);
})
.catch((err) => {
setDeleting(false);
swal({
title: "Warning",
text: "Something went wrong!",
icon: "error",
button: "Retry",
dangerMode: true,
});
});
}
const files = Array.from(e.target.files);
const imagePreviews = files.map((file) => {
return {
url: URL.createObjectURL(file),
file,
};
});
setLocalImages((prevImages) => [...prevImages, ...imagePreviews]);
};
const handleDeleteImage = (url, public_id) => {
if (public_id) {
// Mark image for removal
setRemovedImages((prevRemoved) => [...prevRemoved, public_id]);
const encodedPublicId = encodeURIComponent(public_id);
// Retrieve the authentication token
const token = isAutheticated(); // Ensure this function correctly retrieves the token
// console.log("public_id:", public_id); // Log to debug
// console.log("encodedPublicId:", encodedPublicId); // Log to debug
// Delete image from Cloudinary
axios.delete(`/api/product/deleteImage/${encodedPublicId}`, {
headers: {
Authorization: `Bearer ${token}` // Include the token in the headers
}
})
.then(() => {
setImagePreview((prevImages) => prevImages.filter((img) => img.url !== url));
swal("Success", "Image deleted successfully", "success");
})
.catch((err) => {
console.error(err.response?.data); // Log error for debugging
swal("Error", "Failed to delete image", "error");
});
} else {
// Delete local image
setLocalImages((prevImages) => prevImages.filter((img) => img.url !== url));
}
};
const handleSubmit = () => {
// if (!imagePreview.image) return;
if (data.image?.length < 1) {
swal({
title: "Warning",
text: "PLease select Product Image",
icon: "warning",
button: "ok",
dangerMode: true,
});
return;
}
setLoading(true);
const formData = new FormData();
data.image.forEach((Singleimage) => {
// console.log(Singleimage)
formData.append("image", Singleimage);
});
axios
.patch(`/api/product/update/${productId}`, formData, {
headers: {
"Content-Type": "multipart/form-data",
Authorization: `Bearer ${token}`,
"Access-Control-Allow-Origin": "*",
},
})
// Append local images to formData
localImages.forEach((img) => formData.append('images', img.file));
// Append removedImages as a JSON string
formData.append('removedImages', JSON.stringify(removedImages));
axios.patch(`/api/product/update/${productId}`, formData, {
headers: {
'Content-Type': 'multipart/form-data',
Authorization: `Bearer ${token}`
}
})
.then((res) => {
swal({
title: "Saved",
text: "Product image saved successfully!",
icon: "success",
button: "Close",
});
setImages((prev) => [...prev, res.data?.image]);
setImagePreview({ preview: "", image: "" });
setLoading(false);
setImages(res.data.images);
setLocalImages([]);
setRemovedImages([]);
swal("Success", "Product updated successfully", "success");
})
.catch((err) => {
// console.log(err);
const msg = err?.response?.data?.message || "Something went wrong!";
swal({
title: "Warning",
text: msg,
icon: "warning",
button: "Close",
});
setLoading(false);
});
console.error(err.response.data); // Log the error for debugging
swal("Error", "Failed to update product", "error");
})
.finally(() => setLoading(false));
};
return (
@ -219,13 +106,13 @@ const ProductsImages = (props) => {
id="image"
accept="image/*"
multiple
onChange={(e) => handleChange(e)}
onChange={handleChange}
/>
</div>
<div className="col-lg-3">
<button
className="btn btn-primary"
onClick={() => handleSubmit()}
onClick={handleSubmit}
disabled={!productId || loading}
>
{productId
@ -237,64 +124,33 @@ const ProductsImages = (props) => {
</div>
</div>
<p className="pt-1 pl-2 text-secondary">
Upload jpg, jpeg and png only*
Upload jpg, jpeg, and png only*
</p>
<div>
<strong className="fs-6 fst-italic">
*Please Upload maximum four images
</strong>
</div>
<div className="mb-3" style={{ height: "100px", maxWdth: "100%" }}>
{/* <img
src={imagePreview.preview}
alt="Uploaded Image will be shown here"
style={{ maxHeight: "100px", maxWidth: "100%" }}
/> */}
{imagesPreview.map((image, index) => (
<img
className="p-1"
key={index}
src={image?.url ? image?.url : image}
alt="Uploaded Image will be shown here"
style={{ maxHeight: "100px", maxWidth: "100%" }}
/>
))}
</div>
</div>
{/* <table className="table">
<thead>
<tr>
<th scope="col">Preview</th>
<th scope="col">Actions</th>
</tr>
</thead>
<tbody>
{images.length !== 0 ? (
images.map((r, idx) => (
<tr key={idx}>
<td>
<img src={r.url} alt="preview" height="100px" />
</td>
<td>
<button
className="btn btn-danger btn-sm text-white"
onClick={() => handleDelete(r._id)}
disabled={deleting}
>
Delete
</button>
</td>
</tr>
))
) : (
<tr>
<td colSpan={6} className="text-center fw-bold">
No Image Added
</td>
</tr>
)}
</tbody>
</table> */}
<div className="row">
{imagePreview.map((img) => (
<div key={img.url} className="col-lg-3 mb-3 position-relative">
<img src={img.url} alt="Preview" className="img-thumbnail" />
<button
className="btn btn-danger position-absolute top-0 end-0 m-2"
onClick={() => handleDeleteImage(img.url, img.public_id)}
>
&times;
</button>
</div>
))}
{localImages.map((img) => (
<div key={img.url} className="col-lg-3 mb-3 position-relative">
<img src={img.url} alt="Preview" className="img-thumbnail" />
<button
className="btn btn-danger position-absolute top-0 end-0 m-2"
onClick={() => handleDeleteImage(img.url)}
>
&times;
</button>
</div>
))}
</div>
</>
);
};

View File

@ -1,249 +0,0 @@
import axios from "axios";
import React from "react";
import swal from "sweetalert";
import { isAutheticated } from "src/auth";
const ProductVarients = (props) => {
const token = isAutheticated();
const productId = props.productId;
const taxes = props.taxes;
const sizes = props.sizes;
const { varients, setVarients } = props.data;
const { loading, setLoading } = props.loading;
const addVarientRow = () => {
setVarients((prev) => [
...prev,
{
variant_Name: "",
weight: "",
volume: "",
price: "",
gst_Id: "",
},
]);
};
const handleChange = (e, idx) => {
if (
e.target.name === "weight" &&
e.target.value !== "" &&
!/^[0-9.]+$/.test(e.target.value)
)
return;
if (
e.target.name === "price" &&
e.target.value !== "" &&
!/^[0-9.]+$/.test(e.target.value)
)
return;
let clone = [...varients];
let obj = clone[idx];
// if (e.target.name === "gst_Id") {
// }
obj[e.target.name] = e.target.value;
clone[idx] = obj;
setVarients([...clone]);
};
// variant_Name: "",
// weight: "",
// volume: "",
// price: "",
// gst_Name: "",
// gst_Rate: "",
// gst_Id: "",
const handleSubmit = () => {
const emptyVarients = varients.filter(
(e) =>
!(e.variant_Name === "" && e.price === "" && e.gst_Id === "") &&
(e.variant_Name === "" || e.price === "" || e.gst_Id === "")
);
if (emptyVarients.length !== 0) {
swal({
title: "Warning",
text: "Fill all fields of a row",
icon: "warning",
button: "Return",
});
return;
}
// const variant_Name = [];
// varients.map((e) => e.variant_Name && variant_Name.push(e.variant_Name));
// const duplicate = variant_Name.filter(
// (e) => sizes.indexOf(e) !== sizes.lastIndexOf(e)
// );
// if (duplicate.length !== 0) {
// swal({
// title: "Warning",
// text: "Duplicate sizes selected!",
// icon: "warning",
// button: "Return",
// });
// return;
// }
const varientData = varients.filter((e) => e.variant_Name !== "");
const emptyVariants = varients.reduce(
(arr, e) =>
e.gst_Id !== "" && e.variant_Name === "" && e.price === ""
? [...arr, e._id]
: arr,
[]
);
setLoading(true);
axios
.patch(
`/api/product/update/${productId}`,
{ variants: varientData, delete_variants: emptyVariants },
{
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${token}`,
},
}
)
.then((res) => {
swal({
title: "Saved",
text: "Product variants saved successfully!",
icon: "success",
button: "Close",
});
setVarients((prev) =>
res?.data?.variants?.length > 0 ? [...res?.data?.variants] : prev
);
setLoading(false);
})
.catch((err) => {
const msg = err?.response?.data?.message || "Something went wrong!";
swal({
title: "Warning",
text: msg,
icon: "warning",
button: "Close",
});
setLoading(false);
});
};
return (
<>
<div className="d-flex justify-content-between">
<h5>Product Variants</h5>
<button
className="btn btn-primary btn-sm"
type="button"
onClick={() => handleSubmit()}
disabled={!productId || loading}
>
{productId
? loading
? "Loading"
: "Save Varients"
: "First Save Product Details then Save Varients"}
</button>
</div>
<table className="table">
<thead>
<tr>
{/* <th scope="col">Size</th> */}
<th scope="col">Variant Name</th>
<th scope="col">Price</th>
{/* <th scope="col">Weight (in Grams)</th> */}
{/* <th scope="col">Show in E-store</th> */}
<th scope="col">Tax</th>
</tr>
</thead>
<tbody>
{varients.map((r, idx) => (
<tr key={idx}>
{/* <td>
<select
name="size"
value={r.size}
onChange={(e) => handleChange(e, idx)}
className="form-control"
>
<option value="">---select---</option>
{sizes &&
sizes.map((item, index) => (
<option value={item._id} key={index}>
{item.size}
</option>
))}
</select>
</td> */}
<td>
<input
type="text"
className="form-control"
name="variant_Name"
value={r.variant_Name}
onChange={(e) => handleChange(e, idx)}
/>
</td>
<td>
<input
type="number"
className="form-control"
name="price"
value={r.price}
onChange={(e) => handleChange(e, idx)}
/>
</td>
{/* <td>
<input
type="text"
className="form-control"
name="weight"
value={r.weight}
onChange={(e) => handleChange(e, idx)}
/>
</td> */}
{/* <td>
<select
name="show_in_estore"
value={r.show_in_estore}
onChange={(e) => handleChange(e, idx)}
className="form-control"
>
<option value={true}>Yes</option>
<option value={false}>No</option>
</select>
</td> */}
<td>
<select
name="gst_Id"
value={r.gst_Id?._id ? r.gst_Id?._id : r.gst_Id}
onChange={(e) => handleChange(e, idx)}
className="form-control"
>
<option value="">---select---</option>
{taxes &&
taxes.map((item, index) => (
<option value={item._id} key={index}>
{item.tax} %{item.name}
</option>
))}
</select>
</td>
</tr>
))}
</tbody>
</table>
<div className="text-center">
<button
className="btn btn-primary btn-sm"
onClick={() => addVarientRow()}
>
Add another variant
</button>
</div>
</>
);
};
export default ProductVarients;

View File

@ -42,8 +42,8 @@ const Products = () => {
},
})
.then((res) => {
console.log("res.data?.data", res.data?.product);
setProductsData(res.data?.product);
// console.log(res.data);
setProductsData(res.data?.products);
setTotalData(res.data?.total_data);
setLoading(false);
})
@ -71,6 +71,7 @@ const Products = () => {
},
})
.then((res) => {
// console.log(res?.data?.categories);
setCategories(res?.data?.categories);
});
};
@ -220,7 +221,7 @@ const Products = () => {
}
});
};
console.log("currencyDetails", currencyDetails);
// console.log("currencyDetails", currencyDetails);
return (
<div className="main-content">
<div className="page-content">
@ -415,9 +416,7 @@ const Products = () => {
</td>
<th className="text-start">
{currencyDetails?.CurrencySymbol}
{product?.variants?.length > 0
? product?.variants[0]?.price
: product?.master_price}
{product?.price}
</th>
<td className="text-start">
<span className=""></span>
@ -450,25 +449,9 @@ const Products = () => {
)}
</td>
<td className="text-start">
{/* <Link to={`/products/variants/${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
"
>
Variants
</button>
</Link> */}
<Link
to={`/product/view/${product._id}`}
state={{ currencyDetails }}
// to={`/product/view/${product._id}`}
>
<button
style={{

View File

@ -13,13 +13,6 @@ const ViewProduct = () => {
const token = isAutheticated();
const [productData, setProductData] = useState({});
const [SAW, setSAW] = useState([
{ volume: "", weight: "" },
{ volume: "", weight: "" },
{ volume: "", weight: "" },
{ volume: "", weight: "" },
{ volume: "", weight: "" },
]);
const navigate = useNavigate();
const getProductData = async () => {
@ -30,11 +23,8 @@ const ViewProduct = () => {
},
})
.then((res) => {
console.log(res.data.data);
// console.log(res.data.data);
setProductData(res.data.data);
if (res.data.data?.variants) {
setSAW((prev) => [...res.data.data?.variants]);
}
})
.catch((err) => {});
};
@ -102,32 +92,32 @@ const ViewProduct = () => {
</td>
</tr>
{productData?.master_price && (
{productData?.price && (
<tr>
<th>Master Price</th>
<th>Price</th>
<td>
{currencyDetails?.CurrencySymbol}
{productData?.master_price}
{productData?.price}
</td>
</tr>
)}
{productData?.master_GST && (
{productData?.GST && (
<tr>
<th>Master GST</th>
<td>
{productData?.master_GST?.tax}%{" "}
{productData?.master_GST?.name}
{productData?.GST?.tax}%{" "}
{productData?.GST?.name}
</td>
</tr>
)}
{productData?.master_GST && (
{productData?.GST && (
<tr>
<th>Master GST Price</th>
<th>GST Price</th>
<td>
{currencyDetails?.CurrencySymbol}
{(
(Number(productData?.master_price) *
Number(productData?.master_GST?.tax)) /
(Number(productData?.price) *
Number(productData?.GST?.tax)) /
100
)?.toFixed(2)}
</td>
@ -165,118 +155,6 @@ const ViewProduct = () => {
</thead>
<tbody></tbody>
</table>
<table className="table table-primary mt-3">
<caption
style={{ captionSide: "top" }}
className="text-dark fw-bold"
>
Varients:
</caption>
<thead>
<tr>
<th className="text-center">Variant Name</th>
<th className="text-center">Price</th>
<th className="text-center">GST</th>
</tr>
</thead>
<tbody>
{SAW.map(
(r, i) =>
r.variant_Name !== "" && (
<tr key={i}>
<td className="text-center">
{r?.variant_Name}
</td>
<td className="text-center">
{currencyDetails?.CurrencySymbol}
{r?.price}
</td>
<td className="text-center">
{r?.gst_Id?.name + " " + r?.gst_Id?.tax + "%"}
</td>
</tr>
)
)}
{SAW.filter((e) => e.variant_Name !== "").length ===
0 && (
<tr>
<td colSpan={"6"} className="text-center">
No data available
</td>
</tr>
)}
</tbody>
</table>
{/* <div className="mb-2">
<table className="table table-secondary mt-3">
<caption
style={{ captionSide: "top" }}
className="text-dark fw-bold"
>
Product Fabric:
</caption>
{productData?.product_Fabric?.length > 0 ? (
<>
<thead>
<tr>
<th className="text-center">S. No.</th>
<th className="text-center"> Name</th>
<th className="text-center"> Use For Part</th>
</tr>
</thead>
<tbody>
{productData?.product_Fabric?.map((r, i) => (
<tr key={i}>
<td className="text-center">{++i}</td>
<td className="text-center">
{r?.fabric_Name}
</td>
<td className="text-center">{r?.for_Part}</td>
</tr>
))}
</tbody>
</>
) : (
<>
<h5>No Fabric Allotted for this product!</h5>
</>
)}
</table>
</div> */}
{/* <div className="mb-2">
<table className="table table-info mt-3">
<caption
style={{ captionSide: "top" }}
className="text-dark fw-bold"
>
Relevent Product:
</caption>
{productData?.relevent_product?.length > 0 ? (
<>
<thead>
<tr>
<th className="text-center">S. No.</th>
<th className="text-center">Product Name</th>
</tr>
</thead>
<tbody>
{productData?.relevent_product?.map((r, i) => (
<tr key={i}>
<td className="text-center">{count++}</td>
<td className="text-center">{r?.name}</td>
</tr>
))}
</tbody>
</>
) : (
<>
<h5>No relevent item for this product !</h5>
</>
)}
</table>
</div> */}
</div>
{/* <!-- end table-responsive --> */}