Files
pedwfrontend/lib/newappeal/payloadCleanup.js
T
robbond 5233f62d59 refactor(newappeal): extract payload cleanup helpers (Slice 2a)
- extracted boolean normalization

- extracted null key removal

- extracted internal key stripping

- no behaviour change
2026-04-10 16:37:42 +01:00

29 lines
723 B
JavaScript

export const normalizeYesNoBooleans = (updateBody) => {
updateBody = JSON.stringify(updateBody);
updateBody = updateBody.replace(/:\"Yes\"/gm, `:true`);
updateBody = updateBody.replace(/:\"No\"/gm, `:false`);
updateBody = JSON.parse(updateBody);
return updateBody;
};
export const removeNullKeys = (updateBody) => {
Object.keys(updateBody).forEach((key) => {
if (updateBody[key] === null) {
delete updateBody[key];
}
});
return updateBody;
};
export const stripInternalKeys = (updateBody) => {
Object.keys(updateBody).forEach((key) => {
if (key.indexOf("_") == 0) {
delete updateBody[key];
}
});
return updateBody;
};