RD map with TM and SC
This commit is contained in:
parent
a9329eb772
commit
e51d451dc7
@ -15,9 +15,9 @@ 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://cheminova-api-2.onrender.com";
|
// 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 = {
|
axios.defaults.headers = {
|
||||||
"Cache-Control": "no-cache,no-store",
|
"Cache-Control": "no-cache,no-store",
|
||||||
|
@ -148,7 +148,8 @@ import ViewSalesCoOrdinatorTM from "./views/TerritoryManager/ViewSalesCoOrdinato
|
|||||||
import ViewPrincipalDistributorTM from "./views/TerritoryManager/ViewPrincipalDistributorTM";
|
import ViewPrincipalDistributorTM from "./views/TerritoryManager/ViewPrincipalDistributorTM";
|
||||||
import ViewRetailDistributorTM from "./views/TerritoryManager/ViewRetailDistributor";
|
import ViewRetailDistributorTM from "./views/TerritoryManager/ViewRetailDistributor";
|
||||||
import AddRetailDistributor from "./views/RetailDistributors/addRetailDistributor";
|
import AddRetailDistributor from "./views/RetailDistributors/addRetailDistributor";
|
||||||
import ViewPrincipalDistributorSC from "./views/SalesCoOrdinators/ViewPrincipalDistributorTM";
|
import ViewPrincipalDistributorSC from "./views/SalesCoOrdinators/ViewPrincipalDistributorSC";
|
||||||
|
import ViewRetailDistributorSC from "./views/SalesCoOrdinators/ViewRetailDistributorSC";
|
||||||
const routes = [
|
const routes = [
|
||||||
//dashboard
|
//dashboard
|
||||||
|
|
||||||
@ -246,6 +247,12 @@ const routes = [
|
|||||||
element: ViewPrincipalDistributorSC,
|
element: ViewPrincipalDistributorSC,
|
||||||
navName: "SalesCoOrdinators",
|
navName: "SalesCoOrdinators",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: "/view/SCretaildistributor/:id",
|
||||||
|
name: "View Retail Distributor",
|
||||||
|
element: ViewRetailDistributorSC,
|
||||||
|
navName: "SalesCoOrdinators",
|
||||||
|
},
|
||||||
//TerritoryManager
|
//TerritoryManager
|
||||||
{
|
{
|
||||||
path: "/territorymanager/edit/:id",
|
path: "/territorymanager/edit/:id",
|
||||||
|
@ -24,18 +24,19 @@ const [totalPages, setTotalPages] = useState(1);
|
|||||||
const getRetailDistributorsData = async () => {
|
const getRetailDistributorsData = async () => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
try {
|
try {
|
||||||
const res = await axios.get(`/api/kyc/getAllapproved/`, {
|
const res = await axios.get(`/api/getAllRD`, {
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bearer ${token}`,
|
Authorization: `Bearer ${token}`,
|
||||||
},
|
},
|
||||||
params: {
|
params: {
|
||||||
page: currentPage,
|
page: currentPage,
|
||||||
show: itemPerPage,
|
show: itemPerPage,
|
||||||
name: nameRef.current.value,
|
tradename: nameRef.current.value,
|
||||||
principaldistributor: principalDistributorRef.current.value,
|
principaldistributor: principalDistributorRef.current.value,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
setAllRetailDistributorsData(res.data?.kycs);
|
// console.log(res.data);
|
||||||
|
setAllRetailDistributorsData(res.data?.Retaildistributor);
|
||||||
setTotalData(res.data?.total_data);
|
setTotalData(res.data?.total_data);
|
||||||
setTotalPages(res.data?.total_pages);
|
setTotalPages(res.data?.total_pages);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@ -171,14 +172,14 @@ const [totalPages, setTotalPages] = useState(1);
|
|||||||
allRetailDistributorsData.map((retailDistributor) => (
|
allRetailDistributorsData.map((retailDistributor) => (
|
||||||
<tr key={retailDistributor._id}>
|
<tr key={retailDistributor._id}>
|
||||||
<td className="text-start">
|
<td className="text-start">
|
||||||
{retailDistributor._id}
|
{retailDistributor.uniqueId}
|
||||||
</td>
|
</td>
|
||||||
<td className="text-start">
|
<td className="text-start">
|
||||||
{retailDistributor.trade_name}
|
{retailDistributor.kycDetails.trade_name}
|
||||||
</td>
|
</td>
|
||||||
<td className="text-start">
|
<td className="text-start">
|
||||||
{new Date(
|
{new Date(
|
||||||
retailDistributor.updatedAt
|
retailDistributor.createdAt
|
||||||
).toLocaleString("en-IN", {
|
).toLocaleString("en-IN", {
|
||||||
weekday: "short",
|
weekday: "short",
|
||||||
month: "short",
|
month: "short",
|
||||||
@ -190,20 +191,14 @@ const [totalPages, setTotalPages] = useState(1);
|
|||||||
})}
|
})}
|
||||||
</td>
|
</td>
|
||||||
<td className="text-start">
|
<td className="text-start">
|
||||||
{retailDistributor.principal_distributer
|
{retailDistributor?.principalDetails
|
||||||
?.name || "N/A"}
|
?.name || "N/A"}
|
||||||
</td>
|
</td>
|
||||||
<td className="text-start">
|
<td className="text-start">
|
||||||
{retailDistributor.userType ===
|
{retailDistributor?.mappedTMDetails?.name || "N/A"}
|
||||||
"TerritoryManager"
|
|
||||||
? retailDistributor.addedBy?.name || "N/A"
|
|
||||||
: "N/A"}
|
|
||||||
</td>
|
</td>
|
||||||
<td className="text-start">
|
<td className="text-start">
|
||||||
{retailDistributor.userType ===
|
{retailDistributor?.mappedSCDetails?.name || "N/A"}
|
||||||
"SalesCoOrdinator"
|
|
||||||
? retailDistributor.addedBy?.name || "N/A"
|
|
||||||
: "N/A"}
|
|
||||||
</td>
|
</td>
|
||||||
<td className="text-start">
|
<td className="text-start">
|
||||||
<Link
|
<Link
|
||||||
|
@ -18,7 +18,7 @@ const SingleRetailDistributor = () => {
|
|||||||
const fetchData = async () => {
|
const fetchData = async () => {
|
||||||
try {
|
try {
|
||||||
// Commented out the API call and using dummy data
|
// 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: {
|
headers: {
|
||||||
'Access-Control-Allow-Origin': '*',
|
'Access-Control-Allow-Origin': '*',
|
||||||
Authorization: `Bearer ${token}`,
|
Authorization: `Bearer ${token}`,
|
||||||
@ -72,27 +72,27 @@ const SingleRetailDistributor = () => {
|
|||||||
<Grid container spacing={2}>
|
<Grid container spacing={2}>
|
||||||
<Grid item xs={6}>
|
<Grid item xs={6}>
|
||||||
<Typography>
|
<Typography>
|
||||||
<strong>Trade Name:</strong> {retailerDetails.trade_name}
|
<strong>Trade Name:</strong> {retailerDetails.kyc.trade_name}
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography>
|
<Typography>
|
||||||
<strong>Name:</strong> {retailerDetails.name}
|
<strong>Name:</strong> {retailerDetails.name}
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography>
|
<Typography>
|
||||||
<strong>Address:</strong> {retailerDetails.address}
|
<strong>Address:</strong> {retailerDetails.kyc.address}
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography>
|
<Typography>
|
||||||
<strong>Town/City:</strong> {retailerDetails.city}
|
<strong>Town/City:</strong> {retailerDetails.kyc.city}
|
||||||
</Typography>
|
</Typography>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid item xs={6}>
|
<Grid item xs={6}>
|
||||||
<Typography>
|
<Typography>
|
||||||
<strong>District:</strong> {retailerDetails.district}
|
<strong>District:</strong> {retailerDetails.kyc.district}
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography>
|
<Typography>
|
||||||
<strong>State:</strong> {retailerDetails.state}
|
<strong>State:</strong> {retailerDetails.kyc.state}
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography>
|
<Typography>
|
||||||
<strong>Pincode:</strong> {retailerDetails.pincode}
|
<strong>Pincode:</strong> {retailerDetails.kyc.pincode}
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography>
|
<Typography>
|
||||||
<strong>Mobile Number:</strong> {retailerDetails.mobile_number}
|
<strong>Mobile Number:</strong> {retailerDetails.mobile_number}
|
||||||
@ -111,31 +111,31 @@ const SingleRetailDistributor = () => {
|
|||||||
<Grid container spacing={2}>
|
<Grid container spacing={2}>
|
||||||
<Grid item xs={6}>
|
<Grid item xs={6}>
|
||||||
<Typography>
|
<Typography>
|
||||||
<strong>PAN Number:</strong> {retailerDetails.pan_number}
|
<strong>PAN Number:</strong> {retailerDetails.kyc.pan_number}
|
||||||
</Typography>
|
</Typography>
|
||||||
<Avatar
|
<Avatar
|
||||||
variant="square"
|
variant="square"
|
||||||
src={retailerDetails.pan_img.url}
|
src={retailerDetails.kyc.pan_img.url}
|
||||||
sx={{ width: 100, height: 100, mb: 2, cursor: 'pointer' }}
|
sx={{ width: 100, height: 100, mb: 2, cursor: 'pointer' }}
|
||||||
onClick={() => handleOpenPopup(retailerDetails.pan_img.url)}
|
onClick={() => handleOpenPopup(retailerDetails.kyc.pan_img.url)}
|
||||||
/>
|
/>
|
||||||
<Typography>
|
<Typography>
|
||||||
<strong>Aadhar Number:</strong> {retailerDetails.aadhar_number}
|
<strong>Aadhar Number:</strong> {retailerDetails.kyc.aadhar_number}
|
||||||
</Typography>
|
</Typography>
|
||||||
<Avatar
|
<Avatar
|
||||||
variant="square"
|
variant="square"
|
||||||
src={retailerDetails.aadhar_img.url}
|
src={retailerDetails.kyc.aadhar_img.url}
|
||||||
sx={{ width: 100, height: 100, mb: 2, cursor: 'pointer' }}
|
sx={{ width: 100, height: 100, mb: 2, cursor: 'pointer' }}
|
||||||
onClick={() => handleOpenPopup(retailerDetails.aadhar_img.url)}
|
onClick={() => handleOpenPopup(retailerDetails.kyc.aadhar_img.url)}
|
||||||
/>
|
/>
|
||||||
<Typography>
|
<Typography>
|
||||||
<strong>GST Number:</strong> {retailerDetails.gst_number}
|
<strong>GST Number:</strong> {retailerDetails.kyc.gst_number}
|
||||||
</Typography>
|
</Typography>
|
||||||
<Avatar
|
<Avatar
|
||||||
variant="square"
|
variant="square"
|
||||||
src={retailerDetails.gst_img.url}
|
src={retailerDetails.kyc.gst_img.url}
|
||||||
sx={{ width: 100, height: 100, mb: 2, cursor: 'pointer' }}
|
sx={{ width: 100, height: 100, mb: 2, cursor: 'pointer' }}
|
||||||
onClick={() => handleOpenPopup(retailerDetails.gst_img.url)}
|
onClick={() => handleOpenPopup(retailerDetails.kyc.gst_img.url)}
|
||||||
/>
|
/>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid item xs={6}>
|
<Grid item xs={6}>
|
||||||
@ -144,19 +144,19 @@ const SingleRetailDistributor = () => {
|
|||||||
</Typography>
|
</Typography>
|
||||||
<Avatar
|
<Avatar
|
||||||
variant="square"
|
variant="square"
|
||||||
src={retailerDetails.pesticide_license_img.url}
|
src={retailerDetails.kyc.pesticide_license_img.url}
|
||||||
sx={{ width: 100, height: 100, mb: 2, cursor: 'pointer' }}
|
sx={{ width: 100, height: 100, mb: 2, cursor: 'pointer' }}
|
||||||
onClick={() => handleOpenPopup(retailerDetails.pesticide_license_img.url)}
|
onClick={() => handleOpenPopup(retailerDetails.kyc.pesticide_license_img.url)}
|
||||||
/>
|
/>
|
||||||
<Typography>
|
<Typography>
|
||||||
<strong>Fertilizer License (optional):</strong>
|
<strong>Fertilizer License (optional):</strong>
|
||||||
</Typography>
|
</Typography>
|
||||||
{retailerDetails.fertilizer_license_img ? (
|
{retailerDetails.kyc.fertilizer_license_img ? (
|
||||||
<Avatar
|
<Avatar
|
||||||
variant="square"
|
variant="square"
|
||||||
src={retailerDetails.fertilizer_license_img.url}
|
src={retailerDetails.fertilizer_license_img.url}
|
||||||
sx={{ width: 100, height: 100, mb: 2, cursor: 'pointer' }}
|
sx={{ width: 100, height: 100, mb: 2, cursor: 'pointer' }}
|
||||||
onClick={() => handleOpenPopup(retailerDetails.fertilizer_license_img.url)}
|
onClick={() => handleOpenPopup(retailerDetails.kyc.fertilizer_license_img.url)}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<Typography>Img not available</Typography>
|
<Typography>Img not available</Typography>
|
||||||
@ -166,9 +166,9 @@ const SingleRetailDistributor = () => {
|
|||||||
</Typography>
|
</Typography>
|
||||||
<Avatar
|
<Avatar
|
||||||
variant="square"
|
variant="square"
|
||||||
src={retailerDetails.selfie_entrance_img.url}
|
src={retailerDetails.kyc.selfie_entrance_img.url}
|
||||||
sx={{ width: 100, height: 100, mb: 2, cursor: 'pointer' }}
|
sx={{ width: 100, height: 100, mb: 2, cursor: 'pointer' }}
|
||||||
onClick={() => handleOpenPopup(retailerDetails.selfie_entrance_img.url)}
|
onClick={() => handleOpenPopup(retailerDetails.kyc.selfie_entrance_img.url)}
|
||||||
/>
|
/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
@ -289,6 +289,20 @@ const SalesCoOrdinator = () => {
|
|||||||
PD
|
PD
|
||||||
</button>
|
</button>
|
||||||
</Link>
|
</Link>
|
||||||
|
<Link
|
||||||
|
to={`/view/SCretaildistributor/${salescoordinator._id}`}
|
||||||
|
>
|
||||||
|
<button
|
||||||
|
style={{
|
||||||
|
color: "white",
|
||||||
|
marginRight: "1rem",
|
||||||
|
}}
|
||||||
|
type="button"
|
||||||
|
className="btn btn-primary btn-sm waves-effect waves-light btn-table ml-2"
|
||||||
|
>
|
||||||
|
RD
|
||||||
|
</button>
|
||||||
|
</Link>
|
||||||
</td>
|
</td>
|
||||||
<td className="text-start">
|
<td className="text-start">
|
||||||
<Link
|
<Link
|
||||||
|
@ -47,7 +47,7 @@ const ViewPrincipalDistributorSC = () => {
|
|||||||
}, [id, token]);
|
}, [id, token]);
|
||||||
|
|
||||||
// Fetch Principal Distributors data
|
// Fetch Principal Distributors data
|
||||||
const getTMsprincipaldistributorData = async () => {
|
const getSCsprincipaldistributorData = async () => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
axios
|
axios
|
||||||
.get(`/api/v1/getbySCId/${id}`, {
|
.get(`/api/v1/getbySCId/${id}`, {
|
||||||
@ -79,14 +79,14 @@ const ViewPrincipalDistributorSC = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
getTMsprincipaldistributorData();
|
getSCsprincipaldistributorData();
|
||||||
}, [success, itemPerPage, currentPage]);
|
}, [success, itemPerPage, currentPage]);
|
||||||
|
|
||||||
// Debounced search for Principal Distributors
|
// Debounced search for Principal Distributors
|
||||||
const debouncedSearch = useCallback(
|
const debouncedSearch = useCallback(
|
||||||
debounce(() => {
|
debounce(() => {
|
||||||
setCurrentPage(1);
|
setCurrentPage(1);
|
||||||
getTMsprincipaldistributorData();
|
getSCsprincipaldistributorData();
|
||||||
}, 500),
|
}, 500),
|
||||||
[currentPage, itemPerPage]
|
[currentPage, itemPerPage]
|
||||||
);
|
);
|
||||||
@ -286,7 +286,7 @@ const ViewPrincipalDistributorSC = () => {
|
|||||||
backgroundColor: "#b71c1c", // Darker red on hover
|
backgroundColor: "#b71c1c", // Darker red on hover
|
||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
onClick={() => navigate("/territorymanagers")}
|
onClick={() => navigate("/salescoordinators")}
|
||||||
>
|
>
|
||||||
Back
|
Back
|
||||||
</Button>
|
</Button>
|
573
src/views/SalesCoOrdinators/ViewRetailDistributorSC.js
Normal file
573
src/views/SalesCoOrdinators/ViewRetailDistributorSC.js
Normal file
@ -0,0 +1,573 @@
|
|||||||
|
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 (
|
||||||
|
<div className="main-content">
|
||||||
|
<div className="page-content">
|
||||||
|
<div className="container-fluid">
|
||||||
|
<div className="row">
|
||||||
|
<div className="col-12">
|
||||||
|
<div className="page-title-box d-flex mb-1 align-items-center justify-content-between">
|
||||||
|
{/* Left Side with Information in Separate Columns */}
|
||||||
|
<div className="d-flex flex-column">
|
||||||
|
<div style={{ fontSize: "18px" }} className="fw-bold">
|
||||||
|
Unique ID: {data?.uniqueId}
|
||||||
|
</div>
|
||||||
|
<div style={{ fontSize: "18px" }} className="fw-bold">
|
||||||
|
Name: {data?.name}
|
||||||
|
</div>
|
||||||
|
<div style={{ fontSize: "18px" }} className="fw-bold">
|
||||||
|
Mobile Number: {data?.mobileNumber}
|
||||||
|
</div>
|
||||||
|
<div style={{ fontSize: "18px" }} className="fw-bold">
|
||||||
|
Mail: {data?.email}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Right Side with the Button */}
|
||||||
|
<div className="page-title-right">
|
||||||
|
<Button
|
||||||
|
variant="contained"
|
||||||
|
color="primary"
|
||||||
|
style={{
|
||||||
|
fontWeight: "bold",
|
||||||
|
marginBottom: "1rem",
|
||||||
|
textTransform: "capitalize",
|
||||||
|
}}
|
||||||
|
onClick={handleOpenModal}
|
||||||
|
>
|
||||||
|
Add Retail Distributor
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
variant="contained"
|
||||||
|
color="secondary"
|
||||||
|
style={{
|
||||||
|
fontWeight: "bold",
|
||||||
|
marginBottom: "1rem",
|
||||||
|
marginLeft: "1rem",
|
||||||
|
textTransform: "capitalize",
|
||||||
|
backgroundColor: "#d32f2f", // Red color for danger
|
||||||
|
color: "#fff",
|
||||||
|
"&:hover": {
|
||||||
|
backgroundColor: "#b71c1c", // Darker red on hover
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
onClick={() => navigate("/salescoordinators")}
|
||||||
|
>
|
||||||
|
Back
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<Dialog
|
||||||
|
open={openModal}
|
||||||
|
onClose={handleCloseModal}
|
||||||
|
maxWidth="md"
|
||||||
|
fullWidth
|
||||||
|
>
|
||||||
|
<DialogTitle>Search and Add Retail Distributor</DialogTitle>
|
||||||
|
<DialogContent>
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
display: "flex",
|
||||||
|
gap: "16px",
|
||||||
|
marginBottom: "2rem",
|
||||||
|
marginTop: "-1rem",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<TextField
|
||||||
|
label="Retail Distributor Trade Name"
|
||||||
|
placeholder="Retail Distributor Trade name"
|
||||||
|
inputRef={rdnameRef}
|
||||||
|
onChange={handlemodalSearchChange}
|
||||||
|
disabled={loading}
|
||||||
|
style={{ flex: 1, marginRight: "16px" }}
|
||||||
|
/>
|
||||||
|
<TextField
|
||||||
|
style={{ flex: 1 }}
|
||||||
|
label="Mobile Number"
|
||||||
|
placeholder="Mobile Number"
|
||||||
|
inputRef={rdmobileRef}
|
||||||
|
onChange={handlemodalSearchChange}
|
||||||
|
disabled={loading}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className="table-responsive table-shoot mt-3">
|
||||||
|
<table className="table table-centered table-nowrap">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Trade Name</th>
|
||||||
|
<th>Mobile</th>
|
||||||
|
<th>Email</th>
|
||||||
|
<th>SC</th>
|
||||||
|
<th>Action</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{modalRetailDistributors.length > 0 ? (
|
||||||
|
modalRetailDistributors.map((RD) => (
|
||||||
|
<tr key={RD._id}>
|
||||||
|
<td>{RD.kycDetails.trade_name}</td>
|
||||||
|
<td>{RD.mobile_number}</td>
|
||||||
|
<td>{RD.email}</td>
|
||||||
|
<td>{RD.mappedSCDetails?.name || "N/A"}</td>
|
||||||
|
<td>
|
||||||
|
<Button
|
||||||
|
variant="contained"
|
||||||
|
color="primary"
|
||||||
|
onClick={() =>
|
||||||
|
handleAddRetailDistributor(RD._id)
|
||||||
|
}
|
||||||
|
>
|
||||||
|
Add
|
||||||
|
</Button>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
))
|
||||||
|
) : (
|
||||||
|
<tr>
|
||||||
|
<td colSpan="6" className="text-center">
|
||||||
|
No Retail Distributor found!
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
)}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<div className="d-flex justify-content-between">
|
||||||
|
<div>
|
||||||
|
Showing {modalRetailDistributors?.length} of{" "}
|
||||||
|
{modalTotalData} entries
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<button
|
||||||
|
onClick={handlePreviousPage}
|
||||||
|
disabled={modalcurrentPage === 1 || loading}
|
||||||
|
className="btn btn-primary"
|
||||||
|
>
|
||||||
|
Previous
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
onClick={handleNextPage}
|
||||||
|
disabled={
|
||||||
|
modalRetailDistributors?.length < modalitemPerPage ||
|
||||||
|
loading
|
||||||
|
}
|
||||||
|
className="btn btn-primary ml-2"
|
||||||
|
>
|
||||||
|
Next
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</DialogContent>
|
||||||
|
<DialogActions>
|
||||||
|
<Button onClick={handleCloseModal} color="secondary">
|
||||||
|
Cancel
|
||||||
|
</Button>
|
||||||
|
</DialogActions>
|
||||||
|
</Dialog>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="row">
|
||||||
|
<div className="col-lg-12">
|
||||||
|
<div className="card">
|
||||||
|
<div className="card-body">
|
||||||
|
<div className="row ml-0 mr-0 mb-10">
|
||||||
|
<div className="col-lg-1">
|
||||||
|
<div className="dataTables_length">
|
||||||
|
<label className="w-100">
|
||||||
|
Show
|
||||||
|
<select
|
||||||
|
onChange={(e) => {
|
||||||
|
setItemPerPage(e.target.value);
|
||||||
|
setCurrentPage(1);
|
||||||
|
}}
|
||||||
|
className="form-control"
|
||||||
|
disabled={loading}
|
||||||
|
>
|
||||||
|
<option value="10">10</option>
|
||||||
|
<option value="25">25</option>
|
||||||
|
<option value="50">50</option>
|
||||||
|
<option value="100">100</option>
|
||||||
|
</select>
|
||||||
|
entries
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="col-lg-3">
|
||||||
|
<label>Trade Name:</label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
placeholder="Retail Distributor Trade name"
|
||||||
|
className="form-control"
|
||||||
|
ref={nameRef}
|
||||||
|
onChange={handleSearchChange}
|
||||||
|
disabled={loading}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className="col-lg-3">
|
||||||
|
<label>Mobile Number:</label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
placeholder="Mobile Number"
|
||||||
|
className="form-control"
|
||||||
|
ref={mobileRef}
|
||||||
|
onChange={handleSearchChange}
|
||||||
|
disabled={loading}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="table-responsive table-shoot mt-3">
|
||||||
|
<table className="table table-centered table-nowrap">
|
||||||
|
<thead
|
||||||
|
className="thead-light"
|
||||||
|
style={{ background: "#ecdddd" }}
|
||||||
|
>
|
||||||
|
<tr>
|
||||||
|
<th className="text-start">UniqueID</th>
|
||||||
|
<th className="text-start">Trade Name</th>
|
||||||
|
<th className="text-start">Mobile</th>
|
||||||
|
<th className="text-start">Email</th>
|
||||||
|
<th className="text-start">Created On</th>
|
||||||
|
<th className="text-start">Action</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
|
||||||
|
<tbody>
|
||||||
|
{loading ? (
|
||||||
|
<tr>
|
||||||
|
<td className="text-center" colSpan="6">
|
||||||
|
Loading...
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
) : retaildistributorData?.length > 0 ? (
|
||||||
|
retaildistributorData?.map((RD, i) => {
|
||||||
|
return (
|
||||||
|
<tr key={i}>
|
||||||
|
<td className="text-start">{RD?.uniqueId}</td>
|
||||||
|
<td className="text-start">
|
||||||
|
{RD?.kycDetails?.trade_name}
|
||||||
|
</td>
|
||||||
|
<td className="text-start">
|
||||||
|
{RD?.mobile_number ? (
|
||||||
|
RD?.mobile_number
|
||||||
|
) : (
|
||||||
|
<small className="m-0 text-secondary">
|
||||||
|
No Phone Added!
|
||||||
|
</small>
|
||||||
|
)}
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<td className="text-start">{RD?.email}</td>
|
||||||
|
<td className="text-start">
|
||||||
|
{" "}
|
||||||
|
{new Date(RD.createdAt).toLocaleString(
|
||||||
|
"en-IN",
|
||||||
|
{
|
||||||
|
weekday: "short",
|
||||||
|
month: "short",
|
||||||
|
day: "numeric",
|
||||||
|
year: "numeric",
|
||||||
|
hour: "numeric",
|
||||||
|
minute: "numeric",
|
||||||
|
hour12: true,
|
||||||
|
}
|
||||||
|
)}
|
||||||
|
</td>
|
||||||
|
<td className="text-start">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
style={{ color: "white" }}
|
||||||
|
className="btn btn-danger btn-sm waves-effect waves-light btn-table ml-2"
|
||||||
|
onClick={() => handleDelete(RD._id)}
|
||||||
|
>
|
||||||
|
Delete
|
||||||
|
</button>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
);
|
||||||
|
})
|
||||||
|
) : (
|
||||||
|
<tr>
|
||||||
|
<td className="text-center" colSpan="6">
|
||||||
|
No Retail Distributor found!
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
)}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<div className="d-flex justify-content-between">
|
||||||
|
<div>
|
||||||
|
Showing {retaildistributorData?.length} of {totalData}{" "}
|
||||||
|
entries
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<button
|
||||||
|
onClick={() => setCurrentPage(currentPage - 1)}
|
||||||
|
disabled={currentPage === 1 || loading}
|
||||||
|
className="btn btn-primary"
|
||||||
|
>
|
||||||
|
Previous
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
onClick={() => setCurrentPage(currentPage + 1)}
|
||||||
|
disabled={
|
||||||
|
retaildistributorData?.length < itemPerPage || loading
|
||||||
|
}
|
||||||
|
className="btn btn-primary ml-2"
|
||||||
|
>
|
||||||
|
Next
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ViewRetailDistributorSC;
|
@ -31,9 +31,7 @@ const ViewRetailDistributorTM = () => {
|
|||||||
const modalitemPerPage = 10;
|
const modalitemPerPage = 10;
|
||||||
const [totalData, setTotalData] = useState(0);
|
const [totalData, setTotalData] = useState(0);
|
||||||
const [openModal, setOpenModal] = useState(false);
|
const [openModal, setOpenModal] = useState(false);
|
||||||
const [modalRetailDistributors, setmodalRetailDistributors] = useState(
|
const [modalRetailDistributors, setmodalRetailDistributors] = useState([]);
|
||||||
[]
|
|
||||||
);
|
|
||||||
const [modalTotalData, setModalTotalData] = useState(0);
|
const [modalTotalData, setModalTotalData] = useState(0);
|
||||||
|
|
||||||
// Fetch territory manager data
|
// Fetch territory manager data
|
||||||
@ -50,7 +48,7 @@ const ViewRetailDistributorTM = () => {
|
|||||||
const getTMsretaildistributorData = async () => {
|
const getTMsretaildistributorData = async () => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
axios
|
axios
|
||||||
.get(`/api/kyc/getAllapprovedbytmid/${id}`, {
|
.get(`/api/getAllRDbytmid/${id}`, {
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bearer ${token}`,
|
Authorization: `Bearer ${token}`,
|
||||||
},
|
},
|
||||||
@ -58,11 +56,12 @@ const ViewRetailDistributorTM = () => {
|
|||||||
page: currentPage,
|
page: currentPage,
|
||||||
show: itemPerPage,
|
show: itemPerPage,
|
||||||
tradename: nameRef.current?.value,
|
tradename: nameRef.current?.value,
|
||||||
|
mobile_number: mobileRef.current?.value,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
// console.log(res.data);
|
// console.log(res.data);
|
||||||
setretaildistributorData(res.data?.retaildistributor);
|
setretaildistributorData(res.data?.Retaildistributor);
|
||||||
setTotalData(res.data?.total_data);
|
setTotalData(res.data?.total_data);
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
@ -98,19 +97,19 @@ const ViewRetailDistributorTM = () => {
|
|||||||
const getretaildistributorData = async () => {
|
const getretaildistributorData = async () => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
try {
|
try {
|
||||||
const res = await axios.get(`/api/v1/admin/users`, {
|
const res = await axios.get(`/api/getAllRD`, {
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bearer ${token}`,
|
Authorization: `Bearer ${token}`,
|
||||||
},
|
},
|
||||||
params: {
|
params: {
|
||||||
page: modalcurrentPage,
|
page: modalcurrentPage,
|
||||||
show: modalitemPerPage,
|
show: modalitemPerPage,
|
||||||
name: rdnameRef.current?.value,
|
tradename: rdnameRef.current?.value,
|
||||||
mobileNumber: rdmobileRef.current?.value,
|
mobile_number: rdmobileRef.current?.value,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
setmodalRetailDistributors(res.data?.users);
|
setmodalRetailDistributors(res.data?.Retaildistributor);
|
||||||
setModalTotalData(res.data?.totalUsers);
|
setModalTotalData(res.data?.total_data);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
const msg = err?.response?.data?.message || "Something went wrong!";
|
const msg = err?.response?.data?.message || "Something went wrong!";
|
||||||
swal({
|
swal({
|
||||||
@ -174,12 +173,17 @@ const ViewRetailDistributorTM = () => {
|
|||||||
}).then((value) => {
|
}).then((value) => {
|
||||||
if (value === true) {
|
if (value === true) {
|
||||||
axios
|
axios
|
||||||
.patch(`/api/v1/unmap/${id}`, {}, { // Changed to PATCH and sent an empty body
|
.patch(
|
||||||
headers: {
|
`/api/unmap/${id}`,
|
||||||
"Access-Control-Allow-Origin": "*",
|
{ mappedTM: true },
|
||||||
Authorization: `Bearer ${token}`,
|
{
|
||||||
},
|
// Changed to PATCH and sent an empty body
|
||||||
})
|
headers: {
|
||||||
|
"Access-Control-Allow-Origin": "*",
|
||||||
|
Authorization: `Bearer ${token}`,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
swal({
|
swal({
|
||||||
title: "Deleted",
|
title: "Deleted",
|
||||||
@ -207,8 +211,8 @@ const ViewRetailDistributorTM = () => {
|
|||||||
const handleAddRetailDistributor = async (rdid) => {
|
const handleAddRetailDistributor = async (rdid) => {
|
||||||
try {
|
try {
|
||||||
await axios.put(
|
await axios.put(
|
||||||
`/api/v1/mappedtm/${rdid}`,
|
`/api/mapped/${rdid}`,
|
||||||
{ mappedby: id },
|
{ mappedTM: id },
|
||||||
{
|
{
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bearer ${token}`,
|
Authorization: `Bearer ${token}`,
|
||||||
@ -260,7 +264,7 @@ const ViewRetailDistributorTM = () => {
|
|||||||
|
|
||||||
{/* Right Side with the Button */}
|
{/* Right Side with the Button */}
|
||||||
<div className="page-title-right">
|
<div className="page-title-right">
|
||||||
{/* <Button
|
<Button
|
||||||
variant="contained"
|
variant="contained"
|
||||||
color="primary"
|
color="primary"
|
||||||
style={{
|
style={{
|
||||||
@ -271,7 +275,7 @@ const ViewRetailDistributorTM = () => {
|
|||||||
onClick={handleOpenModal}
|
onClick={handleOpenModal}
|
||||||
>
|
>
|
||||||
Add Retail Distributor
|
Add Retail Distributor
|
||||||
</Button> */}
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
variant="contained"
|
variant="contained"
|
||||||
color="secondary"
|
color="secondary"
|
||||||
@ -292,7 +296,7 @@ const ViewRetailDistributorTM = () => {
|
|||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{/* <Dialog
|
<Dialog
|
||||||
open={openModal}
|
open={openModal}
|
||||||
onClose={handleCloseModal}
|
onClose={handleCloseModal}
|
||||||
maxWidth="md"
|
maxWidth="md"
|
||||||
@ -300,96 +304,105 @@ const ViewRetailDistributorTM = () => {
|
|||||||
>
|
>
|
||||||
<DialogTitle>Search and Add Retail Distributor</DialogTitle>
|
<DialogTitle>Search and Add Retail Distributor</DialogTitle>
|
||||||
<DialogContent>
|
<DialogContent>
|
||||||
<div style={{ display: "flex", gap: "16px", marginBottom:"2rem",marginTop:"-1rem" }}>
|
<div
|
||||||
<TextField
|
style={{
|
||||||
label="Retail Distributor Trade Name"
|
display: "flex",
|
||||||
placeholder="Retail Distributor Trade name"
|
gap: "16px",
|
||||||
inputRef={rdnameRef}
|
marginBottom: "2rem",
|
||||||
onChange={handlemodalSearchChange}
|
marginTop: "-1rem",
|
||||||
disabled={loading}
|
}}
|
||||||
style={{ flex: 1, marginRight: "16px" }}
|
>
|
||||||
/>
|
<TextField
|
||||||
<TextField
|
label="Retail Distributor Trade Name"
|
||||||
style={{ flex: 1 }}
|
placeholder="Retail Distributor Trade name"
|
||||||
label="Mobile Number"
|
inputRef={rdnameRef}
|
||||||
placeholder="Mobile Number"
|
onChange={handlemodalSearchChange}
|
||||||
inputRef={rdmobileRef}
|
disabled={loading}
|
||||||
onChange={handlemodalSearchChange}
|
style={{ flex: 1, marginRight: "16px" }}
|
||||||
disabled={loading}
|
/>
|
||||||
/>
|
<TextField
|
||||||
</div>
|
style={{ flex: 1 }}
|
||||||
<div className="table-responsive table-shoot mt-3">
|
label="Mobile Number"
|
||||||
<table className="table table-centered table-nowrap">
|
placeholder="Mobile Number"
|
||||||
<thead>
|
inputRef={rdmobileRef}
|
||||||
<tr>
|
onChange={handlemodalSearchChange}
|
||||||
<th>Trade Name</th>
|
disabled={loading}
|
||||||
<th>Mobile</th>
|
/>
|
||||||
<th>Approved PD</th>
|
</div>
|
||||||
<th>Action</th>
|
<div className="table-responsive table-shoot mt-3">
|
||||||
</tr>
|
<table className="table table-centered table-nowrap">
|
||||||
</thead>
|
<thead>
|
||||||
<tbody>
|
<tr>
|
||||||
{modalRetailDistributors.length > 0 ? (
|
<th>Trade Name</th>
|
||||||
modalRetailDistributors.map((RD) => (
|
<th>Mobile</th>
|
||||||
<tr key={RD._id}>
|
<th>Email</th>
|
||||||
<td>{RD.trade_name}</td>
|
<th>TM</th>
|
||||||
<td>{RD.mobile_number}</td>
|
<th>Action</th>
|
||||||
<td>{RD.principal_distributer?.name}</td>
|
</tr>
|
||||||
<td>
|
</thead>
|
||||||
<Button
|
<tbody>
|
||||||
variant="contained"
|
{modalRetailDistributors.length > 0 ? (
|
||||||
color="primary"
|
modalRetailDistributors.map((RD) => (
|
||||||
onClick={() =>
|
<tr key={RD._id}>
|
||||||
handleAddRetailDistributor(RD._id)
|
<td>{RD.kycDetails.trade_name}</td>
|
||||||
}
|
<td>{RD.mobile_number}</td>
|
||||||
>
|
<td>{RD.email}</td>
|
||||||
Add
|
<td>{RD.mappedTMDetails?.name || "N/A"}</td>
|
||||||
</Button>
|
<td>
|
||||||
</td>
|
<Button
|
||||||
</tr>
|
variant="contained"
|
||||||
))
|
color="primary"
|
||||||
) : (
|
onClick={() =>
|
||||||
<tr>
|
handleAddRetailDistributor(RD._id)
|
||||||
<td colSpan="6" className="text-center">
|
}
|
||||||
No Retail Distributor found!
|
>
|
||||||
|
Add
|
||||||
|
</Button>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
)}
|
))
|
||||||
</tbody>
|
) : (
|
||||||
</table>
|
<tr>
|
||||||
|
<td colSpan="6" className="text-center">
|
||||||
|
No Retail Distributor found!
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
)}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<div className="d-flex justify-content-between">
|
||||||
|
<div>
|
||||||
|
Showing {modalRetailDistributors?.length} of{" "}
|
||||||
|
{modalTotalData} entries
|
||||||
</div>
|
</div>
|
||||||
<div className="d-flex justify-content-between">
|
<div>
|
||||||
<div>
|
<button
|
||||||
Showing {modalRetailDistributors?.length} of{" "}
|
onClick={handlePreviousPage}
|
||||||
{modalTotalData} entries
|
disabled={modalcurrentPage === 1 || loading}
|
||||||
</div>
|
className="btn btn-primary"
|
||||||
<div>
|
>
|
||||||
<button
|
Previous
|
||||||
onClick={handlePreviousPage}
|
</button>
|
||||||
disabled={modalcurrentPage === 1 || loading}
|
<button
|
||||||
className="btn btn-primary"
|
onClick={handleNextPage}
|
||||||
>
|
disabled={
|
||||||
Previous
|
modalRetailDistributors?.length < modalitemPerPage ||
|
||||||
</button>
|
loading
|
||||||
<button
|
}
|
||||||
onClick={handleNextPage}
|
className="btn btn-primary ml-2"
|
||||||
disabled={
|
>
|
||||||
modalRetailDistributors?.length <
|
Next
|
||||||
modalitemPerPage || loading
|
</button>
|
||||||
}
|
|
||||||
className="btn btn-primary ml-2"
|
|
||||||
>
|
|
||||||
Next
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
<DialogActions>
|
<DialogActions>
|
||||||
<Button onClick={handleCloseModal} color="secondary">
|
<Button onClick={handleCloseModal} color="secondary">
|
||||||
Cancel
|
Cancel
|
||||||
</Button>
|
</Button>
|
||||||
</DialogActions>
|
</DialogActions>
|
||||||
</Dialog> */}
|
</Dialog>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -430,7 +443,7 @@ const ViewRetailDistributorTM = () => {
|
|||||||
disabled={loading}
|
disabled={loading}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
{/* <div className="col-lg-3">
|
<div className="col-lg-3">
|
||||||
<label>Mobile Number:</label>
|
<label>Mobile Number:</label>
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
@ -440,7 +453,7 @@ const ViewRetailDistributorTM = () => {
|
|||||||
onChange={handleSearchChange}
|
onChange={handleSearchChange}
|
||||||
disabled={loading}
|
disabled={loading}
|
||||||
/>
|
/>
|
||||||
</div> */}
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="table-responsive table-shoot mt-3">
|
<div className="table-responsive table-shoot mt-3">
|
||||||
@ -450,12 +463,12 @@ const ViewRetailDistributorTM = () => {
|
|||||||
style={{ background: "#ecdddd" }}
|
style={{ background: "#ecdddd" }}
|
||||||
>
|
>
|
||||||
<tr>
|
<tr>
|
||||||
<th className="text-start">ID</th>
|
<th className="text-start">UniqueID</th>
|
||||||
<th className="text-start">Trade Name</th>
|
<th className="text-start">Trade Name</th>
|
||||||
<th className="text-start">Approved PD</th>
|
|
||||||
<th className="text-start">Mobile</th>
|
<th className="text-start">Mobile</th>
|
||||||
|
<th className="text-start">Email</th>
|
||||||
<th className="text-start">Created On</th>
|
<th className="text-start">Created On</th>
|
||||||
{/* <th className="text-start">Action</th> */}
|
<th className="text-start">Action</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
|
||||||
@ -470,9 +483,10 @@ const ViewRetailDistributorTM = () => {
|
|||||||
retaildistributorData?.map((RD, i) => {
|
retaildistributorData?.map((RD, i) => {
|
||||||
return (
|
return (
|
||||||
<tr key={i}>
|
<tr key={i}>
|
||||||
<td className="text-start">{RD?._id}</td>
|
<td className="text-start">{RD?.uniqueId}</td>
|
||||||
<td className="text-start">{RD?.trade_name}</td>
|
<td className="text-start">
|
||||||
<td className="text-start">{RD?.principal_distributer?.name}</td>
|
{RD?.kycDetails?.trade_name}
|
||||||
|
</td>
|
||||||
<td className="text-start">
|
<td className="text-start">
|
||||||
{RD?.mobile_number ? (
|
{RD?.mobile_number ? (
|
||||||
RD?.mobile_number
|
RD?.mobile_number
|
||||||
@ -482,18 +496,24 @@ const ViewRetailDistributorTM = () => {
|
|||||||
</small>
|
</small>
|
||||||
)}
|
)}
|
||||||
</td>
|
</td>
|
||||||
<td className="text-start"> {new Date(
|
|
||||||
RD.updatedAt
|
<td className="text-start">{RD?.email}</td>
|
||||||
).toLocaleString("en-IN", {
|
<td className="text-start">
|
||||||
weekday: "short",
|
{" "}
|
||||||
month: "short",
|
{new Date(RD.createdAt).toLocaleString(
|
||||||
day: "numeric",
|
"en-IN",
|
||||||
year: "numeric",
|
{
|
||||||
hour: "numeric",
|
weekday: "short",
|
||||||
minute: "numeric",
|
month: "short",
|
||||||
hour12: true,
|
day: "numeric",
|
||||||
})}</td>
|
year: "numeric",
|
||||||
{/* <td className="text-start">
|
hour: "numeric",
|
||||||
|
minute: "numeric",
|
||||||
|
hour12: true,
|
||||||
|
}
|
||||||
|
)}
|
||||||
|
</td>
|
||||||
|
<td className="text-start">
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
style={{ color: "white" }}
|
style={{ color: "white" }}
|
||||||
@ -502,7 +522,7 @@ const ViewRetailDistributorTM = () => {
|
|||||||
>
|
>
|
||||||
Delete
|
Delete
|
||||||
</button>
|
</button>
|
||||||
</td> */}
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
@ -532,8 +552,7 @@ const ViewRetailDistributorTM = () => {
|
|||||||
<button
|
<button
|
||||||
onClick={() => setCurrentPage(currentPage + 1)}
|
onClick={() => setCurrentPage(currentPage + 1)}
|
||||||
disabled={
|
disabled={
|
||||||
retaildistributorData?.length < itemPerPage ||
|
retaildistributorData?.length < itemPerPage || loading
|
||||||
loading
|
|
||||||
}
|
}
|
||||||
className="btn btn-primary ml-2"
|
className="btn btn-primary ml-2"
|
||||||
>
|
>
|
||||||
|
@ -10,6 +10,7 @@ const Dashboard = () => {
|
|||||||
const [users, setUsers] = useState([]);
|
const [users, setUsers] = useState([]);
|
||||||
const [salescoordinator, setSalescoordinator] = useState([]);
|
const [salescoordinator, setSalescoordinator] = useState([]);
|
||||||
const [territorymanager, setTerritorymanager] = useState([]);
|
const [territorymanager, setTerritorymanager] = useState([]);
|
||||||
|
const [retaildistributor, setRetaildistributor] = useState([]);
|
||||||
const token = isAutheticated();
|
const token = isAutheticated();
|
||||||
|
|
||||||
const getAllUsers = async () => {
|
const getAllUsers = async () => {
|
||||||
@ -40,6 +41,15 @@ const Dashboard = () => {
|
|||||||
// console.log(res.data)
|
// console.log(res.data)
|
||||||
setTerritorymanager(res.data.total_data);
|
setTerritorymanager(res.data.total_data);
|
||||||
};
|
};
|
||||||
|
const getAllretaildistributor = async () => {
|
||||||
|
let res = await axios.get(`/api/getAllRD`, {
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${token}`,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
// console.log(res.data)
|
||||||
|
setRetaildistributor(res.data.total_data);
|
||||||
|
};
|
||||||
// //2nd
|
// //2nd
|
||||||
// const [category, setCategory] = useState([]);
|
// const [category, setCategory] = useState([]);
|
||||||
// const getAllCategory = async () => {
|
// const getAllCategory = async () => {
|
||||||
@ -141,6 +151,7 @@ const Dashboard = () => {
|
|||||||
getAllUsers();
|
getAllUsers();
|
||||||
getAllsalescoordinator();
|
getAllsalescoordinator();
|
||||||
getAllterritorymanager();
|
getAllterritorymanager();
|
||||||
|
getAllretaildistributor();
|
||||||
// getAllCategory();
|
// getAllCategory();
|
||||||
// getAllProduct();
|
// getAllProduct();
|
||||||
// getAllRequests();
|
// getAllRequests();
|
||||||
@ -151,6 +162,7 @@ const Dashboard = () => {
|
|||||||
users={users}
|
users={users}
|
||||||
salescoordinator={salescoordinator}
|
salescoordinator={salescoordinator}
|
||||||
territorymanager={territorymanager}
|
territorymanager={territorymanager}
|
||||||
|
retaildistributor={retaildistributor}
|
||||||
// category={category}
|
// category={category}
|
||||||
// product={product}
|
// product={product}
|
||||||
// Requests={Requests}
|
// Requests={Requests}
|
||||||
|
@ -18,7 +18,7 @@ import axios from "axios";
|
|||||||
{
|
{
|
||||||
/* <BeatLoader color="#36d7b7" /> */
|
/* <BeatLoader color="#36d7b7" /> */
|
||||||
}
|
}
|
||||||
const WidgetsDropdown = ({ users,salescoordinator,territorymanager }) => {
|
const WidgetsDropdown = ({ users,salescoordinator,territorymanager,retaildistributor }) => {
|
||||||
// const WidgetsDropdown = ({ users, category, product, Requests }) => {
|
// const WidgetsDropdown = ({ users, category, product, Requests }) => {
|
||||||
// const token = isAutheticated();
|
// const token = isAutheticated();
|
||||||
// const [orders, setOrders] = useState([]);
|
// const [orders, setOrders] = useState([]);
|
||||||
@ -138,6 +138,17 @@ const WidgetsDropdown = ({ users,salescoordinator,territorymanager }) => {
|
|||||||
/>
|
/>
|
||||||
</CCol>
|
</CCol>
|
||||||
</CRow>
|
</CRow>
|
||||||
|
<h4>Retail Distributor</h4>
|
||||||
|
<CRow>
|
||||||
|
<CCol sm={6} lg={3}>
|
||||||
|
<CWidgetStatsA
|
||||||
|
className="mb-4"
|
||||||
|
color="primary"
|
||||||
|
value={<>{retaildistributor}</>}
|
||||||
|
title="Total Reatil Distributor"
|
||||||
|
/>
|
||||||
|
</CCol>
|
||||||
|
</CRow>
|
||||||
<h4>Sales Coordinator</h4>
|
<h4>Sales Coordinator</h4>
|
||||||
<CRow>
|
<CRow>
|
||||||
<CCol sm={6} lg={3}>
|
<CCol sm={6} lg={3}>
|
||||||
|
Loading…
Reference in New Issue
Block a user