File tree Expand file tree Collapse file tree 2 files changed +15
-7
lines changed Expand file tree Collapse file tree 2 files changed +15
-7
lines changed Original file line number Diff line number Diff line change @@ -18,11 +18,6 @@ const tableHeader = {
1818 company : "Company" ,
1919} ;
2020
21- /*
22- -Search - completed
23- -Sort - in progress
24- */
25-
2621const TableView = ( props ) => {
2722 const { getList, userList } = props ;
2823 const [ searchQuery , setSearchQuery ] = useState ( "" ) ;
@@ -36,9 +31,16 @@ const TableView = (props) => {
3631 } , [ getList ] ) ;
3732
3833 useEffect ( ( ) => {
34+ setInitialTableState ( ) ;
35+ } , [ userList ] ) ;
36+
37+ const setInitialTableState = ( ) => {
38+ setSearchQuery ( "" ) ;
39+ setPage ( 1 ) ;
40+ setSortKey ( "" ) ;
3941 const updatedUserList = [ ...userList ] ;
4042 setItems ( updatedUserList . slice ( 0 , itemsPerPage ) ) ;
41- } , [ userList ] ) ;
43+ } ;
4244
4345 const handleChangePage = ( pageNumber ) => {
4446 const updatedItems = [ ...userList ] ;
@@ -103,12 +105,13 @@ const TableView = (props) => {
103105 return (
104106 < div className = { styles . container } >
105107 < div className = "table-view" >
106- < div className = "search" >
108+ < div className = { styles . headerContainer } >
107109 < input
108110 placeholder = "Search by Name"
109111 value = { searchQuery }
110112 onChange = { handleSearch }
111113 />
114+ < button onClick = { setInitialTableState } > Reset</ button >
112115 </ div >
113116 < Table >
114117 < thead >
Original file line number Diff line number Diff line change 1313 transform : rotate (270deg );
1414}
1515
16+ .headerContainer {
17+ padding : 10px ;
18+ display : flex;
19+ justify-content : space-between;
20+ }
You can’t perform that action at this time.
0 commit comments