import ActionsButtons from "components/ActionsButtons/ActionsButtons";
import { selectCart, setTmp } from "features/order/orderSlice";
import { useAppDispatch, useAppSelector } from "redux/hooks";

interface SplitBillTmp {
  totalPeople?: number;
  payFor?: number;
}

export default function PayForActions() {
  const dispatch = useAppDispatch();
  const { tmp } = useAppSelector(selectCart);

  return (
    <ActionsButtons
      quantity={(tmp as SplitBillTmp)?.payFor || 1}
      setQuantity={(value) => dispatch(setTmp({ ...(tmp as SplitBillTmp), payFor: value }))}
      max={(tmp as SplitBillTmp)?.totalPeople || 10}
      min={1}
    />
  );
}
