send update to amazon

This commit is contained in:
GotPPay
2017-12-03 17:38:58 +01:00
parent 74ee9de93f
commit 94d2883c01
6 changed files with 89 additions and 52 deletions

View File

@@ -99,8 +99,10 @@ class App extends Component {
this.setState({invocationName: name, invocationAnswer: answer});
try{
updateSkill(this.createSkill(this.state.allIntents,name,answer)).then(l=>l.text()).then(result=>{
if (JSON.parse(result).nModified!==1)
alert("Error");
let jResult = JSON.parse(result);
if (!(jResult.databaseUpdate && jResult.amazonUpdate)){
alert('Database update : ' + jResult.databaseUpdate + '\r\nAmazon update : ' + jResult.amazonUpdate + '\r\nMessage : ' + jResult.amazonMessage);
}
});
}catch(e){
alert("exception");
@@ -117,8 +119,10 @@ class App extends Component {
newAllIntents.splice(id,1);
this.setState({allIntents: newAllIntents, selectedIntent: {intentName:'', questions:[''],answer:''}});
updateSkill(this.createSkill(newAllIntents)).then(l=>l.text()).then(result=>{
if (JSON.parse(result).nModified!==1)
alert("Error");
let jResult = JSON.parse(result);
if (!(jResult.databaseUpdate && jResult.amazonUpdate)){
alert('Database update : ' + jResult.databaseUpdate + '\r\nAmazon update : ' + jResult.amazonUpdate + '\r\nMessage : ' + jResult.amazonMessage);
}
});
}catch(e){
alert("exception");
@@ -139,8 +143,10 @@ class App extends Component {
}
try{
updateSkill(this.createSkill(newAllIntents)).then(l=>l.text()).then(result=>{
if (JSON.parse(result).nModified!==1)
alert("Error");
let jResult = JSON.parse(result);
if (!(jResult.databaseUpdate && jResult.amazonUpdate)){
alert('Database update : ' + jResult.databaseUpdate + '\r\nAmazon update : ' + jResult.amazonUpdate + '\r\nMessage : ' + jResult.amazonMessage);
}
});
}catch(e){
alert("exception");

View File

@@ -22,7 +22,7 @@ class IntentItem extends Component {
onClick={()=>{this.state.onClick(this.state.intent,this.state.index)}}
flat
tooltipDelay={INTENT_TITLE_TOOLTIP_DELAY}
tooltipLabel={this.state.intent.questions[0].length>INTENT_TITLE_MAX_LENGTH ? this.state.intent.questions[0] : ''}>
tooltipLabel={this.state.intent.intentName.length>INTENT_TITLE_MAX_LENGTH ? this.state.intent.questions[0] : ''}>
{this.state.index+1}. {buttonTitle}
</Button>
<br></br>

View File

@@ -17,7 +17,6 @@ export const deleteSkill = (id)=>{
}
export const updateSkill = (skill)=>{
console.log(skill);
let id = (skill._id) ? skill._id : -1;
let url = `http://${BASE_URL}/updateSkill/${id}`
return fetch(url, {