import axios from 'axios';

// Lokale API-Route verwenden
const apiUrl = '/api';

export const submitContactForm = async (formData: any) => {
  try {
    const response = await axios.post(`${apiUrl}/contact`, formData);
    return response.data;
  } catch (error: any) {
    throw new Error('Error submitting contact form: ' + error.message);
  }
};

export const fetchProjects = async () => {
  try {
    const response = await axios.get(`${apiUrl}/projects`);
    return response.data;
  } catch (error: any) {
    throw new Error('Error fetching projects: ' + (error.message || 'Unknown error'));
  }
};

export const fetchServices = async () => {
  try {
    const response = await axios.get(`${apiUrl}/services`);
    return response.data;
  } catch (error: any) {
    throw new Error('Error fetching services: ' + (error.message || 'Unknown error'));
  }
};