Skip to content

Commit

Permalink
add Api call, clean statistics api call, change type type in teamComm…
Browse files Browse the repository at this point in the history
…ent.type
  • Loading branch information
SimNed committed Sep 10, 2024
1 parent b21bcb3 commit 418344f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 50 deletions.
49 changes: 0 additions & 49 deletions src/api/statistics/statistics.get.ts
Original file line number Diff line number Diff line change
@@ -1,52 +1,3 @@
// import { useQuery } from 'react-query';

// import { mockClassroomsStats, mockConnectionsStats } from 'src/components/admin/dashboard-statistics/mocks/mocks';
// import { axiosRequest } from 'src/utils/axiosRequest';
// import type { ClassroomsStats, ConnectionsStats } from 'types/statistics.type';

// const isDevelopment = process.env.NODE_ENV === 'development';

// async function getClassroomsStats(): Promise<ClassroomsStats[]> {
// if (isDevelopment) {
// // retourne mocks
// return new Promise((resolve) => {
// setTimeout(() => resolve(mockClassroomsStats), 500);
// });
// }

// return (
// await axiosRequest({
// method: 'GET',
// baseURL: '/api',
// url: '/statistics/classrooms',
// })
// ).data;
// }

// export const useGetClassroomsStats = () => {
// return useQuery(['classrooms-stats'], getClassroomsStats);
// };

// async function getConnectionsStats(): Promise<ConnectionsStats> {
// if (isDevelopment) {
// return new Promise((resolve) => {
// setTimeout(() => resolve(mockConnectionsStats), 500);
// });
// }

// return (
// await axiosRequest({
// method: 'GET',
// baseURL: '/api',
// url: '/statistics/connections',
// })
// ).data;
// }

// export const useGetConnectionsStats = () => {
// return useQuery(['connections-stats'], getConnectionsStats);
// };

import { useQuery } from 'react-query';

import { axiosRequest } from 'src/utils/axiosRequest';
Expand Down
18 changes: 18 additions & 0 deletions src/api/teamComment/teamComment.get.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { useQuery } from 'react-query';

import { axiosRequest } from 'src/utils/axiosRequest';
import type { TeamCommentInterface } from 'types/teamComment.type';

async function getTeamComments(): Promise<TeamCommentInterface> {
return (
await axiosRequest({
method: 'GET',
baseURL: '/api',
url: '/statistics/team-comments',
})
).data;
}

export const useGetSessionsStats = () => {
return useQuery(['team-comments'], () => getTeamComments());
};
2 changes: 1 addition & 1 deletion types/teamComment.type.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export interface TeamCommentInterface {
id: number;
type: number;
type: TeamCommentType;
createDate?: Date | string;
updateDate?: Date | string;
text: string;
Expand Down

0 comments on commit 418344f

Please sign in to comment.