2023-07-02 07:02:49 +02:00
|
|
|
import { Menu, Item, Form, FormRow } from 'react-basics';
|
|
|
|
import { useMessages } from 'hooks';
|
|
|
|
import styles from './FieldSelectForm.module.css';
|
|
|
|
|
|
|
|
export default function FieldSelectForm({ fields, onSelect }) {
|
|
|
|
const { formatMessage, labels } = useMessages();
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Form>
|
|
|
|
<FormRow label={formatMessage(labels.fields)}>
|
|
|
|
<Menu className={styles.menu} onSelect={key => onSelect(fields[key])}>
|
2023-07-18 18:09:22 +02:00
|
|
|
{fields.map(({ label, name, type }, index) => {
|
2023-07-02 07:02:49 +02:00
|
|
|
return (
|
|
|
|
<Item key={index} className={styles.item}>
|
2023-07-18 18:09:22 +02:00
|
|
|
<div>{label || name}</div>
|
2023-07-02 07:02:49 +02:00
|
|
|
<div className={styles.type}>{type}</div>
|
|
|
|
</Item>
|
|
|
|
);
|
|
|
|
})}
|
|
|
|
</Menu>
|
|
|
|
</FormRow>
|
|
|
|
</Form>
|
|
|
|
);
|
|
|
|
}
|