This PR adds several UI pages and endpoints, all related to CRUDing Product (aka "baseProduct") objects.
On the UI, this PR adds a ProductForm and ProductTable component used for CREATING and VIEWING these products.
The ProductForm provides both create and edit ability, similar to all other forms on this site.
Also note: I added typescript to mongoose schemas/models according to new stuff I learned. See Product.ts to view the new approach. I will eventually apply that to the existing models/schemas...in due time
Note:
I ran into an issue where empty strings passed from UI forms were causing validation errors on the backend, specifically when those empty strings were used in type: Schema.Types.ObjectId mongoose fields. The fix for this was to add a custom setter on those attributes like: set: (val) => val === '' ? null : val
That way all empty strings are converted to nulls on those fields, which is what I want.
Description
This PR adds several UI pages and endpoints, all related to CRUDing
Product
(aka "baseProduct") objects.On the UI, this PR adds a
ProductForm
andProductTable
component used for CREATING and VIEWING these products.The ProductForm provides both create and edit ability, similar to all other forms on this site.
Also note: I added typescript to mongoose schemas/models according to new stuff I learned. See Product.ts to view the new approach. I will eventually apply that to the existing models/schemas...in due time
Note:
I ran into an issue where empty strings passed from UI forms were causing validation errors on the backend, specifically when those empty strings were used in
type: Schema.Types.ObjectId
mongoose fields. The fix for this was to add a custom setter on those attributes like:set: (val) => val === '' ? null : val
That way all empty strings are converted to nulls on those fields, which is what I want.
Also note, there's a way to set this global setter method, if I can figure out how to set it up: https://github.com/Automattic/mongoose/issues/8851#issuecomment-619450652