
import { createSlice,  } from '@reduxjs/toolkit';
import { sellerAllOrders } from '../api/api';

interface NewOrderState {
  data: any; // Adjust type as needed
  loading: boolean;
  error: string | null;
}

const initialState: NewOrderState = {
  data: [],
  loading: false,
  error: null,
};

const OrdersSlice = createSlice({
  name: 'orders',
  initialState,
  reducers: {},
  extraReducers: (builder) => {
    builder
      .addCase(sellerAllOrders.pending, (state) => {
        state.loading = true;
        state.error = null;
      })
      .addCase(sellerAllOrders.fulfilled, (state, action) => {
        state.loading = false;
        state.data = action.payload;
      })
      .addCase(sellerAllOrders.rejected, (state, action) => {
        state.loading = false;
        state.error = action.payload as string;
      });
  },
});

export default OrdersSlice.reducer;