/* eslint-disable import/no-unresolved */
/* eslint-disable import/order */


import { sageService } from '@/service/sageService';
import { Commercial, CommercialRequest } from '@/types/commercialType';
import { createAsyncThunk } from '@reduxjs/toolkit';


/**
 * get all commercial
 */
export const getCommercials = createAsyncThunk(
  'commercials/getCommercials',
  async (): Promise<Commercial[]> => {
    try {
      return await sageService.commercials();
    } catch (err) {
      throw err;
    }
  }
);


/**
 * get commercials by id
 */
export const getcommercialsById = createAsyncThunk(
  'commercials/getcommercialsById',
  async (id: string): Promise<Commercial> => {
    try {
      return await sageService.commercialsById(id);
    } catch (err) {
      throw err;
    }
  }
);




/**
 * add commercials
 */
export const addCommercial = createAsyncThunk(
  'commercials/addCommercial',
  async (data: CommercialRequest): Promise<Commercial> => {
    try {
      return await sageService.addCommercial(data);
    } catch (err) {
      throw err;
    }
  }
);



/**
 * update commercials
 */
// export const updatecommercials = createAsyncThunk(
//   'commercials/updatecommercials',
//   async (
//     { reference, data }: { reference: string; data: commercialsUpdateRequest }
//   ): Promise<commercials> => {
//     try {
//       return await sageService.updatecommercials(reference, data);
//     } catch (err) {
//       throw err;
//     }
//   }
// );

