1
1
import { TabsSection } from './components/TabsSection.js' ;
2
2
import { UsersSection } from './components/UsersSection.js' ;
3
3
import { UserDetailsSection } from './components/UserDetailsSection.js' ;
4
- import { getUsers , mockUsersData } from './utils/util.js' ;
4
+ import { getUsers } from './utils/util.js' ;
5
5
import { NoUserFound } from './components/NoUserFound.js' ;
6
6
7
7
const { createElement, rerender } = react ;
@@ -26,19 +26,21 @@ let showUser = 0;
26
26
the API pagination issue is resolved. Currently testing pagination using mock data.
27
27
*/
28
28
// usersData[activeTab] = await getUsers(activeTab);
29
+ // add feature flag(feature should be only visible when query params dev=true)
29
30
30
- export const fetchUsers = async ( tabId , page = 1 ) => {
31
+ export const paginateFetchedUsers = async ( tabId , page = 1 ) => {
31
32
if ( isLoading ) {
32
33
return ;
33
34
}
35
+ usersData [ activeTab ] = await getUsers ( activeTab ) ;
34
36
35
37
isLoading = true ;
36
38
37
39
try {
38
40
const start = ( page - 1 ) * INITIAL_USERS ;
39
41
const end = start + INITIAL_USERS ;
40
42
41
- const newUsers = mockUsersData [ tabId ] . slice ( start , end ) ;
43
+ const newUsers = usersData [ tabId ] . slice ( start , end ) ;
42
44
43
45
if ( newUsers . length > 0 ) {
44
46
if ( page === 1 ) {
@@ -99,7 +101,7 @@ export const App = () => {
99
101
users,
100
102
showUser,
101
103
handleUserSelected,
102
- fetchUsers ,
104
+ paginateFetchedUsers ,
103
105
activeTab,
104
106
currentPage,
105
107
isLoading,
@@ -113,4 +115,4 @@ export const App = () => {
113
115
] ) ;
114
116
} ;
115
117
116
- fetchUsers ( activeTab , 1 ) ;
118
+ paginateFetchedUsers ( activeTab , 1 ) ;
0 commit comments