import React, { useEffect } from 'react'
import ProductFactory from '../component/product/ProductFactory'
import { useSelector } from 'react-redux';
import siteLinks from '../links/siteLinks';
import { useLocation, useNavigate } from 'react-router-dom';


export default function ProductPage() {

    const navigate = useNavigate()
    let {pathname} = useLocation()

    const { userDetails: { profile_completed }} = useSelector((state) => state?.userDetails); // CHECKS IF USER Details are avaliable, to determine if user is active

    useEffect(()=>{
        if(!profile_completed){
            navigate(siteLinks.profile_complete, {replace: true, state:{redirectLink: pathname}})
        }
    },[])
    
    return (
        <ProductFactory />
    )
}
