import {useEffect} from 'react'
import {useLocation, useNavigate} from 'react-router-dom'
import Payment from '../components/Payment/Payment'
import { RouteHandler } from '../router/routes'

export default function PaymentPage() {
  const location = useLocation()
  const navigate = useNavigate()
  const queryParams = new URLSearchParams(location?.search);
  const trxRef = queryParams.get("trxref");
  const reference = queryParams.get("reference");
  // console.log('TEST', trxRef, reference)

  useEffect(()=>{
    if(!trxRef || !reference){
      navigate(RouteHandler.dashboardHome, {replace:true})
    }
  },[])
  return (
    <>
        <Payment reference={reference} />
    </>
  )
}
