Commit inicial - Sistema de Gestion Hotelera Hacienda San Angel

- Backend Node.js/Express con PostgreSQL
- Frontend React 19 con Vite
- Docker Compose para orquestacion
- Documentacion completa en README.md
- Scripts SQL para base de datos
- Configuracion de ejemplo (.env.example)
This commit is contained in:
Consultoria AS
2026-01-17 18:52:34 -08:00
commit 0211bea186
210 changed files with 47045 additions and 0 deletions

View File

@@ -0,0 +1,57 @@
import axios from "axios";
const api = axios.create({
baseURL: import.meta.env.VITE_API_BASE_URL,
timeout: 15000,
});
export default api;
//Ejemplo con fetch
const API_BASE_URL = 'http://localhost:4000/api';
export async function createProduct(data) {
try {
const response = await fetch(`${API_BASE_URL}/products`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(data),
});
if (!response.ok) {
throw new Error('Failed to save product');
}
return await response.json();
} catch (error) {
console.error('API error:', error);
throw error;
}
}
export async function fetchProducts() {
const res = await fetch(`${API_BASE_URL}/products`);
if (!res.ok) throw new Error('Error fetching products');
return await res.json();
}
export async function fetchInventoryProducts() {
const res = await fetch(`${API_BASE_URL}/inventory-products`);
if (!res.ok) throw new Error('Error fetching inventory products');
// forma esperada: objeto, ej: { "PILLOWS": { unitCost: 300, tax: "IVA 16%" }, ... }
return await res.json();
}
export async function createExpense(payload) {
const res = await fetch(`${API_BASE_URL}/expenses`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(payload),
});
if (!res.ok) throw new Error('Error creating expense');
return await res.json();
}

View File

@@ -0,0 +1,11 @@
import axios from 'axios';
export async function getContracts() {
try {
const response = await axios.get('http://localhost:3000/api/contracts');
return response.data;
} catch (error) {
console.error('Error fetching contracts:', error);
return [];
}
}

View File

@@ -0,0 +1,13 @@
// services/employeeService.js
// import API from './api';
// export const getEmployees = () => API.get('/employees');
export const getEmployees = async () => {
try {
const response = await axios.get(API_URL);
return response.data;
} catch (error) {
console.error('Error fetching employees:', error);
return [];
}
};

View File

@@ -0,0 +1,6 @@
import axios from "axios";
export const getIncome = async () => {
const response = await axios.get("http://localhost:3000/api/income");
return response.data;
};

View File

@@ -0,0 +1,8 @@
import axios from 'axios';
const API = "http://localhost:4000/api";
export async function getUsers() {
const res = await axios.get(`${API}/users`);
return res.data;
}