import React, { Component } from 'react' import { bindActionCreators } from 'redux' import { connect } from 'react-redux' import { courtesyS } from '../util' import * as actions from './faceAnalysis.actions' import { Loader } from '../common' const errors = { bbox: (

No face found

{"Sorry, we didn't detect a face in that image. "} {"Please choose an image where the face is large and clear."}
), nomatch: (

{"You're clear"}

{"No images in this dataset match your face. We show only matches above 70% probability."}
), error: (

{"No matches found"}

{"Sorry, an error occured."}
), not_an_image: (

{"Not an image"}

{"Sorry, the file you uploaded was not recognized as an image. Please upload a JPG or PNG image and try again."}
), } class FaceAnalysisResult extends Component { render() { const { result, timing } = this.props const { data, error, loading, message } = result let { step, total } = data || {} // console.log(step, total) if (loading) { return (

Uploading...

) } if (error) { // console.log(error) let errorMessage = errors[error] || errors.error return (
{errorMessage}
) } // console.log(result) if (!total) { return (
) } let blurImg = data.data.blur_fn && (
Blurred image
) return (
{!(step && total && message) ? '' : ({step} / {total}: {message})} {blurImg}
Query took {(timing / 1000).toFixed(2)} s.
) } } const mapStateToProps = state => ({ query: state.faceAnalysis.query, result: state.faceAnalysis.result, timing: state.faceAnalysis.timing, options: state.faceAnalysis.options, }) const mapDispatchToProps = dispatch => ({ actions: bindActionCreators({ ...actions }, dispatch), }) export default connect(mapStateToProps, mapDispatchToProps)(FaceAnalysisResult)