UNPKG

analytica-frontend-lib

Version:

Repositório público dos componentes utilizados nas plataformas da Analytica Ensino

77 lines (74 loc) 2.33 kB
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/hooks/useSimulations.ts var _react = require('react'); var BASE_URL = "/performance/simulations"; var segment = (value) => encodeURIComponent(value); var createUseSimulations = (apiClient) => () => { const fetchStudents = _react.useCallback.call(void 0, async (filters = {}) => { const { page = 1, limit = 20, search, classIds } = filters; const response = await apiClient.get( `${BASE_URL}/students`, { params: { page, limit, search, classIds } } ); return response.data.data.students; }, [] ); const fetchStudentSimulations = _react.useCallback.call(void 0, async (userInstitutionId, filters = {}) => { const { page = 1, limit = 20 } = filters; const response = await apiClient.get( `${BASE_URL}/students/${segment(userInstitutionId)}`, { params: { page, limit } } ); return response.data.data; }, [] ); const fetchSimulationDetail = _react.useCallback.call(void 0, async (userInstitutionId, simulationId) => { const response = await apiClient.get( `${BASE_URL}/students/${segment(userInstitutionId)}/${segment(simulationId)}` ); return response.data.data; }, [] ); const fetchNote = _react.useCallback.call(void 0, async (userInstitutionId, simulationId) => { const response = await apiClient.get( `${BASE_URL}/students/${segment(userInstitutionId)}/${segment(simulationId)}/note` ); return response.data.data; }, [] ); const saveNote = _react.useCallback.call(void 0, async (userInstitutionId, simulationId, note) => { const response = await apiClient.post( `${BASE_URL}/students/${segment(userInstitutionId)}/${segment(simulationId)}/note`, { note } ); return response.data.data; }, [] ); return _react.useMemo.call(void 0, () => ({ fetchStudents, fetchStudentSimulations, fetchSimulationDetail, fetchNote, saveNote }), [ fetchStudents, fetchStudentSimulations, fetchSimulationDetail, fetchNote, saveNote ] ); }; exports.createUseSimulations = createUseSimulations; //# sourceMappingURL=chunk-3GSGCLCO.js.map