
import CampaignCalendarService from "@/services/resources/CampaignCalendarService";
export default {
    loadCurrentCampaign(context){
        var service = CampaignCalendarService.build();
        return new Promise((resolve, reject) => {
        service
        .search({
          current: 'true'
        })
        .then(response => {
          if(response.length > 0){
            
            let campaign = {};
             Object.assign(campaign,response[0].campaign);

             campaign.end = response[0].end_billing;
             campaign.start = response[0].start_billing;

            context.commit('setCurrentCampaign', campaign);
            resolve(campaign);
          }else{
              resolve(null);
          }
          
        })
        .catch(err => {
          let resp = JSON.parse(err.response.data);
          
         reject(err);
        });
    });
}
}