diff --git a/src/Components/Modals/CreateModal.js b/src/Components/Modals/CreateModal.js index ef68e26..93360f9 100644 --- a/src/Components/Modals/CreateModal.js +++ b/src/Components/Modals/CreateModal.js @@ -6,14 +6,12 @@ import Row from "react-bootstrap/Row"; import TextInput from "../../pageElements/TextInput"; import Modal from "react-bootstrap/Modal"; import { v4 as uuidv4 } from "uuid"; - import { collection, setDoc, updateDoc, doc } from "firebase/firestore"; import { AppContext } from "../../Hooks/useContext/appContext.js"; import { db } from "../../firebase"; import { objectMap } from "../../Utils/Object"; import { createCaseFields as fields } from "../../Constants/Fields/CreateCaseFields.js"; -import { createCaseAdditionalFields as additionalFields } from "../../Constants/Fields/CreateCaseFields.js"; - +import { floridaCourts } from "../../Constants/Fields/CreateCaseFields.js"; import "../../styles/modals.scss"; import { getFormDataDefaults, @@ -32,6 +30,7 @@ const CreateModal = ({ setShowModal, caseData }) => { const editCaseId = caseData?.id; const isEditing = typeof editCaseId !== "undefined"; const [isBusy, setIsBusy] = useState(false); + const [venueArray, setVenueArray] = useState(); const [newCaseId, setNewCaseId] = useState(); const state = group?.state[0].code ? group?.state[0].code : null; console.log("state", state); @@ -40,8 +39,26 @@ const CreateModal = ({ setShowModal, caseData }) => { getFormDataDefaults(fields, isEditing ? caseData : undefined) ); + function selectVenueValues(data) { + const result = floridaCourts.filter((court) => { + let val; + const target = data?.jurisdiction?.value?.split(" ")[0]; + if (court?.circuit === target) { + return court?.counties; + } + }); + const count = result[0]?.counties; + return count; + } + const handleChangeInput = (e, name) => { + let venArr; const newData = handleFormDataChange(e, name, data, fields); + if (state === "fl") { + venArr = selectVenueValues(newData); + } + + setVenueArray(venArr); if (newData !== null) { setData(newData); } @@ -198,6 +215,8 @@ const CreateModal = ({ setShowModal, caseData }) => { name={"venue"} value={data.venue.value} error={data.venue.error} + type={state === "fl" ? "select" : "text"} + values={venueArray} message={data.venue.message} disabled={isBusy} onChange={(e) => handleChangeInput(e, "venue")} @@ -241,9 +260,12 @@ const CreateModal = ({ setShowModal, caseData }) => { handleChangeInput(e, "jurisdiction")} label={ diff --git a/src/Constants/Fields/CreateCaseFields.js b/src/Constants/Fields/CreateCaseFields.js index 6ed1c15..074169c 100644 --- a/src/Constants/Fields/CreateCaseFields.js +++ b/src/Constants/Fields/CreateCaseFields.js @@ -20,3 +20,101 @@ export const createCaseAdditionalFields = { billingCode: { required: true, maxLength: 45 }, leadAttorneys: { required: true, maxLength: 45 }, }; + +export const floridaCourts = [ + { + circuit: "First", + counties: ["Escambia", "Okaloosa", "Santa Rosa", "Walton"], + }, + { + circuit: "Second", + counties: [ + "Franklin", + "Gadsden", + "Jefferson", + "Leon", + "Liberty", + "Wakulla", + ], + }, + { + circuit: "Third", + counties: [ + "Columbia", + "Dixie", + "Hamilton", + "Lafayette", + "Madison", + "Suwannee", + "Taylor", + ], + }, + { + circuit: "Fourth", + counties: ["Clay", "Duval", "Nassau"], + }, + { + circuit: "Fifth", + counties: ["Citrus", "Hernando", "Lake", "Marion", "Sumter"], + }, + { + circuit: "Sixth", + counties: ["Pasco", "Pinellas"], + }, + { + circuit: "Seventh", + counties: ["Flagler", "Putnam", "St. Johns", "Volusia"], + }, + { + circuit: "Eigth", + counties: ["Alachua", "Baker", "Bradford", "Gilchrist", "Levy", "Union"], + }, + { + circuit: "Ninth", + counties: ["Orange", "Osceola"], + }, + { + circuit: "Tenth", + counties: ["Hardee", "Highlands", "Polk"], + }, + { + circuit: "Eleventh", + counties: ["Miami-Dade"], + }, + { + circuit: "Twelfth", + counties: ["DeSoto", "Manatee", "Sarasota"], + }, + { + circuit: "Thirteenth", + counties: ["Hillsborough"], + }, + { + circuit: "Fourteenth", + counties: ["Bay", "Calhoun", "Gulf", "Holmes", "Jackson", "Washington"], + }, + { + circuit: "Fifteenth", + counties: ["Palm Beach"], + }, + { + circuit: "Sixteenth", + counties: ["Monroe"], + }, + { + circuit: "Seventeenth", + counties: ["Broward"], + }, + { + circuit: "Eighteenth", + counties: ["Brevard", "Seminole"], + }, + { + circuit: "Nineteenth", + counties: ["Indian River", "Martin", "Okeechobee", "St. Lucie"], + }, + { + circuit: "Twentieth", + counties: ["Charlotte", "Collier", "Glades", "Hendry", "Lee"], + }, +]; diff --git a/src/pageElements/TextInput.js b/src/pageElements/TextInput.js index fe9cdf4..e165339 100644 --- a/src/pageElements/TextInput.js +++ b/src/pageElements/TextInput.js @@ -12,9 +12,11 @@ const TextInput = (props) => { values, onChange, id, + state, type, disabled, } = props; + const isFlorida = state === "fl"; return (
{ className={`select-option`} value="" > - {values.map((item, i) => ( - - ))} + {values && values != undefined ? ( + values.map((item, i) => ( + + )) + ) : ( + <> + )} ) : (