diff --git a/components/Forms/CommunityUnitsForms.js b/components/Forms/CommunityUnitsForms.js index b8440f09..41ad1ee8 100644 --- a/components/Forms/CommunityUnitsForms.js +++ b/components/Forms/CommunityUnitsForms.js @@ -107,21 +107,34 @@ function EditCommunityUnitsBasicDeatilsForm(props) { const payload = {} const formData = new FormData(event.target) const formDataObject = Object.fromEntries(formData) - payload['basic'] = {} + // payload['basic'] = {} + const contacts = [] + let contact = {} if (Array(touchedFields.values()).length >= 1) { for (let field of [...touchedFields.values()]) { if (props[field] !== formDataObject[field]) { if (/contact_type_\d/.test(field)) { - payload['contact_type'] = formDataObject[field] + contact = {...contact, contact_type: formDataObject[field]} + } else if (/contact_\d/.test(field)) { - payload['contact'] = formDataObject[field] + contact = {...contact, contact: formDataObject[field]} + contacts.push( + contact + ) + payload['contacts'] = contacts } else if (/chcs_.+/.test(field) || /chas_.+/.test(field) || /chps_.+/.test(field)){ payload[field] = formDataObject[field] } else { - payload['basic'][field] = formDataObject[field] + if(field == 'facility') { + payload['basic'] = {[field]: formDataObject[field]} + + } else { + payload[field] = formDataObject[field] + + } } } @@ -132,6 +145,7 @@ function EditCommunityUnitsBasicDeatilsForm(props) { payload['basic']['contact'] && delete payload['basic']['contact'] payload['basic']['contact_type'] && delete payload['basic']['contact_type'] + try { @@ -1261,30 +1275,38 @@ export function CommunityUnitEditForm(props) { {" > "} - {props?.name} ( # - {props?.code || "NO_CODE"} ) + {props?.props?.name} ( # + {props?.props?.code || "NO_CODE"} ) {/* Header snippet */}
+ { + JSON.stringify(props?.props?.name, null, 2) + } +*/} + +
@@ -330,9 +318,12 @@ async function approveCHUUpdates (e, token) { {/* CHU details */}
{dt.value || " - "}
+ { + JSON.stringify(cu.pending_updates, null, 2) + } +