@@ -6,14 +6,12 @@ import Row from "react-bootstrap/Row";
|
|||||||
import TextInput from "../../pageElements/TextInput";
|
import TextInput from "../../pageElements/TextInput";
|
||||||
import Modal from "react-bootstrap/Modal";
|
import Modal from "react-bootstrap/Modal";
|
||||||
import { v4 as uuidv4 } from "uuid";
|
import { v4 as uuidv4 } from "uuid";
|
||||||
|
|
||||||
import { collection, setDoc, updateDoc, doc } from "firebase/firestore";
|
import { collection, setDoc, updateDoc, doc } from "firebase/firestore";
|
||||||
import { AppContext } from "../../Hooks/useContext/appContext.js";
|
import { AppContext } from "../../Hooks/useContext/appContext.js";
|
||||||
import { db } from "../../firebase";
|
import { db } from "../../firebase";
|
||||||
import { objectMap } from "../../Utils/Object";
|
import { objectMap } from "../../Utils/Object";
|
||||||
import { createCaseFields as fields } from "../../Constants/Fields/CreateCaseFields.js";
|
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 "../../styles/modals.scss";
|
||||||
import {
|
import {
|
||||||
getFormDataDefaults,
|
getFormDataDefaults,
|
||||||
@@ -32,6 +30,7 @@ const CreateModal = ({ setShowModal, caseData }) => {
|
|||||||
const editCaseId = caseData?.id;
|
const editCaseId = caseData?.id;
|
||||||
const isEditing = typeof editCaseId !== "undefined";
|
const isEditing = typeof editCaseId !== "undefined";
|
||||||
const [isBusy, setIsBusy] = useState(false);
|
const [isBusy, setIsBusy] = useState(false);
|
||||||
|
const [venueArray, setVenueArray] = useState();
|
||||||
const [newCaseId, setNewCaseId] = useState();
|
const [newCaseId, setNewCaseId] = useState();
|
||||||
const state = group?.state[0].code ? group?.state[0].code : null;
|
const state = group?.state[0].code ? group?.state[0].code : null;
|
||||||
console.log("state", state);
|
console.log("state", state);
|
||||||
@@ -40,8 +39,26 @@ const CreateModal = ({ setShowModal, caseData }) => {
|
|||||||
getFormDataDefaults(fields, isEditing ? caseData : undefined)
|
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) => {
|
const handleChangeInput = (e, name) => {
|
||||||
|
let venArr;
|
||||||
const newData = handleFormDataChange(e, name, data, fields);
|
const newData = handleFormDataChange(e, name, data, fields);
|
||||||
|
if (state === "fl") {
|
||||||
|
venArr = selectVenueValues(newData);
|
||||||
|
}
|
||||||
|
|
||||||
|
setVenueArray(venArr);
|
||||||
if (newData !== null) {
|
if (newData !== null) {
|
||||||
setData(newData);
|
setData(newData);
|
||||||
}
|
}
|
||||||
@@ -198,6 +215,8 @@ const CreateModal = ({ setShowModal, caseData }) => {
|
|||||||
name={"venue"}
|
name={"venue"}
|
||||||
value={data.venue.value}
|
value={data.venue.value}
|
||||||
error={data.venue.error}
|
error={data.venue.error}
|
||||||
|
type={state === "fl" ? "select" : "text"}
|
||||||
|
values={venueArray}
|
||||||
message={data.venue.message}
|
message={data.venue.message}
|
||||||
disabled={isBusy}
|
disabled={isBusy}
|
||||||
onChange={(e) => handleChangeInput(e, "venue")}
|
onChange={(e) => handleChangeInput(e, "venue")}
|
||||||
@@ -241,9 +260,12 @@ const CreateModal = ({ setShowModal, caseData }) => {
|
|||||||
<TextInput
|
<TextInput
|
||||||
key={"jurisdiction"}
|
key={"jurisdiction"}
|
||||||
name={"jurisdiction"}
|
name={"jurisdiction"}
|
||||||
|
state={state}
|
||||||
value={data.jurisdiction.value}
|
value={data.jurisdiction.value}
|
||||||
|
values={floridaCourts}
|
||||||
error={data.jurisdiction.error}
|
error={data.jurisdiction.error}
|
||||||
message={data.jurisdiction.message}
|
message={data.jurisdiction.message}
|
||||||
|
type={state === "fl" ? "select" : "text"}
|
||||||
disabled={isBusy}
|
disabled={isBusy}
|
||||||
onChange={(e) => handleChangeInput(e, "jurisdiction")}
|
onChange={(e) => handleChangeInput(e, "jurisdiction")}
|
||||||
label={
|
label={
|
||||||
|
|||||||
@@ -20,3 +20,101 @@ export const createCaseAdditionalFields = {
|
|||||||
billingCode: { required: true, maxLength: 45 },
|
billingCode: { required: true, maxLength: 45 },
|
||||||
leadAttorneys: { 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"],
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|||||||
@@ -12,9 +12,11 @@ const TextInput = (props) => {
|
|||||||
values,
|
values,
|
||||||
onChange,
|
onChange,
|
||||||
id,
|
id,
|
||||||
|
state,
|
||||||
type,
|
type,
|
||||||
disabled,
|
disabled,
|
||||||
} = props;
|
} = props;
|
||||||
|
const isFlorida = state === "fl";
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
@@ -45,15 +47,19 @@ const TextInput = (props) => {
|
|||||||
className={`select-option`}
|
className={`select-option`}
|
||||||
value=""
|
value=""
|
||||||
></option>
|
></option>
|
||||||
{values.map((item, i) => (
|
{values && values != undefined ? (
|
||||||
|
values.map((item, i) => (
|
||||||
<option
|
<option
|
||||||
id="ddlProducts"
|
id="ddlProducts"
|
||||||
className={`select-option`}
|
className={`select-option`}
|
||||||
key={`item${i}`}
|
key={`item${i}`}
|
||||||
>
|
>
|
||||||
{item}
|
{isFlorida ? `${item.circuit} Judicial Circuit` : item}
|
||||||
</option>
|
</option>
|
||||||
))}
|
))
|
||||||
|
) : (
|
||||||
|
<></>
|
||||||
|
)}
|
||||||
</select>
|
</select>
|
||||||
) : (
|
) : (
|
||||||
<input
|
<input
|
||||||
|
|||||||
Reference in New Issue
Block a user