feat: Implement Document Types for Digitization module
- Added backend API for managing document types related to digitization, including CRUD operations. - Created DTOs and models for DocumentTypeDigitization with validation using Pydantic. - Updated frontend API service to interact with the new document types API. - Refactored existing forms in the frontend to load and manage document types effectively. - Enhanced data loading and state management in various components related to pedimentos.
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
import { api } from '$lib/api';
|
||||
|
||||
export interface DocumentTypeDigitization {
|
||||
id: number;
|
||||
code: string;
|
||||
description: string;
|
||||
active: boolean;
|
||||
}
|
||||
|
||||
export interface DocumentTypeDigitizationCreate {
|
||||
code: string;
|
||||
description: string;
|
||||
active?: boolean;
|
||||
}
|
||||
|
||||
export interface DocumentTypeDigitizationUpdate {
|
||||
code?: string;
|
||||
description?: string;
|
||||
active?: boolean;
|
||||
}
|
||||
|
||||
const BASE_URL = '/v1/a76/document-types-digitization';
|
||||
|
||||
/**
|
||||
* API para Tipos de Documentos de Digitalización
|
||||
*/
|
||||
export const documentTypesDigitizationApi = {
|
||||
/**
|
||||
* Obtener todos los tipos de documentos para digitalización
|
||||
*/
|
||||
getAll: (activeOnly: boolean = true) => {
|
||||
const url = `${BASE_URL}?active_only=${activeOnly}`;
|
||||
return api.get<DocumentTypeDigitization[]>(url);
|
||||
},
|
||||
|
||||
/**
|
||||
* Obtener un tipo de documento por ID
|
||||
*/
|
||||
getById: (id: number) => {
|
||||
return api.get<DocumentTypeDigitization>(`${BASE_URL}/${id}`);
|
||||
},
|
||||
|
||||
/**
|
||||
* Obtener un tipo de documento por código
|
||||
*/
|
||||
getByCode: (code: string) => {
|
||||
return api.get<DocumentTypeDigitization>(`${BASE_URL}/by-code/${code}`);
|
||||
},
|
||||
|
||||
/**
|
||||
* Crear un nuevo tipo de documento
|
||||
*/
|
||||
create: (data: DocumentTypeDigitizationCreate) => {
|
||||
return api.post<DocumentTypeDigitization>(BASE_URL, data);
|
||||
},
|
||||
|
||||
/**
|
||||
* Actualizar un tipo de documento existente
|
||||
*/
|
||||
update: (id: number, data: DocumentTypeDigitizationUpdate) => {
|
||||
return api.put<DocumentTypeDigitization>(`${BASE_URL}/${id}`, data);
|
||||
},
|
||||
|
||||
/**
|
||||
* Eliminar (soft delete) un tipo de documento
|
||||
*/
|
||||
delete: (id: number) => {
|
||||
return api.delete(`${BASE_URL}/${id}`);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user