diff --git a/src/api/getReservationsList.ts b/src/api/getReservationsList.ts index 51ff9351b631e70ed49d5d42a2bceb935fe2368e..1730150ca21d1955ecf837887af042e55754fc26 100644 --- a/src/api/getReservationsList.ts +++ b/src/api/getReservationsList.ts @@ -1,5 +1,10 @@ import axios from 'axios'; import { ReservationType } from 'types/ReservationType'; +/** + * @async + * Perform GET to get a list of all the reservations inserted by the current user. + * @returns a list of reservations. + */ export const getReservationsList = async (): Promise<ReservationType[]> => - axios(`/api/web/reservations/?field=trip_stages`).then((res) => res.data); + axios(`/api/web/reservations?fields=trip_stages`).then((res) => res.data); diff --git a/src/api/getRoleObject.ts b/src/api/getRoleObject.ts index d1cee6561a09701fed003bfb94c20f33ff13cc2f..0664db03e360e7ac9bf8a5216ab43d85965a0d89 100644 --- a/src/api/getRoleObject.ts +++ b/src/api/getRoleObject.ts @@ -1,5 +1,9 @@ import axios from 'axios'; import { RoleObjectType } from '../types/RoleObjectType'; +/** + * + * @returns {RoleObjectType} + */ export const getRoleObject = async (): Promise<RoleObjectType> => axios('/api/web/login/get_role').then((res) => res.data.roleObject); diff --git a/src/api/getSeniorList.ts b/src/api/getSeniorList.ts deleted file mode 100644 index 271854d863e02875737f0fe2fafd94cddefaa4e3..0000000000000000000000000000000000000000 --- a/src/api/getSeniorList.ts +++ /dev/null @@ -1,9 +0,0 @@ -import axios from 'axios'; -import { SeniorSearchQueryType } from '../types/SeniorSearchQueryType'; - -export const getSeniorList = async ( - name: string, -): Promise<SeniorSearchQueryType[]> => - axios - .get(`/api/web/seniors/by_name/${name}?fields=user,id,member_card_number`) - .then((res) => res.data); diff --git a/src/api/getSeniorListByCard.ts b/src/api/getSeniorListByCard.ts index ed9bfec1ee2d4494fff12c8441ae5c7f2e457217..e8a066f6b013d17986d849be163fdcb3f3b3f5ed 100644 --- a/src/api/getSeniorListByCard.ts +++ b/src/api/getSeniorListByCard.ts @@ -1,6 +1,12 @@ import axios from 'axios'; import { SeniorSearchQueryType } from '../types/SeniorSearchQueryType'; +/** + * @async + * Search and return a senior list linked by the card. + * @param card card number to search. + * @returns {SeniorSearchQueryType[]} list of seniors. + */ export const getSeniorListByCard = async ( card: number, ): Promise<SeniorSearchQueryType[]> => diff --git a/src/api/getSeniorListByLastName.ts b/src/api/getSeniorListByLastName.ts new file mode 100644 index 0000000000000000000000000000000000000000..28c88dc2a0f10cc209fdd218431cbb5204dd8018 --- /dev/null +++ b/src/api/getSeniorListByLastName.ts @@ -0,0 +1,17 @@ +import axios from 'axios'; +import { SeniorSearchQueryType } from '../types/SeniorSearchQueryType'; + +/** + * @async + * Search and return a senior list linked to the last name. + * @param lastName to search. + * @returns {SeniorSearchQueryType[]} list of seniors. + */ +export const getSeniorListByLastName = async ( + lastName: string, +): Promise<SeniorSearchQueryType[]> => + axios + .get( + `/api/web/seniors/by_name/${lastName}?fields=user,id,member_card_number`, + ) + .then((res) => res.data); diff --git a/src/api/postCredentials.ts b/src/api/postCredentials.ts index 78a9b0b254fc6430137f9c4be4b18548cd97123c..c9aa54f098b9f9629b34163745fd8f01067b01ea 100644 --- a/src/api/postCredentials.ts +++ b/src/api/postCredentials.ts @@ -1,6 +1,12 @@ import axios from 'axios'; import { CredentialsType } from 'types/CredentialsType'; +/** + * @async + * Post the user credentials on the server. Used to authenticate the user on the platform. + * @param values credentials of the user. + * @returns {string} response status (see backend docs for status codes). + */ export const postCredentials = async ( values: CredentialsType, ): Promise<string> => diff --git a/src/api/registerSenior.ts b/src/api/registerSenior.ts index d9e3a16f59f08039f3d3672cd74e7a7c6f58a472..6f4b9b10da671d5116c65c7a548a15b76c048cfc 100644 --- a/src/api/registerSenior.ts +++ b/src/api/registerSenior.ts @@ -1,6 +1,12 @@ import axios from 'axios'; import { RegisterSeniorType } from 'types/RegisterSeniorType'; +/** + * @async + * Create an account for the senior on the platform. + * @param values values of the new account. + * @returns {Promise<void>}. + */ export const registerSenior = async ( values: RegisterSeniorType, ): Promise<void> => diff --git a/src/api/setReservation.ts b/src/api/setReservation.ts index e8c2e618a6ed87ea890db806fd1b99b6ba846137..d99c48d67572e13fcfff1e1f4b89a3202070e4cf 100644 --- a/src/api/setReservation.ts +++ b/src/api/setReservation.ts @@ -1,6 +1,12 @@ import axios from 'axios'; import { ReservationType } from 'types/ReservationType'; +/** + * @async + * Register a reservation to the server. + * @param reservation data of the reservation. + * @returns {Promise<void>}. + */ export const setReservation = async ( reservation: ReservationType, ): Promise<void> => axios.post('/api/web/reservations/', reservation); diff --git a/src/api/setRole.ts b/src/api/setRole.ts index 27087fb3697344e4899db8860a77e82168450f9f..073fe69b0692d2e2f1faf85ed1dfcce159278833 100644 --- a/src/api/setRole.ts +++ b/src/api/setRole.ts @@ -3,7 +3,7 @@ import axios from 'axios'; /** * @async * Set the role of the user in the database. - * @return {string} role + * @return {string} role. */ export const setRole = async (role: string): Promise<void> => axios.post('/api/web/login/set_role', { role }); diff --git a/src/api/userRoles.ts b/src/api/userRoles.ts deleted file mode 100644 index 77e66434cebfbba2299eafd90a537960766934c1..0000000000000000000000000000000000000000 --- a/src/api/userRoles.ts +++ /dev/null @@ -1,9 +0,0 @@ -export enum Roles { - /** Website visitor, is not logged. Can access to NonAuthRoutes */ - visitor = '', - /** Can access to routes wrapped by withAuthorization. */ - senior = 'senior', - admin = 'admin', - operator = 'operator', - driver = 'driver', -}