summaryrefslogtreecommitdiff
path: root/src/components/forms/fields/select_field.tsx
blob: 4d67754b83143021481e871743d47526da32aa13 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
export default function SelectField({ properties, options }) {
  let select_field;

  if(properties.error_message) {
    select_field = (
      <div className="mb-6">
        <label className="block mb-2 text-lg text-red-700 dark:text-red-500">{properties.label}</label>
        <select id={properties.id} name={properties.name} className="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500">
          {options}
        </select>
        <p className="mt-2 text-sm text-red-600 dark:text-red-500"> {properties.error_message }</p>
      </div>
    );
  } else {
    select_field = (
      <div className="mb-6">
        <label className="block mb-2 text-lg text-gray-900 dark:text-white">{properties.label}</label>
        <select id={properties.id} name={properties.name} className="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500">
          {options}
        </select>
      </div>
    );
  }

  return select_field;
}