import React, {Component} from 'react' import HoverDecorator from './HoverDecorator' import 'whatwg-fetch' import {connect} from 'react-redux' import './Satisfaction.css' import classNames from 'classnames' @connect( state => ({ sessionId: state.sessionId }) ) export default class Satisfaction extends Component { state = { answer: false, message: 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() } }) }).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}) }) } render() { let {answer, message, messageSent} = this.state, validMessage = typeof message == 'string' && message.length > 4, onSmileyClick = s => this.sendSatisfaction(s) console.log(messageSent) if (!answer) return (
Vous êtes satisfait du simulateur ?
{" "}