Merge pull request #44 from sgmap/more-emails
Tentative pour améliorer la collecte d'emailspull/41/merge
commit
96ce039282
|
@ -31,6 +31,15 @@
|
|||
font-size: 85%;
|
||||
}
|
||||
|
||||
#satisfaction input {
|
||||
border: 1px solid rgb(74, 137, 220, .5);
|
||||
border-radius: .3em;
|
||||
width: 65%;
|
||||
padding: .6em;
|
||||
margin-bottom: .3em;
|
||||
font-size: 85%;
|
||||
}
|
||||
|
||||
#sendMessage {
|
||||
font-size: 100%;
|
||||
border: none;
|
||||
|
|
|
@ -14,35 +14,41 @@ export default class Satisfaction extends Component {
|
|||
state = {
|
||||
answer: false,
|
||||
message: null,
|
||||
address: null,
|
||||
messageSent: false
|
||||
}
|
||||
sendSatisfaction(answer) {
|
||||
let {message} = this.state
|
||||
fetch('https://embauche.beta.gouv.fr/retour-syso', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
fields: {
|
||||
satisfait: answer || '',
|
||||
message: message || '',
|
||||
date: new Date().toISOString(),
|
||||
id: this.props.sessionId,
|
||||
url: document.location.href.toString()
|
||||
}
|
||||
let {message, address} = this.state
|
||||
if (document.location.hostname != 'localhost') {
|
||||
fetch('https://embauche.beta.gouv.fr/retour-syso', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
fields: {
|
||||
satisfait: answer || '',
|
||||
message: (message || '')+(address ? '(envoyé par '+address+')' : ''),
|
||||
date: new Date().toISOString(),
|
||||
id: this.props.sessionId,
|
||||
url: document.location.href.toString()
|
||||
}
|
||||
})
|
||||
}).then(response => {
|
||||
if (!response.ok)
|
||||
return console.log('Erreur dans la récolte de la satisfaction') //eslint-disable-line no-console
|
||||
if (message)
|
||||
return this.setState({messageSent: true})
|
||||
this.setState({answer})
|
||||
})
|
||||
}).then(response => {
|
||||
if (!response.ok)
|
||||
return console.log('Erreur dans la récolte de la satisfaction') //eslint-disable-line no-console
|
||||
if (message)
|
||||
return this.setState({messageSent: true})
|
||||
} else {
|
||||
if (message) this.setState({messageSent: true})
|
||||
this.setState({answer})
|
||||
})
|
||||
}
|
||||
}
|
||||
render() {
|
||||
let {answer, message, messageSent} = this.state,
|
||||
validMessage = typeof message == 'string' && message.length > 4,
|
||||
let {answer, message, address, messageSent} = this.state,
|
||||
validMessage = (typeof message == 'string' && message.length > 4) || (typeof address == 'string' && address.length > 4),
|
||||
onSmileyClick = s => this.sendSatisfaction(s)
|
||||
|
||||
if (!answer)
|
||||
|
@ -60,13 +66,20 @@ export default class Satisfaction extends Component {
|
|||
':|': "Qu'est-ce qui n'a pas été ?"
|
||||
}[answer]
|
||||
|
||||
return (
|
||||
<div id="satisfaction">
|
||||
{!messageSent &&
|
||||
<textarea
|
||||
let feedback = <div>
|
||||
<input type="text"
|
||||
value={this.state.address || ''}
|
||||
onChange={e => this.setState({address: e.target.value})}
|
||||
placeholder="adresse@courriel.com (optionnel)" />
|
||||
<textarea
|
||||
value={this.state.message || ''}
|
||||
onChange={e => this.setState({message: e.target.value})}
|
||||
placeholder={messagePlaceholder} /> }
|
||||
placeholder={messagePlaceholder} />
|
||||
</div>
|
||||
|
||||
return (
|
||||
<div id="satisfaction">
|
||||
{!messageSent && feedback}
|
||||
<button id="sendMessage" disabled={!validMessage || messageSent} onClick={() => this.sendSatisfaction()}>
|
||||
{messageSent ?
|
||||
<i id="messageSent" className="fa fa-check" aria-hidden="true"></i>
|
||||
|
@ -77,7 +90,7 @@ export default class Satisfaction extends Component {
|
|||
}
|
||||
</button>
|
||||
<p>
|
||||
Pour recevoir une réponse, donnez-nous votre adresse ou {' '}
|
||||
Pour recevoir une réponse, laissez-nous votre adresse ou {' '}
|
||||
<a href={"mailto:contact@embauche.beta.gouv.fr?subject=Suggestion pour le simulateur " + this.props.simu}>
|
||||
envoyez-nous directement un mail <i className="fa fa-envelope-open-o" aria-hidden="true" style={{margin: '0 .3em'}}></i>
|
||||
</a>
|
||||
|
|
Loading…
Reference in New Issue