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 }


export default (({ user, sp }: Props) => {
  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>
      </>)
}) satisfies FC<Props>
