Refactor AvalancheImagePicker and ObservationImagePicker #1068
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is based off a comment made in the original work to add images to avalanche observations
This refactors the
AvalancheImagePickerandObservationImagePickerinto a newImageCaptionFieldI tried to make it as generic as possible by following what was done in
TextField.tsx, but what I didn't know is that that only works when the form field value is not a collection. I was having a hard time figuring out how to strongly type the expected array value while keeping it a generic.In the end, I decided to rely on the fact that this component is always used in a
FormProvidersouseControllercan infer the value types for the form data without having to strongly type it likeTextFielddoes. This works, but you lose the compiler throwing an error if thenameproperty does not map to an array of image assets like howTextFieldwill error ifnamedoes not map to a string.