diff --git a/src/Components/Case/CaseTypePage.js b/src/Components/Case/CaseTypePage.js index f6ab179..00fa0b2 100644 --- a/src/Components/Case/CaseTypePage.js +++ b/src/Components/Case/CaseTypePage.js @@ -1,54 +1,29 @@ -import { useEffect, useContext, useState, useRef } from "react"; +import React, { 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 { AppContext } from "../../Hooks/useContext/appContext.js"; +import { doc, onSnapshot } from "firebase/firestore"; +import Radiogroup from "../../pageElements/Radiogroup"; import { caseTags } from "../../Constants/Tags/CaseTags"; +import { db } from "../../firebase"; import "../../styles/casetype-page.scss"; -const CaseTypePage = ({ caseData }) => { +const CaseTypePage = () => { 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 [subCase, setSubCase] = useState(); + const [email, setEmail] = useState(""); + const [contactName, setContactName] = useState(""); + const [billingCode, setBillingCode] = useState(""); + const [leadAttorney, setLeadAttorney] = useState(""); + const [radioValue, setRadioValue] = useState(); + const [selectedCaseTags, setSelectedCaseTags] = useState([]); - const parsedTags = dJSON.parse(JSON.stringify(caseTags)); - - const handleNavigate = () => { - navigate("/documents"); - }; - - const handleBack = () => { - navigate("/cases"); - }; + const typeaheadRef = useRef(); function getCase() { const docRef = doc(db, "cases", caseId); @@ -62,14 +37,9 @@ const CaseTypePage = ({ caseData }) => { return unsub; } - useEffect(getCase, [caseId, appUserId]); + const parsedTags = JSON.parse(JSON.stringify(caseTags)); - const handleChangeInput = (e, name) => { - const newData = handleFormDataChange(e, name, data, fields); - if (newData !== null) { - setData(newData); - } - }; + useEffect(getCase, [caseId, appUserId]); const setSelectedTag = (item) => { console.log("item in setSelectedTag ---------------------->", item); @@ -78,228 +48,105 @@ const CaseTypePage = ({ caseData }) => { 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 ButtonContent = () => { - return ( -
-
-
-
- - ); - }; - const radioOptions = [ { name: "Plaintiff", label: "Plaintiff", value: "Plaintiff" }, { name: "Defendant", label: "Defendant", value: "Defendant" }, ]; - if (!group) { - return null; - } + const handleSetRadioValue = (e) => { + console.log("e", e); + setRadioValue(e.value); + }; return ( -
-
- - - {isEditing ? ( -
Case Type
- ) : ( - <> - )} - { - let item = null; - for (const currentItem of selected) { - item = { ...currentItem }; - } - setSelectedTag(item); - typeaheadRef.current.clear(); - }} - /> -
- {selectedCaseTags.map((tag, i) => ( -
-
-
-
x
-
-
{tag}
+
+
+
+ setLeadAttorney(e.target.value)} + > +
+
+ setBillingCode(e.target.value)} + > +
+
+
+
+ setContactName(e.target.value)} + > +
+
+ setEmail(e.target.value)} + > +
+
+
+
+ { + let item = null; + for (const currentItem of selected) { + item = { ...currentItem }; + } + setSelectedTag(item); + typeaheadRef.current.clear(); + }} + /> +
+ {selectedCaseTags.map((tag, i) => ( +
+
+
+
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" - : "" - } - /> - -
- +
+ ))} +
+
+
+ handleSetRadioValue(e, "clientPosition")} + /> +
+
); }; 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..d5c60d2 --- /dev/null +++ b/src/pageElements/TagSelector.js @@ -0,0 +1,42 @@ +/* + { + let item = null; + for (const currentItem of selected) { + item = { ...currentItem }; + } + setSelectedTag(item); + typeaheadRef.current.clear(); + }} + /> +
+ {selectedCaseTags.map((tag, i) => ( +
+
+
+
x
+
+
{tag}
+
+
+ ))} +
+ + + + setRadioValue(e, "clientPosition")} + /> + + */ diff --git a/src/styles/casetype-page.scss b/src/styles/casetype-page.scss index 0393544..b859d98 100644 --- a/src/styles/casetype-page.scss +++ b/src/styles/casetype-page.scss @@ -1,36 +1,48 @@ -.casetype-container { - width: 920px; +.type-container { display: flex; flex-direction: column; + align-items: center; + justify-content: center; margin-left: auto; margin-right: auto; - align-items: center; + width: 900px; } -.casetype-form { +.type-row { + display: flex; + flex-direction: row; + justify-content: center; width: 100%; + margin-left: auto; + margin-right: auto; +} + +.type-col { + display: flex; + flex-direction: column; + width: 50%; } .case-tag-container { display: flex; + flex-direction: row; + flex-wrap: wrap; border: 1px solid red; - height: 300px; + padding-top: 8px; } .tag-container { - display: flex; - flex-direction: row; - height: 50px; - justify-content: center; + height: 30px; + margin-top: 8px; + margin-bottom: 8px; align-items: center; } .tag-box { background-color: rgba(224, 224, 224, 0.421); display: flex; - flex-direction: row; border-radius: 8px; - margin: 6px 4px; + margin: 4px 4px; padding: 6px; } @@ -39,9 +51,12 @@ } .tag-ex { + cursor: pointer; margin-top: -7px; font-weight: 500; font-size: 0.88rem; + height: 20px; + background-color: blue; } .casetag-name {