CheckPoint: Avances Varios

This commit is contained in:
2025-12-18 13:32:50 -03:00
parent 8f535f3a6e
commit 32663e6324
92 changed files with 12629 additions and 195 deletions

View File

@@ -1,7 +1,7 @@
import axios from 'axios';
const api = axios.create({
baseURL: 'https://localhost:7034/api', // Puerto HTTPS obtenido de launchSettings.json
baseURL: import.meta.env.VITE_API_URL, // Usa la variable de entorno
});
api.interceptors.request.use((config) => {
@@ -12,4 +12,4 @@ api.interceptors.request.use((config) => {
return config;
});
export default api;
export default api;

View File

@@ -1,5 +1,5 @@
import api from './api';
import { AttributeDefinition } from '../types/AttributeDefinition';
import { type AttributeDefinition } from '../types/AttributeDefinition';
export const attributeService = {
getByCategoryId: async (categoryId: number): Promise<AttributeDefinition[]> => {

View File

@@ -1,5 +1,5 @@
import api from './api';
import { Category } from '../types/Category';
import { type Category } from '../types/Category';
export const categoryService = {
getAll: async (): Promise<Category[]> => {

View File

@@ -0,0 +1,20 @@
import api from './api';
export const exportService = {
downloadDiagram: async (date: string) => {
// Axios necesita config especial para descargar archivos (blob)
const response = await api.get('/exports/diagram', {
params: { date },
responseType: 'blob'
});
// Truco para forzar la descarga en el navegador
const url = window.URL.createObjectURL(new Blob([response.data]));
const link = document.createElement('a');
link.href = url;
link.setAttribute('download', `diagrama_${date}.xml`);
document.body.appendChild(link);
link.click();
link.remove();
}
};

View File

@@ -1,5 +1,5 @@
import api from './api';
import { Operation } from '../types/Operation'; // ID: type-import-fix
import { type Operation } from '../types/Operation';
export const operationService = {
getAll: async (): Promise<Operation[]> => {

View File

@@ -1,25 +1,17 @@
import api from './api';
// @ts-ignore
import type { User } from '../types/User';
import { type User } from '../types/User';
interface CreateUserDto {
// DTOs específicos para creación/edición para no usar 'any'
export interface CreateUserDto {
username: string;
password: string;
password?: string; // Opcional en update, requerido en create (validar en UI)
role: string;
email?: string;
}
interface UpdateUserDto {
username: string;
password?: string;
role: string;
email?: string;
email: string;
}
export const userService = {
getAll: async (): Promise<User[]> => {
const response = await api.get<User[]>('/users');
// @ts-ignore
return response.data;
},
@@ -27,11 +19,11 @@ export const userService = {
await api.post('/users', user);
},
update: async (id: number, user: UpdateUserDto): Promise<void> => {
update: async (id: number, user: CreateUserDto): Promise<void> => {
await api.put(`/users/${id}`, user);
},
delete: async (id: number): Promise<void> => {
await api.delete(`/users/${id}`);
}
};
};