From 6fc5fc8f58842859110b2f51056c62186af8c4c9 Mon Sep 17 00:00:00 2001 From: Catherine Molina Betancourt Date: Sun, 7 Dec 2025 09:38:23 -0800 Subject: [PATCH] feat/communityforum --- src/components/DailySummary.jsx | 47 +++++--- src/components/ProgressBar.jsx | 2 +- src/data/questions.js | 189 ++++++++++++++++++++++++++++++-- src/main.jsx | 7 +- src/pages/Community.jsx | 55 +++++++++- src/pages/ForumResponses.jsx | 133 ++++++++++++++++++++++ src/pages/journal.jsx | 182 ++++++++++++++++++++++-------- 7 files changed, 537 insertions(+), 78 deletions(-) create mode 100644 src/pages/ForumResponses.jsx diff --git a/src/components/DailySummary.jsx b/src/components/DailySummary.jsx index 11229f1..6916afa 100644 --- a/src/components/DailySummary.jsx +++ b/src/components/DailySummary.jsx @@ -1,6 +1,5 @@ //react import { useState, useEffect } from 'react'; -import { Link } from 'react-router-dom'; // component import Button from './Button'; @@ -14,20 +13,31 @@ const DailySummary = ({ onSave, }) => { const max_chars = 500; - const [comment, setComment] = useState(initialComment || ''); + + const initialCommentObject = initialComment || {}; + const [comment, setComment] = useState(initialCommentObject.comment || ''); + + const [isOptedOut, setIsOptedOut] = useState( + initialCommentObject.optOut || false + ); + const remainingChars = max_chars - comment.length; useEffect(() => { - setComment(initialComment || ''); + const updatedCommentObject = initialComment || {}; + setComment(updatedCommentObject.comment || ''); + setIsOptedOut(updatedCommentObject.optOut || false); }, [initialComment, day]); const handleSave = () => { - onSave(day, comment); + onSave(day, comment, isOptedOut); onClose(); }; const handleCancel = () => { - setComment(initialComment || ''); + const updatedCommentObject = initialComment || {}; + setComment(updatedCommentObject.comment || ''); + setIsOptedOut(updatedCommentObject.optOut || false); onClose(); }; @@ -46,8 +56,9 @@ const DailySummary = ({ Day {day} Summary -

{question}

- + +

{question}

+