diff --git a/src/Components/Case/CaseTypePage.js b/src/Components/Case/CaseTypePage.js index a6e92e4..c8a2db0 100644 --- a/src/Components/Case/CaseTypePage.js +++ b/src/Components/Case/CaseTypePage.js @@ -1,318 +1,32 @@ -import { useEffect, useContext, useState, useRef } from "react"; -import { useNavigate } from "react-router-dom"; -import Button from "../../pageElements/Button"; -import Form from "react-bootstrap/Form"; -import Col from "react-bootstrap/Col"; -import Row from "react-bootstrap/Row"; -import TextInput from "../../pageElements/TextInput"; -import Radiogroup from "../../pageElements/Radiogroup"; -import { - getFormDataDefaults, - getValidatedFormData, - handleFormDataChange, - isFormDataHasErrors, -} from "../../Utils/Form"; -import { db } from "../../firebase"; -import * as dJSON from "dirty-json"; -import { useParams } from "react-router-dom"; -import { AppContext } from "../../Hooks/useContext/appContext.js"; -import LoadingSpinner from "../../pageElements/LoadingSpinner"; -import { doc, onSnapshot } from "firebase/firestore"; -import { createCaseAdditionalFields as fields } from "../../Constants/Fields/CreateCaseFields.js"; -import { objectMap } from "../../Utils/Object"; -import { Typeahead } from "react-bootstrap-typeahead"; -import { caseTags } from "../../Constants/Tags/CaseTags"; +import { useState } from "react"; import "../../styles/casetype-page.scss"; - -const CaseTypePage = ({ caseData }) => { - const { caseId } = useParams(); - const navigate = useNavigate(); - const { appState } = useContext(AppContext); - const { group } = appState; - const [isEditing, setFsEditing] = useState(false); - const [subCase, setSubCase] = useState(null); - const [isLoading, setIsLoading] = useState(false); - const [selectedCaseTags, setSelectedCaseTags] = useState([]); - const typeaheadRef = useRef(); - const appUserId = group ? group.appUserId : null; - const [data, setData] = useState( - getFormDataDefaults(fields, isEditing ? caseData : undefined) - ); - const [isBusy, setIsBusy] = useState(false); - - const parsedTags = dJSON.parse(JSON.stringify(caseTags)); - - const handleNavigate = () => { - navigate("/documents"); - }; - - const handleBack = () => { - navigate("/cases"); - }; - - function getCase() { - const docRef = doc(db, "cases", caseId); - const unsub = onSnapshot(docRef, (snapshot) => { - if (snapshot.exists() && snapshot.data().ownerId === appUserId) { - setSubCase({ ...snapshot.data(), id: snapshot.id }); - } else { - setSubCase(null); - } - }); - return unsub; - } - - useEffect(getCase, [caseId, appUserId]); - - const handleChangeInput = (e, name) => { - const newData = handleFormDataChange(e, name, data, fields); - if (newData !== null) { - setData(newData); - } - }; - - const setSelectedTag = (item) => { - const temp = [...selectedCaseTags, item.tagName]; - setSelectedCaseTags(temp); - console.log("selectedCaseTags", selectedCaseTags); - }; - - const validateData = () => { - const newData = getValidatedFormData(data, fields); - const hasErrors = isFormDataHasErrors(newData); - setData(newData); - return hasErrors ? null : objectMap(({ value }) => value, newData); - }; - - const handleTagClick = (clickedTag) => { - console.log("handleTagClick tag", clickedTag); - console.log("selectedCaseTags", selectedCaseTags); - const temp = selectedCaseTags; - const foo = temp.filter((tag) => { - if (tag != clickedTag) return tag; - }); - setSelectedCaseTags(foo); - }; - - const ButtonContent = () => { - return ( -
-
-
-
- - ); - }; - - const radioOptions = [ - { name: "Plaintiff", label: "Plaintiff", value: "Plaintiff" }, - { name: "Defendant", label: "Defendant", value: "Defendant" }, - ]; - - if (!group) { - return null; - } - +const CaseTypePage = () => { + const [email, setEmail] = useState(""); + const [contactName, setContactName] = useState(""); return ( -
-
- - - {isEditing ? ( -
Case Type
- ) : ( - <> - )} - { - let item = null; - for (const currentItem of selected) { - item = { ...currentItem }; - } - setSelectedTag(item); - typeaheadRef.current.clear(); - }} - /> -
- {selectedCaseTags.map((tag, i) => ( -
-
-
handleTagClick(tag)} - > -
x
-
-
{tag}
-
-
- ))} -
- - - {isEditing ? ( -
Position
- ) : ( - <> - )} - -
- - - {isEditing ? ( -
Lead Attorney
- ) : ( - <> - )} - handleChangeInput(e, "leadAttorneys")} - label={ - data.leadAttorneys.value.length === 0 - ? isEditing - ? caseData.leadAttorneys - : "Lead Attornery(s)" - : "" - } - /> - - - {isEditing ? ( -
Billing code
- ) : ( - <> - )} - handleChangeInput(e, "billingCode")} - label={ - data.billingCode.value.length === 0 - ? isEditing - ? caseData.billingCode - : "Billing Code" - : "" - } - /> - -
- - - {isEditing ? ( -
Contact Name
- ) : ( - <> - )} - handleChangeInput(e, "contactLastName")} - label={ - data.contactName.value.length === 0 - ? isEditing - ? caseData.contactName - : "Contact Name" - : "" - } - /> - - - {isEditing ? ( -
Contact email
- ) : ( - <> - )} - handleChangeInput(e, "contactEmail")} - label={ - data.contactEmail.value.length === 0 - ? isEditing - ? caseData.contactEmail - : "Contact Email" - : "" - } - /> - -
-
- +
+
+ setContactName(e.target.value)} + > +
+
+ setEmail(e.target.value)} + > +
); }; export default CaseTypePage; - -/* - { - let item = null; - for (const currentItem of selected) { - item = { ...currentItem }; - } - setSelectedTag(item); - typeaheadRef.current.clear(); - }} - /> -
- {selectedCaseTags.map((tag, i) => ( -
-
-
-
x
-
-
{tag}
-
-
- ))} -
- - - - handleChangeInput(e, "clientPosition")} - /> - - */ diff --git a/src/pageElements/TagSelector.js b/src/pageElements/TagSelector.js new file mode 100644 index 0000000..79f5751 --- /dev/null +++ b/src/pageElements/TagSelector.js @@ -0,0 +1,43 @@ +/* + { + let item = null; + for (const currentItem of selected) { + item = { ...currentItem }; + } + setSelectedTag(item); + typeaheadRef.current.clear(); + }} + /> +
+ {selectedCaseTags.map((tag, i) => ( +
+
+
+
x
+
+
{tag}
+
+
+ ))} +
+ + + + handleChangeInput(e, "clientPosition")} + /> + + */ + */ \ No newline at end of file diff --git a/src/styles/casetype-page.scss b/src/styles/casetype-page.scss index 4386b39..59c2d81 100644 --- a/src/styles/casetype-page.scss +++ b/src/styles/casetype-page.scss @@ -1,14 +1,14 @@ -.casetype-container { - width: 920px; +.type-row { display: flex; - flex-direction: column; + flex-direction: row; + justify-content: center; margin-left: auto; margin-right: auto; - align-items: center; } -.casetype-form { - width: 100%; +.type-col { + display: flex; + flex-direction: column; } .case-tag-container {