diff --git a/src/App.js b/src/App.js index 33b0b61..df9c493 100644 --- a/src/App.js +++ b/src/App.js @@ -1,4 +1,4 @@ -import { firebaseConfig } from "./config/Config.js" +import firebaseConfig from "./config/Config.js" import { getApp, initializeApp } from "firebase/app" import { useState, useEffect } from "react" import { @@ -6,29 +6,44 @@ import { collection, getDoc, doc, - getDocs + getDocs, + addDoc } from "firebase/firestore"; -import { getStorage } from "firebase/storage" import Form from 'react-bootstrap/Form'; import Button from 'react-bootstrap/Button'; import 'bootstrap/dist/css/bootstrap.min.css'; import Col from 'react-bootstrap/Col'; import './App.css' +import { FSContext } from ".//contexts/FSContext.js" + +import { useContext } from "react"; -function MyForm() { + export function MyForm(props) { + const db = useContext(FSContext) + const [submitter, setSubmitter] = useState(''); + const [date, setDate] = useState(''); + const [context, setContext] = useState(''); const [selectedOptions, setSelectedOptions] = useState([]); 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 ) + } + return (
@@ -36,14 +51,25 @@ function MyForm() { Enter submitter name: - + Enter the date the shennanigans occurred (dd-mm-yyyy): - + Enter context for this tamper tantrum: - - Select the words used by Ray during his little tamper tantrum: + + Select the words used by Ray during his little tamper tantrum: +