diff --git a/src/components/Flamelink.js b/src/components/Flamelink.js index 4033d59..d79007e 100644 --- a/src/components/Flamelink.js +++ b/src/components/Flamelink.js @@ -1,14 +1,31 @@ -import { Component } from 'react'; +import React, { Component, Fragment } from 'react'; +import Grid from '@material-ui/core/Grid'; import flamelinkApp from '../flamelink.js'; - +import Layout from './Layout'; class Flamelink extends Component { + constructor() { + super(); + + this.state = { + schemaDetails: '' + } + } + + componentDidMount() { + // fetch the project name, once it retrieves resolve the promsie and update the state. + flamelinkApp.schemas.getFields('martenSchemaDemo', { fields: [ 'title', 'key' ] }) + .then(result => this.setState({ + schemaDetails: result + })) + } + render() { - //Grabs data from text field in entry from the martenSchemaDemo - flamelinkApp.content.get('martenSchemaDemo') - .then(flameData => document.getElementById("flamelinkDemo").innerHTML = flameData.field_1538162314419); - - return(null); + return( + + + + ); } } diff --git a/src/components/Layout.js b/src/components/Layout.js new file mode 100644 index 0000000..760b0dc --- /dev/null +++ b/src/components/Layout.js @@ -0,0 +1,49 @@ +import React, { Component, Fragment } from 'react'; +import flamelinkApp from '../flamelink.js'; + +class Layout extends Component { + constructor() { + super(); + + this.state = { + contentDetails: '' + } + } + + + getData(schemaData){ + for (var val in this.props.schemaDetails){ + this.getMoreData(this.props.schemaDetails[val]); + } + } + + getMoreData(moreData){ + var tArray = document.createElement("H1"); + var kArray = document.createElement("P"); + this.getTitle(moreData.title, tArray); + this.getKey(moreData.key, kArray); + } + + getTitle(title, arr){ + var t = document.createTextNode(title); + arr.appendChild(t); + document.getElementById("demo").appendChild(arr); + } + + + getKey(key, arr){ + var k = document.createTextNode(key); + arr.appendChild(k); + document.getElementById("demo").appendChild(arr); + } + + render() { + return( +
+

{this.getData(this.props)}

+
+ ); + } +} + +export default Layout; \ No newline at end of file diff --git a/src/pages/Info.js b/src/pages/Info.js index 838a1e1..3db9d8f 100644 --- a/src/pages/Info.js +++ b/src/pages/Info.js @@ -2,16 +2,17 @@ import React, { Component } from 'react'; import Typography from '@material-ui/core/Typography'; import Flamelink from '../components/Flamelink'; + class Info extends Component { render() { return (
- + Info -

+
);