Skip to content

Commit 054f825

Browse files
committed
ft main admin dashboared
1 parent 5ffba90 commit 054f825

File tree

1 file changed

+13
-61
lines changed

1 file changed

+13
-61
lines changed

Diff for: src/Chart/LineChart.tsx

+13-61
Original file line numberDiff line numberDiff line change
@@ -14,51 +14,15 @@ import { UserInterface } from '../pages/TraineeAttendanceTracker';
1414
import { Organization } from '../components/Organizations';
1515

1616
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
4723
}
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+
`
6226

6327
interface AllOrgUsersInterface {
6428
totalUsers: number;
@@ -87,7 +51,6 @@ export function UserChart() {
8751
| 'dec'
8852
| null;
8953
users: number | null;
90-
organizations: number | null;
9154
}
9255

9356
interface RegistrationDataInterface {
@@ -106,26 +69,17 @@ export function UserChart() {
10669
const [selectedYear, setSelectedYear] = useState<number>();
10770
const [registrationYears, setRegistrationYears] = useState<number[]>();
10871

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);
11374

11475
useEffect(() => {
115-
getAllOrgUsers({
76+
getAllusers({
11677
fetchPolicy: 'network-only',
11778
onCompleted: (data) => {
11879
setAllOrgsUsers(data.getAllOrgUsers);
11980
},
12081
});
121-
122-
getRegistrationStats({
123-
fetchPolicy: 'network-only',
124-
onCompleted: (data) => {
125-
setRegistrationData(data.getRegistrationStats);
126-
},
127-
});
128-
}, [getAllOrgUsers, getRegistrationStats]);
82+
}, [getAllusers]);
12983

13084
useEffect(() => {
13185
const years = [new Date().getFullYear()];
@@ -160,12 +114,10 @@ export function UserChart() {
160114
{
161115
month: null,
162116
users: 0,
163-
organizations: 0,
164117
},
165118
...months.map((month) => ({
166119
month: month as RegistrationDataStatsInterface['month'],
167120
users: null,
168-
organizations: null,
169121
})),
170122
];
171123
if (registrationData) {
@@ -177,7 +129,7 @@ export function UserChart() {
177129
setSelectedRegistrationData(data);
178130
}, [selectedYear, registrationData]);
179131

180-
if (getAllOrgUsersLoading || getRegistrationStatsLoading) {
132+
if (getAllOrgUsersLoading) {
181133
return <div>Loading...</div>;
182134
}
183135

0 commit comments

Comments
 (0)