import { useState, useEffect } from "react";

import { getAccountMoneyInfo } from "../../services";
import { AccountMoneyInfo } from "../../services/interface";

export function useAccountMoneyInfo() {
  const [info, setInfo] = useState<Partial<AccountMoneyInfo>>({
    balance: 0,
    monthly_bill_money: 0,
  });
  function queryInfo() {
    getAccountMoneyInfo().then((res) => {
      setInfo(res.data);
    });
  }
  useEffect(() => {
    queryInfo();
  }, []);

  return { data: info, run: queryInfo };
}
