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 { query, task, result, loading, error } = this.props.result
console.log(this.props.result)
if (loading) {
return (
)
}
console.log(task, result)
if (error) {
// console.log(error)
let errorMessage = errors[error] || errors.error
return (
{errorMessage}
)
}
if (!task && !result) return
return (
Query took {query.timing.toFixed(2)} seconds
)
}
}
const mapStateToProps = state => ({
query: state.faceAnalysis.query,
result: state.faceAnalysis.result,
options: state.faceAnalysis.options,
})
const mapDispatchToProps = dispatch => ({
actions: bindActionCreators({ ...actions }, dispatch),
})
export default connect(mapStateToProps, mapDispatchToProps)(FaceAnalysisResult)