Feat: Tipos de datos y Servicios
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
export interface CreateSuscriptorDto {
|
||||
nombreCompleto: string;
|
||||
email?: string | null;
|
||||
telefono?: string | null;
|
||||
direccion: string;
|
||||
tipoDocumento: string;
|
||||
nroDocumento: string;
|
||||
cbu?: string | null;
|
||||
idFormaPagoPreferida: number;
|
||||
observaciones?: string | null;
|
||||
}
|
||||
5
Frontend/src/models/dtos/Suscripciones/FormaPagoDto.ts
Normal file
5
Frontend/src/models/dtos/Suscripciones/FormaPagoDto.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
export interface FormaPagoDto {
|
||||
idFormaPago: number;
|
||||
nombre: string;
|
||||
requiereCBU: boolean;
|
||||
}
|
||||
14
Frontend/src/models/dtos/Suscripciones/SuscriptorDto.ts
Normal file
14
Frontend/src/models/dtos/Suscripciones/SuscriptorDto.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
export interface SuscriptorDto {
|
||||
idSuscriptor: number;
|
||||
nombreCompleto: string;
|
||||
email?: string | null;
|
||||
telefono?: string | null;
|
||||
direccion: string;
|
||||
tipoDocumento: string;
|
||||
nroDocumento: string;
|
||||
cbu?: string | null;
|
||||
idFormaPagoPreferida: number;
|
||||
nombreFormaPagoPreferida: string;
|
||||
observaciones?: string | null;
|
||||
activo: boolean;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
export interface UpdateSuscriptorDto {
|
||||
nombreCompleto: string;
|
||||
email?: string | null;
|
||||
telefono?: string | null;
|
||||
direccion: string;
|
||||
tipoDocumento: string;
|
||||
nroDocumento: string;
|
||||
cbu?: string | null;
|
||||
idFormaPagoPreferida: number;
|
||||
observaciones?: string | null;
|
||||
}
|
||||
13
Frontend/src/services/Suscripciones/formaPagoService.ts
Normal file
13
Frontend/src/services/Suscripciones/formaPagoService.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import apiClient from '../apiClient';
|
||||
import type { FormaPagoDto } from '../../models/dtos/Suscripciones/FormaPagoDto';
|
||||
|
||||
const API_URL = '/formaspago';
|
||||
|
||||
const getAllFormasDePago = async (): Promise<FormaPagoDto[]> => {
|
||||
const response = await apiClient.get<FormaPagoDto[]>(API_URL);
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export default {
|
||||
getAllFormasDePago,
|
||||
};
|
||||
47
Frontend/src/services/Suscripciones/suscriptorService.ts
Normal file
47
Frontend/src/services/Suscripciones/suscriptorService.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
import apiClient from '../apiClient';
|
||||
import type { SuscriptorDto } from '../../models/dtos/Suscripciones/SuscriptorDto';
|
||||
import type { CreateSuscriptorDto } from '../../models/dtos/Suscripciones/CreateSuscriptorDto';
|
||||
import type { UpdateSuscriptorDto } from '../../models/dtos/Suscripciones/UpdateSuscriptorDto';
|
||||
|
||||
const API_URL = '/suscriptores';
|
||||
|
||||
const getAllSuscriptores = async (nombre?: string, nroDoc?: string, soloActivos: boolean = true): Promise<SuscriptorDto[]> => {
|
||||
const params = new URLSearchParams();
|
||||
if (nombre) params.append('nombre', nombre);
|
||||
if (nroDoc) params.append('nroDoc', nroDoc);
|
||||
params.append('soloActivos', String(soloActivos));
|
||||
|
||||
const response = await apiClient.get<SuscriptorDto[]>(`${API_URL}?${params.toString()}`);
|
||||
return response.data;
|
||||
};
|
||||
|
||||
const getSuscriptorById = async (id: number): Promise<SuscriptorDto> => {
|
||||
const response = await apiClient.get<SuscriptorDto>(`${API_URL}/${id}`);
|
||||
return response.data;
|
||||
};
|
||||
|
||||
const createSuscriptor = async (data: CreateSuscriptorDto): Promise<SuscriptorDto> => {
|
||||
const response = await apiClient.post<SuscriptorDto>(API_URL, data);
|
||||
return response.data;
|
||||
};
|
||||
|
||||
const updateSuscriptor = async (id: number, data: UpdateSuscriptorDto): Promise<void> => {
|
||||
await apiClient.put(`${API_URL}/${id}`, data);
|
||||
};
|
||||
|
||||
const deactivateSuscriptor = async (id: number): Promise<void> => {
|
||||
await apiClient.delete(`${API_URL}/${id}`);
|
||||
};
|
||||
|
||||
const activateSuscriptor = async (id: number): Promise<void> => {
|
||||
await apiClient.post(`${API_URL}/${id}/activar`);
|
||||
};
|
||||
|
||||
export default {
|
||||
getAllSuscriptores,
|
||||
getSuscriptorById,
|
||||
createSuscriptor,
|
||||
updateSuscriptor,
|
||||
deactivateSuscriptor,
|
||||
activateSuscriptor,
|
||||
};
|
||||
Reference in New Issue
Block a user