export const fetchLiterals = async () => {
  const response = await fetch('/api/literals');
  if (!response.ok) {
    throw new Error('Failed to fetch data');
  }
  return response.json();
};

export const saveLiteralsToApi = async (data: any) => {
  const response = await fetch('/api/literals', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    body: JSON.stringify(data),
  });

  if (!response.ok) {
    throw new Error('Error saving data');
  }

  return response.json();
};

export const resetTelegramBot = async () => {
  const response = await fetch('/api/telegram', {
    method: 'GET'
  });

  if (!response.ok) {
    throw new Error('Error resetting Telegram bot');
  }

  return response.json();
};
