Skip to content

Conversation

@jmgasper
Copy link
Contributor

No description provided.

return challenges;
return challenges.map((challenge) => ({
...challenge,
challengeStatus: normalizeChallengeStatus(challenge.challengeStatus),

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),

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;

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();

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;

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,

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.

@jmgasper jmgasper merged commit 517af6a into master Nov 28, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants