import React, { useState, useEffect, useRef,useCallback } from "react"; import { Link } 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'; const AttendanceSalesCoordinator = () => { const token = isAutheticated(); const navigate = useNavigate(); const [loading, setLoading] = useState(false); const [success, setSuccess] = useState(true); const [salescoordinatorsData, setSalesCoOrdinatorsData] = useState([]); const nameRef = useRef(); const mobileRef = useRef(); const VerifySalesCoOrdinatorRef = useRef(); const [currentPage, setCurrentPage] = useState(1); const [itemPerPage, setItemPerPage] = useState(10); const [totalData, setTotalData] = useState(0); const getSalesCoOrdinatorsData = async () => { setLoading(true); try { const res = await axios.get(`/api/salescoordinator/getAll/`, { headers: { Authorization: `Bearer ${token}`, }, params: { page: currentPage, show: itemPerPage, name: nameRef.current.value, mobileNumber: mobileRef.current.value, isVerified: VerifySalesCoOrdinatorRef.current.value, }, }); setSalesCoOrdinatorsData(res.data?.salesCoOrinators); 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(() => { getSalesCoOrdinatorsData(); }, [success, itemPerPage, currentPage]); const debouncedSearch = useCallback(debounce(() => { setCurrentPage(1); getSalesCoOrdinatorsData(); }, 500), []); const handleSearchChange = () => { debouncedSearch(); }; return (
SalesCoOrdinators Attendance
{loading ? ( ) : salescoordinatorsData?.length > 0 ? ( salescoordinatorsData?.map((salescoordinator, i) => { return ( ); }) ) : ( )}
Name Mobile No. Email Verify Register On Action
Loading...
{salescoordinator?.name} {salescoordinator?.mobileNumber} {salescoordinator?.email ? ( salescoordinator?.email ) : ( No Email Added! )} {salescoordinator?.isVerified ? "YES" : "NO"} {new Date( salescoordinator.createdAt ).toLocaleString("en-IN", { weekday: "short", month: "short", day: "numeric", year: "numeric", hour: "numeric", minute: "numeric", hour12: true, })}
No SalesCoOrdinator Available...
Showing {currentPage * itemPerPage - itemPerPage + 1} to{" "} {Math.min(currentPage * itemPerPage, totalData)} of{" "} {totalData} entries
  • setCurrentPage((prev) => prev > 1 ? prev - 1 : prev ) } > Previous
  • = totalData ? "paginate_button page-item next disabled" : "paginate_button page-item next" } > setCurrentPage((prev) => prev * itemPerPage < totalData ? prev + 1 : prev ) } > Next
); }; export default AttendanceSalesCoordinator;