From 7b086678b2a256ca28547bb1bf90d180276cb024 Mon Sep 17 00:00:00 2001 From: "Georgi Ganchev @7DIGIT" Date: Thu, 11 Apr 2024 12:02:08 +0300 Subject: [PATCH 1/2] Add: new questions to the SafetyFeedback --- src/blocks/SafetyFeedback/SafetyFeedback.jsx | 241 ++++++++++++++++-- src/blocks/SafetyFeedback/locales/en.json | 14 +- src/blocks/SafetyFeedback/locales/kk.json | 14 +- src/blocks/SafetyFeedback/locales/ru.json | 14 +- .../SafetyFeedback/safety-feedback.scss | 20 ++ ...GetSecurityCheckAnswersByConsultationId.js | 7 + 6 files changed, 285 insertions(+), 25 deletions(-) diff --git a/src/blocks/SafetyFeedback/SafetyFeedback.jsx b/src/blocks/SafetyFeedback/SafetyFeedback.jsx index bd64bea4..42beb6c3 100644 --- a/src/blocks/SafetyFeedback/SafetyFeedback.jsx +++ b/src/blocks/SafetyFeedback/SafetyFeedback.jsx @@ -10,6 +10,8 @@ import { Icon, RadioButtonSelector, Textarea, + Emoticon, + Slider, } from "@USupport-components-library/src"; import { ThemeContext } from "@USupport-components-library/utils"; @@ -32,9 +34,17 @@ export const SafetyFeedback = ({ consultationId, answers = {} }) => { const { t } = useTranslation("safety-feedback-block"); const navigate = useNavigate(); const hasAnsweredBefore = - Object.values(answers).filter((x) => x !== undefined).length === 5; + Object.values(answers).filter((x) => x !== undefined).length === 11; const [questions, setQuestions] = useState([ + { + label: t("q0"), + field: "providerAttend", + value: answers.hasOwnProperty("providerAttend") + ? answers.providerAttend + : null, + id: 0, + }, { label: t("q1"), field: "contactsDisclosure", @@ -66,6 +76,48 @@ export const SafetyFeedback = ({ consultationId, answers = {} }) => { ? answers.unsafeFeeling : null, id: 4, + showInput: true, + }, + { + label: t("q5"), + field: "feeling", + value: answers.hasOwnProperty("feeling") ? answers.feeling : null, + id: 5, + type: "emoji", + }, + { + label: t("q6"), + field: "addressedNeeds", + value: answers.hasOwnProperty("addressedNeeds") + ? answers.addressedNeeds + : 10, + id: 6, + type: "slider", + }, + { + label: t("q7"), + field: "improveWellbeing", + value: answers.hasOwnProperty("improveWellbeing") + ? answers.improveWellbeing + : 10, + id: 7, + type: "slider", + }, + { + label: t("q8"), + field: "feelingsNow", + value: answers.hasOwnProperty("feelingsNow") ? answers.feelingsNow : 10, + id: 8, + type: "slider", + }, + { + label: t("q9"), + field: "additionalComment", + value: answers.hasOwnProperty("additionalComment") + ? answers.additionalComment + : null, + id: 9, + type: "textarea", }, ]); @@ -105,14 +157,22 @@ export const SafetyFeedback = ({ consultationId, answers = {} }) => { }; const canSubmit = useMemo(() => { + const questionsExcludingLast = questions.slice(0, -1); + return ( - questions.filter((x) => x.value !== null && x.value !== undefined) - .length === questions.length + questionsExcludingLast.filter( + (x) => x.value !== null && x.value !== undefined + ).length === questionsExcludingLast.length ); }, [questions]); return ( - +

{t("heading")}

@@ -127,25 +187,51 @@ export const SafetyFeedback = ({ consultationId, answers = {} }) => {

{t("warning")}

{questions.map((question) => ( - - - + <> + + {question?.type === "emoji" ? ( + + ) : question?.type === "slider" ? ( + + ) : question?.type === "textarea" ? ( + + ) : ( + + )} + + {question.id === 4 && questions[4].value === true && ( + +