-
Notifications
You must be signed in to change notification settings - Fork 0
Add in status normalization for SFDC usage #28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| return challenges; | ||
| return challenges.map((challenge) => ({ | ||
| ...challenge, | ||
| challengeStatus: normalizeChallengeStatus(challenge.challengeStatus), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[correctness]
Ensure that normalizeChallengeStatus handles all possible values of challenge.challengeStatus correctly. If there are any unexpected values, consider adding a default case or error handling to avoid potential runtime issues.
| return payments; | ||
| return payments.map((payment) => ({ | ||
| ...payment, | ||
| challengeStatus: normalizeChallengeStatus(payment.challengeStatus), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[correctness]
Verify that normalizeChallengeStatus can handle all possible values of payment.challengeStatus. Consider adding validation or error handling for unexpected values to prevent potential issues.
| export const normalizeChallengeStatus = ( | ||
| status: string | null | undefined, | ||
| ): string | null | undefined => { | ||
| if (status === null || status === undefined) return status; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[💡 style]
Consider using status == null instead of status === null || status === undefined for a more concise check for both null and undefined.
| status: string | null | undefined, | ||
| ): string | null | undefined => { | ||
| if (status === null || status === undefined) return status; | ||
| const trimmed = String(status).trim(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[💡 readability]
The conversion String(status) is unnecessary here since status is already a string type due to the function signature. Consider removing it for clarity.
| ): string | null | undefined => { | ||
| if (status === null || status === undefined) return status; | ||
| const trimmed = String(status).trim(); | ||
| if (!trimmed) return status; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[correctness]
Returning status here might be misleading because status could be a string with only whitespace. Consider returning null or undefined explicitly to indicate an invalid or empty status.
|
|
||
| export const normalizedPaymentData = mockPaymentData.map((payment) => ({ | ||
| ...payment, | ||
| challengeStatus: normalizeChallengeStatus(payment.challengeStatus) as string, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[❗❗ correctness]
Consider handling the case where payment.challengeStatus might be null or undefined before passing it to normalizeChallengeStatus. This could prevent potential runtime errors if normalizeChallengeStatus does not handle such cases internally.
No description provided.