change product and razorpay
This commit is contained in:
parent
88de98706f
commit
63aecdaaa3
@ -14,7 +14,7 @@ import { cibGmail } from "@coreui/icons";
|
||||
import { createRoot } from "react-dom/client";
|
||||
|
||||
const setupAxios = () => {
|
||||
// axios.defaults.baseURL = "http://localhost:5000";
|
||||
//axios.defaults.baseURL = "http://localhost:5000";
|
||||
axios.defaults.baseURL = "https://api.smellika.com";
|
||||
|
||||
axios.defaults.headers = {
|
||||
|
@ -743,6 +743,7 @@ const Products = () => {
|
||||
|
||||
const nameRef = useRef();
|
||||
const categoryRef = useRef();
|
||||
const FeatureProductRef = useRef();
|
||||
|
||||
const [currentPage, setCurrentPage] = useState(1);
|
||||
const [itemPerPage, setItemPerPage] = useState(10);
|
||||
@ -765,6 +766,7 @@ const Products = () => {
|
||||
show: itemPerPage,
|
||||
name: nameRef.current.value,
|
||||
category: categoryRef.current.value,
|
||||
FeatureProduct: FeatureProductRef.current.value,
|
||||
},
|
||||
})
|
||||
.then((res) => {
|
||||
@ -836,9 +838,12 @@ const Products = () => {
|
||||
setSuccess((prev) => !prev);
|
||||
})
|
||||
.catch((err) => {
|
||||
let msg = err?.response?.data?.message
|
||||
? err?.response?.data?.message
|
||||
: "Something went wrong!";
|
||||
swal({
|
||||
title: "Warning",
|
||||
text: "Something went wrong!",
|
||||
text: msg,
|
||||
icon: "error",
|
||||
button: "Retry",
|
||||
dangerMode: true,
|
||||
@ -847,6 +852,47 @@ const Products = () => {
|
||||
}
|
||||
});
|
||||
};
|
||||
const handleFeaturedProduct = (id) => {
|
||||
swal({
|
||||
title: "Are you sure?",
|
||||
icon: "warning",
|
||||
buttons: {
|
||||
Yes: { text: "Yes", value: true },
|
||||
Cancel: { text: "Cancel", value: "cancel" },
|
||||
},
|
||||
}).then((value) => {
|
||||
if (value === true) {
|
||||
axios
|
||||
.patch(`/api/product/admin/feature_product/status/${id}`, {
|
||||
headers: {
|
||||
"Access-Control-Allow-Origin": "*",
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
})
|
||||
.then((res) => {
|
||||
swal({
|
||||
title: "Changed",
|
||||
text: " Feature Product status changed successfully!",
|
||||
icon: "success",
|
||||
button: "ok",
|
||||
});
|
||||
setSuccess((prev) => !prev);
|
||||
})
|
||||
.catch((err) => {
|
||||
let msg = err?.response?.data?.msg
|
||||
? err?.response?.data?.msg
|
||||
: "Something went wrong!";
|
||||
swal({
|
||||
title: "Warning",
|
||||
text: msg,
|
||||
icon: "warning",
|
||||
button: "ok",
|
||||
dangerMode: true,
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
const handleStatus = (id) => {
|
||||
swal({
|
||||
title: "Are you sure?",
|
||||
@ -866,7 +912,7 @@ const Products = () => {
|
||||
})
|
||||
.then((res) => {
|
||||
swal({
|
||||
title: "Chenged",
|
||||
title: "Changed",
|
||||
text: "Product status changed successfully!",
|
||||
icon: "success",
|
||||
button: "ok",
|
||||
@ -973,6 +1019,18 @@ const Products = () => {
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
<div className="col-lg-3">
|
||||
<label>Feature Product:</label>
|
||||
<select
|
||||
className="form-control"
|
||||
ref={FeatureProductRef}
|
||||
disabled={loading}
|
||||
>
|
||||
<option value="">----Select----</option>
|
||||
<option value="true">YES</option>
|
||||
<option value="false">NO</option>
|
||||
</select>
|
||||
</div>
|
||||
<div className="col-lg-2">
|
||||
<button
|
||||
className="btn btn-primary ms-1 mt-4"
|
||||
@ -1000,6 +1058,8 @@ const Products = () => {
|
||||
<th className="text-start">Image</th>
|
||||
<th className="text-start">Product</th>
|
||||
<th className="text-start">Category</th>
|
||||
<th className="text-start">Feature Product</th>
|
||||
|
||||
<th className="text-start">Price</th>
|
||||
<th className="text-start">Status</th>
|
||||
|
||||
@ -1052,6 +1112,23 @@ const Products = () => {
|
||||
? product.category?.categoryName
|
||||
: "Category Not selected "}
|
||||
</td>
|
||||
|
||||
<td className="text-center">
|
||||
<span className=""></span>
|
||||
<button
|
||||
type="button"
|
||||
className={`badge text-white ${
|
||||
product?.featured_Product === true
|
||||
? "text-bg-success"
|
||||
: "text-bg-danger"
|
||||
}`}
|
||||
onClick={() => {
|
||||
handleFeaturedProduct(product._id);
|
||||
}}
|
||||
>
|
||||
{product?.featured_Product ? "YES" : "NO"}
|
||||
</button>
|
||||
</td>
|
||||
<th className="text-start">
|
||||
₹
|
||||
{product?.total_amount
|
||||
@ -1088,7 +1165,6 @@ const Products = () => {
|
||||
}
|
||||
)}
|
||||
</td>
|
||||
|
||||
<td className="text-start">
|
||||
{/* <Link to={`/products/variants/${product._id}`}>
|
||||
<button
|
||||
|
Loading…
Reference in New Issue
Block a user