Skip to content

Commit

Permalink
refactor getNumberFromTask logic to gracefully handle all scenarios
Browse files Browse the repository at this point in the history
  • Loading branch information
mythilytm committed Oct 24, 2024
1 parent e8d35a7 commit 86ff4d8
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions plugin-hrm-form/src/utils/task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,14 @@ export const getNumberFromTask = (task: CustomITask) => {
return getContactValueFromWebchat(task);
}

if (!channelTransformations[channelType] && channelType !== 'undefined') {
console.error(`Channel type ${channelType} is not supported`);
return null;
if (channelTransformations[channelType]) {
// return the "defaultFrom" with the transformations on the identifier corresponding to each channel
return channelTransformations[channelType as ChannelTypes].reduce((accum, f) => f(accum), defaultFrom);
}

// otherwise, return the "defaultFrom" with the transformations on the identifier corresponding to each channel
return channelTransformations[channelType as ChannelTypes].reduce((accum, f) => f(accum), defaultFrom);
if (channelType === undefined) return null;
console.error(`Channel type ${channelType} is not supported`, typeof channelType, channelType, task);
return null;
};

/**
Expand Down

0 comments on commit 86ff4d8

Please sign in to comment.