This commit is contained in:
Kenneth Jannette
2024-01-31 16:08:12 -06:00
parent bc6172e047
commit 82a09f3f73

View File

@@ -1,18 +1,41 @@
import { useState } from "react";
import React, { useEffect, useContext, useState, useRef } from "react";
import { useNavigate } from "react-router-dom";
import { useParams } from "react-router-dom";
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 = () => {
const { caseId } = useParams();
const navigate = useNavigate();
const { appState } = useContext(AppContext);
const { group } = appState;
const appUserId = group ? group.appUserId : null;
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 parsedTags = JSON.parse(JSON.stringify(caseTags));
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;
}
const parsedTags = JSON.parse(JSON.stringify(caseTags));
useEffect(getCase, [caseId, appUserId]);
const radioOptions = [
{ name: "Plaintiff", label: "Plaintiff", value: "Plaintiff" },
{ name: "Defendant", label: "Defendant", value: "Defendant" },