OpenFn / unicef-cambodia

UNICEF Cambodia - Primero Interoperability
https://openfn.github.io/unicef-cambodia/
1 stars 2 forks source link

fix services_section destructure, #95 #96

Closed grayey closed 2 years ago

grayey commented 2 years ago

@elias-ba please review.

This feature fixes the destructure error when state.data[0] is undefined.

aleksa-krolls commented 2 years ago

@taylordowns2000 can you check this out this PR? Pls merge if it looks good so that @daissatou2 can keep testing.

And @grayey I chatted with Taylor... can you start assigning him to any pull requests? He'll be the one reviewing and providing feedback

aleksa-krolls commented 2 years ago

@grayey after making the changes, pls merge the PR to master and let @daissatou2 know when done so she can re-test. Thanks!

grayey commented 2 years ago

@taylordowns2000 I've tried it and setting the default like this _const { servicessection = null } = state.data[0]; in this case doesn't fix it because state.data[0] is undefined . We are trying to destructure undefined. It'd work in a case where there is an object in the first place, but services_section is missing as a property. For instance, const { services_section = null } = {} OR { x, y, etc }.

@aleksa-krolls