2017-12-02 22:48:45 +01:00
import React , { Component } from 'react' ;
import { Button , TextField } from 'react-md' ;
import '../css/Intent.css'
import { INVOCATION _NAME _MAX _LENGTH , INVOCATION _ANSWER _MAX _LENGTH } from '../config' ;
class LaunchRequest extends Component {
constructor ( props ) {
super ( props ) ;
this . state = { invocationName : props . invocationName , invocationAnswer : props . invocationAnswer } ;
this . handleNameEdit = this . handleNameEdit . bind ( this ) ;
this . handleAnswerEdit = this . handleAnswerEdit . bind ( this ) ;
}
componentWillReceiveProps ( props ) {
this . setState ( { invocationName : props . invocationName , invocationAnswer : props . invocationAnswer } ) ;
}
render ( ) {
return (
< div className = "LaunchRequestBox" >
< h5 style = { { textAlign : 'left' , marginTop : '30px' , marginLeft : '20px' } } > Invocation name customers use to activate the skill . For example "Open Saburly" or "Talk to Saburly" < / h 5 >
< TextField
id = "invocation name"
lineDirection = "center"
placeholder = "Saburly"
label = "Invocation name"
className = "md-cell md-cell--bottom"
style = { { width : '60%' , marginLeft : '20px' } }
maxLength = { INVOCATION _NAME _MAX _LENGTH }
onChange = { this . handleNameEdit }
value = { this . state . invocationName } / >
< br > < / b r >
< h5 style = { { textAlign : 'left' , marginLeft : '20px' , marginTop : '30px' } } > Answer customers get from Alexa when they activate the skill . < / h 5 >
< TextField
id = "invocation answer"
lineDirection = "center"
placeholder = "We are Saburly, ask us something about us"
label = "Answer"
className = "md-cell md-cell--bottom"
style = { { width : '60%' , marginLeft : '20px' } }
maxLength = { INVOCATION _ANSWER _MAX _LENGTH }
onChange = { this . handleAnswerEdit }
value = { this . state . invocationAnswer } / >
< br > < / b r >
< br > < / b r >
2018-01-10 13:27:09 +01:00
< Button style = { { float : 'right' , marginRight : '20px' } } flat primary swapTheming
onClick = { ( ) => { this . props . onSaveClick ( this . state . invocationName , this . state . invocationAnswer ) } }
disabled = { this . props . waiting } > Save < / B u t t o n >
2017-12-02 22:48:45 +01:00
< / d i v >
) ;
}
handleNameEdit ( e ) {
if ( e . length === INVOCATION _NAME _MAX _LENGTH ) return ;
this . setState ( { invocationName : e } ) ;
}
handleAnswerEdit ( e ) {
if ( e . length === INVOCATION _ANSWER _MAX _LENGTH ) return ;
this . setState ( { invocationAnswer : e } ) ;
}
}
export default LaunchRequest ;