import { fetchApi } from './client';
import type { SiteSettings, TimezoneOption } from './types';

export const siteSettingsApi = {
  get: () => fetchApi<{ settings: SiteSettings }>('/api/site-settings'),

  update: (data: Partial<SiteSettings>) =>
    fetchApi<{ settings: SiteSettings; message: string }>('/api/site-settings', {
      method: 'PUT',
      body: JSON.stringify(data),
    }),

  getTimezones: () =>
    fetchApi<{ timezones: TimezoneOption[] }>('/api/site-settings/timezones'),

  setFeaturedEvent: (eventId: string | null) =>
    fetchApi<{ featuredEventId: string | null; message: string }>('/api/site-settings/featured-event', {
      method: 'PUT',
      body: JSON.stringify({ eventId }),
    }),
};
