Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nisum-scorecard
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Venkaiah Naidu Singamchetty
nisum-scorecard
Commits
755f2adb
Commit
755f2adb
authored
Mar 22, 2024
by
Ramadevi Guduri
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
reportsuiand slice
parent
09e51d5b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
262 additions
and
192 deletions
+262
-192
index.jsx
src/pages/reportexport/index.jsx
+241
-143
exporttableslice.js
src/redux/reducers/exporttableslice.js
+21
-49
No files found.
src/pages/reportexport/index.jsx
View file @
755f2adb
import
React
,
{
useEffect
,
useState
}
from
'react'
import
React
,
{
useEffect
,
useState
}
from
"react"
;
import
{
useDispatch
,
useSelector
}
from
'react-redux'
import
{
useDispatch
,
useSelector
}
from
"react-redux"
;
import
{
fetchReportstableData
}
from
'../../redux/reducers/exporttableslice'
;
import
{
import
{
setPastMonth
,
setPastTwoMonths
,
setPastsixMonths
,
setPasttwelvemonths
}
from
'../../redux/reducers/exporttableslice'
;
fetchReportstableData
,
fetchReportesActivitiesData
,
}
from
"../../redux/reducers/exporttableslice"
;
import
{
fetchReportees
}
from
"../../redux/reducers/reporteesSlice"
;
import
{
convertUTCToLocal
}
from
"../../utils/commonFunctions"
;
import
Table
from
"../../components/table"
;
function
Exporttable
()
{
function
Exporttable
()
{
const
dispatch
=
useDispatch
()
const
dispatch
=
useDispatch
();
const
{
user
}
=
useSelector
((
state
)
=>
state
.
userDetails
);
const
{
user
}
=
useSelector
((
state
)
=>
state
.
userDetails
);
const
{
totalReporteesData
}
=
useSelector
((
state
)
=>
state
.
totalreportees
);
const
{
activitiesData
}
=
useSelector
((
state
)
=>
state
.
totalreportees
);
const
[
selectedOption
,
setSelectedOption
]
=
useState
(
''
);
const
{
reportees
,
loading
,
totalCount
,
currPage
,
pagesCount
}
=
useSelector
(
(
state
)
=>
state
.
reportees
);
const
[
selectedEmployee
,
setSelectedEmployee
]
=
useState
(
0
);
const
[
fromDate
,
setFromDate
]
=
useState
(
""
);
const
[
toDate
,
setToDate
]
=
useState
(
""
);
const
[
inputValue
,
setInputValue
]
=
useState
(
''
);
console
.
log
(
activitiesData
,
"activitiesData"
);
const
calculateDateRange
=
(
monthsAgo
)
=>
{
const
toDate
=
new
Date
().
toISOString
().
split
(
"T"
)[
0
];
const
fromDate
=
new
Date
();
fromDate
.
setMonth
(
fromDate
.
getMonth
()
-
monthsAgo
);
const
fromDateFormatted
=
fromDate
.
toISOString
().
split
(
"T"
)[
0
];
return
{
fromDate
:
fromDateFormatted
,
toDate
};
};
const
handleDropdownChange
=
(
event
)
=>
{
const
handleDropdownChange
=
(
event
)
=>
{
const
selectedValue
=
event
.
target
.
value
;
const
selectedValue
=
event
.
target
.
value
;
setSelectedOption
(
selectedValue
);
let
fromDate
,
toDate
;
if
(
selectedValue
===
'pastMonth'
)
{
dispatch
(
setPastMonth
());
if
(
selectedValue
===
"pastMonth"
)
{
}
else
if
(
selectedValue
===
'pastthreeMonth'
)
{
({
fromDate
,
toDate
}
=
calculateDateRange
(
1
));
dispatch
(
setPastTwoMonths
());
}
else
if
(
selectedValue
===
"pastthreeMonth"
)
{
}
else
if
(
selectedValue
===
'pastsixMonth'
){
({
fromDate
,
toDate
}
=
calculateDateRange
(
3
));
dispatch
(
setPastsixMonths
());
}
else
if
(
selectedValue
===
"pastsixMonth"
)
{
}
else
if
(
selectedValue
===
'pasttwelvemonth'
)
({
fromDate
,
toDate
}
=
calculateDateRange
(
6
));
dispatch
(
setPasttwelvemonths
());
}
else
if
(
selectedValue
===
"pasttwelvemonth"
)
{
({
fromDate
,
toDate
}
=
calculateDateRange
(
12
));
}
setFromDate
(
fromDate
);
setToDate
(
toDate
);
};
const
handleView
=
(
e
)
=>
{
e
.
preventDefault
();
let
data
=
{
empId
:
Number
(
selectedEmployee
),
fromDate
:
fromDate
,
toDate
:
toDate
,
};
console
.
log
(
data
,
"data"
);
dispatch
(
fetchReportesActivitiesData
(
data
));
};
};
useEffect
(()
=>
{
dispatch
(
fetchReportstableData
({
reportees
:
user
.
reportees
,
page
:
1
,
perPage
:
user
.
reportees
.
length
}))
},
[
user
]);
if
(
totalReporteesData
?.
length
>
0
)
return
(
<
div
>
<
div
className=
""
>
<
div
className=
"text-blue-800 py-3 pl-2 text-center"
>
Genarate Report
</
div
>
<
div
>
<
form
className=
" p-2 text-[12px]"
>
<
div
className=
"flex items-center justify-evenly "
>
<
div
className=
'flex items-center'
>
<
label
htmlFor=
"countries"
className=
'font-semibold'
>
Select Employee:
</
label
>
<
select
className=
"bg-gray-50 ml-2 w-[200px] border border-gray-300 text-gray-900 text-sm rounded-sm focus:ring-blue-500 focus:border-blue-500 block p-2.5 dark:bg-gray-700"
>
<
option
id=
""
value=
""
>
Select
</
option
>
{
totalReporteesData
&&
totalReporteesData
.
map
((
reportee
)
=>
<
option
>
{
reportee
?.
empName
}
</
option
>)
}
</
select
>
</
div
>
<
div
className=
'flex items-center'
>
<
label
htmlFor=
"countries"
className=
'font-semibold'
>
Select Period:
</
label
>
<
select
value=
{
selectedOption
}
onChange=
{
handleDropdownChange
}
className=
"bg-gray-50 ml-2 w-[200px] border border-gray-300 text-gray-900 text-sm focus:ring-blue-500 focus:border-blue-500 block p-2.5 dark:bg-gray-700 "
>
<
option
id=
""
value=
""
>
Select
</
option
>
<
option
id=
""
value=
"pastMonth"
>
Past 1 months
</
option
>
<
option
id=
""
value=
"pastthreeMonth"
>
Past 3 months
</
option
>
<
option
id=
""
value=
"pastsixMonth"
>
Past 6 months
</
option
>
<
option
id=
""
value=
"pasttwelvemonth"
>
Past year
</
option
>
</
select
>
</
div
>
<
div
className=
'flex'
>
<
button
className=
"px-8 py-2 ml-5 w-[100px] h-[40px] bg-green-500 text-white font-semibold rounded-md"
>
View
</
button
>
<
button
type=
"button"
className=
"px-3 py-2 ml-5 w-[100px] h-[40px] bg-red-500 font-semibold text-white rounded-md"
>
Download
</
button
>
</
div
>
</
div
>
</
form
>
useEffect
(()
=>
{
</
div
>
if
(
user
)
{
let
data
=
{
reportees
:
user
.
reportees
,
page
:
1
,
perPage
:
user
.
reportees
.
length
,
};
dispatch
(
fetchReportees
(
data
));
}
},
[
user
]);
const
headers
=
[
{
title
:
"Activity Name"
,
id
:
"aName"
},
{
title
:
"Date"
,
id
:
"recorded_date"
,
render
:
(
value
)
=>
convertUTCToLocal
(
value
),
},
{
title
:
"Rated By"
,
id
:
"ratedBy"
},
{
title
:
"Score"
,
id
:
"score"
,
render
:
(
value
)
=>
(
<
div
className=
"w-[35px] px-3 bg-blue-400 rounded-full text-white font-bold text-center p-[4px]"
>
{
value
}
</
div
>
),
},
{
title
:
"Comments"
,
id
:
"comments"
,
render
:
(
value
)
=>
(
<
span
className=
"listData"
title=
{
value
}
>
{
value
}
</
span
>
),
},
];
if
(
reportees
?.
length
>
0
)
{
return
(
<
div
>
<
div
className=
{
` overflow-auto sm:rounded-lg p-4 bg-gray-100`
}
>
<
div
className=
"text-blue-800 py-3 pl-2 text-center"
>
{
" "
}
Genarate Report
</
div
>
<
div
>
<
form
className=
" p-2 text-[12px]"
>
<
div
className=
"flex items-center justify-evenly "
>
<
div
className=
"flex items-center"
>
<
label
htmlFor=
"countries"
className=
"font-semibold"
>
Select Employee:
{
" "
}
</
label
>
<
select
onChange=
{
(
e
)
=>
setSelectedEmployee
(
e
.
target
.
value
)
}
value=
{
selectedEmployee
}
className=
"bg-gray-50 ml-2 w-[200px] border border-gray-300 text-gray-900 text-sm rounded-sm focus:ring-blue-500 focus:border-blue-500 block p-2.5 dark:bg-gray-700"
>
<
option
id=
""
value=
""
>
Select
</
option
>
{
reportees
&&
reportees
.
map
((
reportee
)
=>
(
<
option
key=
{
reportee
.
empId
}
id=
{
reportee
.
empId
}
value=
{
reportee
.
empId
}
>
{
reportee
?.
empName
}
</
option
>
))
}
</
select
>
</
div
>
<
div
className=
"flex items-center"
>
<
label
htmlFor=
"countries"
className=
"font-semibold"
>
Select Period:
</
label
>
<
select
onChange=
{
handleDropdownChange
}
className=
"bg-gray-50 ml-2 w-[200px] border border-gray-300 text-gray-900 text-sm focus:ring-blue-500 focus:border-blue-500 block p-2.5 dark:bg-gray-700 "
>
<
option
id=
""
value=
""
>
Select
</
option
>
<
option
id=
""
value=
"pastMonth"
>
Past 1 months
</
option
>
<
option
id=
""
value=
"pastthreeMonth"
>
Past 3 months
</
option
>
<
option
id=
""
value=
"pastsixMonth"
>
Past 6 months
</
option
>
<
option
id=
""
value=
"pasttwelvemonth"
>
Past year
</
option
>
</
select
>
</
div
>
<
div
className=
"flex"
>
<
button
className=
"px-8 py-2 ml-5 w-[100px] h-[40px] bg-blue-500 text-white font-semibold rounded-md"
onClick=
{
(
e
)
=>
handleView
(
e
)
}
>
View
</
button
>
<
button
disabled=
{
true
}
type=
"button"
className=
"px-3 py-2 ml-5 w-[100px] h-[40px] bg-gray-500 font-semibold text-white rounded-md"
>
Download
</
button
>
</
div
>
</
div
>
<
div
className=
'mx-20 items-center justify-center '
>
</
div
>
<
div
className=
'mt-5'
>
</
form
>
<
div
className=
'max-w-sm ml-4'
>
</
div
>
<
div
className=
"relative"
>
<
div
className=
"absolute mt-3 flex items-center ps-3 pointer-events-none"
>
{
activitiesData
?.
length
>
0
&&
(
<
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"
>
<
Table
headers=
{
headers
}
loading=
{
loading
}
data=
{
activitiesData
}
/>
<
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
>
{
/* {
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>
<
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 className="p-4">
</
div
>
<table className="w-full text-sm text-left rtl:text-right text-gray-500 bg-transparent justify-center border-separate border-spacing-y-2">
<
div
className=
"p-4"
>
<thead className="text-xs text-gray-700 uppercase bg-gray-50">
<
table
className=
"border-2 border-collapse w-full border-[#B7B7B7]"
>
<tr className="mb-2">
<
thead
>
<
tr
>
<th className="border-2 p-2 border-[#B7B7B7] text-start font-medium bg-[#D9D9D9] w-4/12">
ACTIVITY NAME
<
th
className=
"border-2 p-2 border-[#B7B7B7] text-start font-medium bg-[#D9D9D9] w-4/12"
>
</th>
ACTIVITY NAME
<th className="border-2 p-2 border-[#B7B7B7] text-start font-medium bg-[#D9D9D9] w-4/12 ">
</
th
>
DATE
<
th
className=
"border-2 p-2 border-[#B7B7B7] text-start font-medium bg-[#D9D9D9] w-4/12 "
>
</th>
DATE
<th className="border-2 p-2 border-[#B7B7B7] text-start font-medium bg-[#D9D9D9] w-4/12 " >
</
th
>
SCORE
<
th
className=
"border-2 p-2 border-[#B7B7B7] text-start font-medium bg-[#D9D9D9] w-4/12 "
>
</th>
SCORE
<th className="border-2 p-2 border-[#B7B7B7] text-start font-medium bg-[#D9D9D9] w-4/12 " >
</
th
>
COMMENTS
<
th
className=
"border-2 p-2 border-[#B7B7B7] text-start font-medium bg-[#D9D9D9] w-4/12 "
>
</th>
COMMENTS
</
th
>
</tr>
</thead>
</
tr
>
<tbody>
</
thead
>
<
tbody
>
{activitiesData.map((activitie)=>
<
tr
>
<tr className="bg-white hover:bg-gray-300 ">
<td className="px-6 py-2 " >{activitie.aName}</td>
<
td
className=
"border-2 p-2 border-[#B7B7B7] bg-white"
>
<td className="px-6 py-2 " >{convertUTCToLocal(activitie.recorded_date)}</td>
ABC
<td className="px-6 py-2 " >{activitie.score}</td>
</
td
>
<td className="px-6 py-2 " >{activitie.comments}</td>
<
td
className=
"border-2 p-2 border-[#B7B7B7] bg-white"
>
01/01/2024
</tr>
</
td
>
)}
<
td
className=
"border-2 p-2 border-[#B7B7B7] bg-white"
>
5
</
td
>
</tbody>
<
td
className=
"border-2 p-2 border-[#B7B7B7] bg-white"
>
</table>
VERY GOOD
</
td
>
</
tr
>
<
tr
>
<
td
className=
"border-2 p-2 border-[#B7B7B7] bg-white"
>
XYZ
</
td
>
<
td
className=
"border-2 p-2 border-[#B7B7B7] bg-white"
>
01/01/2024
</
td
>
<
td
className=
"border-2 p-2 border-[#B7B7B7] bg-white"
>
4
</
td
>
<
td
className=
"border-2 p-2 border-[#B7B7B7] bg-white"
>
GOOD
</
td
>
</
tr
>
</
tbody
>
</
table
>
</
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
>
</
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
;
\ No newline at end of file
src/redux/reducers/exporttableslice.js
View file @
755f2adb
import
{
createSlice
,
createAsyncThunk
}
from
"@reduxjs/toolkit"
;
import
{
createSlice
,
createAsyncThunk
}
from
"@reduxjs/toolkit"
;
import
{
base_url
}
from
"../../utils/constants"
;
import
{
base_url
}
from
"../../utils/constants"
;
import
axios
from
"axios"
;
import
axios
from
"axios"
;
const
initialState
=
{
const
initialState
=
{
totalReporteesData
:
[],
//
totalReporteesData: [],
activitiesData
:
null
,
activitiesData
:
[]
,
loading
:
false
,
loading
:
false
,
error
:
null
,
error
:
null
,
fromDate
:
null
,
toDate
:
null
,
};
};
export
const
fetchReportstableData
=
createAsyncThunk
(
"getreportees"
,
async
(
data
)
=>
{
return
await
axios
.
post
(
`
${
base_url
}
/getreportees`
,
data
)
export
const
fetchReportesActivitiesData
=
createAsyncThunk
(
"gettotalactivities"
,
async
(
data
)
=>
{
return
await
axios
.
post
(
`
${
base_url
}
/getActivities`
,
data
)
.
then
((
response
)
=>
response
.
data
);
.
then
((
response
)
=>
response
.
data
);
});
});
const
exporttableSlice
=
createSlice
({
const
exporttableSlice
=
createSlice
({
name
:
"totalReportees"
,
name
:
"totalReportees"
,
initialState
,
initialState
,
...
@@ -23,57 +24,28 @@ const exporttableSlice = createSlice({
...
@@ -23,57 +24,28 @@ const exporttableSlice = createSlice({
resetReporteesTableData
:()
=>
{
resetReporteesTableData
:()
=>
{
return
initialState
return
initialState
},
},
setPastMonth
:
(
state
)
=>
{
const
toDate
=
new
Date
();
const
fromDate
=
new
Date
();
fromDate
.
setMonth
(
fromDate
.
getMonth
()
-
1
);
state
.
fromDate
=
fromDate
;
state
.
toDate
=
toDate
;
console
.
log
(
fromDate
,
toDate
)
},
setPastTwoMonths
:
(
state
)
=>
{
const
toDate
=
new
Date
();
const
fromDate
=
new
Date
();
fromDate
.
setMonth
(
fromDate
.
getMonth
()
-
3
);
state
.
fromDate
=
fromDate
;
state
.
toDate
=
toDate
;
console
.
log
(
fromDate
,
toDate
)
},
setPastsixMonths
:
(
state
)
=>
{
const
toDate
=
new
Date
();
const
fromDate
=
new
Date
();
fromDate
.
setMonth
(
fromDate
.
getMonth
()
-
6
);
state
.
fromDate
=
fromDate
;
state
.
toDate
=
toDate
;
console
.
log
(
fromDate
,
toDate
)
},
setPasttwelvemonths
:
(
state
)
=>
{
const
toDate
=
new
Date
();
const
fromDate
=
new
Date
();
fromDate
.
setMonth
(
fromDate
.
getMonth
()
-
12
);
state
.
fromDate
=
fromDate
;
state
.
toDate
=
toDate
;
console
.
log
(
fromDate
,
toDate
)
},
},
},
extraReducers
:
(
builder
)
=>
{
extraReducers
:
(
builder
)
=>
{
builder
.
addCase
(
fetchReportstableData
.
pending
,
(
state
)
=>
{
builder
.
addCase
(
fetchReportesActivitiesData
.
pending
,
(
state
)
=>
{
state
.
loading
=
true
;
state
.
loading
=
true
;
state
.
error
=
"pending"
;
state
.
error
=
"pending"
;
});
});
builder
.
addCase
(
fetchReportstableData
.
fulfilled
,
(
state
,
action
)
=>
{
builder
.
addCase
(
fetchReportesActivitiesData
.
fulfilled
,
(
state
,
action
)
=>
{
console
.
log
(
action
.
payload
.
activities
)
state
.
loading
=
false
;
state
.
loading
=
false
;
state
.
totalReporteesData
=
action
.
payload
.
data
;
state
.
activitiesData
=
action
.
payload
.
activities
;
state
.
error
=
""
;
state
.
error
=
""
;
});
});
builder
.
addCase
(
fetchReport
stable
Data
.
rejected
,
(
state
,
action
)
=>
{
builder
.
addCase
(
fetchReport
esActivities
Data
.
rejected
,
(
state
,
action
)
=>
{
state
.
loading
=
false
;
state
.
loading
=
false
;
state
.
totalReporte
esData
=
null
;
state
.
activiti
esData
=
null
;
state
.
error
=
action
.
error
||
"Something went wrong!"
;
state
.
error
=
action
.
error
||
"Something went wrong!"
;
});
});
},
},
});
});
export
const
{
resetReporteesTableData
,
setPastMonth
,
setPastTwoMonths
,
setPastsixMonths
,
setPasttwelvemonths
}
=
exporttableSlice
.
actions
;
export
const
{
resetReporteesTableData
}
=
exporttableSlice
.
actions
;
export
default
exporttableSlice
.
reducer
;
export
default
exporttableSlice
.
reducer
;
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment