diff --git a/components/MarkChoices.tsx b/components/MarkChoices.tsx index 2de6089..b48078c 100644 --- a/components/MarkChoices.tsx +++ b/components/MarkChoices.tsx @@ -4,26 +4,26 @@ import { MarkedProps } from "../models/poll"; const MarkChoices = (props: { sortedChoices: number[]; - newUserMarked: MarkedProps; - setNewUserMarked: Dispatch; + newMarked: MarkedProps; + setNewMarked: Dispatch; }): JSX.Element => { - const { sortedChoices, newUserMarked, setNewUserMarked } = props; + const { sortedChoices, newMarked, setNewMarked } = props; const handleNameChange = (e: React.ChangeEvent): void => { const { value } = e.target; - setNewUserMarked({ ...newUserMarked, userID: value }); + setNewMarked({ ...newMarked, userID: value }); }; const handleChoiceChange = (e: React.ChangeEvent): void => { const { value, checked } = e.target; if (checked) { - const newChoices = newUserMarked.choices; + const newChoices = newMarked.choices; newChoices.push(parseInt(value, 10)); - setNewUserMarked({ ...newUserMarked, choices: newChoices }); + setNewMarked({ ...newMarked, choices: newChoices }); } else { - const newChoices = newUserMarked.choices; + const newChoices = newMarked.choices; newChoices.splice(newChoices.indexOf(parseInt(value, 10)), 1); // remove the unchecked element from array - setNewUserMarked({ ...newUserMarked, choices: newChoices }); + setNewMarked({ ...newMarked, choices: newChoices }); } }; diff --git a/components/SubmitChoices.tsx b/components/SubmitChoices.tsx index fe1b181..6c16fe7 100644 --- a/components/SubmitChoices.tsx +++ b/components/SubmitChoices.tsx @@ -1,18 +1,18 @@ import { Button } from "react-bootstrap"; import { MarkedProps } from "../models/poll"; -const SubmitChoices = (props: { newUserMarked: MarkedProps }): JSX.Element => { - const { newUserMarked } = props; +const SubmitChoices = (props: { newMarked: MarkedProps }): JSX.Element => { + const { newMarked } = props; const handleSubmit = (): void => { - // PUT newUserMarked at v1/poll/{pollID} + // PUT newMarked at v1/poll/:pollID }; return (