Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ yarn-debug.log*
yarn-error.log*

*.env

*.pem
*.vscode

# e2e test case
Expand Down
2 changes: 0 additions & 2 deletions config/constants/development.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,9 @@ module.exports = {
CHALLENGE_TRACKS_URL: `${DEV_API_HOSTNAME}/v5/challenge-tracks`,
CHALLENGE_PHASES_URL: `${DEV_API_HOSTNAME}/v5/challenge-phases`,
CHALLENGE_TIMELINES_URL: `${DEV_API_HOSTNAME}/v5/challenge-timelines`,
COPILOTS_URL: `https://copilots.${DOMAIN}`,
PROJECT_API_URL: `${DEV_API_HOSTNAME}/v5/projects`,
GROUPS_API_URL: `${DEV_API_HOSTNAME}/v5/groups`,
TERMS_API_URL: `${DEV_API_HOSTNAME}/v5/terms`,
MEMBERS_API_URL: `${DEV_API_HOSTNAME}/v5/members`,
RESOURCES_API_URL: `${DEV_API_HOSTNAME}/v5/resources`,
RESOURCE_ROLES_API_URL: `${DEV_API_HOSTNAME}/v5/resource-roles`,
SUBMISSIONS_API_URL: `${DEV_API_HOSTNAME}/v5/submissions`,
Expand Down
94 changes: 7 additions & 87 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 32 additions & 7 deletions src/components/ChallengeEditor/ChallengeName-Field/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,47 @@ import styles from './ChallengeName-Field.module.scss'
import cn from 'classnames'

const ChallengeNameField = ({ challenge, onUpdateInput }) => {
const handleChange = (e) => {
// Remove any characters that are NOT letters, numbers, or spaces
const sanitizedValue = e.target.value.replace(/[^a-zA-Z0-9 ]/g, '')

Choose a reason for hiding this comment

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

Consider adding a comment explaining the regex pattern used for sanitizing the input. This will help future developers understand the intention behind the pattern.

onUpdateInput({
target: {
name: e.target.name,
value: sanitizedValue
}
})
}

return (
<>
<div className={styles.row}>
<div className={cn(styles.field, styles.col1)}>
<label htmlFor='challengeName'>Work Name <span>*</span> :</label>
<label htmlFor='challengeName'>
Work Name <span>*</span> :
</label>
</div>
<div className={cn(styles.field, styles.col2)}>
<input className={styles.challengeName} id='name' name='name' type='text' placeholder='Work Name' value={challenge.name} maxLength='200' required onChange={onUpdateInput} />
<input
className={styles.challengeName}
id='name'
name='name'
type='text'
placeholder='Work Name'
value={challenge.name}
maxLength='200'
required
onChange={handleChange}

Choose a reason for hiding this comment

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

Ensure that the handleChange function is correctly handling all edge cases for input sanitization. For example, verify that it doesn't inadvertently remove valid characters or fail to update the input when necessary.

/>
</div>
</div>
{ challenge.submitTriggered && !challenge.name && <div className={styles.row}>
<div className={cn(styles.field, styles.col1)} />
<div className={cn(styles.field, styles.col2, styles.error)}>
Work Name is required field
{challenge.submitTriggered && !challenge.name && (
<div className={styles.row}>
<div className={cn(styles.field, styles.col1)} />
<div className={cn(styles.field, styles.col2, styles.error)}>
Work Name is required field
</div>
</div>
</div> }
)}
</>
)
}
Expand Down
10 changes: 8 additions & 2 deletions src/components/ChallengesComponent/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import PropTypes from 'prop-types'
import { Helmet } from 'react-helmet'
import { Link } from 'react-router-dom'
import ProjectStatus from './ProjectStatus'
import { PROJECT_ROLES, PROJECT_STATUS, COPILOTS_URL } from '../../config/constants'
import { PROJECT_ROLES, PROJECT_STATUS, COPILOTS_URL, CHALLENGE_STATUS } from '../../config/constants'
import { PrimaryButton, OutlineButton } from '../Buttons'
import ChallengeList from './ChallengeList'
import styles from './ChallengesComponent.module.scss'
Expand Down Expand Up @@ -53,6 +53,12 @@ const ChallengesComponent = ({
const isReadOnly = checkReadOnlyRoles(auth.token) || loginUserRoleInProject === PROJECT_ROLES.READ
const isAdminOrCopilot = checkAdminOrCopilot(auth.token, activeProject)

const projectStatus = activeProject && activeProject.status

Choose a reason for hiding this comment

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

Consider using optional chaining (?.) to safely access status property of activeProject. This can help avoid potential errors if activeProject is null or undefined. Example: const projectStatus = activeProject?.status ? activeProject.status.toUpperCase() : ''.

? activeProject.status.toUpperCase()
: ''
const isCompletedOrCancelled =
projectStatus === CHALLENGE_STATUS.CANCELLED || projectStatus === CHALLENGE_STATUS.COMPLETED

useEffect(() => {
const loggedInUser = auth.user
const projectMembers = activeProject.members
Expand Down Expand Up @@ -94,7 +100,7 @@ const ChallengesComponent = ({
className={styles.btnOutline}
/>
)}
{(checkAdmin(auth.token) || checkManager(auth.token)) && (
{(checkAdmin(auth.token) || checkManager(auth.token)) && !isCompletedOrCancelled && (

Choose a reason for hiding this comment

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

Consider adding a comment to explain the logic behind the !isCompletedOrCancelled condition to ensure future maintainability and clarity for other developers.

<OutlineButton
text='Request Copilot'
type={'info'}
Expand Down
Loading