Skip to content

Commit

Permalink
feat(statistics): new statistics section
Browse files Browse the repository at this point in the history
  • Loading branch information
daniele-dematteo committed Apr 4, 2024
1 parent 9c240f4 commit 5122071
Show file tree
Hide file tree
Showing 14 changed files with 1,501 additions and 118 deletions.
108 changes: 57 additions & 51 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 4 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,8 @@
"prepare": "husky install",
"commit": "commit",
"bump": "standard-version",
"lint:check": "eslint '**/*.{ts,tsx}'",
"lint": "npm run lint:check -- --fix",
"format:check": "prettier --check '**/*.{ts,tsx,md}'",
"format": "prettier --write '**/*.{ts,tsx,md}'",
"types:check": "tsc --noEmit",
"check": "npm run lint:check && npm run format:check && npm run types:check",
"postinstall": "react-native setup-ios-permissions && pod-install"
},
Expand All @@ -24,12 +21,11 @@
"@fortawesome/free-regular-svg-icons": "^6.2.1",
"@fortawesome/free-solid-svg-icons": "^6.2.1",
"@fortawesome/react-native-fontawesome": "^0.3.0",
"@gorhom/bottom-sheet": "^4.5.1",
"@kyupss/native-swipeable": "^1.0.1",
"@gorhom/bottom-sheet": "^4.6.1",
"@miblanchard/react-native-slider": "^2.2.0",
"@openspacelabs/react-native-zoomable-view": "^2.1.5",
"@orama/orama": "^2.0.0-beta.8",
"@polito/api-client": "^1.0.0-ALPHA.58",
"@polito/api-client": "^1.0.0-ALPHA.59",
"@react-native-async-storage/async-storage": "^1.17.11",
"@react-native-clipboard/clipboard": "^1.12.1",
"@react-native-community/blur": "^4.3.0",
Expand Down Expand Up @@ -74,11 +70,13 @@
"react-native-file-viewer": "^2.1.5",
"react-native-fs": "^2.20.0",
"react-native-gesture-handler": "^2.13.1",
"react-native-gifted-charts": "^1.4.8",
"react-native-html-to-pdf": "^0.12.0",
"react-native-image-crop-picker": "^0.38.0",
"react-native-keyboard-accessory": "^0.1.16",
"react-native-keyboard-aware-scroll-view": "^0.9.5",
"react-native-keychain": "^8.1.1",
"react-native-linear-gradient": "^2.8.3",
"react-native-mime-types": "^2.3.0",
"react-native-modal": "^13.0.1",
"react-native-override-color-scheme": "^1.0.3",
Expand Down
29 changes: 28 additions & 1 deletion src/core/queries/offeringHooks.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { Degree as ApiDegree, OfferingApi } from '@polito/api-client';
import {
Degree as ApiDegree,
CourseStatistics,
OfferingApi,
} from '@polito/api-client';
import { GetCourseStatisticsRequest } from '@polito/api-client/apis/OfferingApi';
import { MenuAction } from '@react-native-menu/menu';
import { useQuery } from '@tanstack/react-query';

Expand Down Expand Up @@ -84,3 +89,25 @@ export const useGetOfferingCourse = ({
}),
);
};

export const useGetCourseStatistics = ({
courseShortcode,
teacherId,
year,
}: GetCourseStatisticsRequest) => {
const offeringClient = useOfferingClient();

return useQuery<CourseStatistics>(
compact([
DEGREES_QUERY_PREFIX,
COURSES_QUERY_PREFIX,
courseShortcode,
year,
teacherId,
]),
() =>
offeringClient
.getCourseStatistics({ courseShortcode, teacherId, year })
.then(pluckData),
);
};
Loading

0 comments on commit 5122071

Please sign in to comment.