Merge branch 'master' of http://128.199.30.231/possibillion/smellika-admin
This commit is contained in:
commit
2cf3842b91
@ -65,7 +65,7 @@ const _nav = [
|
||||
},
|
||||
{
|
||||
component: CNavItem,
|
||||
name: "Gst Rate",
|
||||
name: "GST Rate",
|
||||
icon: <CIcon icon={cilTablet} customClassName="nav-icon" />,
|
||||
to: "/tax",
|
||||
},
|
||||
|
@ -187,8 +187,21 @@ const AddProduct = () => {
|
||||
});
|
||||
});
|
||||
};
|
||||
const handlePriceChange = (e) => {
|
||||
const newPrice = e.target.value;
|
||||
setPrice(newPrice);
|
||||
const selectedTaxObj = allTax.find((t) => t._id === 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));
|
||||
}
|
||||
};
|
||||
// console.log(data);
|
||||
console.log(productImages);
|
||||
// console.log(productImages);
|
||||
return (
|
||||
<div className="container">
|
||||
<div className="row">
|
||||
@ -253,13 +266,13 @@ const AddProduct = () => {
|
||||
className="form-control"
|
||||
id="name"
|
||||
value={name}
|
||||
maxLength={25}
|
||||
maxLength={35}
|
||||
onChange={(e) => setName(e.target.value)}
|
||||
/>
|
||||
{name ? (
|
||||
<>
|
||||
<small className="charLeft mt-4 fst-italic">
|
||||
{25 - name.length} characters left
|
||||
{35 - name.length} characters left
|
||||
</small>
|
||||
</>
|
||||
) : (
|
||||
@ -271,18 +284,19 @@ const AddProduct = () => {
|
||||
<label htmlFor="title" className="form-label">
|
||||
Description*
|
||||
</label>
|
||||
<input
|
||||
<textarea
|
||||
type="text"
|
||||
className="form-control"
|
||||
id="description"
|
||||
value={description}
|
||||
maxLength="100"
|
||||
rows={8}
|
||||
maxLength="400"
|
||||
onChange={(e) => setDescription(e.target.value)}
|
||||
/>
|
||||
{description ? (
|
||||
<>
|
||||
<small className="charLeft mt-4 fst-italic">
|
||||
{100 - description.length} characters left
|
||||
{400 - description.length} characters left
|
||||
</small>
|
||||
</>
|
||||
) : (
|
||||
@ -405,7 +419,7 @@ const AddProduct = () => {
|
||||
className="form-control"
|
||||
id="price"
|
||||
value={price}
|
||||
onChange={(e) => setPrice(e.target.value)}
|
||||
onChange={(e) => handlePriceChange(e)}
|
||||
/>
|
||||
</div>
|
||||
<div className="">
|
||||
@ -464,7 +478,7 @@ const AddProduct = () => {
|
||||
{allTax.length > 0 && (
|
||||
<div className=" mb-3">
|
||||
<label htmlFor="title" className="form-label">
|
||||
Gst*
|
||||
GST*
|
||||
</label>{" "}
|
||||
<select
|
||||
className="form-control"
|
||||
@ -485,7 +499,7 @@ const AddProduct = () => {
|
||||
|
||||
<div className="mb-3 me-3">
|
||||
<label htmlFor="title" className="form-label">
|
||||
Gst Amount (Rs) *
|
||||
GST Amount (Rs) *
|
||||
</label>
|
||||
<input
|
||||
disabled
|
||||
|
@ -33,6 +33,7 @@ const EditProduct = () => {
|
||||
const [price, setPrice] = useState("");
|
||||
const [category, setCategoryName] = useState("");
|
||||
const [error, setError] = useState("");
|
||||
const [initTax, setInitTax] = useState();
|
||||
const [selectedTax, setselectedTax] = useState();
|
||||
const [totalAmt, setTotalAmt] = useState(0);
|
||||
const [gst_amount, setGst_amount] = useState(0);
|
||||
@ -48,13 +49,14 @@ const EditProduct = () => {
|
||||
},
|
||||
})
|
||||
.then((res) => {
|
||||
console.log(res?.data?.product?.gst?._id);
|
||||
// console.log(res?.data?.product?.gst?._id);
|
||||
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?.name);
|
||||
setselectedTax(res.data.product?.gst);
|
||||
setInitTax(res.data.product?.gst?._id);
|
||||
setTotalAmt(res.data.product?.total_amount);
|
||||
setGst_amount(res.data.product?.gst_amount);
|
||||
})
|
||||
@ -68,6 +70,7 @@ const EditProduct = () => {
|
||||
});
|
||||
});
|
||||
};
|
||||
// console.log(selectedTax, "selectedTax");
|
||||
|
||||
const getCategories = async () => {
|
||||
try {
|
||||
@ -111,6 +114,7 @@ const EditProduct = () => {
|
||||
}, [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));
|
||||
@ -118,7 +122,29 @@ const EditProduct = () => {
|
||||
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 === "" ||
|
||||
@ -127,6 +153,8 @@ const EditProduct = () => {
|
||||
selectedTax === "" ||
|
||||
gst_amount === "" ||
|
||||
price === "" ||
|
||||
totalAmt === "" ||
|
||||
gst_amount === "" ||
|
||||
(productImages.length == 0 && newUpdatedImages.length == 0)
|
||||
) {
|
||||
swal({
|
||||
@ -148,7 +176,7 @@ const EditProduct = () => {
|
||||
formData.append("total_amount", totalAmt);
|
||||
formData.append("gst_amount", gst_amount);
|
||||
|
||||
formData.append("gst", selectedTax);
|
||||
formData.append("gst", initTax === "" ? selectedTax : initTax);
|
||||
|
||||
newUpdatedImages.length > 0 &&
|
||||
newUpdatedImages.forEach((Singleimage) => {
|
||||
@ -280,7 +308,7 @@ const EditProduct = () => {
|
||||
onClick={() => handleSubmit()}
|
||||
disabled={loading}
|
||||
>
|
||||
{loading ? "Loading" : "Edit"}
|
||||
{loading ? "Loading" : "Save"}
|
||||
</Button>
|
||||
<Link to="/products">
|
||||
<Button
|
||||
@ -312,13 +340,13 @@ const EditProduct = () => {
|
||||
className="form-control"
|
||||
id="name"
|
||||
value={name}
|
||||
maxLength={25}
|
||||
maxLength={35}
|
||||
onChange={(e) => setName(e.target.value)}
|
||||
/>
|
||||
{name ? (
|
||||
<>
|
||||
<small className="charLeft mt-4 fst-italic">
|
||||
{25 - name.length} characters left
|
||||
{35 - name.length} characters left
|
||||
</small>
|
||||
</>
|
||||
) : (
|
||||
@ -330,18 +358,19 @@ const EditProduct = () => {
|
||||
<label htmlFor="title" className="form-label">
|
||||
Description*
|
||||
</label>
|
||||
<input
|
||||
<textarea
|
||||
type="text"
|
||||
className="form-control"
|
||||
id="description"
|
||||
rows="8"
|
||||
value={description}
|
||||
maxLength="100"
|
||||
maxLength="400"
|
||||
onChange={(e) => setDescription(e.target.value)}
|
||||
/>
|
||||
{description ? (
|
||||
<>
|
||||
<small className="charLeft mt-4 fst-italic">
|
||||
{100 - description.length} characters left
|
||||
{400 - description.length} characters left
|
||||
</small>
|
||||
</>
|
||||
) : (
|
||||
@ -477,7 +506,7 @@ const EditProduct = () => {
|
||||
className="form-control"
|
||||
id="price"
|
||||
value={price}
|
||||
onChange={(e) => setPrice(e.target.value)}
|
||||
onChange={(e) => handlePriceChange(e)}
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
@ -501,16 +530,22 @@ const EditProduct = () => {
|
||||
{allTax.length > 0 && (
|
||||
<div className=" mb-3">
|
||||
<label htmlFor="title" className="form-label">
|
||||
Gst*
|
||||
GST*
|
||||
</label>{" "}
|
||||
<select
|
||||
className=" form-control"
|
||||
name=""
|
||||
id=""
|
||||
value={JSON.stringify(selectedTax?._id)}
|
||||
onChange={(e) => TaxRatechange(e)}
|
||||
>
|
||||
<option value="">--Select--</option>
|
||||
|
||||
{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}
|
||||
@ -522,7 +557,7 @@ const EditProduct = () => {
|
||||
|
||||
<div className="mb-3 me-3">
|
||||
<label htmlFor="title" className="form-label">
|
||||
Gst Amount (Rs) *
|
||||
GST Amount (Rs) *
|
||||
</label>
|
||||
<input
|
||||
disabled
|
||||
|
@ -62,6 +62,7 @@ const Products = () => {
|
||||
useEffect(() => {
|
||||
getProductsData();
|
||||
}, [success]);
|
||||
console.log(productsData);
|
||||
|
||||
useEffect(() => {
|
||||
const loadData = () => {
|
||||
@ -143,6 +144,9 @@ const Products = () => {
|
||||
}
|
||||
setTimeout(() => handleSearchClick(query), 100);
|
||||
}, [query]);
|
||||
const uniqueCategoryNames = [
|
||||
...new Set(showData?.map((product) => product?.category?.categoryName)),
|
||||
];
|
||||
useEffect(() => {
|
||||
setTimeout(() => {
|
||||
if (filterCategory !== "") {
|
||||
@ -301,7 +305,7 @@ const Products = () => {
|
||||
setFilterCategory(e.target.value)
|
||||
}
|
||||
>
|
||||
{showData.map((product, i) => (
|
||||
{uniqueCategoryNames.map((categoryName, i) => (
|
||||
<MenuItem
|
||||
key={i}
|
||||
style={{
|
||||
@ -311,9 +315,9 @@ const Products = () => {
|
||||
textAlign: "left",
|
||||
padding: "0.5rem",
|
||||
}}
|
||||
value={product.category?.categoryName}
|
||||
value={categoryName}
|
||||
>
|
||||
{product.category?.categoryName}
|
||||
{categoryName}
|
||||
</MenuItem>
|
||||
))}
|
||||
</Select>
|
||||
|
@ -10,6 +10,7 @@ function NewOrders() {
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [success, setSuccess] = useState(true);
|
||||
const [newOrdersData, setNewOrdersData] = useState([]);
|
||||
console.log(newOrdersData);
|
||||
|
||||
const [currentPage, setCurrentPage] = useState(1);
|
||||
const [itemPerPage, setItemPerPage] = useState(10);
|
||||
|
@ -137,6 +137,8 @@ function ViewOrders() {
|
||||
status: orderStatus,
|
||||
courierName,
|
||||
TrackingID,
|
||||
sendemail: orderDetails?.user?.email,
|
||||
customerName: orderDetails?.user?.name,
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
|
Loading…
Reference in New Issue
Block a user