diff --git a/src/App.js b/src/App.js index df9c493..9947727 100644 --- a/src/App.js +++ b/src/App.js @@ -20,7 +20,7 @@ import { FSContext } from ".//contexts/FSContext.js" import { useContext } from "react"; - export function MyForm(props) { +export function MyForm(props) { const db = useContext(FSContext) const [submitter, setSubmitter] = useState(''); const [date, setDate] = useState(''); @@ -30,45 +30,53 @@ import { useContext } from "react"; const handleCheckboxChange = (event) => { const { value, checked } = event.target; if (checked) { - setSelectedOptions([selectedOptions, value]); + setSelectedOptions([...selectedOptions, value]); } else { setSelectedOptions(selectedOptions.filter((option) => option !== value)); } }; const submitHandler = async (event) => { - event.preventDefault() - const incident = {setSubmitter: submitter, setDate: date, setContext: context, setSelectedOptions: selectedOptions } - const col = collection(db, `incidents/`) - const ref = await addDoc(col, incident ) - console.log( ref ) - } + event.preventDefault() + const incident = { submitter, date, context, selectedOptions } + const col = collection(db, `incidents/`) + const ref = await addDoc(col, incident) + console.log(ref) + } return ( -
To be added
-