import { useLocation } from "react-router-dom";
import { PaymentFailed } from "./PaymentFailed";
import { PaymentSuccess } from "./PaymentSuccess";

export const PaymentResult = () => {
  const location = useLocation();
  const urlParams = new URLSearchParams(location.search);
  const params = Object.fromEntries(urlParams.entries());

  return (
    <>
      {params?.error && <PaymentFailed params={params} />}
      {!params?.error && <PaymentSuccess params={params} />}
    </>
  );
};
