'use client';

import { cn } from '@/lib/utils';

export const EMPLOYEE_CODE_LABEL = 'รหัสพนักงาน';
export const EMPLOYEE_NAME_LABEL = 'ชื่อพนักงาน';

export function buildEmployeeSearchPlaceholder(extraTerms: string[] = []) {
  const terms = [
    EMPLOYEE_CODE_LABEL,
    EMPLOYEE_NAME_LABEL,
    ...extraTerms.map((term) => term.trim()).filter(Boolean)
  ];

  return `ค้นหาด้วย${terms.join(' ')}...`;
}

export function EmployeeIdentity({
  employeeCode,
  employeeName,
  secondary,
  className,
  codeClassName,
  nameClassName,
  secondaryClassName
}: {
  employeeCode?: string | null;
  employeeName: string;
  secondary?: string | null;
  className?: string;
  codeClassName?: string;
  nameClassName?: string;
  secondaryClassName?: string;
}) {
  return (
    <div className={cn('flex min-w-0 flex-col', className)}>
      <span className={cn('truncate text-sm font-semibold whitespace-nowrap', codeClassName)}>
        {employeeCode?.trim() || '-'}
      </span>
      <span className={cn('truncate font-medium', nameClassName)}>{employeeName}</span>
      {secondary ? (
        <span className={cn('text-muted-foreground truncate text-xs', secondaryClassName)}>
          {secondary}
        </span>
      ) : null}
    </div>
  );
}
