diff --git a/src/_nav.js b/src/_nav.js index 2e52e46..a27b8d9 100644 --- a/src/_nav.js +++ b/src/_nav.js @@ -99,7 +99,7 @@ const _nav = [ }, { component: CNavItem, - name: "Retail Distributor", + name: "Retailers", icon: , to: "/retail-distributor", group: "RetailDistributor", @@ -307,6 +307,13 @@ const _nav = [ to: "/logo", group: "Settings", }, + { + component: CNavItem, + name: "Mobile App", + icon: , + to: "/mobile-app", + group: "Settings", + }, // { // component: CNavItem, // name: "Copyright Message", diff --git a/src/routes.js b/src/routes.js index 0c43088..a5b41aa 100644 --- a/src/routes.js +++ b/src/routes.js @@ -269,7 +269,7 @@ const routes = [ }, { path: "/view/SCretaildistributor/:id", - name: "View Retail Distributor", + name: "View Retailer", element: ViewRetailDistributorSC, navName: "SalesCoOrdinators", }, @@ -312,7 +312,7 @@ const routes = [ }, { path: "/view/retaildistributor/:id", - name: "View Retail Distributor", + name: "View Retailer", element: ViewRetailDistributorTM, navName: "TerritoryManagers", }, @@ -388,25 +388,25 @@ const routes = [ }, { path: "/retaildistributor/view/:id", - name: "Single Retail Distributor", + name: "Single Retailer", element: SingleRetailDistributor, navName: "RetailDistributor", }, { path: "/retaildistributor/add", - name: "Add Retail Distributor", + name: "Add Retailer", element: AddRetailDistributor, navName: "RetailDistributor", }, { path: "/add-retail-distributor/multiple", - name: "Add Retail Distributor", + name: "Add Retailer", element: AddMultiplerd, navName: "RetailDistributor", }, { path: "/retaildistributor/mapping/:id", - name: "Mapping Retail Distributor with PD SC TM", + name: "Mapping Retailer with PD SC TM", element: MapRD, navName: "RetailDistributor", }, @@ -499,7 +499,7 @@ const routes = [ }, { path: "/view/mappedretaildistributor/:id", - name: "view retail distributor", + name: "view Retailer", element: ViewRetailDistributorPD, navName: "PrincipalDistributor", }, diff --git a/src/views/PrincipalDistributors/ViewRetailDistributorPD.js b/src/views/PrincipalDistributors/ViewRetailDistributorPD.js index 1c6f785..2b119b8 100644 --- a/src/views/PrincipalDistributors/ViewRetailDistributorPD.js +++ b/src/views/PrincipalDistributors/ViewRetailDistributorPD.js @@ -44,7 +44,7 @@ const ViewRetailDistributorPD = () => { .catch((error) => console.error("Error fetching sc data:", error)); }, [id, token]); - // Fetch Retail Distributors data + // Fetch Retailers data const getPDsretaildistributorData = async () => { setLoading(true); axios @@ -81,7 +81,7 @@ const ViewRetailDistributorPD = () => { getPDsretaildistributorData(); }, [success, itemPerPage, currentPage]); - // Debounced search for Retail Distributors + // Debounced search for Retailers const debouncedSearch = useCallback( debounce(() => { setCurrentPage(1); @@ -93,7 +93,7 @@ const ViewRetailDistributorPD = () => { const handleSearchChange = useCallback(() => { debouncedSearch(); }, [debouncedSearch]); - // Fetch Retail Distributors data for modal + // Fetch Retailers data for modal const getretaildistributorData = async () => { setLoading(true); try { @@ -130,7 +130,7 @@ const ViewRetailDistributorPD = () => { } }, [openModal, modalcurrentPage]); - // Debounced search for Retail Distributors in modal + // Debounced search for Retailers in modal const debouncedmodalSearch = useCallback( debounce(() => { setmodalCurrentPage(1); @@ -187,7 +187,7 @@ const ViewRetailDistributorPD = () => { .then((res) => { swal({ title: "Deleted", - text: "Retail Distributor Unmapped successfully!", + text: "Retailer Unmapped successfully!", icon: "success", button: "ok", }); @@ -221,7 +221,7 @@ const ViewRetailDistributorPD = () => { ); swal({ title: "Success", - text: "Retail Distributor added successfully!", + text: "Retailer added successfully!", icon: "success", button: "Ok", }); @@ -274,7 +274,7 @@ const ViewRetailDistributorPD = () => { }} onClick={handleOpenModal} > - Add Retail Distributor + Add Retailer -
Add Multiple Retail Distributor
+
Add Multiple Retailers
@@ -141,11 +141,11 @@ const AddMultiplerd = () => { {errors.length > 0 && (
-
Finding errors while adding the Retail Distributor.
+
Finding errors while adding the Retailers.
- + @@ -172,11 +172,11 @@ const AddMultiplerd = () => { )} {updatedDistributors.length > 0 && (
-
Updated Retail Distributors
+
Updated Retailers
Retail Distributor NameRetailer Name Email Phone PAN
- + @@ -203,11 +203,11 @@ const AddMultiplerd = () => { )} {newlyCreated.length > 0 && (
-
Newly Created Retail Distributors:
+
Newly Created Retailers:
Retail Distributor NameRetailer Name Email Phone PAN
- + diff --git a/src/views/RetailDistributors/DistributorOrders.js b/src/views/RetailDistributors/DistributorOrders.js index 10b937a..8958a13 100644 --- a/src/views/RetailDistributors/DistributorOrders.js +++ b/src/views/RetailDistributors/DistributorOrders.js @@ -241,7 +241,7 @@ const SingleDistributorOrder = () => { mb: 3, }} > - {distributortype === "principaldistributor" ? "Principal Distributor Details":"Retail Distributor Details"} + {distributortype === "principaldistributor" ? "Principal Distributor Details":"Retailers Details"} Cancel diff --git a/src/views/RetailDistributors/MapRD.js b/src/views/RetailDistributors/MapRD.js index b1043d6..695aca2 100644 --- a/src/views/RetailDistributors/MapRD.js +++ b/src/views/RetailDistributors/MapRD.js @@ -67,7 +67,7 @@ const MapRD = () => { .then((res) => { swal({ title: "Deleted", - text: "Retail Distributor Unmapped successfully!", + text: "Retailer Unmapped successfully!", icon: "success", button: "Ok", }); diff --git a/src/views/RetailDistributors/RetailDistributor.js b/src/views/RetailDistributors/RetailDistributor.js index cdd05a1..8c0f8ba 100644 --- a/src/views/RetailDistributors/RetailDistributor.js +++ b/src/views/RetailDistributors/RetailDistributor.js @@ -77,7 +77,7 @@ const RetailDistributor = () => {
- Retail Distributors + Retailers
)} diff --git a/src/views/RetailDistributors/SingleRetailDistributor.js b/src/views/RetailDistributors/SingleRetailDistributor.js index 1c6d638..ee91692 100644 --- a/src/views/RetailDistributors/SingleRetailDistributor.js +++ b/src/views/RetailDistributors/SingleRetailDistributor.js @@ -485,7 +485,7 @@ const SingleRetailDistributor = () => { - {/* Address of retail distributor */} + {/* Address of Retailer */}
• Addresses{" "} diff --git a/src/views/RetailDistributors/addRetailDistributor.js b/src/views/RetailDistributors/addRetailDistributor.js index fad9510..23ea330 100644 --- a/src/views/RetailDistributors/addRetailDistributor.js +++ b/src/views/RetailDistributors/addRetailDistributor.js @@ -151,7 +151,7 @@ const AddRetailDistributor = () => { }); if (response.data.success) { - toast.success("Retail Distributor created successfully!"); + toast.success("Retailers created successfully!"); navigate("/retail-distributor"); } } catch (error) { @@ -181,7 +181,7 @@ const AddRetailDistributor = () => { Cancel - Add Retail Distributor + Add Retailer
diff --git a/src/views/SalesCoOrdinators/ViewRetailDistributorSC.js b/src/views/SalesCoOrdinators/ViewRetailDistributorSC.js index 1e42e32..b18a20f 100644 --- a/src/views/SalesCoOrdinators/ViewRetailDistributorSC.js +++ b/src/views/SalesCoOrdinators/ViewRetailDistributorSC.js @@ -44,7 +44,7 @@ const ViewRetailDistributorSC = () => { .catch((error) => console.error("Error fetching sc data:", error)); }, [id, token]); - // Fetch Retail Distributors data + // Fetch Retailers data const getSCsretaildistributorData = async () => { setLoading(true); axios @@ -81,7 +81,7 @@ const ViewRetailDistributorSC = () => { getSCsretaildistributorData(); }, [success, itemPerPage, currentPage]); - // Debounced search for Retail Distributors + // Debounced search for Retailers const debouncedSearch = useCallback( debounce(() => { setCurrentPage(1); @@ -93,7 +93,7 @@ const ViewRetailDistributorSC = () => { const handleSearchChange = useCallback(() => { debouncedSearch(); }, [debouncedSearch]); - // Fetch Retail Distributors data for modal + // Fetch Retailers data for modal const getretaildistributorData = async () => { setLoading(true); try { @@ -130,7 +130,7 @@ const ViewRetailDistributorSC = () => { } }, [openModal, modalcurrentPage]); - // Debounced search for Retail Distributors in modal + // Debounced search for Retailers in modal const debouncedmodalSearch = useCallback( debounce(() => { setmodalCurrentPage(1); @@ -187,7 +187,7 @@ const ViewRetailDistributorSC = () => { .then((res) => { swal({ title: "Deleted", - text: "Retail Distributor Unmapped successfully!", + text: "Retailer Unmapped successfully!", icon: "success", button: "ok", }); @@ -221,7 +221,7 @@ const ViewRetailDistributorSC = () => { ); swal({ title: "Success", - text: "Retail Distributor added successfully!", + text: "Retailer added successfully!", icon: "success", button: "Ok", }); @@ -274,7 +274,7 @@ const ViewRetailDistributorSC = () => { }} onClick={handleOpenModal} > - Add Retail Distributor + Add Retailer
)} @@ -440,7 +440,7 @@ const ViewRetailDistributorSC = () => { { ) : ( )} diff --git a/src/views/TerritoryManager/ViewRetailDistributor.js b/src/views/TerritoryManager/ViewRetailDistributor.js index 68286ac..08e836c 100644 --- a/src/views/TerritoryManager/ViewRetailDistributor.js +++ b/src/views/TerritoryManager/ViewRetailDistributor.js @@ -44,7 +44,7 @@ const ViewRetailDistributorTM = () => { .catch((error) => console.error("Error fetching TM data:", error)); }, [id, token]); - // Fetch Retail Distributors data + // Fetch Retailers data const getTMsretaildistributorData = async () => { setLoading(true); axios @@ -81,7 +81,7 @@ const ViewRetailDistributorTM = () => { getTMsretaildistributorData(); }, [success, itemPerPage, currentPage]); - // Debounced search for Retail Distributors + // Debounced search for Retailers const debouncedSearch = useCallback( debounce(() => { setCurrentPage(1); @@ -93,7 +93,7 @@ const ViewRetailDistributorTM = () => { const handleSearchChange = useCallback(() => { debouncedSearch(); }, [debouncedSearch]); - // Fetch Retail Distributors data for modal + // Fetch Retailers data for modal const getretaildistributorData = async () => { setLoading(true); try { @@ -130,7 +130,7 @@ const ViewRetailDistributorTM = () => { } }, [openModal, modalcurrentPage]); - // Debounced search for Retail Distributors in modal + // Debounced search for Retailers in modal const debouncedmodalSearch = useCallback( debounce(() => { setmodalCurrentPage(1); @@ -187,7 +187,7 @@ const ViewRetailDistributorTM = () => { .then((res) => { swal({ title: "Deleted", - text: "Retail Distributor Unmapped successfully!", + text: "Retailer Unmapped successfully!", icon: "success", button: "ok", }); @@ -221,7 +221,7 @@ const ViewRetailDistributorTM = () => { ); swal({ title: "Success", - text: "Retail Distributor added successfully!", + text: "Retailer added successfully!", icon: "success", button: "Ok", }); @@ -274,7 +274,7 @@ const ViewRetailDistributorTM = () => { }} onClick={handleOpenModal} > - Add Retail Distributor + Add Retailer )} @@ -440,7 +440,7 @@ const ViewRetailDistributorTM = () => { { ) : ( )} diff --git a/src/views/configuration/MobileApp.js b/src/views/configuration/MobileApp.js index 94af13e..0f0a455 100644 --- a/src/views/configuration/MobileApp.js +++ b/src/views/configuration/MobileApp.js @@ -1,21 +1,303 @@ +// import React, { useEffect, useState } from "react"; +// import swal from "sweetalert"; +// import ClipLoader from "react-spinners/ClipLoader"; +// import { Link } from "react-router-dom"; +// import axios from "axios"; +// import { isAutheticated } from "src/auth"; + +// function MobileApp() { +// const [loading, setLoading] = useState(false); +// const [PDApp, setPDApp] = useState(""); +// const [RDApp, setRDApp] = useState(""); +// const [SCApp, setSCApp] = useState(""); +// const [TMApp, setTMApp] = useState(""); +// const [display, setDisplay] = useState(true); +// const token = isAutheticated(); + +// // urlcreated images + +// const [PDAppUrl, setPDAppUrl] = useState(""); +// const [RDAppUrl, setRDAppUrl] = useState(""); +// const [SCAppUrl, setSCAppUrl] = useState(""); +// const [TMAppUrl, setTMAppUrl] = useState(""); + +// useEffect(() => { +// async function getConfiguration() { +// const configDetails = await axios.get(`/api/config`, { +// headers: { +// Authorization: `Bearer ${token}`, +// }, +// }); +// // console.log(configDetails.data.result[0]?.mobileapp[0]); +// const data = configDetails.data.result[0]?.mobileapp[0]; +// setPDApp(data?.PDApp); +// setRDApp(data?.RDApp); +// setSCApp(data?.SCApp); +// setTMApp(data?.TMApp); +// } +// getConfiguration(); +// }, []); + +// async function handelSubmit() { +// setLoading(true); + +// const formdata = new FormData(); +// formdata.append("PDApp", PDApp); +// formdata.append("RDApp", RDApp); +// formdata.append("SCApp", SCApp); +// formdata.append("TMApp", TMApp); + +// await axios +// .post(`/api/config/mobile-app`, formdata, { +// headers: { +// Authorization: `Bearer ${token}`, +// "Content-Type": "multipart/formdata", +// "Access-Control-Allow-Origin": "*", +// }, +// }) +// .then((res) => { +// setLoading(false); +// swal("Success!", res.data.message, res.data.status); +// }) +// .catch((error) => { +// setLoading(false); +// }); +// } + +// return ( +//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//

Mobile App

+ +// +//
+//
+//
+// <> +// +//
+// { +// setPDApp(e.target.files[0]); +// if ( +// e.target.files && +// e.target.files[0] +// ) { +// setPDAppUrl({ +// image: URL.createObjectURL( +// e.target.files[0] +// ), +// }); +// console.log(setPDAppUrl); +// } +// }} +// className="form-control input-field mb-3 col-md-6 d-inline-block" +// id="basicpill-phoneno-input" +// /> +// {display ? ( +// +// ) : ( +// "" +// )} +//
+// +//
+// { +// setRDApp(e.target.files[0]); + +// if (e.target.files && e.target.files[0]) { +// setRDAppUrl({ +// image: URL.createObjectURL( +// e.target.files[0] +// ), +// }); +// } +// }} +// className="form-control input-field mt-1 col-md-6 d-inline-block" +// id="basicpill-phoneno-input" +// />{" "} +// {display ? ( +// +// ) : ( +// "" +// )} +// +// { +// setSCApp(e.target.files[0]); + +// if (e.target.files && e.target.files[0]) { +// setSCAppUrl({ +// image: URL.createObjectURL( +// e.target.files[0] +// ), +// }); +// } +// }} +// className="form-control input-field col-md-6 d-inline-block" +// id="basicpill-phoneno-input" +// />{" "} +// {display ? ( +// +// ) : ( +// "" +// )} +// +// { +// setRDApp(e.target.files[0]); + +// if (e.target.files && e.target.files[0]) { +// setRDAppUrl({ +// image: URL.createObjectURL( +// e.target.files[0] +// ), +// }); +// } +// }} +// className="form-control input-field col-md-6 d-inline-block" +// id="basicpill-phoneno-input" +// />{" "} +// {display ? ( +// +// ) : ( +// "" +// )} +// +//
+//
+//
+//
+//
+//
+// +//
+//
+//
+// +//
+//
+ +// {/* */} +//
+//
+//
+//
+//
+// {/* */} +//
+// {/* */} +//
+//
+// ); +// } + +// export default MobileApp; import React, { useEffect, useState } from "react"; import swal from "sweetalert"; import ClipLoader from "react-spinners/ClipLoader"; -import { Link } from "react-router-dom"; import axios from "axios"; import { isAutheticated } from "src/auth"; function MobileApp() { const [loading, setLoading] = useState(false); - const [PDApp, setPDApp] = useState(""); - const [RDApp, setRDApp] = useState(""); - const [SCApp, setSCApp] = useState(""); - const [TMApp, setTMApp] = useState(""); - const [display, setDisplay] = useState(true); + const [PDApp, setPDApp] = useState(null); + const [RDApp, setRDApp] = useState(null); + const [SCApp, setSCApp] = useState(null); + const [TMApp, setTMApp] = useState(null); const token = isAutheticated(); - // urlcreated images - + // URLs for the uploaded APKs const [PDAppUrl, setPDAppUrl] = useState(""); const [RDAppUrl, setRDAppUrl] = useState(""); const [SCAppUrl, setSCAppUrl] = useState(""); @@ -23,17 +305,20 @@ function MobileApp() { useEffect(() => { async function getConfiguration() { - const configDetails = await axios.get(`/api/config`, { - headers: { - Authorization: `Bearer ${token}`, - }, - }); - // console.log(configDetails.data.result[0]?.logo[0]); - const data = configDetails.data.result[0]?.logo[0]; - setPDApp(data?.PDApp); - setRDApp(data?.RDApp); - setSCApp(data?.SCApp); - setTMApp(data?.TMApp); + try { + const configDetails = await axios.get(`/api/config`, { + headers: { + Authorization: `Bearer ${token}`, + }, + }); + const data = configDetails.data.result[0]?.mobileapp[0]; + setPDAppUrl(data?.PDAppUrl || ""); + setRDAppUrl(data?.RDAppUrl || ""); + setSCAppUrl(data?.SCAppUrl || ""); + setTMAppUrl(data?.TMAppUrl || ""); + } catch (error) { + console.error("Failed to fetch configuration", error); + } } getConfiguration(); }, []); @@ -41,27 +326,33 @@ function MobileApp() { async function handelSubmit() { setLoading(true); - const formdata = new FormData(); - formdata.append("PDApp", PDApp); - formdata.append("RDApp", RDApp); - formdata.append("SCApp", SCApp); - formdata.append("TMApp", TMApp); + const formData = new FormData(); + if (PDApp) formData.append("PDApp", PDApp); + if (RDApp) formData.append("RDApp", RDApp); + if (SCApp) formData.append("SCApp", SCApp); + if (TMApp) formData.append("TMApp", TMApp); - await axios - .post(`/api/config/logo`, formdata, { + try { + const response = await axios.post(`/api/config/mobile-app`, formData, { headers: { Authorization: `Bearer ${token}`, - "Content-Type": "multipart/formdata", - "Access-Control-Allow-Origin": "*", + "Content-Type": "multipart/form-data", }, - }) - .then((res) => { - setLoading(false); - swal("Success!", res.data.message, res.data.status); - }) - .catch((error) => { - setLoading(false); }); + setLoading(false); + swal("Success!", response.data.message, "success"); + + // Update the APK URLs from response + setPDAppUrl(response.data.PDAppUrl); + setRDAppUrl(response.data.RDAppUrl); + setSCAppUrl(response.data.SCAppUrl); + setTMAppUrl(response.data.TMAppUrl); + + } catch (error) { + setLoading(false); + console.error("Failed to upload APKs", error); + swal("Error", "Failed to upload APKs", "error"); + } } return ( @@ -73,174 +364,87 @@ function MobileApp() {
-
-
-

Mobile App

- -
-
-
-
- <> - -
- { - setPDApp(e.target.files[0]); - if ( - e.target.files && - e.target.files[0] - ) { - setPDAppUrl({ - image: URL.createObjectURL( - e.target.files[0] - ), - }); - console.log(setPDAppUrl); - } - }} - className="form-control input-field mb-3 col-md-6 d-inline-block" - id="basicpill-phoneno-input" - /> - {display ? ( - - ) : ( - "" - )} -
- -
- { - setRDApp(e.target.files[0]); - - if (e.target.files && e.target.files[0]) { - setRDAppUrl({ - image: URL.createObjectURL( - e.target.files[0] - ), - }); - } - }} - className="form-control input-field mt-1 col-md-6 d-inline-block" - id="basicpill-phoneno-input" - />{" "} - {display ? ( - - ) : ( - "" - )} - - { - setSCApp(e.target.files[0]); - - if (e.target.files && e.target.files[0]) { - setSCAppUrl({ - image: URL.createObjectURL( - e.target.files[0] - ), - }); - } - }} - className="form-control input-field col-md-6 d-inline-block" - id="basicpill-phoneno-input" - />{" "} - {display ? ( - - ) : ( - "" - )} - -
-
+

Mobile App

+ +
+
+
+ + setPDApp(e.target.files[0])} + className="form-control input-field mb-3" + /> + {PDAppUrl && ( + + Download PD App + + )}
-
-
-
- -
-
+
+ + setRDApp(e.target.files[0])} + className="form-control input-field mb-3" + /> + {RDAppUrl && ( + + Download RD App + + )}
- +
+ + setSCApp(e.target.files[0])} + className="form-control input-field mb-3" + /> + {SCAppUrl && ( + + Download SC App + + )} +
+
+ + setTMApp(e.target.files[0])} + className="form-control input-field mb-3" + /> + {TMAppUrl && ( + + Download TM App + + )} +
+
-
- - {/* */} + +
- {/* */}
- {/* */} ); diff --git a/src/views/widgets/WidgetsDropdown.js b/src/views/widgets/WidgetsDropdown.js index d0b1e9e..c988811 100644 --- a/src/views/widgets/WidgetsDropdown.js +++ b/src/views/widgets/WidgetsDropdown.js @@ -147,14 +147,14 @@ const WidgetsDropdown = ({ /> {/* */} - {/*

Retail Distributor

*/} + {/*

Retailers

*/} {/* */} {retaildistributor}} - title="Total Reatil Distributor" + title="Total Reatailers" /> {/* */} @@ -252,7 +252,7 @@ const WidgetsDropdown = ({ className="mb-4" color="primary" value={<>{product}} - title="Total products" + title="Total SKUs" />
Retail Distributor NameRetailer Name Email Phone PAN
- No Retail Distributor found! + No Retailer found!
- No Retail Distributor found! + No Retailer found!
- No Retail Distributor found! + No Retailer found!
- No Retail Distributor found! + No Retailers found!
- No Retail Distributor found! + No Retailer found!