Skip to content

Commit

Permalink
Merge main branch
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminJohnson2204 committed Feb 29, 2024
2 parents 58faaf3 + f7d7462 commit bdb51c6
Show file tree
Hide file tree
Showing 47 changed files with 1,456 additions and 38 deletions.
6 changes: 5 additions & 1 deletion backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,9 @@
},
"_moduleAliases": {
"src": "src"
}
},
"cacheDirectories": [
"node_modules/",
".next/cache/"
]
}
23 changes: 21 additions & 2 deletions backend/src/controllers/vsr.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,24 @@
import { RequestHandler } from "express";
import { validationResult } from "express-validator";
import createHttpError from "http-errors";
import VSRModel from "src/models/vsr";
import validationErrorParser from "src/util/validationErrorParser";

export const getVSR: RequestHandler = async (req, res, next) => {
const { id } = req.params;

try {
const vsr = await VSRModel.findById(id);

if (vsr === null) {
throw createHttpError(404, "VSR not found at id " + id);
}
res.status(200).json(vsr);
} catch (error) {
next(error);
}
};

export const createVSR: RequestHandler = async (req, res, next) => {
// extract any errors that were found by the validator
const errors = validationResult(req);
Expand All @@ -25,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 @@ -40,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
24 changes: 23 additions & 1 deletion backend/src/models/vsr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { InferSchemaType, Schema, model } from "mongoose";

const vsrSchema = new Schema({
name: { type: String, required: true },
date: { type: Date, required: true },
gender: { type: String, require: true },
age: { type: Number, require: true },
maritalStatus: { type: String, required: true },
Expand All @@ -13,6 +12,29 @@ const vsrSchema = new Schema({
employmentStatus: { type: String, require: true },
incomeLevel: { type: String, require: true },
sizeOfHome: { type: String, require: true },
streetAddress: { type: String, required: true },
city: { type: String, required: true },
state: { type: String, required: true },
zipCode: { type: Number, required: true },
phoneNumber: { type: String, required: true },
email: { type: String, required: true },
branch: { type: [String], required: true },
conflicts: { type: [String], required: true },
dischargeStatus: { type: String, required: true },
serviceConnected: { type: String, required: true },
lastRank: { type: String, required: true },
militaryId: { type: Number, required: true },
petCompanion: { type: String, required: true },
hearFrom: { type: String, required: true },
bedroomFurnishing: { type: [String], required: true },
bathroomFurnishing: { type: [String], required: true },
kitchenFurnishing: { type: [String], required: true },
livingRoomFurnishing: { type: [String], required: true },
diningRoomFurnishing: { type: [String], required: true },
otherFurnishing: { type: [String], required: true },
dateReceived: { type: Date, required: true },
lastUpdated: { type: Date, required: true },
status: { type: String, required: true },
});

type VSR = InferSchemaType<typeof vsrSchema>;
Expand Down
1 change: 1 addition & 0 deletions backend/src/routes/vsr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import * as VSRValidator from "src/validators/vsr";

const router = express.Router();

router.get("/:id", VSRController.getVSR);
router.post("/", VSRValidator.createVSR, VSRController.createVSR);
router.get("/", VSRController.getAllVSRS);

Expand Down
41 changes: 41 additions & 0 deletions frontend/__tests__/sampleData/pap.vsrs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
[
{
"_id": {
"$oid": "65bc31561826f0d6ee2c4b21"
},
"name": "Sophia Yu",
"gender": "Female",
"age": "25",
"agesOfGirls": ["11"],
"employmentStatus": "Employed",
"ethnicity": "Asian",
"incomeLevel": "$12,500 - $25,000",
"maritalStatus": "Single",
"sizeOfHome": "House",
"spouseName": "Name",
"branch": ["Air Force", "Navy"],
"city": "San Diego",
"conflicts": ["WWII", "Irani Crisis"],
"email": "[email protected]",
"phoneNumber": "(858) 790-2406",
"state": "CA",
"streetAddress": "13571 Marguerite Creek Way",
"zipCode": "92130",
"agesOfBoys": [10],
"bedroomFurnishing": [],
"dischargeStatus": "dischargeStatus-1",
"lastRank": "lastRank-1",
"militaryId": 1030,
"petCompanion": "Yes-1",
"serviceConnected": "Yes-1",
"bathroomFurnishing": ["Toiletries"],
"dateReceived": "2024-02-26T03:43:15.152Z",
"diningRoomFurnishing": ["Chairs", "Table"],
"kitchenFurnishing": ["Oven"],
"lastUpdated": "2024-02-26T03:43:15.152Z",
"livingRoomFurnishing": ["Couch"],
"otherFurnishing": ["Lawn Chair"],
"status": "Received",
"hearFrom": "Family-1"
}
]
58 changes: 29 additions & 29 deletions frontend/package-lock.json

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

1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,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
3 changes: 3 additions & 0 deletions frontend/public/dropdown.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions frontend/public/ic_arrowback.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions frontend/public/ic_edit.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions frontend/public/ic_upload.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions frontend/public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!doctype html>
<html lang="en">
<head>
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Inter&family=Lora&family=Open+Sans&display=swap"
rel="stylesheet"
/>
</head>
</html>
3 changes: 3 additions & 0 deletions frontend/public/keyboard_arrow_down10.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions frontend/public/keyboard_arrow_down24.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added frontend/public/lora.woff
Binary file not shown.
Binary file added frontend/public/opensans.woff
Binary file not shown.
9 changes: 9 additions & 0 deletions frontend/public/user_ellipse.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit bdb51c6

Please sign in to comment.