import { createAsyncThunk } from "@reduxjs/toolkit";
import axios from "axios";

export const getPoultryTransportProductsByCodeService = createAsyncThunk(
  "GET_POULTRY_TRANSPORT_PRODUCTS_BY_CODE_SERVICE",
  async (params) => {
    try {
      const { data, status } = await axios.get(
        "https://rsibackend.rasadyar.com/app/get-all-products-transport-products-by-code/",
        {
          params: {
            code: params.code,
            type: params.type,
            date1: params.date1 || "",
            date2: params.date2 || "",
            search: params.search || "",
            from: params.from || "",
          },
        }
      );
      return { data, status };
    } catch (error) {
      return { error: error.response?.data || error.message };
    }
  }
);
