From 63aecdaaa3e6522b20434fb6b96dae47e19ce06e Mon Sep 17 00:00:00 2001 From: pawan-dot <71133473+pawan-dot@users.noreply.github.com> Date: Fri, 26 Apr 2024 15:38:06 +0530 Subject: [PATCH] change product and razorpay --- src/index.js | 2 +- src/views/Products/Products.js | 82 ++++++++++++++++++++++++++++++++-- 2 files changed, 80 insertions(+), 4 deletions(-) diff --git a/src/index.js b/src/index.js index 3e4516a..466639c 100644 --- a/src/index.js +++ b/src/index.js @@ -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 = { diff --git a/src/views/Products/Products.js b/src/views/Products/Products.js index 4cb6d68..c11f724 100644 --- a/src/views/Products/Products.js +++ b/src/views/Products/Products.js @@ -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 = () => { ))} +