import { api } from '@/lib/api';
import { ENDPOINTS } from '@/constants/endpoints';

type CashMovePayload = {
  user_id: string;
  wallet_id: string;
  amount: number;
  coa_account_id: string;
  description: string;
  type: "deposit" | "withdraw";
};

type GoldMovePayload = {
  user_id: string;
  wallet_id: string;
  grams: number;
  coa_account_id: string;
  description: string;
  type: "deposit" | "withdraw";
};

type ReconPayload = {
  wallet_id: string;
  wallet_type: "cash" | "gold";
};

export function useWalletEngine() {
  const moveCash = async (payload: CashMovePayload) => {
    return api.post(ENDPOINTS.WALLET_ENGINE.CASH_MOVE, payload);
  };

  const moveGold = async (payload: GoldMovePayload) => {
    return api.post(ENDPOINTS.WALLET_ENGINE.GOLD_MOVE, payload);
  };

  const reconcileWallet = async (payload: ReconPayload) => {
    return api.post(ENDPOINTS.WALLET_ENGINE.RECONCILE, payload);
  };

  return { moveCash, moveGold, reconcileWallet };
}
