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

feat(template): add missing checkbox field

parent ec0578c6
No related branches found
No related tags found
1 merge request!10Update ai4eosc branch with recent main (multiple templates)
import { FC } from 'react';
import clsx from 'clsx';
import { CutterField } from 'lib/client';
type CheckboxInput = {
field: CutterField;
flagged?: boolean;
className?: string;
};
const CheckboxInput: FC<CheckboxInput> = ({ field, flagged = false, className }) => {
return (
<div>
<input
className={clsx(
'rounded input mt-0 mb-1 mr-2',
flagged && 'border-warning',
className
)}
type="checkbox"
name={field.name}
id={field.name}
// TODO: type assertion due to api typing not being good enough
defaultChecked={field.default as boolean}
/>
<label htmlFor={field.name}>{field.prompt ?? field.name}</label>
</div>
);
};
export default CheckboxInput;
......@@ -4,6 +4,7 @@ import SelectInput from './SelectInput';
import TextInput from './TextInput';
import Badge from 'components/Badge';
import { CutterField } from 'lib/client';
import CheckboxInput from 'components/template/CheckboxInput';
type FormFieldProps = { field: CutterField; flagged: boolean };
const Formfield: FC<FormFieldProps> = ({ field, flagged }) => {
......@@ -19,6 +20,7 @@ const Formfield: FC<FormFieldProps> = ({ field, flagged }) => {
{field.type === 'select' && (
<SelectInput field={field} flagged={flagged} className="mt-1" />
)}
{field.type === 'checkbox' && <CheckboxInput field={field} className="mt-1" />}
</>
)}
</div>
......
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