2021-08-26 11:25:03 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* FormModal
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
import React from 'react';
|
|
|
|
import { useIntl } from 'react-intl';
|
|
|
|
import {
|
2021-08-26 12:08:07 +02:00
|
|
|
Stack,
|
|
|
|
Grid,
|
|
|
|
GridItem,
|
2021-08-26 11:25:03 +02:00
|
|
|
ModalLayout,
|
|
|
|
ModalHeader,
|
|
|
|
ModalFooter,
|
|
|
|
ModalBody,
|
|
|
|
Button,
|
|
|
|
Breadcrumbs,
|
|
|
|
Crumb,
|
|
|
|
} from '@strapi/parts';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
// import { getTrad } from '../../../utils';
|
|
|
|
|
2021-08-26 12:08:07 +02:00
|
|
|
const FormModal = ({ headerBreadcrumbs, layout, isOpen, onToggle }) => {
|
2021-08-26 11:25:03 +02:00
|
|
|
const { formatMessage } = useIntl();
|
|
|
|
|
2021-08-26 12:08:07 +02:00
|
|
|
console.log({ fo: layout.form });
|
|
|
|
|
2021-08-26 11:25:03 +02:00
|
|
|
if (!isOpen) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<ModalLayout onClose={onToggle} labelledBy="title">
|
|
|
|
<ModalHeader>
|
|
|
|
<Breadcrumbs label={headerBreadcrumbs.join(', ')}>
|
|
|
|
{headerBreadcrumbs.map(crumb => (
|
|
|
|
<Crumb key={crumb}>{crumb}</Crumb>
|
|
|
|
))}
|
|
|
|
</Breadcrumbs>
|
|
|
|
</ModalHeader>
|
2021-08-26 12:08:07 +02:00
|
|
|
<ModalBody>
|
|
|
|
<Stack size={1}>
|
|
|
|
<Grid gap={5}>
|
|
|
|
{layout.form.map(row => {
|
|
|
|
return row.map(input => {
|
|
|
|
console.log({ input });
|
|
|
|
|
|
|
|
return (
|
|
|
|
<GridItem key={input.name} col={input.size} xs={12}>
|
|
|
|
{input.intlLabel.id}
|
|
|
|
{/* <Inputs
|
|
|
|
{...input}
|
|
|
|
// customInputs={{ string: () => "TEXT CUSTOM" }}
|
|
|
|
error={formErrors?.[input.name]}
|
|
|
|
onChange={handleChange}
|
|
|
|
value={modifiedData[input.name]}
|
|
|
|
/> */}
|
|
|
|
</GridItem>
|
|
|
|
);
|
|
|
|
});
|
|
|
|
})}
|
|
|
|
</Grid>
|
|
|
|
</Stack>
|
|
|
|
</ModalBody>
|
2021-08-26 11:25:03 +02:00
|
|
|
<ModalFooter
|
|
|
|
startActions={
|
|
|
|
<Button variant="tertiary" onClick={onToggle} type="button">
|
|
|
|
{formatMessage({ id: 'app.components.Button.cancel', defaultMessage: 'Cancel' })}
|
|
|
|
</Button>
|
|
|
|
}
|
|
|
|
endActions={
|
|
|
|
<>
|
|
|
|
<Button>
|
|
|
|
{formatMessage({ id: 'app.components.Button.save', defaultMessage: 'Save' })}
|
|
|
|
</Button>
|
|
|
|
</>
|
|
|
|
}
|
|
|
|
/>
|
|
|
|
</ModalLayout>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
FormModal.propTypes = {
|
|
|
|
headerBreadcrumbs: PropTypes.arrayOf(PropTypes.string).isRequired,
|
2021-08-26 12:08:07 +02:00
|
|
|
layout: PropTypes.shape({
|
|
|
|
form: PropTypes.arrayOf(PropTypes.array),
|
|
|
|
schema: PropTypes.object,
|
|
|
|
}).isRequired,
|
2021-08-26 11:25:03 +02:00
|
|
|
isOpen: PropTypes.bool.isRequired,
|
|
|
|
onToggle: PropTypes.func.isRequired,
|
|
|
|
};
|
|
|
|
|
|
|
|
export default FormModal;
|