Skip to content

Commit

Permalink
Fix saving (everything except date works)
Browse files Browse the repository at this point in the history
  • Loading branch information
anjaleenaren committed Nov 18, 2023
1 parent e3fde05 commit c911d9f
Show file tree
Hide file tree
Showing 6 changed files with 137 additions and 82 deletions.
38 changes: 25 additions & 13 deletions client/src/FormPage/PageTwo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,12 @@ export default function PageTwo({ data, setData }: Props) {
const [homicideDate, sethomicideDate] = React.useState<Dayjs | null>();

let homicideFields;
if (data.crimeType == 'Homicide') {
if (data?.crimeType == 'Homicide') {
homicideFields = (
<div>
<FormControl required sx={{ m: 1, minWidth: 420 }}>
<TextField
value={data.homMNum}
value={data?.homMNum}
id="outlined-number"
label="M#/S#/AID#"
onChange={(event) =>
Expand Down Expand Up @@ -115,7 +115,7 @@ export default function PageTwo({ data, setData }: Props) {
Type Of Crime / Victimization
</InputLabel>
<Select
value={data.crimeType}
value={data?.crimeType}
labelId="demo-simple-select-label"
id="demo-simple-select-label"
label="Type Of Crime / Victimization"
Expand Down Expand Up @@ -154,9 +154,9 @@ export default function PageTwo({ data, setData }: Props) {
<InputLabel id="demo-simple-select-label">Gun Violence?</InputLabel>
<Select
value={
data.isGunViolence
data?.isGunViolence
? 'Yes'
: data.isGunViolence === false
: data?.isGunViolence === false
? 'No'
: ''
}
Expand Down Expand Up @@ -185,24 +185,36 @@ export default function PageTwo({ data, setData }: Props) {

<FormControl required sx={{ m: 1, minWidth: 420 }}>
<TextField
value={data.incidentAddress}
value={data?.incidentAddressObj?.street}
id="outlined-basic"
label="Street Address of Incident"
variant="outlined"
onChange={(event) =>
setData({ ...data, incidentAddress: event.target.value })
setData({
...data,
incidentAddressObj: {
...(data?.incidentAddressObj || {}),
street: event.target.value,
},
})
}
/>
</FormControl>

<FormControl required sx={{ m: 1, minWidth: 240 }}>
<TextField
value={data.incidentAddressZip}
value={data?.incidentAddressObj?.zipcode}
id="outlined-basic"
label="Zip Code of Incident"
variant="outlined"
onChange={(event) =>
setData({ ...data, incidentAddressZip: event.target.value })
setData({
...data,
incidentAddressObj: {
...(data?.incidentAddressObj || {}),
zipcode: event.target.value,
},
})
}
/>
</FormControl>
Expand All @@ -213,9 +225,9 @@ export default function PageTwo({ data, setData }: Props) {
<InputLabel id="demo-simple-select-label">Incident Reported to the Police?</InputLabel>
<Select
value={
data.reportedToPolice
data?.reportedToPolice
? 'Yes'
: data.reportedToPolice === false
: data?.reportedToPolice === false
? 'No'
: ''
}
Expand Down Expand Up @@ -244,7 +256,7 @@ export default function PageTwo({ data, setData }: Props) {

<FormControl required sx={{ m: 1, minWidth: 360 }}>
<TextField
value={data.crimeDCNum}
value={data?.crimeDCNum}
id="outlined-number"
label="Police Incident # (DC#)"
type="number"
Expand All @@ -259,7 +271,7 @@ export default function PageTwo({ data, setData }: Props) {
Police District of Incident
</InputLabel>
<Select
value={data.crimeDistrict}
value={data?.crimeDistrict}
labelId="demo-simple-select-label"
id="demo-simple-select-label"
label="Police District of Incident"
Expand Down
12 changes: 6 additions & 6 deletions client/src/ReferralView/ReferralViewPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,11 @@ export default function FormPage({ globalProps, setGlobalProps }: GlobalProps) {
<Tab sx={{ fontSize: '13px' }} label="Victimization / Crime Info" />
<Tab label="Contact Info" />
<Tab label="Referral Source Info" />
<Tab label="Additional Homicide Info" />
<Tab sx={{ fontSize: '13px' }} label="Communication History" />
<Tab label="Victim Services Outcome" />
<Tab label="Counselling Services Outcome" />
<Tab label="Youth Services Outcome" />
<Tab label="Additional Homicide Info" />
</Tabs>
</div>
{!referral ? (
Expand All @@ -151,19 +151,19 @@ export default function FormPage({ globalProps, setGlobalProps }: GlobalProps) {
<ReferralSource referral={data} setReferral={setData} />
</TabPanel>
<TabPanel value={value} index={4}>
<CommunicationHistory referral={data} setReferral={setData} />
<AdditionalHomInfo referral={data} setReferral={setData} />
</TabPanel>
<TabPanel value={value} index={5}>
<VictimServicesOutcome data={data} setData={setData} />
<CommunicationHistory referral={data} setReferral={setData} />
</TabPanel>
<TabPanel value={value} index={6}>
<CounselingServicesOutcome data={data} setData={setData} />
<VictimServicesOutcome data={data} setData={setData} />
</TabPanel>
<TabPanel value={value} index={7}>
<YouthServicesOutcome data={data} setData={setData} />
<CounselingServicesOutcome data={data} setData={setData} />
</TabPanel>
<TabPanel value={value} index={8}>
<AdditionalHomInfo referral={data} setReferral={setData} />
<YouthServicesOutcome data={data} setData={setData} />
</TabPanel>
</div>
) : (
Expand Down
20 changes: 16 additions & 4 deletions client/src/ReferralView/VictimCrime.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -218,24 +218,36 @@ export default function PageTwo({ referral, setReferral }: Props) {

<FormControl required sx={{ m: 1, minWidth: 420 }}>
<TextField
value={data?.incidentAddress}
value={data?.incidentAddressObj?.street}
id="outlined-basic"
label="Street Address of Incident"
variant="outlined"
onChange={(event) =>
setData({ ...data, incidentAddress: event.target.value })
setData({
...data,
incidentAddressObj: {
...(data?.incidentAddressObj || {}),
street: event.target.value,
},
})
}
/>
</FormControl>

<FormControl required sx={{ m: 1, minWidth: 240 }}>
<TextField
value={data?.incidentAddressZip}
value={data?.incidentAddressObj?.zipcode}
id="outlined-basic"
label="Zip Code of Incident"
variant="outlined"
onChange={(event) =>
setData({ ...data, incidentAddressZip: event.target.value })
setData({
...data,
incidentAddressObj: {
...(data?.incidentAddressObj || {}),
zipcode: event.target.value,
},
})
}
/>
</FormControl>
Expand Down
40 changes: 27 additions & 13 deletions server/src/controllers/referral.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -741,6 +741,8 @@ const updateReferral = async (
const { id } = req.params;

const {
staffName,
status,
departmentInCharge,
program,
staffAssigned,
Expand All @@ -758,17 +760,17 @@ const updateReferral = async (
survivorAge,
survivorSchoolOrCommunitySite,
survivorGrade,
survivorPreferredContactMethod,
isGuardianResponsible,
guardianName,
guardianRelationship,
guardianAddressObj,
guardianPhone,
guardianEmail,
guardianPreferredContactMethod,
survivorAddressObj,
survivorEmailAddress,
survivorAddressObj,
survivorPhoneNumber,
survivorPreferredContactMethod,
notesFromOrg,
primaryLanguage,
relationshipToVictim,
Expand All @@ -792,17 +794,24 @@ const updateReferral = async (
homMNum,
homCaseInformation,
historyOfCommunication,
victimServicesOutcome,
counsellingServicesOutcome,
youthServicesOutcome,
outreachLetterSent,
transferredToCCWaitlist,
followUpLetterSent,
transferredToETO,
victimServicesOutcome,
counsellingServicesOutcome,
youthServicesOutcome,
reportedToPolice
incidentAddressObj,
incidentAddressZip,
incidentAddressCity,
incidentAddressState,
serviceRequestedVictim,
otherServiceRequestedVictim,
reportedToPolice,
victimName,
victimGender,
date,
} = req.body;
// console.log("survivorAddressObj")
// console.log(survivorAddressObj)

if (
isReferral === undefined ||
Expand Down Expand Up @@ -858,6 +867,7 @@ const updateReferral = async (
const prevReferral = await getReferralById(id);
const referral = await updateReferralById(
id,
staffName,
status,
departmentInCharge,
program,
Expand All @@ -876,17 +886,17 @@ const updateReferral = async (
survivorAge,
survivorSchoolOrCommunitySite,
survivorGrade,
survivorPreferredContactMethod,
isGuardianResponsible,
guardianName,
guardianRelationship,
guardianAddressObj,
guardianPhone,
guardianEmail,
guardianPreferredContactMethod,
survivorAddressObj,
survivorEmailAddress,
survivorAddressObj,
survivorPhoneNumber,
survivorPreferredContactMethod,
notesFromOrg,
primaryLanguage,
relationshipToVictim,
Expand All @@ -910,14 +920,18 @@ const updateReferral = async (
homMNum,
homCaseInformation,
historyOfCommunication,
victimServicesOutcome,
counsellingServicesOutcome,
youthServicesOutcome,
outreachLetterSent,
transferredToCCWaitlist,
followUpLetterSent,
transferredToETO,
victimServicesOutcome,
counsellingServicesOutcome,
youthServicesOutcome,
incidentAddressObj,
reportedToPolice,
victimName,
victimGender,
date
);

const staffEmail = staffAssigned?.email;
Expand Down
6 changes: 5 additions & 1 deletion server/src/models/referral.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ const addressItemSchema = new mongoose.Schema({
type: String,
required: false,
},
zip: {
zipcode: {
type: String,
required: false,
},
Expand Down Expand Up @@ -560,6 +560,10 @@ const ReferralSchema = new mongoose.Schema({
type: addressItemSchema,
required: false,
},
reportedToPolice: {
type: Boolean,
required: false,
},
victimName: {
type: String,
required: true,
Expand Down
Loading

0 comments on commit c911d9f

Please sign in to comment.