Skip to content
Snippets Groups Projects
Verified Commit bc556f28 authored by Defendi Alberto's avatar Defendi Alberto
Browse files

Document api components.

parent f3e4bdc2
No related branches found
No related tags found
2 merge requests!69Possibility to insert a reservation and new docs.,!67Insert a reservation and search by senior.
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);
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);
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[]> =>
......
import axios from 'axios';
import { SeniorSearchQueryType } from '../types/SeniorSearchQueryType';
export const getSeniorList = async (
name: string,
/**
* @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/${name}?fields=user,id,member_card_number`)
.get(
`/api/web/seniors/by_name/${lastName}?fields=user,id,member_card_number`,
)
.then((res) => res.data);
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> =>
......
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> =>
......
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);
......@@ -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 });
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',
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment