diff --git a/USupport-components-library b/USupport-components-library index 1df81e3a..da55b0fd 160000 --- a/USupport-components-library +++ b/USupport-components-library @@ -1 +1 @@ -Subproject commit 1df81e3a063af11f844765ebd2964df94c50a7f6 +Subproject commit da55b0fdf973104552ad662852ccafcea136fd08 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 && ( + +