@@ -14,51 +14,15 @@ import { UserInterface } from '../pages/TraineeAttendanceTracker';
14
14
import { Organization } from '../components/Organizations' ;
15
15
16
16
export function UserChart ( ) {
17
- const GET_ALL_ORG_USERS = gql `
18
- query GetAllOrgUsers {
19
- getAllOrgUsers {
20
- totalUsers
21
- organizations {
22
- organization {
23
- id
24
- name
25
- description
26
- admin {
27
- id
28
- email
29
- profile {
30
- name
31
- phoneNumber
32
- }
33
- }
34
- status
35
- }
36
- members {
37
- email
38
- profile {
39
- name
40
- }
41
- }
42
- monthPercentage
43
- loginsCount
44
- recentLocation
45
- }
46
- }
17
+ const GetAllUsers = gql `
18
+ query GetAllUsers($orgToken: String!) {
19
+ getAllUsers(orgToken: $orgToken) {
20
+ id
21
+ firstName
22
+ lastName
47
23
}
48
- ` ;
49
-
50
- const GET_REGISTRATION_STATS = gql `
51
- query GetRegistrationStats {
52
- getRegistrationStats {
53
- year
54
- stats {
55
- month
56
- users
57
- organizations
58
- }
59
- }
60
- }
61
- ` ;
24
+ }
25
+ `
62
26
63
27
interface AllOrgUsersInterface {
64
28
totalUsers : number ;
@@ -87,7 +51,6 @@ export function UserChart() {
87
51
| 'dec'
88
52
| null ;
89
53
users : number | null ;
90
- organizations : number | null ;
91
54
}
92
55
93
56
interface RegistrationDataInterface {
@@ -106,26 +69,17 @@ export function UserChart() {
106
69
const [ selectedYear , setSelectedYear ] = useState < number > ( ) ;
107
70
const [ registrationYears , setRegistrationYears ] = useState < number [ ] > ( ) ;
108
71
109
- const [ getAllOrgUsers , { loading : getAllOrgUsersLoading } ] =
110
- useLazyQuery ( GET_ALL_ORG_USERS ) ;
111
- const [ getRegistrationStats , { loading : getRegistrationStatsLoading } ] =
112
- useLazyQuery ( GET_REGISTRATION_STATS ) ;
72
+ const [ getAllusers , { loading : getAllOrgUsersLoading } ] =
73
+ useLazyQuery ( GetAllUsers ) ;
113
74
114
75
useEffect ( ( ) => {
115
- getAllOrgUsers ( {
76
+ getAllusers ( {
116
77
fetchPolicy : 'network-only' ,
117
78
onCompleted : ( data ) => {
118
79
setAllOrgsUsers ( data . getAllOrgUsers ) ;
119
80
} ,
120
81
} ) ;
121
-
122
- getRegistrationStats ( {
123
- fetchPolicy : 'network-only' ,
124
- onCompleted : ( data ) => {
125
- setRegistrationData ( data . getRegistrationStats ) ;
126
- } ,
127
- } ) ;
128
- } , [ getAllOrgUsers , getRegistrationStats ] ) ;
82
+ } , [ getAllusers ] ) ;
129
83
130
84
useEffect ( ( ) => {
131
85
const years = [ new Date ( ) . getFullYear ( ) ] ;
@@ -160,12 +114,10 @@ export function UserChart() {
160
114
{
161
115
month : null ,
162
116
users : 0 ,
163
- organizations : 0 ,
164
117
} ,
165
118
...months . map ( ( month ) => ( {
166
119
month : month as RegistrationDataStatsInterface [ 'month' ] ,
167
120
users : null ,
168
- organizations : null ,
169
121
} ) ) ,
170
122
] ;
171
123
if ( registrationData ) {
@@ -177,7 +129,7 @@ export function UserChart() {
177
129
setSelectedRegistrationData ( data ) ;
178
130
} , [ selectedYear , registrationData ] ) ;
179
131
180
- if ( getAllOrgUsersLoading || getRegistrationStatsLoading ) {
132
+ if ( getAllOrgUsersLoading ) {
181
133
return < div > Loading...</ div > ;
182
134
}
183
135
0 commit comments