- Tradução de rotas para português (entrar, cadastro, configuracoes, etc) - Ajuste de responsividade na página Financeiro (mobile) - Correção navegação Configurações para usuário CEO/Business Owner - Modal de gerenciamento de equipe com lista de profissionais - Exibição de fotógrafos, cinegrafistas e recepcionistas disponíveis por data - Ajuste de layout da logo nas telas de login e cadastro - Correção de z-index do header - Melhoria de espaçamento e padding em cards
83 lines
2 KiB
TypeScript
83 lines
2 KiB
TypeScript
// Serviço para comunicação com o backend
|
|
const API_BASE_URL = import.meta.env.VITE_API_URL || 'http://localhost:3000/api';
|
|
|
|
interface ApiResponse<T> {
|
|
data: T | null;
|
|
error: string | null;
|
|
isBackendDown: boolean;
|
|
}
|
|
|
|
// Função auxiliar para fazer requisições
|
|
async function fetchFromBackend<T>(endpoint: string): Promise<ApiResponse<T>> {
|
|
try {
|
|
const response = await fetch(`${API_BASE_URL}${endpoint}`, {
|
|
method: 'GET',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
},
|
|
});
|
|
|
|
if (!response.ok) {
|
|
throw new Error(`HTTP error! status: ${response.status}`);
|
|
}
|
|
|
|
const data = await response.json();
|
|
return {
|
|
data,
|
|
error: null,
|
|
isBackendDown: false,
|
|
};
|
|
} catch (error) {
|
|
console.error(`Error fetching ${endpoint}:`, error);
|
|
return {
|
|
data: null,
|
|
error: error instanceof Error ? error.message : 'Erro desconhecido',
|
|
isBackendDown: true,
|
|
};
|
|
}
|
|
}
|
|
|
|
// Funções específicas para cada endpoint
|
|
|
|
/**
|
|
* Busca as funções profissionais disponíveis
|
|
*/
|
|
export async function getProfessionalRoles(): Promise<ApiResponse<string[]>> {
|
|
return fetchFromBackend<string[]>('/professional-roles');
|
|
}
|
|
|
|
/**
|
|
* Busca os tipos de eventos disponíveis
|
|
*/
|
|
export async function getEventTypes(): Promise<ApiResponse<string[]>> {
|
|
return fetchFromBackend<string[]>('/event-types');
|
|
}
|
|
|
|
/**
|
|
* Busca os cursos/turmas disponíveis
|
|
*/
|
|
export async function getCourses(): Promise<ApiResponse<Array<{
|
|
id: string;
|
|
name: string;
|
|
institution: string;
|
|
year: number;
|
|
}>>> {
|
|
return fetchFromBackend('/courses');
|
|
}
|
|
|
|
/**
|
|
* Busca as instituições/empresas disponíveis
|
|
*/
|
|
export async function getInstitutions(): Promise<ApiResponse<Array<{
|
|
id: string;
|
|
name: string;
|
|
}>>> {
|
|
return fetchFromBackend('/institutions');
|
|
}
|
|
|
|
/**
|
|
* Busca os anos de formatura disponíveis
|
|
*/
|
|
export async function getGraduationYears(): Promise<ApiResponse<number[]>> {
|
|
return fetchFromBackend<number[]>('/graduation-years');
|
|
}
|