import React from 'react'; import PropTypes from 'prop-types'; import { get } from 'lodash'; import { Collapse } from 'reactstrap'; import useDataManager from '../../hooks/useDataManager'; import Inputs from '../Inputs'; import FieldComponent from '../FieldComponent'; import Banner from './Banner'; import FormWrapper from './FormWrapper'; const DraggedItem = ({ componentFieldName, fields, isOpen, onClickToggle, schema, }) => { const { modifiedData } = useDataManager(); const mainField = get(schema, ['settings', 'mainField'], 'id'); const displayedValue = get( modifiedData, [...componentFieldName.split('.'), mainField], null ); const getField = fieldName => get(schema, ['schema', 'attributes', fieldName], {}); const getMeta = fieldName => get(schema, ['metadatas', fieldName, 'edit'], {}); console.log({ fields }); return ( <> {fields.map((fieldRow, key) => { return (
{fieldRow.map(field => { const currentField = getField(field.name); const isComponent = get(currentField, 'type', '') === 'component'; const keys = `${componentFieldName}.${field.name}`; if (isComponent) { const componentUid = currentField.component; const metas = getMeta(field.name); console.log({ componentUid, currentField }); return ( ); } return (
{}} />
); })}
); })}
); }; DraggedItem.defaultProps = { fields: [], isOpen: false, }; DraggedItem.propTypes = { componentFieldName: PropTypes.string.isRequired, fields: PropTypes.array, isOpen: PropTypes.bool, onClickToggle: PropTypes.func.isRequired, schema: PropTypes.object.isRequired, }; export default DraggedItem;