diff --git a/backend/src/db.ts b/backend/src/db.ts index 58d55c3..50a105d 100644 --- a/backend/src/db.ts +++ b/backend/src/db.ts @@ -10,6 +10,6 @@ export const appDataSource = new DataSource({ database: DB_NAME, password: DB_PASSWORD, ssl: false, - entities: Entities.MT, + entities: Entities.LOCAL_DATA, synchronize: false, }); diff --git a/frontend/src/components/Table.tsx b/frontend/src/components/Table.tsx index ca0471f..c8c48df 100644 --- a/frontend/src/components/Table.tsx +++ b/frontend/src/components/Table.tsx @@ -1,7 +1,8 @@ import * as React from 'react'; -import { DocumentNode, useQuery } from '@apollo/client'; +import { useQuery } from '@apollo/client'; import { useState } from 'react'; -import { User, UserMT } from '../queries/types'; +import { User } from '../queries/types'; +import { GET_USERS } from '../queries/user'; type Checkbox = { onClick: () => void; @@ -17,17 +18,13 @@ const Checkbox: React.FC = ({ onClick }) => { ); }; -type Table = { - query: DocumentNode; -} - -export const Table: React.FC = ({ query }) => { - const { loading, error, data } = useQuery(query); +export const Table = () => { + const { loading, error, data } = useQuery(GET_USERS); const [isTableShown, setIsTableShown] = useState(false); if (loading) return

Loading...

; if (error) return

Upps...There is an error. :(

; - const users = data?.getUsers || data?.getUsersMT; + const users = data?.getUsers; const handleShowTable = () => { setIsTableShown(!isTableShown); @@ -41,24 +38,24 @@ export const Table: React.FC
= ({ query }) => {
- - - - - - + + + + + + - {users.map((user: User | UserMT) => { + {users.map((user: User) => { return ( - - - - - - + + + + + + ); })} @@ -69,4 +66,3 @@ export const Table: React.FC
idemailfirst_namelast_namejob_positionrole_idFirst NameLast nameCountryRoleInvitedRegistered
{user.id}{user.email}{user.first_name}{user.last_name}{user.job_position}{user.role_id}{user.name}{user.lastName}{user.country}{user.role}{user.isInvited.toString()}{user.isRegistered.toString()}
= ({ query }) => { ); }; - diff --git a/frontend/src/containers/Dashboard.tsx b/frontend/src/containers/Dashboard.tsx index 6a4be3c..3ddfcdb 100644 --- a/frontend/src/containers/Dashboard.tsx +++ b/frontend/src/containers/Dashboard.tsx @@ -1,23 +1,28 @@ +import { useQuery } from '@apollo/client'; +import { BarChart } from '../components/BarChart'; +import { LineChart } from '../components/LineChart'; +import { PieChart } from '../components/PieChart'; +import { RadarChart } from '../components/RadarChart'; import { SectionTitle } from '../components/SectionTitle'; import { Table } from '../components/Table'; -import { GET_USERS_MT } from '../queries/user'; - +import { GET_USERS_BY_COUNTRY, GET_USERS_BY_ROLE } from '../queries/user'; +import { Summary } from './Summary'; export const Dashboard = () => { - // const { loading: loadingUsersByCountry, error: errorUsersByCountry, data: usersByCountry } = useQuery(GET_USERS_BY_COUNTRY); - // const { loading: loadingUsersByRole, error: errorUsersByRole, data: usersByRole } = useQuery(GET_USERS_BY_ROLE); + const { loading: loadingUsersByCountry, error: errorUsersByCountry, data: usersByCountry } = useQuery(GET_USERS_BY_COUNTRY); + const { loading: loadingUsersByRole, error: errorUsersByRole, data: usersByRole } = useQuery(GET_USERS_BY_ROLE); - // if (loadingUsersByCountry && loadingUsersByRole) return

Loading...

; - // if (errorUsersByCountry || errorUsersByRole) return

Upps...There is an error. :(

; + if (loadingUsersByCountry && loadingUsersByRole) return

Loading...

; + if (errorUsersByCountry || errorUsersByRole) return

Upps...There is an error. :(

; return (
- {/* */} -
- {/* -
+ +
+ +
@@ -26,7 +31,7 @@ export const Dashboard = () => {
-
*/} + ); }; diff --git a/frontend/src/queries/types.ts b/frontend/src/queries/types.ts index 65aa00c..4593dab 100644 --- a/frontend/src/queries/types.ts +++ b/frontend/src/queries/types.ts @@ -1,22 +1,9 @@ -// export type User = { -// id: number; -// name: string; -// lastName: string; -// role: string; - -// } - -export interface User extends UserMT { +export type User = { + id: number; + name: string; + lastName: string; + role: string; country: string; isInvited: boolean; isRegistered: boolean; -} - -export type UserMT = { - id: number; - email: string; - first_name: string; - last_name: string; - job_position: string; - role_id: number; } \ No newline at end of file diff --git a/frontend/src/queries/user.ts b/frontend/src/queries/user.ts index 7d661bd..8eaa86a 100644 --- a/frontend/src/queries/user.ts +++ b/frontend/src/queries/user.ts @@ -14,19 +14,6 @@ export const GET_USERS = gql` } `; -export const GET_USERS_MT = gql` - query GetUsersMT { - getUsersMT { - id - email - first_name - last_name - job_position - role_id - } - } -`; - export const GET_USER_REGISTRATION_STATISTICS = gql` query GetUserRegistrationStatistics { getUserRegistrationStatistics {