Skip to content

Commit

Permalink
Minor fixes to VSR fields & individual view
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminJohnson2204 committed Feb 25, 2024
1 parent 5321b1d commit 8eedf26
Show file tree
Hide file tree
Showing 11 changed files with 79 additions and 60 deletions.
7 changes: 5 additions & 2 deletions backend/src/controllers/vsr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,10 @@ export const createVSR: RequestHandler = async (req, res, next) => {
validationErrorParser(errors);

// Get the current date as a timestamp for when VSR was submitted
const date = new Date();
const currentDate = new Date();

const vsr = await VSRModel.create({
name,
date,
gender,
age,
maritalStatus,
Expand All @@ -56,6 +55,10 @@ export const createVSR: RequestHandler = async (req, res, next) => {
employmentStatus,
incomeLevel,
sizeOfHome,

// Use current date as timestamp for received & updated
dateReceived: currentDate,
lastUpdated: currentDate,
});

// 201 means a new resource has been created successfully
Expand Down
6 changes: 2 additions & 4 deletions backend/src/models/vsr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,8 @@ const vsrSchema = new Schema({
livingRoomFurnishing: { type: [String], required: true },
diningRoomFurnishing: { type: [String], required: true },
otherFurnishing: { type: [String], required: true },
date: { type: String, required: true },
caseId: { type: String, required: true },
dateReceived: { type: String, required: true },
lastUpdated: { type: String, required: true },
dateReceived: { type: Date, required: true },
lastUpdated: { type: Date, required: true },
status: { type: String, required: true },
});

Expand Down
2 changes: 0 additions & 2 deletions frontend/__tests__/sampleData/pap.vsrs.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"gender": "Female",
"age": "25",
"agesOfGirls": ["11"],
"date": "02/02/2024",
"employmentStatus": "Employed",
"ethnicity": "Asian",
"incomeLevel": "$12,500 - $25,000",
Expand All @@ -30,7 +29,6 @@
"petCompanion": "Yes-1",
"serviceConnected": "Yes-1",
"bathroomFurnishing": ["Toiletries"],
"caseId": "A168868",
"dateReceived": "02-04-2024 [10:00 AM]",
"diningRoomFurnishing": ["Chairs", "Table"],
"kitchenFurnishing": ["Oven"],
Expand Down
9 changes: 9 additions & 0 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
"@emotion/react": "^11.11.3",
"@emotion/styled": "^11.11.0",
"@material/textfield": "^14.0.0",
"@mui/material": "^5.15.5",
"@mui/material": "^5.15.6",
"@mui/styled-engine-sc": "^6.0.0-alpha.13",
"@testing-library/jest-dom": "^6.1.4",
Expand All @@ -26,6 +25,7 @@
"firebase": "^10.6.0",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"moment": "^2.30.1",
"next": "14.0.3",
"react": "^18",
"react-dom": "^18",
Expand Down
69 changes: 31 additions & 38 deletions frontend/src/api/VSRs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { APIResult, handleAPIError, post, get } from "@/api/requests";
export interface VSRJson {
_id: string;
name: string;
date: string;
gender: string;
age: number;
maritalStatus: string;
Expand All @@ -23,17 +22,16 @@ export interface VSRJson {
branch: string[];
conflicts: string[];
dischargeStatus: string;
serviceConnected: string;
serviceConnected: boolean;
lastRank: string;
militaryId: number;
petCompanion: string;
petCompanion: boolean;
bedroomFurnishing: string[];
bathroomFurnishing: string[];
kitchenFurnishing: string[];
livingRoomFurnishing: string[];
diningRoomFurnishing: string[];
otherFurnishing: string[];
caseId: string;
dateReceived: string;
lastUpdated: string;
status: string;
Expand All @@ -43,7 +41,6 @@ export interface VSRJson {
export interface VSR {
_id: string;
name: string;
date: string;
gender: string;
age: number;
maritalStatus: string;
Expand All @@ -63,19 +60,18 @@ export interface VSR {
branch: string[];
conflicts: string[];
dischargeStatus: string;
serviceConnected: string;
serviceConnected: boolean;
lastRank: string;
militaryId: number;
petCompanion: string;
petCompanion: boolean;
bedroomFurnishing: string[];
bathroomFurnishing: string[];
kitchenFurnishing: string[];
livingRoomFurnishing: string[];
diningRoomFurnishing: string[];
otherFurnishing: string[];
caseId: string;
dateReceived: string;
lastUpdated: string;
dateReceived: Date;
lastUpdated: Date;
status: string;
hearFrom: string;
}
Expand All @@ -92,37 +88,35 @@ export interface CreateVSRRequest {
employmentStatus: string;
incomeLevel: string;
sizeOfHome: string;
streetAddress: string;
city: string;
state: string;
zipCode: number;
phoneNumber: string;
email: string;
branch: string[];
conflicts: string[];
dischargeStatus: string;
serviceConnected: string;
lastRank: string;
militaryId: number;
petCompanion: string;
bedroomFurnishing: string[];
bathroomFurnishing: string[];
kitchenFurnishing: string[];
livingRoomFurnishing: string[];
diningRoomFurnishing: string[];
otherFurnishing: string[];
caseId: string;
dateReceived: string;
lastUpdated: string;
status: string;
hearFrom: string;

// Comment-out page 2 & 3 fields for now because they're not implemented on the form yet
// streetAddress: string;
// city: string;
// state: string;
// zipCode: number;
// phoneNumber: string;
// email: string;
// branch: string[];
// conflicts: string[];
// dischargeStatus: string;
// serviceConnected: boolean;
// lastRank: string;
// militaryId: number;
// petCompanion: boolean;
// bedroomFurnishing: string[];
// bathroomFurnishing: string[];
// kitchenFurnishing: string[];
// livingRoomFurnishing: string[];
// diningRoomFurnishing: string[];
// otherFurnishing: string[];
// status: string;
// hearFrom: string;
}

function parseVSR(vsr: VSRJson) {
return {
_id: vsr._id,
name: vsr.name,
date: new Date(vsr.date).toISOString(),
gender: vsr.gender,
age: vsr.age,
maritalStatus: vsr.maritalStatus,
Expand Down Expand Up @@ -152,9 +146,8 @@ function parseVSR(vsr: VSRJson) {
livingRoomFurnishing: vsr.livingRoomFurnishing,
diningRoomFurnishing: vsr.diningRoomFurnishing,
otherFurnishing: vsr.otherFurnishing,
caseId: vsr.caseId,
dateReceived: vsr.dateReceived,
lastUpdated: vsr.lastUpdated,
dateReceived: new Date(vsr.dateReceived),
lastUpdated: new Date(vsr.lastUpdated),
status: vsr.status,
hearFrom: vsr.hearFrom,
};
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/app/vsr/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ const VeteranServiceRequest: React.FC = () => {
) : null}

<p className={styles.sectionHeader}>Children (under 18)</p>

<div className={styles.formRow}>
{renderChildInput("boy")}
{renderChildInput("girl")}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const AdditionalInfo = ({ vsr }: AdditionalInfoProps) => {
<div className={styles.row}>
<ListDetail
title="Are you interested in a companionship animal (pet)?"
values={[vsr.petCompanion]}
values={[vsr.petCompanion ? "Yes" : "No"]}
/>
</div>
<div className={styles.row}>
Expand Down
25 changes: 22 additions & 3 deletions frontend/src/components/VSRIndividual/CaseDetails/CaseDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,23 @@ import AccordionDetails from "@mui/material/AccordionDetails";
import Typography from "@mui/material/Typography";
import { SingleDetail, DropdownDetail } from "@/components/VSRIndividual";
import { type VSR } from "@/api/VSRs";
import moment from "moment";

export interface CaseDetailsProp {
vsr: VSR;
}
export const CaseDetails = ({ vsr }: CaseDetailsProp) => {
const expanded = true;

/**
* Formats a Date object as a string in our desired format, using Moment.js library
*/
const formatDate = (date: Date) => {
const dateMoment = moment(date);
// We need to do 2 separate format() calls because Moment treats brackets ("[]") as escape chars
return `${dateMoment.format("MM-DD-YYYY")} [${dateMoment.format("hh:mm A")}]`;
};

return (
<div className={styles.box}>
<Accordion className={styles.accordian} defaultExpanded expanded={expanded}>
Expand All @@ -23,9 +34,17 @@ export const CaseDetails = ({ vsr }: CaseDetailsProp) => {
</AccordionSummary>
<AccordionDetails>
<div className={styles.details}>
<SingleDetail title="Case ID:" value={vsr.caseId} valueFontSize="20px" />
<SingleDetail title="Date Received:" value={vsr.dateReceived} valueFontSize="20px" />
<SingleDetail title="Last Updated:" value={vsr.lastUpdated} valueFontSize="20px" />
<SingleDetail title="Case ID:" value={vsr._id} valueFontSize="20px" />
<SingleDetail
title="Date Received:"
value={formatDate(vsr.dateReceived)}
valueFontSize="20px"
/>
<SingleDetail
title="Last Updated:"
value={formatDate(vsr.lastUpdated)}
valueFontSize="20px"
/>
<DropdownDetail
title="Status:"
value={vsr.status != undefined ? vsr.status : "Received"}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,7 @@ export const MilitaryBackground = ({ vsr }: MilitaryBackgroundProps) => {
<div className={styles.row}>
<ListDetail
title="Service Connected"
values={
vsr.serviceConnected && vsr.serviceConnected.length
? [vsr.serviceConnected]
: ["N/A"]
}
values={[vsr.serviceConnected ? "Yes" : "No"]}
/>
</div>
<div className={styles.row}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,23 +70,26 @@ export const PersonalInformation = ({ vsr }: PersonalInformationProps) => {
/>
</div>
<div className={styles.row}>
<SingleDetail title="Number of boy(s)" value="2" />
<SingleDetail title="Number of boy(s)" value={vsr.agesOfBoys?.length ?? 0} />
<SingleDetail
className={styles.second}
title="Age(s)"
value={vsr.agesOfBoys && vsr.agesOfBoys.length > 0 ? vsr.agesOfBoys : "N/A"}
/>
</div>
<div className={styles.row}>
<SingleDetail title="Number of girl(s)" value="2" />
<SingleDetail title="Number of girl(s)" value={vsr.agesOfGirls?.length ?? 0} />
<SingleDetail
className={styles.second}
title="Age(s)"
value={vsr.agesOfGirls && vsr.agesOfGirls.length > 0 ? vsr.agesOfGirls : "N/A"}
/>
</div>
<div className={styles.row}>
<ListDetail title="Ethnicity" values={[vsr.ethnicity]} />
<ListDetail
title="Ethnicity"
values={vsr.ethnicity && vsr.ethnicity.length > 0 ? vsr.ethnicity : ["N/A"]}
/>
</div>
<div className={styles.row}>
<ListDetail title="Employment Status" values={[vsr.employmentStatus]} />
Expand Down

0 comments on commit 8eedf26

Please sign in to comment.