import type { FC } from 'react'
import * as React from 'react'
import { useTranslation } from 'react-i18next'

type CardProps = {
  name: string
  type: string
  required: boolean
  description?: string
}

const Card: FC<CardProps> = ({
  name,
  type,
  required,
  description,
}) => {
  const { t } = useTranslation()

  return (
    <div className="flex flex-col py-0.5">
      <div className="flex h-6 items-center gap-x-1 pl-1 pr-0.5">
        <div className="truncate border border-transparent px-1 py-px text-text-primary system-sm-semibold">
          {name}
        </div>
        <div className="px-1 py-0.5 text-text-tertiary system-xs-medium">
          {type}
        </div>
        {
          required && (
            <div className="px-1 py-0.5 text-text-warning system-2xs-medium-uppercase">
              {t('nodes.llm.jsonSchema.required', { ns: 'workflow' })}
            </div>
          )
        }
      </div>

      {description && (
        <div className="truncate px-2 pb-1 text-text-tertiary system-xs-regular">
          {description}
        </div>
      )}
    </div>
  )
}

export default React.memo(Card)
