integraion with backend in progress

This commit is contained in:
Malar Kannan
2017-07-18 18:33:20 +05:30
parent 726e81c88e
commit 3cc73e5404
6 changed files with 229 additions and 4 deletions

View File

@@ -11,6 +11,16 @@ import {
} from 'semantic-ui-react';
const { Box } = require('reflexbox');
const serialize = function(obj: any) {
var str = [];
for(var p in obj){
if (obj.hasOwnProperty(p)) {
str.push(encodeURIComponent(p) + '=' + encodeURIComponent(obj[p]));
}
}
return str.join('&');
};
export class LexEdit extends React.Component<any, any> {
imageRoot = '/png/';
constructor(props: any) {
@@ -90,9 +100,21 @@ export class LexEdit extends React.Component<any, any> {
let lexItem = this.props.lexItem;
this.setState({ lexItem });
}
private handleOnLoad(event: any) {
// this.props.load(this.state.lexItem)
console.log('loading from server');
let lexItem = this.props.lexItem;
let word = _.get<any>(lexItem, this.props.fieldMetaMap.label.lens, '');
let pos = _.get<any>(lexItem, this.props.fieldMetaMap.pos.lens, '');
let args = serialize({word,pos});
fetch('/morph?'+args)
.then((response) => response.text())
.then((jsonMorph) => {
console.log(jsonMorph);
})
.catch((e) => {
console.log('errored :', e);
});
}
private handleOnChange(event: any) {