import Separator from '@/components/MenuSeparator'
import PrefetchLink from '@/components/PrefetchLink'
import { cn } from '@/lib/utils'

import type { FC } from 'react'

import type { User } from '@/types'

type Props = { user:  User | null,
	       sp?:   boolean }


const TopNavUser: FC<Props> = ({ user, sp }) => {
  if (!(user))
    return

  const className = cn ((sp
			 ? 'md:hidden w-full min-h-[40px] flex items-center pl-8'
			 : 'hidden md:block ml-auto pr-4'),
		        'font-bold text-red-600 hover:text-red-400',
		        'dark:text-yellow-400 dark:hover:text-yellow-200')

  return (
      <>
	{sp && <Separator/>}
	<PrefetchLink to="/users/settings"
	      className={className}>
	  {user.name || '名もなきニジラー'}
	</PrefetchLink>
      </>)
}

export default TopNavUser