import React, { Component } from 'react'; import Grid from '@material-ui/core/Grid'; import Typography from '@material-ui/core/Typography'; import { withStyles } from '@material-ui/core/styles'; import flamelinkApp from '../../utilities/flamelink.js'; import FlameLinkImage from './FlameLinkImage'; import FlameLinkFieldSet from './FlameLinkFieldSet'; const styles = theme => ({ flamelinkItem: { paddingRight: 20, paddingLeft: 20, paddingTop: 20, }, }); class FlameLinkCollectionStructure extends Component { state = { schemaContent: '', } componentDidMount() { global.mediaID = ''; flamelinkApp.content.get(this.props.schemaName) .then(result => this.setState({ schemaContent: result })) } getContent(content, field, key, type, description) { if (type === 'text') { if (description === 'h1') { return ( {content[key]} ) } if (description === 'h2') { return ( {content[key]} ) } if (description === 'h3') { return ( {content[key]} ) } if (description === 'h4') { return ( {content[key]} ) } if (description === 'h5') { return ( {content[key]} ) } if (description === 'h6') { return ( {content[key]} ) } else { return ( {content[key]} ) } } if (type === 'textarea') { return ( {content[key]} ) } if (type === 'media') { for (var val in content[key]) { global.mediaID = content[key][val]; return } } if (type === 'fieldset') { if (content === '') { return } else { return } } } render() { const { classes } = this.props; const lg = this.props.field.gridColumns.lg; const md = this.props.field.gridColumns.md; const sm = this.props.field.gridColumns.sm; const xs = this.props.field.gridColumns.xs; return ( {this.getContent(this.props.schemaContent, this.props.field, this.props.field.key, this.props.type, this.props.field.description)} ); } } export default withStyles(styles)(FlameLinkCollectionStructure);