import axios from 'axios';
import { getAjaxActionUrl } from '../utils';

export const apiLoadTimeslotSettings = (callback, onError) => {
  const requestUrl = getAjaxActionUrl('load_timeslot_settings');
  axios.post(requestUrl).then(response => {
    callback(response.data)
  }).catch(err => {
    console.error('Dreamfox WDD: AJAX error loading timeslot settings', err);
    if (onError) onError(err)
  });
}

export const apiSaveTimeslotSettings = (data, callback, onError) => {
  const requestUrl = getAjaxActionUrl('save_timeslot_settings');
  axios.post(requestUrl, {
    data: data,
  }).then(response => {
    callback(response)
  }).catch(err => {
    console.error('Dreamfox WDD: AJAX error saving timeslot settings', err);
    if (onError) onError(err)
  });
}
