diff --git a/source/components/Satisfaction.js b/source/components/Satisfaction.js index cc2e64525..0832c8d77 100644 --- a/source/components/Satisfaction.js +++ b/source/components/Satisfaction.js @@ -1,17 +1,15 @@ -import React, {Component} from 'react' +import React, { Component } from 'react' import HoverDecorator from './HoverDecorator' import 'whatwg-fetch' -import {connect} from 'react-redux' +import { connect } from 'react-redux' import './Satisfaction.css' import classNames from 'classnames' -import ReactPiwik from './Tracker'; +import ReactPiwik from './Tracker' -@connect( - state => ({ - sessionId: state.sessionId - }) -) +@connect(state => ({ + sessionId: state.sessionId +})) export default class Satisfaction extends Component { state = { answer: false, @@ -20,7 +18,7 @@ export default class Satisfaction extends Component { messageSent: false } sendSatisfaction(answer) { - let {message, address} = this.state + let { message, address } = this.state if (document.location.hostname != 'localhost') { fetch('https://embauche.beta.gouv.fr/retour-syso', { method: 'POST', @@ -30,30 +28,34 @@ export default class Satisfaction extends Component { body: JSON.stringify({ fields: { satisfait: answer || '', - message: (message || '')+(address ? '(envoyé par '+address+')' : ''), + message: + (message || '') + (address ? '(envoyé par ' + address + ')' : ''), date: new Date().toISOString(), id: this.props.sessionId, url: document.location.href.toString() } }) }).then(response => { + console.log(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}) + if (message) return this.setState({ messageSent: true }) + this.setState({ answer }) }) } else { - if (message) this.setState({messageSent: true}) - this.setState({answer}) + console.log('!!!!!!!! Les retours ne sont pas envoyés en localhost !') + if (message) this.setState({ messageSent: true }) + this.setState({ answer }) } } render() { - let {answer, message, address, messageSent} = this.state, - validMessage = (typeof message == 'string' && message.length > 4) || (typeof address == 'string' && address.length > 4), + let { answer, message, address, messageSent } = this.state, + validMessage = + (typeof message == 'string' && message.length > 4) || + (typeof address == 'string' && address.length > 4), onSmileyClick = s => { // Pour l'instant on double le flux avec Piwik - ReactPiwik.push(['trackEvent', 'feedback', 'smiley', s]); + ReactPiwik.push(['trackEvent', 'feedback', 'smiley', s]) this.sendSatisfaction(s) } @@ -62,50 +64,68 @@ export default class Satisfaction extends Component {

Vous êtes satisfait du simulateur ?

- - + +

) let messagePlaceholder = { ':)': 'Envoyez-nous un commentaire !', - ':|': "Qu'est-ce qui n'a pas été ?" + ':|': 'Qu\'est-ce qui n\'a pas été ?' }[answer] - let feedback =
- this.setState({address: e.target.value})} - placeholder="adresse@courriel.com (optionnel)" /> -