You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We need a way to store the available furniture items, and the items that a specific veteran has requested. On the third page of the VSR form (Figma link), it should show all the available furniture items and allow the veteran to select which items they want, as well as quantities.
For this task, focus on the database and backend first, since there is a lot of work involved just on the backend. We will also need separate tasks to update the create & retrieve VSR API routes, and the frontend for the VSR form and VSR individual view.
Backend
Furniture item database model
Create a DB model for a furniture item. It should have the following fields (all of which are required):
category: String. Determines which section on the VSR form the item should show up on. E.g. "bedroom", "bathroom".
name: String. The name for the furniture item. E.g. "Matching Box Spring(s)", "Blankets"
isGasElectric: Boolean. Represents whether this item has gas and electric options available. Currently, only the stove and dryer should have this property set to true; all other items should have it set to false.
allowMultiple: Boolean. Represents whether we should allow veterans to ask for more than 1 of this item. For the items with the plus and minus buttons to select a quantity on the Figma, this property should be true, and for the items where you just select/deselect it but don't choose a quantity, it should be false.
categoryIndex: Number. Index of the item within its category. Should be an integer. Will be used to put items in a specific order within each category. For example, within "Bedroom", the "Matching Box Spring(s)" furniture item's category index is 1, "Matching Bed Frame(s)" should be 2, etc.
Data population script
We need a way of loading the current furniture items into the database. Creating the furniture item DB model will define what an item should look list, but we need to also define which items exist. Rather than manually entering them one at a time through MongoSH or something, we should create a script that will load the furniture items into the MongoDB database. By "script" I mean a JS/TS file that will run code to create all the items that exist. You can create a JSON file for the data itself, and the script will just read the items from that JSON file and insert them into the database. Creating a script for this will allow each developer to insert the data into their own local database, and will allow us to insert the data into the production database, in an automated way.
Furniture item & VSR association
Now that we've defined what furniture items are available, we need a way to store which items each veteran has requested. We can do this by adding a field to the VSR model called requestedItems. This field should be required, and is an array of objects, where each object has the following fields:
itemId: Required. The ID (_id field) of the item that was requested. I think there's an ObjectID type or something in Mongoose.
quantity: Number, required. The quantity of the item that the veteran requested. Should be 1 for items where you can't choose a quantity (allowMultiple field).
isGas: Optional, boolean. Use this field only if the item has isGasElectric set to true. Set this field to true if the veteran chose gas, and false if they chose electric.
Additionally, we'll need an otherItems field to the VSR model, an optional field for anything the veteran enters into the "Identify other necessary items" box.
The text was updated successfully, but these errors were encountered:
We need a way to store the available furniture items, and the items that a specific veteran has requested. On the third page of the VSR form (Figma link), it should show all the available furniture items and allow the veteran to select which items they want, as well as quantities.
For this task, focus on the database and backend first, since there is a lot of work involved just on the backend. We will also need separate tasks to update the create & retrieve VSR API routes, and the frontend for the VSR form and VSR individual view.
Backend
Furniture item database model
Create a DB model for a furniture item. It should have the following fields (all of which are required):
category
: String. Determines which section on the VSR form the item should show up on. E.g. "bedroom", "bathroom".name
: String. The name for the furniture item. E.g. "Matching Box Spring(s)", "Blankets"isGasElectric
: Boolean. Represents whether this item has gas and electric options available. Currently, only the stove and dryer should have this property set to true; all other items should have it set to false.allowMultiple
: Boolean. Represents whether we should allow veterans to ask for more than 1 of this item. For the items with the plus and minus buttons to select a quantity on the Figma, this property should be true, and for the items where you just select/deselect it but don't choose a quantity, it should be false.categoryIndex
: Number. Index of the item within its category. Should be an integer. Will be used to put items in a specific order within each category. For example, within "Bedroom", the "Matching Box Spring(s)" furniture item's category index is 1, "Matching Bed Frame(s)" should be 2, etc.Data population script
We need a way of loading the current furniture items into the database. Creating the furniture item DB model will define what an item should look list, but we need to also define which items exist. Rather than manually entering them one at a time through MongoSH or something, we should create a script that will load the furniture items into the MongoDB database. By "script" I mean a JS/TS file that will run code to create all the items that exist. You can create a JSON file for the data itself, and the script will just read the items from that JSON file and insert them into the database. Creating a script for this will allow each developer to insert the data into their own local database, and will allow us to insert the data into the production database, in an automated way.
Furniture item & VSR association
Now that we've defined what furniture items are available, we need a way to store which items each veteran has requested. We can do this by adding a field to the VSR model called
requestedItems
. This field should be required, and is an array of objects, where each object has the following fields:itemId
: Required. The ID (_id
field) of the item that was requested. I think there's an ObjectID type or something in Mongoose.quantity
: Number, required. The quantity of the item that the veteran requested. Should be 1 for items where you can't choose a quantity (allowMultiple
field).isGas
: Optional, boolean. Use this field only if the item hasisGasElectric
set to true. Set this field to true if the veteran chose gas, and false if they chose electric.Additionally, we'll need an
otherItems
field to the VSR model, an optional field for anything the veteran enters into the "Identify other necessary items" box.The text was updated successfully, but these errors were encountered: