import React, { useEffect, useState } from "react";

const CheckoutPage = () => {
  const [isSuccess, setIsSuccess] = useState(null);

  useEffect(() => {
    const urlParams = new URLSearchParams(window.location.search);
    const successParam = urlParams.get("success");

    if (successParam === "true") {
      setIsSuccess(true);
    } else {
      setIsSuccess(false);
    }
  }, []);

  return (
    <div className="flex min-h-screen items-center justify-center">
      <div className="text-center">
        {isSuccess === true && (
          <div className="text-green-600">
            <span className="text-4xl">&#10003;</span> Transaction Successful
          </div>
        )}
        {isSuccess === false && (
          <div className="text-red-700">
            <span className="text-4xl">&#10060;</span> Transaction Failed
          </div>
        )}
      </div>
    </div>
  );
};

export default CheckoutPage;
