diff --git a/src/services/consent.service.ts b/src/services/consent.service.ts index 185b123064e38d2ce903f0fc177a80a9bd5cad1b..4009d65754d095dd4ad84688786a255da80060a5 100644 --- a/src/services/consent.service.ts +++ b/src/services/consent.service.ts @@ -24,7 +24,7 @@ export class ConsentService { ): Promise<IConsentPagination | null> => { try { const { data } = await axios.get( - `/api/admin/consent?search=${search}&limit=${limit}&page=${page}`, + `/api/admin/sge/consent?search=${search}&limit=${limit}&page=${page}`, axiosHeaders ) const consentPagination = data as ConsentPaginationEntity diff --git a/src/services/sgeConsent.service.ts b/src/services/sgeConsent.service.ts deleted file mode 100644 index 986e0fab8fad60acaa8bb7b872e1eb5cf3bac996..0000000000000000000000000000000000000000 --- a/src/services/sgeConsent.service.ts +++ /dev/null @@ -1,87 +0,0 @@ -import axios, { AxiosRequestConfig } from 'axios' -import { DateTime } from 'luxon' -import { toast } from 'react-toastify' -import { - ISgeConsent, - ISgeConsentPagination, - SgeConsentEntity, - SgeConsentPaginationEntity, -} from '../models/sgeConsent.model' - -export class SgeConsentService { - /** - * Search for consents - * @param search - * @param limit - * @param page - * @param axiosHeaders - */ - public searchConsents = async ( - search: string, - limit: number, - page: number, - axiosHeaders: AxiosRequestConfig - ): Promise<ISgeConsentPagination | null> => { - try { - const { data } = await axios.get( - `/api/admin/sge/consent?search=${search}&limit=${limit}&page=${page}`, - axiosHeaders - ) - const consentPagination = data as SgeConsentPaginationEntity - return this.parseConsentPagination(consentPagination) - } catch (e) { - if (e.response.status === 403) { - toast.error("Accès refusé : vous n'avez pas les droits nécessaires") - } else { - toast.error('Erreur lors de la récupération des consentements') - } - console.error(e) - return null - } - } - - /** - * Converts consent entity into consent - * @param consentEntity - */ - public parseConsent = (consentEntity: SgeConsentEntity): ISgeConsent => { - const startDate = DateTime.fromISO(consentEntity.CreatedAt, { - zone: 'utc', - }).setLocale('fr-FR') - const endDate = DateTime.fromISO(consentEntity.endDate, { - zone: 'utc', - }).setLocale('fr-FR') - - return { - ID: consentEntity.ID, - startDate: startDate, - endDate: endDate, - firstname: consentEntity.firstname, - lastname: consentEntity.lastname, - pointID: consentEntity.pointID, - address: consentEntity.address, - postalCode: consentEntity.postalCode, - city: consentEntity.city, - safetyOnBoarding: consentEntity.safetyOnBoarding, - } - } - - /** - * Converts consent pagination entity into consent pagination - * @param consentPaginationEntity - */ - public parseConsentPagination = ( - consentPaginationEntity: SgeConsentPaginationEntity - ): ISgeConsentPagination => { - const rows = consentPaginationEntity.rows.map(consent => - this.parseConsent(consent) - ) - - const consentPagination: ISgeConsentPagination = { - rows: rows, - totalRows: consentPaginationEntity.totalRows, - totalPages: consentPaginationEntity.totalPages, - } - return consentPagination - } -}