change product and razorpay

This commit is contained in:
pawan-dot 2024-04-26 15:38:06 +05:30
parent 88de98706f
commit 63aecdaaa3
2 changed files with 80 additions and 4 deletions

View File

@ -14,7 +14,7 @@ import { cibGmail } from "@coreui/icons";
import { createRoot } from "react-dom/client"; import { createRoot } from "react-dom/client";
const setupAxios = () => { const setupAxios = () => {
// axios.defaults.baseURL = "http://localhost:5000"; //axios.defaults.baseURL = "http://localhost:5000";
axios.defaults.baseURL = "https://api.smellika.com"; axios.defaults.baseURL = "https://api.smellika.com";
axios.defaults.headers = { axios.defaults.headers = {

View File

@ -743,6 +743,7 @@ const Products = () => {
const nameRef = useRef(); const nameRef = useRef();
const categoryRef = useRef(); const categoryRef = useRef();
const FeatureProductRef = useRef();
const [currentPage, setCurrentPage] = useState(1); const [currentPage, setCurrentPage] = useState(1);
const [itemPerPage, setItemPerPage] = useState(10); const [itemPerPage, setItemPerPage] = useState(10);
@ -765,6 +766,7 @@ const Products = () => {
show: itemPerPage, show: itemPerPage,
name: nameRef.current.value, name: nameRef.current.value,
category: categoryRef.current.value, category: categoryRef.current.value,
FeatureProduct: FeatureProductRef.current.value,
}, },
}) })
.then((res) => { .then((res) => {
@ -836,9 +838,12 @@ const Products = () => {
setSuccess((prev) => !prev); setSuccess((prev) => !prev);
}) })
.catch((err) => { .catch((err) => {
let msg = err?.response?.data?.message
? err?.response?.data?.message
: "Something went wrong!";
swal({ swal({
title: "Warning", title: "Warning",
text: "Something went wrong!", text: msg,
icon: "error", icon: "error",
button: "Retry", button: "Retry",
dangerMode: true, 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) => { const handleStatus = (id) => {
swal({ swal({
title: "Are you sure?", title: "Are you sure?",
@ -866,7 +912,7 @@ const Products = () => {
}) })
.then((res) => { .then((res) => {
swal({ swal({
title: "Chenged", title: "Changed",
text: "Product status changed successfully!", text: "Product status changed successfully!",
icon: "success", icon: "success",
button: "ok", button: "ok",
@ -973,6 +1019,18 @@ const Products = () => {
))} ))}
</select> </select>
</div> </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"> <div className="col-lg-2">
<button <button
className="btn btn-primary ms-1 mt-4" className="btn btn-primary ms-1 mt-4"
@ -1000,6 +1058,8 @@ const Products = () => {
<th className="text-start">Image</th> <th className="text-start">Image</th>
<th className="text-start">Product</th> <th className="text-start">Product</th>
<th className="text-start">Category</th> <th className="text-start">Category</th>
<th className="text-start">Feature Product</th>
<th className="text-start">Price</th> <th className="text-start">Price</th>
<th className="text-start">Status</th> <th className="text-start">Status</th>
@ -1052,6 +1112,23 @@ const Products = () => {
? product.category?.categoryName ? product.category?.categoryName
: "Category Not selected "} : "Category Not selected "}
</td> </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"> <th className="text-start">
{product?.total_amount {product?.total_amount
@ -1088,7 +1165,6 @@ const Products = () => {
} }
)} )}
</td> </td>
<td className="text-start"> <td className="text-start">
{/* <Link to={`/products/variants/${product._id}`}> {/* <Link to={`/products/variants/${product._id}`}>
<button <button