'use client'
import React from 'react'
import {checkIsAuthenticated} from '../../lib/checkIsAuthenticated'
import { useRouter } from 'next/navigation'


export default function AuthButton({user}) {
    console.log(user)
    const router = useRouter()
  return (
    <>    <button
          onClick={()=>router.replace(user?'api/auth/signout':'auth/sign_in')}
            type="button"
            className="text-white  bg-blue-900 hover:bg-green-950 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm px-4 py-2 text-center dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800"
          >
            {user && "Sign Out" || "Sign In"} 
                     </button>
                     {user && <button
                     type="button"
                     className="text-white  bg-blue-900 hover:bg-green-950 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm px-4 py-2 text-center dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800"
                   >
                     <Link href="/sign-up">Get a Free Shop</Link>
                   </button>}</>

  )
}
