refactor(newappeal): extract payload cleanup helpers (Slice 2a)
- extracted boolean normalization - extracted null key removal - extracted internal key stripping - no behaviour change
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
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;
|
||||
};
|
||||
Reference in New Issue
Block a user