import { UIConfigField } from '@/lib/config/types';
import SettingsField from '../SettingsField';

const Search = ({
  fields,
  values,
  token,
}: {
  fields: UIConfigField[];
  values: Record<string, unknown>;
  token?: string | null;
}) => {
  return (
    <div className="flex-1 space-y-6 overflow-y-auto px-6 py-6">
      {fields.map((field) => (
        <SettingsField
          key={field.key}
          field={field}
          value={
            (values?.[field.key] as string | undefined) ??
            (field.scope === 'client' ? localStorage.getItem(field.key) : undefined) ??
            field.default
          }
          dataAdd="search"
          token={token}
        />
      ))}
    </div>
  );
};

export default Search;
