From 8e7a28a1211ff4550a5d9568d122463bd55f731e Mon Sep 17 00:00:00 2001 From: jpb626 Date: Tue, 5 Aug 2025 13:25:47 -0400 Subject: [PATCH 1/3] fixed poll vote text styling --- client/src/pages/Home.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/client/src/pages/Home.tsx b/client/src/pages/Home.tsx index f8dbd35..a5dfd40 100644 --- a/client/src/pages/Home.tsx +++ b/client/src/pages/Home.tsx @@ -109,11 +109,11 @@ const Home = () => { disabled={areButtonsDisabled} onClick={() => handleVote(i)} className={`${isSelected ? "btn" : "btn btn-outline"} inline-block w-auto max-w-none break-words`} - style={{ height: "auto", maxHeight: "none" }} + style={{ height: "auto", maxHeight: "none", justifyContent: "space-between"}} > -
+
{ans}
-
+
{isAdmin || selectedOption !== null ? voteText : ""}
From 640533276670942e83d43d79e6a376e90db26b1b Mon Sep 17 00:00:00 2001 From: jb272727 Date: Fri, 8 Aug 2025 14:28:36 -0400 Subject: [PATCH 2/3] adding delete button for options inside adminview --- client/src/components/AdminView.tsx | 40 ++++++++++++++++++++----- client/src/components/PageContainer.tsx | 2 +- client/src/pages/Home.tsx | 4 +-- 3 files changed, 36 insertions(+), 10 deletions(-) diff --git a/client/src/components/AdminView.tsx b/client/src/components/AdminView.tsx index 107c279..28607f0 100644 --- a/client/src/components/AdminView.tsx +++ b/client/src/components/AdminView.tsx @@ -21,6 +21,7 @@ export const AdminView = () => { const pollOptionMaxTextLength = 100; const pollQuestionMaxTextLength = 150; const maxOptions = 10; + const minOptions = 2; // state const [question, setQuestion] = useState(""); @@ -57,7 +58,7 @@ export const AdminView = () => { }, [poll]); const validOptions = options.filter((o) => o.trim() !== ""); - const isValid = question.trim() !== "" && validOptions.length >= 2; + const isValid = question.trim() !== "" && validOptions.length >= minOptions; // handlers const addOption = () => { @@ -65,6 +66,15 @@ export const AdminView = () => { setOptions((prev) => [...prev, ""]); } }; + const removeOption = (i: number) => { + if (options.length > minOptions) { // 2 is min options + setOptions(prev => { + const copy = [...prev]; + copy.splice(i, 1); + return copy; + }); + } + } // detect edits for modal type changes useEffect(() => { @@ -152,7 +162,7 @@ export const AdminView = () => { }; return ( -
+

Create or Update Poll

{errorMessage &&

{errorMessage}

} @@ -171,13 +181,15 @@ export const AdminView = () => { {question.length}/{pollQuestionMaxTextLength}
- + {/* poll options */}
+ {options.map((opt, i) => ( -
+
-
+ +
{ maxLength={pollOptionMaxTextLength} placeholder={`Option ${i + 1}`} /> + + {options.length > minOptions && ( + + )}
- + + {/* overlayed like your question field */} + {opt.length}/{pollOptionMaxTextLength}
))}
+ {/* add poll option */} {options.length < maxOptions && (
@@ -208,7 +234,7 @@ export const AdminView = () => { )}

Results Display

-
+