Closed mattwalo32 closed 3 years ago
Create a new picture field. Here are the steps involved in adding any new field
In the backend constants.js
, make sure your field exists in fieldEnum
. In your case, PHOTO
already exists, so nothing to do.
In the frontend constants.js
, make sure your field exists in FIELD_TYPES
. When you add the field, make sure the value exactly matches whats on the backend.
Now we need to define what data is actually going to be stored in this field in the backend. I think we don't need to do anything special here.... the value can just be an array of file schemas, just like our fieldEnum.FILE
type. Go into generateFieldSchema
in metadata.js
and add a case for fieldEnum.PHOTO
where you define what the schema will look like.
Now you can get to the bulk of the work on the frontend. Create a new PhotoField
component in the Fields
folder on the frontend. Then go into StepField.js
and add a case for the photo where you return your new photo field. So now if you encounter a step with a fieldType
of PHOTO
, your component will be rendered!
Here's some things I'd recommend:
StepField.js
. Then to make sure you got everything done right, go into mongoDB atlas and create a new field (in any step) with a fieldType of PHOTO
. If you restart your backend, if everything was done right, then when you view the step with the photo field, your log statement should print. Then from there, you can start writing your component and you'll actually be able to see it. Let me know if you need help with the mongo DB part.Fields
to get an idea of how your component should be structured.Closing to split this into two smaller tasks
We should add a field that allows users to take a picture of the patient and view it on the dashboard.