Skip to content

Commit

Permalink
Merge main branch
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminJohnson2204 committed Mar 23, 2024
2 parents e654a5c + f7abd7b commit da6f2b7
Show file tree
Hide file tree
Showing 22 changed files with 1,243 additions and 341 deletions.
266 changes: 266 additions & 0 deletions backend/__tests__/furnitureItems.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,266 @@
[
{
"category": "bedroom",
"name": "Twin mat.",
"allowMultiple": true,
"categoryIndex": 1
},
{
"category": "bedroom",
"name": "Full Mat.",
"allowMultiple": true,
"categoryIndex": 2
},
{
"category": "bedroom",
"name": "Queen Mat.",
"allowMultiple": true,
"categoryIndex": 3
},
{
"category": "bedroom",
"name": "King Mat.",
"allowMultiple": true,
"categoryIndex": 4
},
{
"category": "bedroom",
"name": "Matching Box Spring(s)",
"allowMultiple": true,
"categoryIndex": 5
},
{
"category": "bedroom",
"name": "Matching Bed Frame(s)",
"allowMultiple": true,
"categoryIndex": 6
},
{
"category": "bedroom",
"name": "Night Stand(s)",
"allowMultiple": true,
"categoryIndex": 7
},
{
"category": "bedroom",
"name": "Sheet Set(s)",
"allowMultiple": true,
"categoryIndex": 8
},
{
"category": "bedroom",
"name": "Blankets",
"allowMultiple": true,
"categoryIndex": 9
},
{
"category": "bedroom",
"name": "Dresser",
"allowMultiple": false,
"categoryIndex": 10
},
{
"category": "bathroom",
"name": "Bath Rug(s)",
"allowMultiple": true,
"categoryIndex": 1
},
{
"category": "bathroom",
"name": "Towel(s)",
"allowMultiple": true,
"categoryIndex": 2
},
{
"category": "bathroom",
"name": "Wash Cloth(s)",
"allowMultiple": true,
"categoryIndex": 3
},
{
"category": "kitchen",
"name": "Dish Set(s)",
"allowMultiple": true,
"categoryIndex": 1
},
{
"category": "kitchen",
"name": "Glasses",
"allowMultiple": true,
"categoryIndex": 2
},
{
"category": "kitchen",
"name": "Stove (Gas)",
"allowMultiple": false,
"categoryIndex": 3
},
{
"category": "kitchen",
"name": "Stove (Electric)",
"allowMultiple": false,
"categoryIndex": 4
},
{
"category": "kitchen",
"name": "Cups",
"allowMultiple": false,
"categoryIndex": 5
},
{
"category": "kitchen",
"name": "Silverware",
"allowMultiple": false,
"categoryIndex": 6
},
{
"category": "kitchen",
"name": "Pots and Pans",
"allowMultiple": false,
"categoryIndex": 7
},
{
"category": "kitchen",
"name": "Cooking Utensils",
"allowMultiple": false,
"categoryIndex": 8
},
{
"category": "kitchen",
"name": "Can Opener",
"allowMultiple": false,
"categoryIndex": 9
},
{
"category": "kitchen",
"name": "Refrigerator",
"allowMultiple": false,
"categoryIndex": 10
},
{
"category": "kitchen",
"name": "Microwave",
"allowMultiple": false,
"categoryIndex": 11
},
{
"category": "kitchen",
"name": "Toaster",
"allowMultiple": false,
"categoryIndex": 12
},
{
"category": "kitchen",
"name": "Coffee Pot",
"allowMultiple": false,
"categoryIndex": 13
},
{
"category": "living room",
"name": "Desk Lamp(s)",
"allowMultiple": true,
"categoryIndex": 1
},
{
"category": "living room",
"name": "Floor Lamp(s)",
"allowMultiple": true,
"categoryIndex": 2
},
{
"category": "living room",
"name": "End Table(s)",
"allowMultiple": true,
"categoryIndex": 3
},
{
"category": "living room",
"name": "Couch/Loveseat",
"allowMultiple": true,
"categoryIndex": 4
},
{
"category": "living room",
"name": "Rug(s)",
"allowMultiple": true,
"categoryIndex": 5
},
{
"category": "living room",
"name": "Couch",
"allowMultiple": false,
"categoryIndex": 6
},
{
"category": "living room",
"name": "Chair",
"allowMultiple": false,
"categoryIndex": 7
},
{
"category": "living room",
"name": "Coffee Table",
"allowMultiple": false,
"categoryIndex": 8
},
{
"category": "living room",
"name": "TV",
"allowMultiple": false,
"categoryIndex": 9
},
{
"category": "living room",
"name": "TV Stand",
"allowMultiple": false,
"categoryIndex": 10
},
{
"category": "living room",
"name": "TV/Stereo Wall Unit",
"allowMultiple": false,
"categoryIndex": 11
},
{
"category": "living room",
"name": "Desk",
"allowMultiple": false,
"categoryIndex": 12
},
{
"category": "dining room",
"name": "Chairs",
"allowMultiple": true,
"categoryIndex": 1
},
{
"category": "dining room",
"name": "China Cabinet/Buffet",
"allowMultiple": false,
"categoryIndex": 2
},
{
"category": "dining room",
"name": "Table",
"allowMultiple": false,
"categoryIndex": 3
},
{
"category": "other",
"name": "Dryer (Gas)",
"allowMultiple": false,
"categoryIndex": 1
},
{
"category": "other",
"name": "Dryer (Electric)",
"allowMultiple": false,
"categoryIndex": 2
},
{
"category": "other",
"name": "Washer",
"allowMultiple": false,
"categoryIndex": 3
}
]
2 changes: 2 additions & 0 deletions backend/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import cors from "cors";
import express, { NextFunction, Request, Response } from "express";
import { isHttpError } from "http-errors";
import vsrRoutes from "../src/routes/vsr";
import furnitureItemRoutes from "../src/routes/furnitureItem";
import { userRouter } from "src/routes/users";
import env from "src/util/validateEnv";

Expand Down Expand Up @@ -54,5 +55,6 @@ app.use((error: unknown, req: Request, res: Response, next: NextFunction) => {
});

app.use("/api/vsr", vsrRoutes);
app.use("/api/furnitureItems", furnitureItemRoutes);

export default app;
16 changes: 16 additions & 0 deletions backend/src/controllers/furnitureItem.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { RequestHandler } from "express";
import createHttpError from "http-errors";
import FurnitureItemModel from "src/models/furnitureItem";

export const getFurnitureItems: RequestHandler = async (req, res, next) => {
try {
const furnitureItems = await FurnitureItemModel.find();

if (furnitureItems === null) {
throw createHttpError(404, "Furniture items not found");
}
res.status(200).json(furnitureItems);
} catch (error) {
next(error);
}
};
30 changes: 29 additions & 1 deletion backend/src/controllers/vsr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,20 @@ export const createVSR: RequestHandler = async (req, res, next) => {
employmentStatus,
incomeLevel,
sizeOfHome,
hearFrom,
petCompanion,
militaryId,
lastRank,
serviceConnected,
dischargeStatus,
email,
phoneNumber,
zipCode,
state,
city,
streetAddress,
selectedFurnitureItems,
additionalItems,
} = req.body;

try {
Expand Down Expand Up @@ -61,8 +75,22 @@ export const createVSR: RequestHandler = async (req, res, next) => {
lastUpdated: currentDate,

status: "Received",
});

hearFrom,
petCompanion,
militaryId,
lastRank,
serviceConnected,
dischargeStatus,
email,
phoneNumber,
zipCode,
state,
city,
streetAddress,
selectedFurnitureItems,
additionalItems,
});
// 201 means a new resource has been created successfully
// the newly created VSR is sent back to the user
res.status(201).json(vsr);
Expand Down
13 changes: 13 additions & 0 deletions backend/src/models/furnitureItem.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { InferSchemaType, Schema, model } from "mongoose";

const furnitureItemSchema = new Schema({
_id: { type: String, required: true },
category: { type: String, required: true },
name: { type: String, required: true },
allowMultiple: { type: Boolean, required: true },
categoryIndex: { type: Number, required: true },
});

type FurnitureItem = InferSchemaType<typeof furnitureItemSchema>;

export default model<FurnitureItem>("FurnitureItem", furnitureItemSchema);
13 changes: 7 additions & 6 deletions backend/src/models/vsr.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import { InferSchemaType, Schema, model } from "mongoose";

const furntitureInputSchema = new Schema({
furnitureItemId: { type: String, required: true },
quantity: { type: Number, required: true },
});

const vsrSchema = new Schema({
name: { type: String, required: true },
gender: { type: String, require: true },
Expand All @@ -26,12 +31,8 @@ const vsrSchema = new Schema({
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 },
selectedFurnitureItems: { type: [furntitureInputSchema], required: true },
additionalItems: { type: String, required: false },
dateReceived: { type: Date, required: true },
lastUpdated: { type: Date, required: true },
status: { type: String, required: true },
Expand Down
8 changes: 8 additions & 0 deletions backend/src/routes/furnitureItem.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import express from "express";
import * as FurnitureItemController from "src/controllers/furnitureItem";

const router = express.Router();

router.get("/", FurnitureItemController.getFurnitureItems);

export default router;
Loading

0 comments on commit da6f2b7

Please sign in to comment.