From 7a7935c50045a71b7f9815f455f968b146a058ff Mon Sep 17 00:00:00 2001 From: memeriau Date: Mon, 24 Jan 2022 20:16:29 +0100 Subject: [PATCH] inject saved comment in form --- src/components/VolunteerBoard/DayWishes/DayWishes.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/components/VolunteerBoard/DayWishes/DayWishes.tsx b/src/components/VolunteerBoard/DayWishes/DayWishes.tsx index 7b89471..e0191a7 100644 --- a/src/components/VolunteerBoard/DayWishes/DayWishes.tsx +++ b/src/components/VolunteerBoard/DayWishes/DayWishes.tsx @@ -1,6 +1,7 @@ import { FC, memo, useCallback, useEffect, useRef, useState } from "react" import classnames from "classnames" import get from "lodash/get" +import set from "lodash/set" import styles from "./styles.module.scss" import { daysChoice, @@ -16,6 +17,7 @@ const DayWishes: FC = (): JSX.Element | null => { useEffect(() => { if (!userWishes) return + console.log("userWishes", userWishes) const newSelection = get(userWishes, "dayWishes", []).reduce( (acc: selectionChoices, day: string) => ({ ...acc, @@ -24,7 +26,8 @@ const DayWishes: FC = (): JSX.Element | null => { daysChoice ) setSelection(newSelection) - }, [setSelection, userWishes]) + set(commentRef, "current.value", get(userWishes, "dayWishesComment", "")) + }, [setSelection, commentRef, userWishes]) const onChoiceClick = useCallback( (id) => {