Commit dc3a068f authored by Ramadevi Guduri's avatar Ramadevi Guduri

Merge branch 'master' of...

Merge branch 'master' of https://gitlab.mynisum.com/vsingamchetty/nisum-scorecard into scorecarduidesigns
parents dabd46a9 44a5d874
import React from 'react'
function DownloadIcon() {
return (
<svg width="25px" height="25px" viewBox="0 0 24 24" fill="none" className='mr-2'>
<path d="M12 7L12 14M12 14L15 11M12 14L9 11" stroke="white" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M16 17H12H8" stroke="white" stroke-width="1.5" stroke-linecap="round"/>
<path d="M2 12C2 7.28595 2 4.92893 3.46447 3.46447C4.92893 2 7.28595 2 12 2C16.714 2 19.0711 2 20.5355 3.46447C22 4.92893 22 7.28595 22 12C22 16.714 22 19.0711 20.5355 20.5355C19.0711 22 16.714 22 12 22C7.28595 22 4.92893 22 3.46447 20.5355C2 19.0711 2 16.714 2 12Z" stroke="white" stroke-width="1.5"/>
</svg>
)
}
export default DownloadIcon
...@@ -51,14 +51,14 @@ function LeftSidebar() { ...@@ -51,14 +51,14 @@ function LeftSidebar() {
return ( return (
<div className=" w-[33%] flex flex-col px-[5px]"> <div className=" w-[33%] flex flex-col px-[5px]">
<div className=" flex mt-3 items-center justify-between"> <div className=" flex mt-3 items-center">
<p className="text-xl text-blue-400 font-semibold pl-4"> <p className="text-xl text-blue-400 font-semibold pl-4">
Reportees Reportees
</p> </p>
<input <input
placeholder="Search" placeholder="Search"
type="text" type="text"
className="p-2 border rounded w-[160px] placeholder:text-[14px]" className="p-2 border rounded ml-[16px] placeholder:text-[14px]"
value={inputValue} value={inputValue}
onChange={handleChange} onChange={handleChange}
/> />
...@@ -69,7 +69,7 @@ function LeftSidebar() { ...@@ -69,7 +69,7 @@ function LeftSidebar() {
{(reportees.length) ? reportees?.map(({ empName, score, empId }) => ( {(reportees.length) ? reportees?.map(({ empName, score, empId }) => (
<button onClick={() => dispatch(setViewReportee(empId))} <button onClick={() => dispatch(setViewReportee(empId))}
// to={`/viewreportee`} // to={`/viewreportee`}
className={`flex items-center hover:bg-blue-400 hover:text-white bg-${viewReportee?.empId == empId ? "blue-400 text-white" : "white" className={`flex rounded-lg items-center hover:bg-blue-400 hover:text-white bg-${viewReportee?.empId == empId ? "blue-400 text-white" : "white"
} p-2 justify-between mb-1 w-full`} } p-2 justify-between mb-1 w-full`}
key={empId} key={empId}
> >
......
...@@ -46,7 +46,7 @@ function Dashboard() { ...@@ -46,7 +46,7 @@ function Dashboard() {
useEffect(() => { useEffect(() => {
if (userDetails.user) { if (userDetails.user) {
setReporteIds(userDetails.user.reportees) setReporteIds(userDetails.user.reportees)
navigate("/dashboard") // navigate("/dashboard")
} else { } else {
navigate("/") navigate("/")
} }
......
...@@ -6,6 +6,7 @@ import { fetchReportees } from "../../redux/reducers/reporteesSlice"; ...@@ -6,6 +6,7 @@ import { fetchReportees } from "../../redux/reducers/reporteesSlice";
import { convertUTCToLocal } from "../../utils/commonFunctions"; import { convertUTCToLocal } from "../../utils/commonFunctions";
import Table from "../../components/table"; import Table from "../../components/table";
import { base_url } from "../../utils/constants"; import { base_url } from "../../utils/constants";
import DownloadIcon from '../../assets/icons/downloadIcon';
import jsPDF from 'jspdf'; import jsPDF from 'jspdf';
import 'jspdf-autotable'; import 'jspdf-autotable';
...@@ -23,6 +24,11 @@ function Exporttable() { ...@@ -23,6 +24,11 @@ function Exporttable() {
const [inputValue, setInputValue] = useState(''); const [inputValue, setInputValue] = useState('');
const [pdfData, setPdfData] = useState([]); const [pdfData, setPdfData] = useState([]);
const [pdfLoading, setPdfLoading] = useState(false); const [pdfLoading, setPdfLoading] = useState(false);
const [preState, setPreState] = useState({
preEmployee: 0,
preFromDate: '',
preToDate: ''
})
const calculateDateRange = (monthsAgo) => { const calculateDateRange = (monthsAgo) => {
const toDate = new Date().toISOString().split("T")[0]; const toDate = new Date().toISOString().split("T")[0];
...@@ -52,6 +58,11 @@ function Exporttable() { ...@@ -52,6 +58,11 @@ function Exporttable() {
const handleView = (e) => { const handleView = (e) => {
if (selectedEmployee && fromDate && toDate) { if (selectedEmployee && fromDate && toDate) {
e.preventDefault(); e.preventDefault();
setPreState({
preEmployee: selectedEmployee,
preFromDate: fromDate,
preToDate: toDate
})
let data = { let data = {
empId: Number(selectedEmployee), empId: Number(selectedEmployee),
fromDate: fromDate, fromDate: fromDate,
...@@ -75,11 +86,11 @@ function Exporttable() { ...@@ -75,11 +86,11 @@ function Exporttable() {
}) })
}, [user]); }, [user]);
useEffect(() => { // useEffect(() => {
if(activitiesData.length > 0) { // if(activitiesData.length > 0) {
dispatch(resetActivitiesData()) // dispatch(resetActivitiesData())
} // }
}, [selectedEmployee, toDate, fromDate]) // }, [selectedEmployee, toDate, fromDate])
const headers = [ const headers = [
{ title: "Activity Name", id: "aName" }, { title: "Activity Name", id: "aName" },
...@@ -155,8 +166,23 @@ function Exporttable() { ...@@ -155,8 +166,23 @@ function Exporttable() {
} }
} }
const disableBtn = (type) => {
if(!selectedEmployee || !fromDate || !toDate) {
return true
} else {
const {preEmployee, preFromDate, preToDate} = preState;
if(type === 'view'){
if(preEmployee === selectedEmployee && fromDate === preFromDate && toDate === preToDate) {
return true;
}
} else {
if((preEmployee !== selectedEmployee && fromDate !== preFromDate && toDate !== preToDate) || activitiesData.length === 0) {
return true;
}
}
}
}
if (reportees?.length > 0) {
return ( return (
<div> <div>
<div className={` overflow-auto sm:rounded-lg p-4 bg-[#E9EDEE]`}> <div className={` overflow-auto sm:rounded-lg p-4 bg-[#E9EDEE]`}>
...@@ -219,19 +245,22 @@ function Exporttable() { ...@@ -219,19 +245,22 @@ function Exporttable() {
</div> </div>
<div className="flex"> <div className="flex">
<button <button
disabled={!fromDate || !selectedEmployee || !toDate} // disabled={!fromDate || !selectedEmployee || !toDate}
className={`px-8 py-2 ml-5 w-[100px] h-[40px] bg-blue-500 text-white font-semibold rounded-md disabled:bg-gray-400 ${selectedEmployee && fromDate && toDate ? "bg-blue-500" : "bg-gray-500" }`} disabled={disableBtn('view')}
onClick={(e) => handleView(e)} className="px-8 py-2 ml-5 w-[100px] h-[40px] bg-blue-500 text-white font-semibold rounded-md disabled:bg-gray-400"
onClick={(e) => handleView(e)}
> >
View View
</button> </button>
<button <button
onClick={getPdfList} onClick={getPdfList}
disabled={pdfLoading || !fromDate || !selectedEmployee || !toDate} //disabled={pdfLoading || !fromDate || !selectedEmployee || !toDate}
disabled={disableBtn()}
type="button" type="button"
className="px-3 py-2 ml-5 min-w-[100px] disabled:bg-gray-400 h-[40px] bg-blue-500 font-semibold text-white rounded-md flex items-center justify-center" className="px-3 py-2 ml-5 min-w-[100px] disabled:bg-gray-400 h-[40px] bg-blue-500 font-semibold text-white rounded-md flex items-center justify-center"
> >
<DownloadIcon />
<span>{pdfLoading ? "Downloading..." : "Download"}</span> <span>{pdfLoading ? "Downloading..." : "Download"}</span>
{ pdfLoading && <div className="loading ml-2 "></div>} { pdfLoading && <div className="loading ml-2 "></div>}
</button> </button>
...@@ -240,36 +269,13 @@ function Exporttable() { ...@@ -240,36 +269,13 @@ function Exporttable() {
</form> </form>
</div> </div>
{ activitiesData?.length > 0 && ( {/* { activitiesData?.length > 0 && ( */}
<Table headers={headers} loading={loading} data={activitiesData} /> <Table headers={headers} loading={loading} data={activitiesData} />
)} {/* )} */}
{/* {
activitiesData?.length>0 && <div className='mx-20 items-center justify-center '>
<div className='mt-5'>
<div className='max-w-sm ml-4'>
<div className="relative">
<div className="absolute mt-3 flex items-center ps-3 pointer-events-none">
<svg className="w-4 h-4 text-gray-500 dark:text-gray-400" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 20 20">
<path stroke="currentColor" strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="m19 19-4-4m0-7A7 7 0 1 1 1 8a7 7 0 0 1 14 0Z" />
</svg>
</div>
<input type="search" id="default-search" className="block p-2 ps-10 text-sm text-gray-900 border border-gray-300 rounded-lg bg-gray-50 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500" placeholder="Search " />
</div>
</div>
</div>
} */}
</div> </div>
</div> </div>
); );
} else {
return (
<div classNameName="w-full h-full">
<p className="text-center align-middle pt-14 pb-14 text-blue-500 font-bold">
No records to display
</p>
</div>
);
}
} }
export default Exporttable; export default Exporttable;
...@@ -81,7 +81,7 @@ function Viewreportee() { ...@@ -81,7 +81,7 @@ function Viewreportee() {
useEffect(() => { useEffect(() => {
if (user) { if (user) {
navigate(`/viewreportee`) // navigate(`/viewreportee`)
setOpen({ "accordianOne": false, "accordianTwo": false }) setOpen({ "accordianOne": false, "accordianTwo": false })
} else { } else {
navigate("/") navigate("/")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment