diff --git a/src/Components/Document/DocEditPage.js b/src/Components/Document/DocEditPage.js index e57d795..7edc5f8 100644 --- a/src/Components/Document/DocEditPage.js +++ b/src/Components/Document/DocEditPage.js @@ -46,14 +46,13 @@ const DocEditPage = () => { const [index, setIndex] = useState(0); const [isBusy, setIsBusy] = useState(false); // For document generation: - - const state = group.state[0] ? group.state[0].code : "ny"; + const state = group?.state[0] ? group.state[0].code : "ny"; const lawFirm = group ? group?.firm : null; const streetAdd = group ? group?.streetAddress : null; - const city = group ? group.city : null; - const usState = group.state[0] ? group.state[0].code : "ny"; - const zipCode = group ? group.zipCode : null; - const telephone = group ? group.telephone : null; + const city = group ? group?.city : null; + const usState = group?.state[0] ? group?.state[0].code : "ny"; + const zipCode = group ? group?.zipCode : null; + const telephone = group ? group?.telephone : null; const apiUrl = process.env.NODE_ENV === "development" diff --git a/src/Components/Document/ReqEditPage.js b/src/Components/Document/ReqEditPage.js index 10c3dfb..97dc026 100644 --- a/src/Components/Document/ReqEditPage.js +++ b/src/Components/Document/ReqEditPage.js @@ -37,7 +37,7 @@ const RequestEditPage = () => { const [fetchedCase, setFetchedCase] = useState(); const [showInputEle, setShowInputEle] = useState(true); const [document, setDocument] = useState(null); - const appUserId = group ? group.appUserId : null; + const appUserId = group ? group?.appUserId : null; const [docId, setDocId] = useState(documentId); const [saveDocumentId, setSaveDocumentId] = useState(""); const [showSaveModal, setShowSaveModal] = useState(false); @@ -46,13 +46,13 @@ const RequestEditPage = () => { const [showErrorModal, setShowErrorModal] = useState(false); const [isBusy, setIsBusy] = useState(false); // Case Vars - const state = group.state[0] ? group.state[0].code : "ny"; + const state = group?.state[0] ? group.state[0].code : "ny"; const lawFirm = group ? group?.firm : null; const streetAdd = group ? group?.streetAddress : null; - const city = group ? group.city : null; - const usState = group.state[0] ? group.state[0].code : "ny"; - const zipCode = group ? group.zipCode : null; - const telephone = group ? group.telephone : null; + const city = group ? group?.city : null; + const usState = group?.state[0] ? group?.state[0].code : "ny"; + const zipCode = group ? group?.zipCode : null; + const telephone = group ? group?.telephone : null; const apiUrl = process.env.NODE_ENV === "development" @@ -190,14 +190,14 @@ const RequestEditPage = () => { ? fetchedCase?.leadAttorneys : null; const reqType = documentType; - const captionOne = fetchedCase.caption; - const captionTwo = fetchedCase.captionTwo; - const caseNum = fetchedCase.caseNumber; - const plaintiffs = fetchedCase.plaintiffParties; - const defendants = fetchedCase.defendantParties; - const venued = fetchedCase.venue; - const juris = fetchedCase.jurisdiction; - const judge = fetchedCase.judge; + const captionOne = fetchedCase?.caption; + const captionTwo = fetchedCase?.captionTwo; + const caseNum = fetchedCase?.caseNumber; + const plaintiffs = fetchedCase?.plaintiffParties; + const defendants = fetchedCase?.defendantParties; + const venued = fetchedCase?.venue; + const juris = fetchedCase?.jurisdiction; + const judge = fetchedCase?.judge; const clientPosition = fetchedCase?.clientPosition ? fetchedCase?.clientPosition : null; @@ -308,10 +308,10 @@ const RequestEditPage = () => { const displayCopy = state === "ny" - ? docEditCopy.NewYork + ? docEditCopy?.NewYork : state === "nj" - ? docEditCopy.NewJersey - : docEditCopy.NewYork; + ? docEditCopy?.NewJersey + : docEditCopy?.NewYork; const servingParty = fetchedCase?.clientPosition === "Defendant" diff --git a/src/Constants/Copy/docEditCopy.js b/src/Constants/Copy/docEditCopy.js index e6cf19b..5ab774f 100644 --- a/src/Constants/Copy/docEditCopy.js +++ b/src/Constants/Copy/docEditCopy.js @@ -59,15 +59,15 @@ export const docEditCopy = { export const outgoingComesNow = (state, fetchedCase) => { let copyString; - const position = fetchedCase.clientPosition; + const position = fetchedCase?.clientPosition; const parties = - fetchedCase.clientPosition === "Plaintiff" - ? fetchedCase.plaintiffParties - : fetchedCase.defendantParties; + fetchedCase?.clientPosition === "Plaintiff" + ? fetchedCase?.plaintiffParties + : fetchedCase?.defendantParties; const adversary = - fetchedCase.clientPosition === "Plaintiff" - ? fetchedCase.defendantParties - : fetchedCase.plaintiffParties; + fetchedCase?.clientPosition === "Plaintiff" + ? fetchedCase?.defendantParties + : fetchedCase?.plaintiffParties; if (state === "ny") { copyString = `COMES NOW, ${position}, ${parties}, through counsel, and hereby propounds these Interrogatories and Requests for Production on ${adversary}, to be answered under oath, in writing, in accordance with NY CPLR 3120 - 3130.`;