Skip to content

Conversation

@hentrymartin
Copy link
Collaborator

Related JIRA Ticket:

https://topcoder.atlassian.net/browse/PM-3563

What's in this PR?

  • Added other industry to work experience form


const ModalAddWork: FC<ModalAddWorkProps> = (props: ModalAddWorkProps) => {
const [workInfo, setWorkInfo] = useState(emptyWorkInfo())
const [formErrors, setFormErrors] = useState<any>({

Choose a reason for hiding this comment

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

[⚠️ maintainability]
Consider using a more specific type instead of any for formErrors to improve type safety and maintainability.

errorTmp.endDate = 'Required'
}

if (workInfo.industry === 'Other' && !workInfo.otherIndustry?.trim()) {

Choose a reason for hiding this comment

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

[❗❗ correctness]
The check for workInfo.otherIndustry?.trim() assumes otherIndustry is a string. Ensure workInfo.otherIndustry is always initialized as a string to avoid potential runtime errors.

setWorkInfo({
...workInfo,
industry: event.target.value,
otherIndustry: event.target.value === 'Other' ? workInfo.otherIndustry : undefined,

Choose a reason for hiding this comment

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

[⚠️ correctness]
When setting otherIndustry to undefined, ensure that this does not unintentionally affect other parts of the application that may rely on otherIndustry being a string.

name='otherIndustry'
label='Please specify your industry *'
value={workInfo.otherIndustry || ''}
onChange={function onChange(event: any) {

Choose a reason for hiding this comment

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

[💡 maintainability]
Consider using a more specific type instead of any for the event parameter in the onChange function to improve type safety.

case 'industry':
value = event.target.value
if (value !== 'Other') {
oldFormValues.otherIndustry = undefined

Choose a reason for hiding this comment

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

[💡 readability]
Consider using delete oldFormValues.otherIndustry instead of setting it to undefined for better clarity and to avoid potential issues with object property checks.

}
}

if (formValues.industry === 'Other' && !trim(formValues.otherIndustry as string)) {

Choose a reason for hiding this comment

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

[⚠️ correctness]
The check for formValues.industry === 'Other' and !trim(formValues.otherIndustry as string) is correct, but ensure that formValues.otherIndustry is always a string before trimming to avoid runtime errors.

position && industry
? `, ${getIndustryOptionLabel(industry)}`
: (industry ? getIndustryOptionLabel(industry) : '')
? `, ${industry === 'Other'

Choose a reason for hiding this comment

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

[⚠️ readability]
The nested ternary operators make this logic difficult to read and understand. Consider refactoring this into a separate function to improve readability and maintainability.


if (keys.includes(v)) {
return IndustryEnumToLabel[v]
return v

Choose a reason for hiding this comment

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

[❗❗ correctness]
The change from IndustryEnumToLabel[v] to v in getIndustryOptionValue might lead to incorrect behavior if v is expected to be a key in IndustryEnumToLabel. This could result in returning the key itself instead of its corresponding label. Verify if this change aligns with the intended logic.

@hentrymartin hentrymartin merged commit 63faad1 into dev Jan 26, 2026
8 checks passed
@hentrymartin hentrymartin deleted the pm-3563 branch January 26, 2026 15:34
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.

3 participants