Skip to content
Snippets Groups Projects
Commit ec0578c6 authored by Christophe's avatar Christophe
Browse files

fix(template): fix not using select input

parent 0515516b
No related branches found
No related tags found
1 merge request!10Update ai4eosc branch with recent main (multiple templates)
......@@ -7,19 +7,20 @@ import { CutterField } from 'lib/client';
type FormFieldProps = { field: CutterField; flagged: boolean };
const Formfield: FC<FormFieldProps> = ({ field, flagged }) => {
// TODO: type assertion because API schema issues
const defaultValue = field.default as string | boolean;
return (
<div className={field.default === BLANK_FIELD ? '-mb-3' : ''}>
<label htmlFor={field.name}>{field.prompt ?? field.name}</label>{' '}
{flagged && <Badge type="warning">Missing</Badge>}
{field.default != BLANK_FIELD &&
(typeof defaultValue == 'string' ? (
<TextInput field={field} flagged={flagged} className="mt-1" />
) : Array.isArray(defaultValue) ? (
<SelectInput field={field} flagged={flagged} className="mt-1" />
) : undefined)}
{field.default != BLANK_FIELD && (
<>
{field.type === 'text' && (
<TextInput field={field} flagged={flagged} className="mt-1" />
)}
{field.type === 'select' && (
<SelectInput field={field} flagged={flagged} className="mt-1" />
)}
</>
)}
</div>
);
};
......
......@@ -12,7 +12,7 @@ const SelectInput: FC<SelectInputProps> = ({ field, flagged = false, className }
<select
name={field.name}
id={field.name}
className={clsx('selectpicker form-control', flagged && 'border-warning', className)}
className={clsx('rounded', flagged && 'border-warning', className)}
>
{field.options?.map((option) => (
<option value={option.name} key={option.name}>
......
......@@ -10,7 +10,7 @@ type TextInputProps = {
const TextInput: FC<TextInputProps> = ({ field, flagged = false, className }) => {
return (
<input
className={clsx('input', flagged && 'border-warning', className)}
className={clsx('rounded input', flagged && 'border-warning', className)}
type="text"
name={field.name}
id={field.name}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment