|
|
|
@@ -1,4 +1,4 @@ |
|
|
|
import React from "react"; |
|
|
|
import React, { useEffect } from "react"; |
|
|
|
import PropTypes from "prop-types"; |
|
|
|
import { |
|
|
|
FirstStepCreateReviewContainer, |
|
|
|
@@ -20,8 +20,6 @@ import { useFormik } from "formik"; |
|
|
|
import * as Yup from "yup"; |
|
|
|
import useScreenDimensions from "../../../hooks/useScreenDimensions"; |
|
|
|
|
|
|
|
// const selectFieldValidation = Yup.string().oneOf(Object.keys(reviewEnum).map(property => reviewEnum[property].mainText)); |
|
|
|
|
|
|
|
const FirstStepCreateReview = (props) => { |
|
|
|
const offer = props.offer; |
|
|
|
const interlocutor = props.interlocutor; |
|
|
|
@@ -31,6 +29,20 @@ const FirstStepCreateReview = (props) => { |
|
|
|
props.goToNextStep(values); |
|
|
|
}; |
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
if (props.informations?.exchangeSucceed) { |
|
|
|
formik.setFieldValue( |
|
|
|
"exchangeSucceed", |
|
|
|
props.informations?.exchangeSucceed |
|
|
|
); |
|
|
|
formik.setFieldValue( |
|
|
|
"correctCommunication", |
|
|
|
props.informations?.correctCommunication |
|
|
|
); |
|
|
|
formik.setFieldValue("comment", props.informations?.comment); |
|
|
|
} |
|
|
|
}, [props.informations]); |
|
|
|
|
|
|
|
const formik = useFormik({ |
|
|
|
initialValues: { |
|
|
|
exchangeSucceed: reviewEnum.YES.mainText, |
|
|
|
@@ -64,18 +76,15 @@ const FirstStepCreateReview = (props) => { |
|
|
|
leftText={t("reviews.isCorrectCommunication").toUpperCase()} |
|
|
|
/> |
|
|
|
<SelectField |
|
|
|
defaultValue={reviewEnum.YES} |
|
|
|
defaultValue={formik.values.correctCommunication} |
|
|
|
onChange={(event) => |
|
|
|
formik.setFieldValue( |
|
|
|
"correctCommunication", |
|
|
|
event.target.value.mainText |
|
|
|
) |
|
|
|
formik.setFieldValue("correctCommunication", event.target.value) |
|
|
|
} |
|
|
|
> |
|
|
|
{Object.keys(reviewEnum).map((property) => ( |
|
|
|
<SelectOption |
|
|
|
key={reviewEnum[property].value} |
|
|
|
value={reviewEnum[property]} |
|
|
|
value={reviewEnum[property].mainText} |
|
|
|
> |
|
|
|
{reviewEnum[property].mainText} |
|
|
|
</SelectOption> |
|
|
|
@@ -84,21 +93,22 @@ const FirstStepCreateReview = (props) => { |
|
|
|
|
|
|
|
<FieldLabel leftText={t("reviews.hasExchangeSucceed").toUpperCase()} /> |
|
|
|
<SelectField |
|
|
|
defaultValue={reviewEnum.YES} |
|
|
|
defaultValue={formik.values.exchangeSucceed} |
|
|
|
onChange={(event) => |
|
|
|
formik.setFieldValue("exchangeSucceed", event.target.value.mainText) |
|
|
|
formik.setFieldValue("exchangeSucceed", event.target.value) |
|
|
|
} |
|
|
|
> |
|
|
|
{Object.keys(reviewEnum).map((property) => { |
|
|
|
if (property === "NOT_BAD") return; |
|
|
|
return ( |
|
|
|
<SelectOption |
|
|
|
key={reviewEnum[property].value} |
|
|
|
value={reviewEnum[property]} |
|
|
|
> |
|
|
|
{reviewEnum[property].mainText} |
|
|
|
</SelectOption> |
|
|
|
)})} |
|
|
|
<SelectOption |
|
|
|
key={reviewEnum[property].value} |
|
|
|
value={reviewEnum[property].mainText} |
|
|
|
> |
|
|
|
{reviewEnum[property].mainText} |
|
|
|
</SelectOption> |
|
|
|
); |
|
|
|
})} |
|
|
|
</SelectField> |
|
|
|
|
|
|
|
<FieldLabel leftText={t("reviews.comment")} /> |
|
|
|
@@ -131,6 +141,11 @@ FirstStepCreateReview.propTypes = { |
|
|
|
offer: PropTypes.any, |
|
|
|
interlocutor: PropTypes.any, |
|
|
|
goToNextStep: PropTypes.func, |
|
|
|
informations: PropTypes.shape({ |
|
|
|
exchangeSucceed: PropTypes.string, |
|
|
|
correctCommunication: PropTypes.string, |
|
|
|
comment: PropTypes.string, |
|
|
|
}), |
|
|
|
}; |
|
|
|
|
|
|
|
export default FirstStepCreateReview; |