Skip to content

Topcoder Admin App - Misc Update 0505 #1069

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

Closed
wants to merge 1 commit into from

Conversation

suppermancool
Copy link
Collaborator

@@ -10,6 +10,7 @@ import {
useState,
} from 'react'
import { useSearchParams } from 'react-router-dom'
import _ from 'lodash'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The lodash library is imported but not used in the current code changes. Consider removing the import if it is not needed to avoid unnecessary dependencies.

page: 1,
perPage: 25,
status: ChallengeStatus.Active,
track: null!, // eslint-disable-line @typescript-eslint/no-non-null-assertion, unicorn/no-null
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using null! with non-null assertion can lead to runtime errors if track is accessed before being properly initialized. Consider using a more type-safe approach, such as optional chaining or default values.

perPage: 25,
status: ChallengeStatus.Active,
track: null!, // eslint-disable-line @typescript-eslint/no-non-null-assertion, unicorn/no-null
type: null!, // eslint-disable-line @typescript-eslint/no-non-null-assertion, unicorn/no-null
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using null! with non-null assertion can lead to runtime errors if type is accessed before being properly initialized. Consider using a more type-safe approach, such as optional chaining or default values.

})
const disableReset = useMemo(() => _.isEqual(filterCriteria, defaultFilter), [filterCriteria])
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider importing only the isEqual function from lodash instead of the entire lodash library to reduce bundle size: import isEqual from 'lodash/isEqual';

&& challenges.length === 0
}
onReset={handleReset}
onReset={function onReset() {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using an arrow function for onReset to maintain consistency with other function definitions in the component.

...defaultFilter,
})
setTimeout(() => {
search()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The setTimeout function is used here without a delay parameter. If the intention is to execute search() immediately, consider removing setTimeout for clarity.

handleSubmit,
control,
formState: { isValid },
formState: { isValid, isDirty },
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The isDirty property is being destructured from formState but is not used anywhere in the component. Consider removing it if it's not needed.

onClick={function onClick() {
reset(defaultValues)
setTimeout(() => {
onSubmit(defaultValues)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider providing a delay duration for setTimeout to ensure consistent behavior across different environments.

onClick={handleReset}
disabled={props.disabled}
disabled={props.disabled || props.disableReset}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider renaming props.disableReset to props.isResetDisabled for consistency with boolean naming conventions.

<a
href={`${EnvironmentConfig.ADMIN.CHALLENGE_URL}/${challenge.id}`}
className={styles.challengeTitle}
onClick={function onClick() {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The onClick handler is setting window.location.href to the same URL as the href attribute. This is redundant and can be removed unless there is a specific reason for having both.

handleSubmit,
control,
formState: { isValid },
formState: { isValid, isDirty },
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The isDirty property is being destructured from formState but is not used anywhere in the component. If it's not needed, consider removing it to keep the code clean.

onClick={function onClick() {
reset(defaultValues)
setTimeout(() => {
onSubmit(defaultValues)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding a delay duration to the setTimeout function to ensure consistent behavior. Currently, it defaults to 0 milliseconds, which might not be necessary.


.challengeTitleLink {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The class .challengeTitleLink is defined but not used in this diff. Ensure that it is applied to the appropriate elements in the HTML/JSX to have the intended effect.

@@ -45,13 +46,17 @@ const ChallengeTitle: FC<{
review: ReviewSummary
}> = props => {
const goToChallenge = useEventCallback(() => {
window.location.href = `https://www.topcoder.com/challenges/${props.review.legacyChallengeId}`
window.location.href = `${EnvironmentConfig.ADMIN.CHALLENGE_URL}/${props.review.legacyChallengeId}`
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider verifying that EnvironmentConfig.ADMIN.CHALLENGE_URL is correctly defined and accessible to avoid potential runtime errors.

return (
<LinkButton onClick={goToChallenge} className={styles.challengeTitle}>
return props.review.legacyChallengeId ? (
<LinkButton onClick={goToChallenge} className={styles.challengeTitleLink}>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure that props.review.legacyChallengeId is always defined when expected. If it can be undefined, consider handling this case appropriately to avoid unexpected behavior.

return (
<LinkButton onClick={goToChallenge} className={styles.challengeTitle}>
return props.review.legacyChallengeId ? (
<LinkButton onClick={goToChallenge} className={styles.challengeTitleLink}>
{props.review.challengeName}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The class name styles.challengeTitleLink should be verified to ensure it matches the intended styling. If this is a new class name, ensure it is defined in the styles.

{props.review.challengeName}
</LinkButton>
) : (
<span className={styles.challengeTitleText}>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The class name styles.challengeTitleText should be verified to ensure it matches the intended styling. If this is a new class name, ensure it is defined in the styles.

@@ -44,3 +44,9 @@
font-size: 14px;
color: $black-60;
}

.blockBtns {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using a more descriptive class name than .blockBtns to improve readability and maintainability of the code. A name that reflects the purpose or context of the buttons would be beneficial.

handleSubmit,
control,
formState: { errors, isValid },
formState: { errors, isValid, isDirty },
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The addition of isDirty to the destructured formState object is a good practice for tracking form changes. However, ensure that isDirty is actually used in the component logic to avoid unnecessary destructuring.

<Button
secondary
onClick={function onClick() {
reset(defaultValues)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding a delay duration to the setTimeout function to ensure consistent behavior across different environments.

})
}}
size='lg'
disabled={!isDirty}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The disabled attribute is set based on !isDirty. Ensure that isDirty is correctly updated to reflect the form's state, as this affects the usability of the Reset button.

@suppermancool suppermancool deleted the admin-f2f-30376773 branch May 7, 2025 06:14
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.

1 participant