import Actions from '../../../types/Store/Actions';
import Order, { AllOrderItem } from '../../../types/Order/Order';
import { RechargeOrderItem } from '@/api/order';
export const SELECT_ORDER = 'SELECT_ORDER';
export const UPDATE_CONSUME_ORDERS = 'UPDATE_CONSUME_ORDERS';
export const APPEND_CONSUME_ORDERS = 'APPEND_CONSUME_ORDERS';
export const UPDATE_CONSUME_LASTID = 'UPDATE_CONSUME_LASTID';
export const UPDATE_RECHARGE_ORDERS = 'UPDATE_RECHARGE_ORDERS';
export const APPEND_RECHARGE_ORDERS = 'APPEND_RECHARGE_ORDERS';
export const UPDATE_RECHARGE_LASTID = 'UPDATE_RECHARGE_LASTID';

export type UpdateOrderParams<T> = {
  lastOrderId?: number;
  list: T[];
};

export const selectOrder = (state: Order): Actions => ({
  type: SELECT_ORDER,
  payload: state,
});

export const updateConsumeOrders = (state: AllOrderItem[]): Actions => ({
  type: UPDATE_CONSUME_ORDERS,
  payload: state,
});
export const appendConsumeOrders = (state: AllOrderItem[]): Actions => ({
  type: APPEND_CONSUME_ORDERS,
  payload: state,
});
export const updateConsumeLastId = (data: number): Actions => ({
  type: UPDATE_CONSUME_LASTID,
  payload: data,
});
export const updateRechargeOrders = (state: RechargeOrderItem[]): Actions => ({
  type: UPDATE_RECHARGE_ORDERS,
  payload: state,
});
export const appendRechargeOrders = (state: RechargeOrderItem[]): Actions => ({
  type: APPEND_RECHARGE_ORDERS,
  payload: state,
});
export const updateRechargeLastId = (data: number): Actions => ({
  type: UPDATE_RECHARGE_LASTID,
  payload: data,
});
