diff --git a/src/hospitality-web/src/contexts/AuthContext.tsx b/src/hospitality-web/src/contexts/AuthContext.tsx index 925e7a0..afcbf11 100644 --- a/src/hospitality-web/src/contexts/AuthContext.tsx +++ b/src/hospitality-web/src/contexts/AuthContext.tsx @@ -1,4 +1,5 @@ -import React, { createContext, useContext, useState, useEffect, ReactNode } from 'react'; +import React, { createContext, useContext, useState, useEffect } from 'react'; +import type { ReactNode } from 'react'; import { authApi } from '../lib/api'; import type { LoginRequest, UserInfo } from '../types/auth'; diff --git a/src/hospitality-web/src/lib/api.ts b/src/hospitality-web/src/lib/api.ts index 1db0993..f17b495 100644 --- a/src/hospitality-web/src/lib/api.ts +++ b/src/hospitality-web/src/lib/api.ts @@ -1,7 +1,7 @@ import axios from 'axios'; import type { LoginRequest, LoginResponse, UserInfo } from '../types/auth'; -const API_BASE_URL = 'http://localhost:5163/api'; +const API_BASE_URL = import.meta.env.VITE_API_URL || 'http://localhost:5163/api'; export const api = axios.create({ baseURL: API_BASE_URL, @@ -50,3 +50,51 @@ export const authApi = { return response.data; }, }; + +// Event API +export const eventsApi = { + getAll: () => api.get('/events'), + getById: (id: string) => api.get(`/events/${id}`), + create: (data: any) => api.post('/events', data), + update: (id: string, data: any) => api.put(`/events/${id}`, data), + delete: (id: string) => api.delete(`/events/${id}`), +}; + +// Group API +export const groupsApi = { + getByEventId: (eventId: string) => api.get(`/events/${eventId}/groups`), + getById: (id: string) => api.get(`/groups/${id}`), + create: (eventId: string, data: any) => api.post(`/events/${eventId}/groups`, data), + update: (id: string, data: any) => api.put(`/groups/${id}`, data), + delete: (id: string) => api.delete(`/groups/${id}`), +}; + +// People API +export const peopleApi = { + getById: (id: string) => api.get(`/people/${id}`), + create: (groupId: string, data: any) => api.post(`/groups/${groupId}/people`, data), + update: (id: string, data: any) => api.put(`/people/${id}`, data), + delete: (id: string) => api.delete(`/people/${id}`), + assignQuota: (personId: string, data: any) => api.post(`/people/${personId}/quotas`, data), +}; + +// Product API +export const productsApi = { + getByEventId: (eventId: string) => api.get(`/events/${eventId}/products`), + create: (eventId: string, data: any) => api.post(`/events/${eventId}/products`, data), + update: (id: string, data: any) => api.put(`/products/${id}`, data), + delete: (id: string) => api.delete(`/products/${id}`), +}; + +// QR Code API +export const qrCodeApi = { + getByQrCode: (qrCode: string) => api.get(`/qr/${qrCode}`), + getQuotas: (qrCode: string) => api.get(`/qr/${qrCode}/quotas`), +}; + +// Transaction API +export const transactionsApi = { + create: (data: any) => api.post('/transactions', data), + getByPersonId: (personId: string) => api.get(`/transactions/person/${personId}`), + getByEventId: (eventId: string) => api.get(`/transactions/event/${eventId}`), +};