diff --git a/src/index.js b/src/index.js
index 8a829f2..0ab534a 100644
--- a/src/index.js
+++ b/src/index.js
@@ -15,9 +15,9 @@ 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://cheminova-api-2.onrender.com";
- // axios.defaults.baseURL = "https://api.cnapp.co.in";
+ axios.defaults.baseURL = "https://api.cnapp.co.in";
axios.defaults.headers = {
"Cache-Control": "no-cache,no-store",
diff --git a/src/routes.js b/src/routes.js
index d0cab84..2105a1b 100644
--- a/src/routes.js
+++ b/src/routes.js
@@ -148,6 +148,10 @@ import ViewSalesCoOrdinatorTM from "./views/TerritoryManager/ViewSalesCoOrdinato
import ViewPrincipalDistributorTM from "./views/TerritoryManager/ViewPrincipalDistributorTM";
import ViewRetailDistributorTM from "./views/TerritoryManager/ViewRetailDistributor";
import AddRetailDistributor from "./views/RetailDistributors/addRetailDistributor";
+import ViewPrincipalDistributorSC from "./views/SalesCoOrdinators/ViewPrincipalDistributorSC";
+import ViewRetailDistributorSC from "./views/SalesCoOrdinators/ViewRetailDistributorSC";
+import ViewRetailDistributorPD from "./views/PrincipalDistributors/ViewRetailDistributorPD";
+import MapRD from "./views/RetailDistributors/MapRD";
const routes = [
//dashboard
@@ -239,6 +243,18 @@ const routes = [
element: AddSalesCoOrdinator,
navName: "SalesCoOrdinators",
},
+ {
+ path: "/view/SCprincipaldistributor/:id",
+ name: "View Principal Distributor",
+ element: ViewPrincipalDistributorSC,
+ navName: "SalesCoOrdinators",
+ },
+ {
+ path: "/view/SCretaildistributor/:id",
+ name: "View Retail Distributor",
+ element: ViewRetailDistributorSC,
+ navName: "SalesCoOrdinators",
+ },
//TerritoryManager
{
path: "/territorymanager/edit/:id",
@@ -345,6 +361,12 @@ const routes = [
element: AddRetailDistributor,
navName: "RetailDistributor",
},
+ {
+ path: "/retaildistributor/mapping/:id",
+ name: "Mapping Retail Distributor with PD SC TM",
+ element: MapRD,
+ navName: "RetailDistributor",
+ },
//----------------------- End Product Management Routes------------------------------------------------
//Departure
@@ -395,6 +417,12 @@ const routes = [
element: AddMultiplePd,
navName: "PrincipalDistributor",
},
+ {
+ path: "/view/mappedretaildistributor/:id",
+ name: "view retail distributor",
+ element: ViewRetailDistributorPD,
+ navName: "PrincipalDistributor",
+ },
//Inventory
{
path: "/inventory",
diff --git a/src/views/Leaves/LeaveTerritoryManager.js b/src/views/Leaves/LeaveTerritoryManager.js
index 5140712..b02b53a 100644
--- a/src/views/Leaves/LeaveTerritoryManager.js
+++ b/src/views/Leaves/LeaveTerritoryManager.js
@@ -34,7 +34,7 @@ const LeaveTerritoryManager = () => {
isVerified: verifyRef.current.value,
},
});
- setterritorymanagersData(res.data?.territorymanager);
+ setterritorymanagersData(res.data?.territoryManager);
setTotalData(res.data?.total_data);
} catch (err) {
const msg = err?.response?.data?.message || "Something went wrong!";
@@ -56,7 +56,7 @@ const LeaveTerritoryManager = () => {
const debouncedSearch = useCallback(debounce(() => {
setCurrentPage(1);
- getterritorymanagerData();
+ getterritorymanagersData();
}, 500), []);
const handleSearchChange = () => {
diff --git a/src/views/Leaves/SingleUserLeave.js b/src/views/Leaves/SingleUserLeave.js
index 6679194..a4fce93 100644
--- a/src/views/Leaves/SingleUserLeave.js
+++ b/src/views/Leaves/SingleUserLeave.js
@@ -28,7 +28,6 @@ const [userType, setUserType] = useState("");
show: itemPerPage,
},
});
- console.log(res.data);
setuser(res.data?.user);
setleaveData(res.data?.leave);
setUserType(res.data?.userType);
diff --git a/src/views/Leaves/TodayLeaves.js b/src/views/Leaves/TodayLeaves.js
index d87ae6c..b1f4fd0 100644
--- a/src/views/Leaves/TodayLeaves.js
+++ b/src/views/Leaves/TodayLeaves.js
@@ -27,7 +27,7 @@ const TodayLeave = () => {
show: itemPerPage,
},
});
- console.log(res.data);
+ // console.log(res.data);
setSalesCoOrdinatorsData(res.data?.leave);
setTotalData(res.data?.total_data);
} catch (err) {
@@ -99,7 +99,7 @@ const TodayLeave = () => {
textTransform: "capitalize",
}}
onClick={() => {
- navigate("/territorymanager/attendance", {
+ navigate("/territorymanager/leave", {
replace: true,
});
}}
diff --git a/src/views/PrincipalDistributors/ViewRetailDistributorPD.js b/src/views/PrincipalDistributors/ViewRetailDistributorPD.js
new file mode 100644
index 0000000..1c6f785
--- /dev/null
+++ b/src/views/PrincipalDistributors/ViewRetailDistributorPD.js
@@ -0,0 +1,577 @@
+import React, { useState, useEffect, useRef, useCallback } from "react";
+import { Link, useParams } from "react-router-dom";
+import axios from "axios";
+import Button from "@material-ui/core/Button";
+import { useNavigate } from "react-router-dom";
+import { isAutheticated } from "src/auth";
+import swal from "sweetalert";
+import debounce from "lodash.debounce";
+import Dialog from "@material-ui/core/Dialog";
+import DialogActions from "@material-ui/core/DialogActions";
+import DialogContent from "@material-ui/core/DialogContent";
+import DialogTitle from "@material-ui/core/DialogTitle";
+import TextField from "@material-ui/core/TextField";
+
+const ViewRetailDistributorPD = () => {
+ const token = isAutheticated();
+ const { id } = useParams();
+ const navigate = useNavigate();
+ const [loading, setLoading] = useState(false);
+ const [success, setSuccess] = useState(true);
+ const [retaildistributorData, setretaildistributorData] = useState([]);
+ const [data, setData] = useState({});
+ const nameRef = useRef();
+ const mobileRef = useRef();
+ const rdnameRef = useRef();
+ const rdmobileRef = useRef();
+
+ const [currentPage, setCurrentPage] = useState(1);
+ const [itemPerPage, setItemPerPage] = useState(10);
+ const [modalcurrentPage, setmodalCurrentPage] = useState(1);
+ const modalitemPerPage = 10;
+ const [totalData, setTotalData] = useState(0);
+ const [openModal, setOpenModal] = useState(false);
+ const [modalRetailDistributors, setmodalRetailDistributors] = useState([]);
+ const [modalTotalData, setmodalTotalData] = useState(0);
+
+ // Fetch territory manager data
+ useEffect(() => {
+ axios
+ .get(`/api/v1/admin/user/${id}`, {
+ headers: { Authorization: `Bearer ${token}` },
+ })
+ .then((response) => setData(response.data.user))
+ .catch((error) => console.error("Error fetching sc data:", error));
+ }, [id, token]);
+
+ // Fetch Retail Distributors data
+ const getPDsretaildistributorData = async () => {
+ setLoading(true);
+ axios
+ .get(`/api/getAllRDbypdid/${id}`, {
+ headers: {
+ Authorization: `Bearer ${token}`,
+ },
+ params: {
+ page: currentPage,
+ show: itemPerPage,
+ tradename: nameRef.current?.value,
+ mobile_number: mobileRef.current?.value,
+ },
+ })
+ .then((res) => {
+ // console.log(res.data);
+ setretaildistributorData(res.data?.Retaildistributor);
+ setTotalData(res.data?.total_data);
+ })
+ .catch((err) => {
+ const msg = err?.response?.data?.message || "Something went wrong!";
+ swal({
+ title: "Error",
+ text: msg,
+ icon: "error",
+ button: "Retry",
+ dangerMode: true,
+ });
+ })
+ .finally(() => setLoading(false));
+ };
+
+ useEffect(() => {
+ getPDsretaildistributorData();
+ }, [success, itemPerPage, currentPage]);
+
+ // Debounced search for Retail Distributors
+ const debouncedSearch = useCallback(
+ debounce(() => {
+ setCurrentPage(1);
+ getPDsretaildistributorData();
+ }, 500),
+ [currentPage, itemPerPage]
+ );
+
+ const handleSearchChange = useCallback(() => {
+ debouncedSearch();
+ }, [debouncedSearch]);
+ // Fetch Retail Distributors data for modal
+ const getretaildistributorData = async () => {
+ setLoading(true);
+ try {
+ const res = await axios.get(`/api/getAllRD`, {
+ headers: {
+ Authorization: `Bearer ${token}`,
+ },
+ params: {
+ page: modalcurrentPage,
+ show: modalitemPerPage,
+ tradename: rdnameRef.current?.value,
+ mobile_number: rdmobileRef.current?.value,
+ },
+ });
+ setmodalRetailDistributors(res.data?.Retaildistributor);
+ setmodalTotalData(res.data?.total_data);
+ } catch (err) {
+ const msg = err?.response?.data?.message || "Something went wrong!";
+ swal({
+ title: "Error",
+ text: msg,
+ icon: "error",
+ button: "Retry",
+ dangerMode: true,
+ });
+ } finally {
+ setLoading(false);
+ }
+ };
+
+ useEffect(() => {
+ if (openModal) {
+ getretaildistributorData();
+ }
+ }, [openModal, modalcurrentPage]);
+
+ // Debounced search for Retail Distributors in modal
+ const debouncedmodalSearch = useCallback(
+ debounce(() => {
+ setmodalCurrentPage(1);
+ getretaildistributorData();
+ }, 500),
+ [modalcurrentPage]
+ );
+
+ const handlemodalSearchChange = useCallback(() => {
+ debouncedmodalSearch();
+ }, [debouncedmodalSearch]);
+
+ const handleOpenModal = () => {
+ setOpenModal(true);
+ };
+
+ const handleCloseModal = () => {
+ setOpenModal(false);
+ };
+ const handlePreviousPage = () => {
+ if (modalcurrentPage > 1) {
+ setmodalCurrentPage(modalcurrentPage - 1);
+ }
+ };
+
+ const handleNextPage = () => {
+ if (modalRetailDistributors.length === modalitemPerPage) {
+ setmodalCurrentPage(modalcurrentPage + 1);
+ }
+ };
+
+ const handleDelete = (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/unmap/${id}`,
+ { principal_distributor: true },
+ {
+ // Changed to PATCH and sent an empty body
+ headers: {
+ "Access-Control-Allow-Origin": "*",
+ Authorization: `Bearer ${token}`,
+ },
+ }
+ )
+ .then((res) => {
+ swal({
+ title: "Deleted",
+ text: "Retail Distributor Unmapped successfully!",
+ icon: "success",
+ button: "ok",
+ });
+ setSuccess((prev) => !prev);
+ })
+ .catch((err) => {
+ let msg = err?.response?.data?.message
+ ? err?.response?.data?.message
+ : "Something went wrong!";
+ swal({
+ title: "Warning",
+ text: msg,
+ icon: "error",
+ button: "Retry",
+ dangerMode: true,
+ });
+ });
+ }
+ });
+ };
+ const handleAddRetailDistributor = async (rdid) => {
+ try {
+ await axios.put(
+ `/api/mapped/${rdid}`,
+ { principal_distributor: id },
+ {
+ headers: {
+ Authorization: `Bearer ${token}`,
+ },
+ }
+ );
+ swal({
+ title: "Success",
+ text: "Retail Distributor added successfully!",
+ icon: "success",
+ button: "Ok",
+ });
+ setSuccess((prev) => !prev);
+ handleCloseModal(); // Close modal after adding
+ } catch (err) {
+ const msg = err?.response?.data?.message || "Something went wrong!";
+ swal({
+ title: "Error",
+ text: msg,
+ icon: "error",
+ button: "Retry",
+ dangerMode: true,
+ });
+ }
+ };
+
+ return (
+
-
+
{
Date Registered |
Last Purchase |
Orders |
+
Mapping |
Action |
@@ -246,13 +247,13 @@ const principalDistributor = () => {
{new Date(user.createdAt).toLocaleString(
"en-IN",
{
- weekday: "short",
+ // weekday: "short",
month: "short",
day: "numeric",
year: "numeric",
- hour: "numeric",
- minute: "numeric",
- hour12: true,
+ // hour: "numeric",
+ // minute: "numeric",
+ // hour12: true,
}
)}
@@ -267,7 +268,22 @@ const principalDistributor = () => {
_id={user?._id}
setLoading1={setLoading1}
/>
-
+
+
+
+
+ |
{/* {
data.price === "" ||
data.GST === "" ||
data.category === "" ||
- data.description === "" ||
data.product_Status === ""||
data.HSN_Code === "" ||
data.brand === ""
diff --git a/src/views/RetailDistributors/MapRD.js b/src/views/RetailDistributors/MapRD.js
new file mode 100644
index 0000000..97736e4
--- /dev/null
+++ b/src/views/RetailDistributors/MapRD.js
@@ -0,0 +1,897 @@
+import React, { useState, useEffect, useRef, useCallback } from "react";
+import axios from "axios";
+import {
+ Box,
+ Typography,
+ Grid,
+ Paper,
+ Dialog,
+ DialogContent,
+ DialogTitle,
+} from "@mui/material";
+import { useParams, useNavigate } from "react-router-dom";
+import { isAutheticated } from "../../auth";
+import Button from "@material-ui/core/Button";
+import swal from "sweetalert";
+import debounce from "lodash.debounce";
+import TextField from "@mui/material/TextField";
+import DialogActions from "@mui/material/DialogActions";
+
+const MapRD = () => {
+ const { id } = useParams();
+ const token = isAutheticated();
+ const navigate = useNavigate();
+
+ const [loading, setLoading] = useState(false);
+ const [success, setSuccess] = useState(true);
+ const [data, setData] = useState(null);
+
+ const pdnameRef = useRef();
+ const pdmobileRef = useRef();
+ const scnameRef = useRef();
+ const scmobileRef = useRef();
+ const tmnameRef = useRef();
+ const tmmobileRef = useRef();
+
+ const [modalcurrentPage, setmodalCurrentPage] = useState(1);
+ const modalitemPerPage = 10;
+ const [openPDModal, setOpenPDModal] = useState(false);
+ const [openSCModal, setOpenSCModal] = useState(false);
+ const [openTMModal, setOpenTMModal] = useState(false);
+
+ // For opening each modal
+ const handleOpenPDModal = () => setOpenPDModal(true);
+ const handleOpenSCModal = () => setOpenSCModal(true);
+ const handleOpenTMModal = () => setOpenTMModal(true);
+
+ // For closing each modal
+ const handleClosePDModal = () => setOpenPDModal(false);
+ const handleCloseSCModal = () => setOpenSCModal(false);
+ const handleCloseTMModal = () => setOpenTMModal(false);
+
+ const [modalTotalData, setModalTotalData] = useState(0);
+ const [modalSalesCoordinators, setModalSalesCoordinators] = useState([]);
+ const [modalPrincipalDistributors, setmodalPrincipalDistributors] = useState(
+ []
+ );
+ const [modalterritorymanagers, setmodalterritorymanagers] = useState([]);
+
+ useEffect(() => {
+ const fetchData = async () => {
+ try {
+ // Commented out the API call and using dummy data
+ const response = await axios.get(`/api/getRD/${id}`, {
+ headers: {
+ "Access-Control-Allow-Origin": "*",
+ Authorization: `Bearer ${token}`,
+ "Content-Type": "multipart/form-data",
+ },
+ });
+ setData(response.data);
+ // console.log('Retailer Details: ', response.data);
+ } catch (error) {
+ console.error("Error fetching data: ", error);
+ }
+ };
+
+ fetchData();
+ }, [id, token, success]);
+
+ // SC
+ const getSalesCoOrdinatorsData = async () => {
+ setLoading(true);
+ try {
+ const res = await axios.get(`/api/salescoordinator/getAll`, {
+ headers: {
+ Authorization: `Bearer ${token}`,
+ },
+ params: {
+ page: modalcurrentPage,
+ show: modalitemPerPage,
+ name: scnameRef.current?.value,
+ mobileNumber: scmobileRef.current?.value,
+ },
+ });
+ setModalSalesCoordinators(res.data?.salesCoOrinators);
+ setModalTotalData(res.data?.total_data);
+ } catch (err) {
+ const msg = err?.response?.data?.message || "Something went wrong!";
+ swal({
+ title: "Error",
+ text: msg,
+ icon: "error",
+ button: "Retry",
+ dangerMode: true,
+ });
+ } finally {
+ setLoading(false);
+ }
+ };
+
+ useEffect(() => {
+ if (openSCModal) {
+ getSalesCoOrdinatorsData();
+ }
+ }, [openSCModal, modalcurrentPage]);
+
+ // Debounced search for Sales Coordinators in modal
+ const debouncedmodalSearchforSC = useCallback(
+ debounce(() => {
+ setmodalCurrentPage(1);
+ getSalesCoOrdinatorsData();
+ }, 500),
+ [modalcurrentPage]
+ );
+
+ const handlemodalSearchChangeinSC = useCallback(() => {
+ debouncedmodalSearchforSC();
+ }, [debouncedmodalSearchforSC]);
+
+ // PD
+ const getprincipaldistributorData = async () => {
+ setLoading(true);
+ try {
+ const res = await axios.get(`/api/v1/admin/users`, {
+ headers: {
+ Authorization: `Bearer ${token}`,
+ },
+ params: {
+ page: modalcurrentPage,
+ show: modalitemPerPage,
+ name: pdnameRef.current?.value,
+ mobileNumber: pdmobileRef.current?.value,
+ },
+ });
+ setmodalPrincipalDistributors(res.data?.users);
+ setModalTotalData(res.data?.totalUsers);
+ } catch (err) {
+ const msg = err?.response?.data?.message || "Something went wrong!";
+ swal({
+ title: "Error",
+ text: msg,
+ icon: "error",
+ button: "Retry",
+ dangerMode: true,
+ });
+ } finally {
+ setLoading(false);
+ }
+ };
+
+ useEffect(() => {
+ if (openPDModal) {
+ getprincipaldistributorData();
+ }
+ }, [openPDModal, modalcurrentPage]);
+
+ // Debounced search for Principal Distributors in modal
+ const debouncedmodalSearchforPD = useCallback(
+ debounce(() => {
+ setmodalCurrentPage(1);
+ getprincipaldistributorData();
+ }, 500),
+ [modalcurrentPage]
+ );
+
+ const handlemodalSearchChangeinPD = useCallback(() => {
+ debouncedmodalSearchforPD();
+ }, [debouncedmodalSearchforPD]);
+
+ // TM
+ const getTerritorymanagersData = async () => {
+ setLoading(true);
+ try {
+ const res = await axios.get(`/api/territorymanager/getAll`, {
+ headers: {
+ Authorization: `Bearer ${token}`,
+ },
+ params: {
+ page: modalcurrentPage,
+ show: modalitemPerPage,
+ name: tmnameRef.current?.value,
+ mobileNumber: tmmobileRef.current?.value,
+ },
+ });
+ setmodalterritorymanagers(res.data?.territoryManager);
+ setModalTotalData(res.data?.total_data);
+ } catch (err) {
+ const msg = err?.response?.data?.message || "Something went wrong!";
+ swal({
+ title: "Error",
+ text: msg,
+ icon: "error",
+ button: "Retry",
+ dangerMode: true,
+ });
+ } finally {
+ setLoading(false);
+ }
+ };
+
+ useEffect(() => {
+ if (openTMModal) {
+ getTerritorymanagersData();
+ }
+ }, [openTMModal, modalcurrentPage]);
+
+ // Debounced search for Territory manager in modal
+ const debouncedmodalSearchforTM = useCallback(
+ debounce(() => {
+ setmodalCurrentPage(1);
+ getTerritorymanagersData();
+ }, 500),
+ [modalcurrentPage]
+ );
+
+ const handlemodalSearchChangeinTM = useCallback(() => {
+ debouncedmodalSearchforTM();
+ }, [debouncedmodalSearchforTM]);
+
+ const handlePreviousPage = () => {
+ if (modalcurrentPage > 1) {
+ setmodalCurrentPage(modalcurrentPage - 1);
+ }
+ };
+ const handleDelete = (designation) => {
+ swal({
+ title: "Are you sure?",
+ icon: "warning",
+ buttons: {
+ Yes: { text: "Yes", value: true },
+ Cancel: { text: "Cancel", value: "cancel" },
+ },
+ }).then((value) => {
+ if (value === true) {
+ // Create the data object based on designation
+ let data = {};
+ if (designation === "TM") {
+ data.mappedTM = true;
+ } else if (designation === "SC") {
+ data.mappedSC = true;
+ } else {
+ data.principal_distributor = true;
+ }
+
+ // Make the PATCH request with the constructed data object
+ axios
+ .patch(
+ `/api/unmap/${id}`,
+ data, // Send the constructed data object
+ {
+ headers: {
+ "Access-Control-Allow-Origin": "*",
+ Authorization: `Bearer ${token}`,
+ },
+ }
+ )
+ .then((res) => {
+ swal({
+ title: "Deleted",
+ text: "Retail Distributor Unmapped successfully!",
+ icon: "success",
+ button: "Ok",
+ });
+ setSuccess((prev) => !prev);
+ })
+ .catch((err) => {
+ let msg = err?.response?.data?.message || "Something went wrong!";
+ swal({
+ title: "Warning",
+ text: msg,
+ icon: "error",
+ button: "Retry",
+ dangerMode: true,
+ });
+ });
+ }
+ });
+ };
+
+ const handleUpdateMapping = async (rdid, designation) => {
+ try {
+ // Create the data object based on designation
+ let data = {};
+ if (designation === "TM") {
+ data.mappedTM = rdid;
+ } else if (designation === "SC") {
+ data.mappedSC = rdid;
+ } else {
+ data.principal_distributor = rdid;
+ }
+
+ // Make the API request
+ await axios.put(
+ `/api/mapped/${id}`,
+ data, // Send the constructed data object
+ {
+ headers: {
+ Authorization: `Bearer ${token}`,
+ },
+ }
+ );
+
+ // Success alert
+ swal({
+ title: "Success",
+ text: "Mapped successfully!",
+ icon: "success",
+ button: "Ok",
+ });
+
+ // Trigger success state change and close modals
+ setSuccess((prev) => !prev);
+ handleClosePDModal();
+ handleCloseSCModal();
+ handleCloseTMModal();
+ } catch (err) {
+ // Handle error and show error message
+ const msg = err?.response?.data?.message || "Something went wrong!";
+ swal({
+ title: "Error",
+ text: msg,
+ icon: "error",
+ button: "Retry",
+ dangerMode: true,
+ });
+ }
+ };
+
+ if (!data) {
+ return Loading...;
+ }
+
+ return (
+
+
+ Retailer Details
+
+
+
+
+
+ Retailer Details
+
+
+
+
+ Trade Name: {data.kyc.trade_name}
+
+
+ Name: {data.name}
+
+
+ Address: {data.kyc.address}
+
+
+ Town/City: {data.kyc.city}
+
+
+ District: {data.kyc.district}
+
+
+ State: {data.kyc.state}
+
+
+ Pincode: {data.kyc.pincode}
+
+
+ Mobile Number: {data.mobile_number}
+
+
+
+
+ Mapped Territory Manager:{" "}
+ {data?.mappedTM?.name || "Not Mapped"}
+
+
+ Mapped Principal Distributor:{" "}
+ {data?.principal_distributer?.name || "Not Mapped"}
+
+
+ Mapped Sales Coordinator:{" "}
+ {data?.mappedSC?.name || "Not Mapped"}
+
+
+
+
+
+ {/* Territory Managers */}
+
+
+
+ Territory Manager Details
+
+
+
+
+
+
+
+
+
+ Name: {data.mappedTM?.name || "Not Mapped"}
+
+
+ Mobile Number:{" "}
+ {data.mappedTM?.mobileNumber || "Not Mapped"}
+
+
+ Email: {data.mappedTM?.email || "Not Mapped"}
+
+
+
+
+
+ {/* Sales Coordinators */}
+
+
+
+ Sales Coordinator Details
+
+
+
+
+
+
+
+
+
+ Name: {data.mappedSC?.name || "Not Mapped"}
+
+
+ Mobile Number:{" "}
+ {data.mappedSC?.mobileNumber || "Not Mapped"}
+
+
+ Email: {data.mappedSC?.email || "Not Mapped"}
+
+
+
+
+
+ {/* Principal Distributor */}
+
+
+
+ Principal Distributor Details
+
+
+
+
+
+
+
+
+
+ Name:{" "}
+ {data.principal_distributer?.name || "Not Mapped"}
+
+
+ Mobile Number:{" "}
+ {data.principal_distributer?.phone || "Not Mapped"}
+
+
+ Email:{" "}
+ {data.principal_distributer?.email || "Not Mapped"}
+
+
+
+
+ {/* Principal Distributor */}
+
+ {/* Sales Coordinator */}
+
+ {/* Territory Manager */}
+
+
+ );
+};
+
+export default MapRD;
diff --git a/src/views/RetailDistributors/RetailDistributor.js b/src/views/RetailDistributors/RetailDistributor.js
index b617b8c..439faef 100644
--- a/src/views/RetailDistributors/RetailDistributor.js
+++ b/src/views/RetailDistributors/RetailDistributor.js
@@ -24,18 +24,19 @@ const [totalPages, setTotalPages] = useState(1);
const getRetailDistributorsData = async () => {
setLoading(true);
try {
- const res = await axios.get(`/api/kyc/getAllapproved/`, {
+ const res = await axios.get(`/api/getAllRD`, {
headers: {
Authorization: `Bearer ${token}`,
},
params: {
page: currentPage,
show: itemPerPage,
- name: nameRef.current.value,
+ tradename: nameRef.current.value,
principaldistributor: principalDistributorRef.current.value,
},
});
- setAllRetailDistributorsData(res.data?.kycs);
+ // console.log(res.data);
+ setAllRetailDistributorsData(res.data?.Retaildistributor);
setTotalData(res.data?.total_data);
setTotalPages(res.data?.total_pages);
} catch (err) {
@@ -156,6 +157,7 @@ const [totalPages, setTotalPages] = useState(1);
| Principal Distributor |
Territory Manager |
Sales Coordinator |
+
Mapping |
Action |
@@ -171,14 +173,14 @@ const [totalPages, setTotalPages] = useState(1);
allRetailDistributorsData.map((retailDistributor) => (
- {retailDistributor._id}
+ {retailDistributor.uniqueId}
|
- {retailDistributor.trade_name}
+ {retailDistributor.kycDetails.trade_name}
|
{new Date(
- retailDistributor.updatedAt
+ retailDistributor.createdAt
).toLocaleString("en-IN", {
weekday: "short",
month: "short",
@@ -190,21 +192,31 @@ const [totalPages, setTotalPages] = useState(1);
})}
|
- {retailDistributor.principal_distributer
+ {retailDistributor?.principalDetails
?.name || "N/A"}
|
- {retailDistributor.userType ===
- "TerritoryManager"
- ? retailDistributor.addedBy?.name || "N/A"
- : "N/A"}
+ {retailDistributor?.mappedTMDetails?.name || "N/A"}
|
- {retailDistributor.userType ===
- "SalesCoOrdinator"
- ? retailDistributor.addedBy?.name || "N/A"
- : "N/A"}
+ {retailDistributor?.mappedSCDetails?.name || "N/A"}
|
+
+
+
+
+ |
{
const fetchData = async () => {
try {
// Commented out the API call and using dummy data
- const response = await axios.get(`api/kyc/get-single-kyc/${id}`, {
+ const response = await axios.get(`/api/getRD/${id}`, {
headers: {
'Access-Control-Allow-Origin': '*',
Authorization: `Bearer ${token}`,
@@ -72,27 +72,27 @@ const SingleRetailDistributor = () => {
- Trade Name: {retailerDetails.trade_name}
+ Trade Name: {retailerDetails.kyc.trade_name}
Name: {retailerDetails.name}
- Address: {retailerDetails.address}
+ Address: {retailerDetails.kyc.address}
- Town/City: {retailerDetails.city}
+ Town/City: {retailerDetails.kyc.city}
- District: {retailerDetails.district}
+ District: {retailerDetails.kyc.district}
- State: {retailerDetails.state}
+ State: {retailerDetails.kyc.state}
- Pincode: {retailerDetails.pincode}
+ Pincode: {retailerDetails.kyc.pincode}
Mobile Number: {retailerDetails.mobile_number}
@@ -111,31 +111,31 @@ const SingleRetailDistributor = () => {
- PAN Number: {retailerDetails.pan_number}
+ PAN Number: {retailerDetails.kyc.pan_number}
handleOpenPopup(retailerDetails.pan_img.url)}
+ onClick={() => handleOpenPopup(retailerDetails.kyc.pan_img.url)}
/>
- Aadhar Number: {retailerDetails.aadhar_number}
+ Aadhar Number: {retailerDetails.kyc.aadhar_number}
handleOpenPopup(retailerDetails.aadhar_img.url)}
+ onClick={() => handleOpenPopup(retailerDetails.kyc.aadhar_img.url)}
/>
- GST Number: {retailerDetails.gst_number}
+ GST Number: {retailerDetails.kyc.gst_number}
handleOpenPopup(retailerDetails.gst_img.url)}
+ onClick={() => handleOpenPopup(retailerDetails.kyc.gst_img.url)}
/>
@@ -144,19 +144,19 @@ const SingleRetailDistributor = () => {
handleOpenPopup(retailerDetails.pesticide_license_img.url)}
+ onClick={() => handleOpenPopup(retailerDetails.kyc.pesticide_license_img.url)}
/>
Fertilizer License (optional):
- {retailerDetails.fertilizer_license_img ? (
+ {retailerDetails.kyc.fertilizer_license_img ? (
handleOpenPopup(retailerDetails.fertilizer_license_img.url)}
+ onClick={() => handleOpenPopup(retailerDetails.kyc.fertilizer_license_img.url)}
/>
) : (
Img not available
@@ -166,9 +166,9 @@ const SingleRetailDistributor = () => {
handleOpenPopup(retailerDetails.selfie_entrance_img.url)}
+ onClick={() => handleOpenPopup(retailerDetails.kyc.selfie_entrance_img.url)}
/>
diff --git a/src/views/RetailDistributors/addRetailDistributor.js b/src/views/RetailDistributors/addRetailDistributor.js
index 0750e51..fad9510 100644
--- a/src/views/RetailDistributors/addRetailDistributor.js
+++ b/src/views/RetailDistributors/addRetailDistributor.js
@@ -20,6 +20,7 @@ const AddRetailDistributor = () => {
const [user, setUser] = useState({
name: "",
+ email: "",
trade_name: "",
address: "",
state: "",
@@ -104,6 +105,7 @@ const AddRetailDistributor = () => {
// Validate input fields
if (
!user.name ||
+ !user.email ||
!user.trade_name ||
!user.address ||
!user.mobile_number ||
@@ -121,9 +123,10 @@ const AddRetailDistributor = () => {
const formData = new FormData();
formData.append("name", user.name);
+ formData.append("email", user.email);
formData.append("trade_name", user.trade_name);
formData.append("address", user.address);
- formData.append("state", selectedState.value);
+ formData.append("state", selectedState.label);
formData.append("city", selectedCity.value);
formData.append("district", user.district);
formData.append("pincode", user.pincode);
@@ -164,7 +167,6 @@ const AddRetailDistributor = () => {
const handleCancel = () => {
navigate("/retail-distributor");
};
-
return (
{
/>
-
+
+
+
+ Email*
+
+
+
+
+
+
{/* Trade Name */}
diff --git a/src/views/SalesCoOrdinators/SalesCoOrdinator.js b/src/views/SalesCoOrdinators/SalesCoOrdinator.js
index cad844a..f6ae423 100644
--- a/src/views/SalesCoOrdinators/SalesCoOrdinator.js
+++ b/src/views/SalesCoOrdinators/SalesCoOrdinator.js
@@ -214,6 +214,7 @@ const SalesCoOrdinator = () => {
Email |
Verify |
Register On |
+ Mapping |
Action |
|
@@ -264,16 +265,46 @@ const SalesCoOrdinator = () => {
{new Date(
salescoordinator.createdAt
).toLocaleString("en-IN", {
- weekday: "short",
+ // weekday: "short",
month: "short",
day: "numeric",
year: "numeric",
- hour: "numeric",
- minute: "numeric",
- hour12: true,
+ // hour: "numeric",
+ // minute: "numeric",
+ // hour12: true,
})}
+
+
+
+
+
+
+ |
+
diff --git a/src/views/SalesCoOrdinators/ViewPrincipalDistributorSC.js b/src/views/SalesCoOrdinators/ViewPrincipalDistributorSC.js
new file mode 100644
index 0000000..1ecf551
--- /dev/null
+++ b/src/views/SalesCoOrdinators/ViewPrincipalDistributorSC.js
@@ -0,0 +1,553 @@
+import React, { useState, useEffect, useRef, useCallback } from "react";
+import { Link, useParams } from "react-router-dom";
+import axios from "axios";
+import Button from "@material-ui/core/Button";
+import { useNavigate } from "react-router-dom";
+import { isAutheticated } from "src/auth";
+import swal from "sweetalert";
+import debounce from "lodash.debounce";
+import Dialog from "@material-ui/core/Dialog";
+import DialogActions from "@material-ui/core/DialogActions";
+import DialogContent from "@material-ui/core/DialogContent";
+import DialogTitle from "@material-ui/core/DialogTitle";
+import TextField from "@material-ui/core/TextField";
+
+const ViewPrincipalDistributorSC = () => {
+ const token = isAutheticated();
+ const { id } = useParams();
+ const navigate = useNavigate();
+ const [loading, setLoading] = useState(false);
+ const [success, setSuccess] = useState(true);
+ const [principaldistributorData, setprincipaldistributorData] = useState([]);
+ const [data, setData] = useState({});
+ const nameRef = useRef();
+ const mobileRef = useRef();
+ const pdnameRef = useRef();
+ const pdmobileRef = useRef();
+
+ const [currentPage, setCurrentPage] = useState(1);
+ const [itemPerPage, setItemPerPage] = useState(10);
+ const [modalcurrentPage, setmodalCurrentPage] = useState(1);
+ const modalitemPerPage = 10;
+ const [totalData, setTotalData] = useState(0);
+ const [openModal, setOpenModal] = useState(false);
+ const [modalPrincipalDistributors, setmodalPrincipalDistributors] = useState(
+ []
+ );
+ const [modalTotalData, setModalTotalData] = useState(0);
+
+ // Fetch territory manager data
+ useEffect(() => {
+ axios
+ .get(`/api/salescoordinator/getOne/${id}`, {
+ headers: { Authorization: `Bearer ${token}` },
+ })
+ .then((response) => setData(response.data.data))
+ .catch((error) => console.error("Error fetching SC data:", error));
+ }, [id, token]);
+
+ // Fetch Principal Distributors data
+ const getSCsprincipaldistributorData = async () => {
+ setLoading(true);
+ axios
+ .get(`/api/v1/getbySCId/${id}`, {
+ headers: {
+ Authorization: `Bearer ${token}`,
+ },
+ params: {
+ page: currentPage,
+ show: itemPerPage,
+ name: nameRef.current?.value,
+ mobileNumber: mobileRef.current?.value,
+ },
+ })
+ .then((res) => {
+ setprincipaldistributorData(res.data?.principaldistributor);
+ setTotalData(res.data?.total_data);
+ })
+ .catch((err) => {
+ const msg = err?.response?.data?.message || "Something went wrong!";
+ swal({
+ title: "Error",
+ text: msg,
+ icon: "error",
+ button: "Retry",
+ dangerMode: true,
+ });
+ })
+ .finally(() => setLoading(false));
+ };
+
+ useEffect(() => {
+ getSCsprincipaldistributorData();
+ }, [success, itemPerPage, currentPage]);
+
+ // Debounced search for Principal Distributors
+ const debouncedSearch = useCallback(
+ debounce(() => {
+ setCurrentPage(1);
+ getSCsprincipaldistributorData();
+ }, 500),
+ [currentPage, itemPerPage]
+ );
+
+ const handleSearchChange = useCallback(() => {
+ debouncedSearch();
+ }, [debouncedSearch]);
+ // Fetch Principal Distributors data for modal
+ const getprincipaldistributorData = async () => {
+ setLoading(true);
+ try {
+ const res = await axios.get(`/api/v1/admin/users`, {
+ headers: {
+ Authorization: `Bearer ${token}`,
+ },
+ params: {
+ page: modalcurrentPage,
+ show: modalitemPerPage,
+ name: pdnameRef.current?.value,
+ mobileNumber: pdmobileRef.current?.value,
+ },
+ });
+ // console.log(res.data.users);
+ setmodalPrincipalDistributors(res.data?.users);
+ setModalTotalData(res.data?.totalUsers);
+ } catch (err) {
+ const msg = err?.response?.data?.message || "Something went wrong!";
+ swal({
+ title: "Error",
+ text: msg,
+ icon: "error",
+ button: "Retry",
+ dangerMode: true,
+ });
+ } finally {
+ setLoading(false);
+ }
+ };
+
+ useEffect(() => {
+ if (openModal) {
+ getprincipaldistributorData();
+ }
+ }, [openModal, modalcurrentPage]);
+
+ // Debounced search for Principal Distributors in modal
+ const debouncedmodalSearch = useCallback(
+ debounce(() => {
+ setmodalCurrentPage(1);
+ getprincipaldistributorData();
+ }, 500),
+ [modalcurrentPage]
+ );
+
+ const handlemodalSearchChange = useCallback(() => {
+ debouncedmodalSearch();
+ }, [debouncedmodalSearch]);
+
+ const handleOpenModal = () => {
+ setOpenModal(true);
+ };
+
+ const handleCloseModal = () => {
+ setOpenModal(false);
+ };
+ const handlePreviousPage = () => {
+ if (modalcurrentPage > 1) {
+ setmodalCurrentPage(modalcurrentPage - 1);
+ }
+ };
+
+ const handleNextPage = () => {
+ if (modalPrincipalDistributors.length === modalitemPerPage) {
+ setmodalCurrentPage(modalcurrentPage + 1);
+ }
+ };
+
+ const handleDelete = (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/v1/unmapSC/${id}`, {}, { // Changed to PATCH and sent an empty body
+ headers: {
+ "Access-Control-Allow-Origin": "*",
+ Authorization: `Bearer ${token}`,
+ },
+ })
+ .then((res) => {
+ swal({
+ title: "Deleted",
+ text: "Principal Distributor Unmapped successfully!",
+ icon: "success",
+ button: "ok",
+ });
+ setSuccess((prev) => !prev);
+ })
+ .catch((err) => {
+ let msg = err?.response?.data?.message
+ ? err?.response?.data?.message
+ : "Something went wrong!";
+ swal({
+ title: "Warning",
+ text: msg,
+ icon: "error",
+ button: "Retry",
+ dangerMode: true,
+ });
+ });
+ }
+ });
+ };
+ const handleAddPrincipalDistributor = async (pdid) => {
+ try {
+ await axios.put(
+ `/api/v1/mappedSC/${pdid}`,
+ { mappedbySC: id },
+ {
+ headers: {
+ Authorization: `Bearer ${token}`,
+ },
+ }
+ );
+ swal({
+ title: "Success",
+ text: "Principal Distributor added successfully!",
+ icon: "success",
+ button: "Ok",
+ });
+ setSuccess((prev) => !prev);
+ handleCloseModal(); // Close modal after adding
+ } catch (err) {
+ const msg = err?.response?.data?.message || "Something went wrong!";
+ swal({
+ title: "Error",
+ text: msg,
+ icon: "error",
+ button: "Retry",
+ dangerMode: true,
+ });
+ }
+ };
+
+ return (
+
+
+
+
+
+
+ {/* Left Side with Information in Separate Columns */}
+
+
+ Unique ID: {data?.uniqueId}
+
+
+ Name: {data?.name}
+
+
+ Mobile Number: {data?.mobileNumber}
+
+
+ Mail: {data?.email}
+
+
+
+ {/* Right Side with the Button */}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Unique Id |
+ SBU |
+ Name |
+ Mobile No. |
+ Email |
+ Action |
+
+
+
+
+ {loading ? (
+
+
+ Loading...
+ |
+
+ ) : principaldistributorData?.length > 0 ? (
+ principaldistributorData?.map((PD, i) => {
+ return (
+
+ {PD?.uniqueId} |
+ {PD?.SBU} |
+ {PD?.name} |
+ {PD?.phone} |
+
+ {PD?.email ? (
+ PD?.email
+ ) : (
+
+ No Email Added!
+
+ )}
+ |
+
+
+ |
+
+ );
+ })
+ ) : (
+
+
+ No Principal Distributor found!
+ |
+
+ )}
+
+
+
+
+
+ Showing {principaldistributorData?.length} of {totalData}{" "}
+ entries
+
+
+
+
+
+
+
+
+
+
+
+
+
+ );
+};
+
+export default ViewPrincipalDistributorSC;
diff --git a/src/views/SalesCoOrdinators/ViewRetailDistributorSC.js b/src/views/SalesCoOrdinators/ViewRetailDistributorSC.js
new file mode 100644
index 0000000..1e42e32
--- /dev/null
+++ b/src/views/SalesCoOrdinators/ViewRetailDistributorSC.js
@@ -0,0 +1,577 @@
+import React, { useState, useEffect, useRef, useCallback } from "react";
+import { Link, useParams } from "react-router-dom";
+import axios from "axios";
+import Button from "@material-ui/core/Button";
+import { useNavigate } from "react-router-dom";
+import { isAutheticated } from "src/auth";
+import swal from "sweetalert";
+import debounce from "lodash.debounce";
+import Dialog from "@material-ui/core/Dialog";
+import DialogActions from "@material-ui/core/DialogActions";
+import DialogContent from "@material-ui/core/DialogContent";
+import DialogTitle from "@material-ui/core/DialogTitle";
+import TextField from "@material-ui/core/TextField";
+
+const ViewRetailDistributorSC = () => {
+ const token = isAutheticated();
+ const { id } = useParams();
+ const navigate = useNavigate();
+ const [loading, setLoading] = useState(false);
+ const [success, setSuccess] = useState(true);
+ const [retaildistributorData, setretaildistributorData] = useState([]);
+ const [data, setData] = useState({});
+ const nameRef = useRef();
+ const mobileRef = useRef();
+ const rdnameRef = useRef();
+ const rdmobileRef = useRef();
+
+ const [currentPage, setCurrentPage] = useState(1);
+ const [itemPerPage, setItemPerPage] = useState(10);
+ const [modalcurrentPage, setmodalCurrentPage] = useState(1);
+ const modalitemPerPage = 10;
+ const [totalData, setTotalData] = useState(0);
+ const [openModal, setOpenModal] = useState(false);
+ const [modalRetailDistributors, setmodalRetailDistributors] = useState([]);
+ const [modalTotalData, setmodalTotalData] = useState(0);
+
+ // Fetch territory manager data
+ useEffect(() => {
+ axios
+ .get(`/api/salescoordinator/getOne/${id}`, {
+ headers: { Authorization: `Bearer ${token}` },
+ })
+ .then((response) => setData(response.data.data))
+ .catch((error) => console.error("Error fetching sc data:", error));
+ }, [id, token]);
+
+ // Fetch Retail Distributors data
+ const getSCsretaildistributorData = async () => {
+ setLoading(true);
+ axios
+ .get(`/api/getAllRDbyscid/${id}`, {
+ headers: {
+ Authorization: `Bearer ${token}`,
+ },
+ params: {
+ page: currentPage,
+ show: itemPerPage,
+ tradename: nameRef.current?.value,
+ mobile_number: mobileRef.current?.value,
+ },
+ })
+ .then((res) => {
+ // console.log(res.data);
+ setretaildistributorData(res.data?.Retaildistributor);
+ setTotalData(res.data?.total_data);
+ })
+ .catch((err) => {
+ const msg = err?.response?.data?.message || "Something went wrong!";
+ swal({
+ title: "Error",
+ text: msg,
+ icon: "error",
+ button: "Retry",
+ dangerMode: true,
+ });
+ })
+ .finally(() => setLoading(false));
+ };
+
+ useEffect(() => {
+ getSCsretaildistributorData();
+ }, [success, itemPerPage, currentPage]);
+
+ // Debounced search for Retail Distributors
+ const debouncedSearch = useCallback(
+ debounce(() => {
+ setCurrentPage(1);
+ getSCsretaildistributorData();
+ }, 500),
+ [currentPage, itemPerPage]
+ );
+
+ const handleSearchChange = useCallback(() => {
+ debouncedSearch();
+ }, [debouncedSearch]);
+ // Fetch Retail Distributors data for modal
+ const getretaildistributorData = async () => {
+ setLoading(true);
+ try {
+ const res = await axios.get(`/api/getAllRD`, {
+ headers: {
+ Authorization: `Bearer ${token}`,
+ },
+ params: {
+ page: modalcurrentPage,
+ show: modalitemPerPage,
+ tradename: rdnameRef.current?.value,
+ mobile_number: rdmobileRef.current?.value,
+ },
+ });
+ setmodalRetailDistributors(res.data?.Retaildistributor);
+ setmodalTotalData(res.data?.total_data);
+ } catch (err) {
+ const msg = err?.response?.data?.message || "Something went wrong!";
+ swal({
+ title: "Error",
+ text: msg,
+ icon: "error",
+ button: "Retry",
+ dangerMode: true,
+ });
+ } finally {
+ setLoading(false);
+ }
+ };
+
+ useEffect(() => {
+ if (openModal) {
+ getretaildistributorData();
+ }
+ }, [openModal, modalcurrentPage]);
+
+ // Debounced search for Retail Distributors in modal
+ const debouncedmodalSearch = useCallback(
+ debounce(() => {
+ setmodalCurrentPage(1);
+ getretaildistributorData();
+ }, 500),
+ [modalcurrentPage]
+ );
+
+ const handlemodalSearchChange = useCallback(() => {
+ debouncedmodalSearch();
+ }, [debouncedmodalSearch]);
+
+ const handleOpenModal = () => {
+ setOpenModal(true);
+ };
+
+ const handleCloseModal = () => {
+ setOpenModal(false);
+ };
+ const handlePreviousPage = () => {
+ if (modalcurrentPage > 1) {
+ setmodalCurrentPage(modalcurrentPage - 1);
+ }
+ };
+
+ const handleNextPage = () => {
+ if (modalRetailDistributors.length === modalitemPerPage) {
+ setmodalCurrentPage(modalcurrentPage + 1);
+ }
+ };
+
+ const handleDelete = (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/unmap/${id}`,
+ { mappedSC: true },
+ {
+ // Changed to PATCH and sent an empty body
+ headers: {
+ "Access-Control-Allow-Origin": "*",
+ Authorization: `Bearer ${token}`,
+ },
+ }
+ )
+ .then((res) => {
+ swal({
+ title: "Deleted",
+ text: "Retail Distributor Unmapped successfully!",
+ icon: "success",
+ button: "ok",
+ });
+ setSuccess((prev) => !prev);
+ })
+ .catch((err) => {
+ let msg = err?.response?.data?.message
+ ? err?.response?.data?.message
+ : "Something went wrong!";
+ swal({
+ title: "Warning",
+ text: msg,
+ icon: "error",
+ button: "Retry",
+ dangerMode: true,
+ });
+ });
+ }
+ });
+ };
+ const handleAddRetailDistributor = async (rdid) => {
+ try {
+ await axios.put(
+ `/api/mapped/${rdid}`,
+ { mappedSC: id },
+ {
+ headers: {
+ Authorization: `Bearer ${token}`,
+ },
+ }
+ );
+ swal({
+ title: "Success",
+ text: "Retail Distributor added successfully!",
+ icon: "success",
+ button: "Ok",
+ });
+ setSuccess((prev) => !prev);
+ handleCloseModal(); // Close modal after adding
+ } catch (err) {
+ const msg = err?.response?.data?.message || "Something went wrong!";
+ swal({
+ title: "Error",
+ text: msg,
+ icon: "error",
+ button: "Retry",
+ dangerMode: true,
+ });
+ }
+ };
+
+ return (
+
+
+
+
+
+
+ {/* Left Side with Information in Separate Columns */}
+
+
+ Unique ID: {data?.uniqueId}
+
+
+ Name: {data?.name}
+
+
+ Mobile Number: {data?.mobileNumber}
+
+
+ Mail: {data?.email}
+
+
+
+ {/* Right Side with the Button */}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ UniqueID |
+ Trade Name |
+ Mobile |
+ Email |
+ Created On |
+ Action |
+
+
+
+
+ {loading ? (
+
+
+ Loading...
+ |
+
+ ) : retaildistributorData?.length > 0 ? (
+ retaildistributorData?.map((RD, i) => {
+ return (
+
+ {RD?.uniqueId} |
+
+ {RD?.kycDetails?.trade_name}
+ |
+
+ {RD?.mobile_number ? (
+ RD?.mobile_number
+ ) : (
+
+ No Phone Added!
+
+ )}
+ |
+
+ {RD?.email} |
+
+ {" "}
+ {new Date(RD.createdAt).toLocaleString(
+ "en-IN",
+ {
+ weekday: "short",
+ month: "short",
+ day: "numeric",
+ year: "numeric",
+ hour: "numeric",
+ minute: "numeric",
+ hour12: true,
+ }
+ )}
+ |
+
+
+ |
+
+ );
+ })
+ ) : (
+
+
+ No Retail Distributor found!
+ |
+
+ )}
+
+
+
+
+
+ Showing {retaildistributorData?.length} of {totalData}{" "}
+ entries
+
+
+
+
+
+
+
+
+
+
+
+
+
+ );
+};
+
+export default ViewRetailDistributorSC;
diff --git a/src/views/TerritoryManager/TerritoryManager.js b/src/views/TerritoryManager/TerritoryManager.js
index f76faae..e5566b4 100644
--- a/src/views/TerritoryManager/TerritoryManager.js
+++ b/src/views/TerritoryManager/TerritoryManager.js
@@ -214,6 +214,7 @@ const TerritoryManager = () => {
| Email |
Verify |
Register On |
+
Mapping |
Action |
@@ -264,13 +265,13 @@ const TerritoryManager = () => {
{new Date(
territorymanager.createdAt
).toLocaleString("en-IN", {
- weekday: "short",
+ // weekday: "short",
month: "short",
day: "numeric",
year: "numeric",
- hour: "numeric",
- minute: "numeric",
- hour12: true,
+ // hour: "numeric",
+ // minute: "numeric",
+ // hour12: true,
})}
@@ -316,6 +317,8 @@ const TerritoryManager = () => {
RD
+ |
+
diff --git a/src/views/TerritoryManager/ViewPrincipalDistributorTM.js b/src/views/TerritoryManager/ViewPrincipalDistributorTM.js
index 06efb5e..8151a90 100644
--- a/src/views/TerritoryManager/ViewPrincipalDistributorTM.js
+++ b/src/views/TerritoryManager/ViewPrincipalDistributorTM.js
@@ -327,6 +327,8 @@ const ViewPrincipalDistributorTM = () => {
| Name |
Mobile |
Email |
+
SC |
+
TM |
Action |
@@ -339,6 +341,8 @@ const ViewPrincipalDistributorTM = () => {
{PD.name} |
{PD.phone} |
{PD.email} |
+
{PD.mappedbySC?.name || "N/A"} |
+
{PD.mappedby?.name || "N/A"} |
|