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
Original file line number Diff line number Diff line change
Expand Up @@ -164,13 +164,24 @@ const ModifyWorkExpirenceModal: FC<ModifyWorkExpirenceModalProps> = (props: Modi
}
}

const companyName: string | undefined = formValues.company as string | undefined
Copy link

Choose a reason for hiding this comment

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

[💡 maintainability]
The variable companyName is assigned the value of formValues.company cast to string | undefined. However, formValues.company is already typed as string | undefined, making the cast redundant.

const startDateIso: string | undefined = formValues.startDate
? (formValues.startDate as Date).toISOString()
: undefined
const endDateIso: string | undefined = formValues.endDate
? (formValues.endDate as Date).toISOString()
: undefined

const updatedWorkExpirence: UserTrait = {
cityTown: formValues.city,
company: formValues.company,
company: companyName,
companyName,
endDate: endDateIso,
industry: formValues.industry,
position: formValues.position,
timePeriodFrom: formValues.startDate ? (formValues.startDate as Date).toISOString() : undefined,
timePeriodTo: formValues.endDate ? (formValues.endDate as Date).toISOString() : undefined,
startDate: startDateIso,
timePeriodFrom: startDateIso,
timePeriodTo: endDateIso,
working: formValues.currentlyWorking,
}

Expand All @@ -195,13 +206,17 @@ const ModifyWorkExpirenceModal: FC<ModifyWorkExpirenceModalProps> = (props: Modi
setEditedItemIndex(indx)

setFormValues({
city: work.cityTown,
company: work.company,
city: work.cityTown || work.city,
company: work.company || work.companyName,
currentlyWorking: work.working,
endDate: work.timePeriodTo ? new Date(work.timePeriodTo) : undefined,
endDate: work.timePeriodTo
? new Date(work.timePeriodTo)
: (work.endDate ? new Date(work.endDate) : undefined),
industry: work.industry,
position: work.position,
startDate: work.timePeriodFrom ? new Date(work.timePeriodFrom) : undefined,
startDate: work.timePeriodFrom
? new Date(work.timePeriodFrom)
: (work.startDate ? new Date(work.startDate) : undefined),
})
}

Expand Down Expand Up @@ -256,28 +271,39 @@ const ModifyWorkExpirenceModal: FC<ModifyWorkExpirenceModalProps> = (props: Modi
{editedItemIndex === undefined && !addingNewItem ? (
<div className={classNames(styles.workExpirenceWrap, !workExpirence?.length ? styles.noItems : '')}>
{
workExpirence?.map((work: UserTrait, indx: number) => (
<div
className={styles.workExpirenceCardWrap}
key={`${work.company}-${work.industry}-${work.position}`}
>
<WorkExpirenceCard work={work} isModalView />
<div className={styles.actionElements}>
<Button
className={styles.ctaBtn}
icon={IconOutline.PencilIcon}
onClick={bind(handleWorkExpirenceEdit, this, indx)}
size='lg'
/>
<Button
className={styles.ctaBtn}
icon={IconOutline.TrashIcon}
onClick={bind(handleWorkExpirenceDelete, this, indx)}
size='lg'
/>
workExpirence?.map((work: UserTrait, indx: number) => {
const companyName: string | undefined = work.company || work.companyName
Copy link

Choose a reason for hiding this comment

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

[⚠️ correctness]
The uniqueKey generation logic uses work.timePeriodFrom || work.startDate. If both timePeriodFrom and startDate are defined, timePeriodFrom will always be used. Consider whether this logic is intentional and if it covers all edge cases.

const uniqueKey: string = [
companyName,
work.industry,
work.position,
work.timePeriodFrom || work.startDate,
].filter(Boolean)
.join('-')

return (
<div
className={styles.workExpirenceCardWrap}
key={uniqueKey || `${work.position}-${indx}`}
>
Copy link

Choose a reason for hiding this comment

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

[⚠️ correctness]
The fallback key ${work.position}-${indx} might not be unique if multiple entries have the same position and index. Consider using a more robust unique identifier.

<WorkExpirenceCard work={work} isModalView />
<div className={styles.actionElements}>
<Button
className={styles.ctaBtn}
icon={IconOutline.PencilIcon}
onClick={bind(handleWorkExpirenceEdit, this, indx)}
size='lg'
/>
<Button
className={styles.ctaBtn}
icon={IconOutline.TrashIcon}
onClick={bind(handleWorkExpirenceDelete, this, indx)}
size='lg'
/>
</div>
</div>
</div>
))
)
})
}
</div>
) : undefined}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,23 @@ const WorkExpirence: FC<WorkExpirenceProps> = (props: WorkExpirenceProps) => {
{!loading && (
<>
{(workExpirence?.length as number) > 0
? workExpirence?.map((work: UserTrait) => (
<WorkExpirenceCard
key={`${work.company}-${work.industry}-${work.position}`}
work={work}
/>
))
? workExpirence?.map((work: UserTrait, index: number) => {
const companyName: string | undefined = work.company || work.companyName
Copy link

Choose a reason for hiding this comment

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

[⚠️ correctness]
The variable companyName is assigned using a fallback mechanism (work.company || work.companyName). Ensure that work.companyName is a valid alternative and that this fallback logic is intended. If both fields can be undefined, consider handling this case explicitly.

const uniqueKey: string = [
Copy link

Choose a reason for hiding this comment

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

[❗❗ correctness]
The uniqueKey generation logic uses multiple fields to create a key. Ensure that all fields used (companyName, work.industry, work.position, work.timePeriodFrom, work.startDate) are consistently available and that their combination will always result in a unique key. If any field can be undefined, this might lead to non-unique keys.

companyName,
work.industry,
work.position,
work.timePeriodFrom || work.startDate,
].filter(Boolean)
.join('-')

return (
<WorkExpirenceCard
key={uniqueKey || `${work.position || 'experience'}-${index}`}
work={work}
/>
)
})
: (
<EmptySection
selfMessage={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,34 +12,63 @@ interface WorkExpirenceCardProps {
isModalView?: boolean
}

const WorkExpirenceCard: FC<WorkExpirenceCardProps> = (props: WorkExpirenceCardProps) => (
<div className={classNames(styles.workExpirenceCard, props.isModalView ? styles.workExpirenceCardModalView : '')}>
<div className={styles.workExpirenceCardHeader}>
<div className={styles.workExpirenceCardHeaderLeft}>
<p className='body-main-bold'>
{props.work.position}
{props.work.industry ? `, ${getIndustryOptionLabel(props.work.industry)}` : undefined}
</p>
<p>
{props.work.company}
{props.work.cityTown ? `, ${props.work.cityTown}` : undefined}
</p>
</div>
{
props.work.timePeriodFrom || props.work.timePeriodTo || props.work.working ? (
<div className={styles.workExpirenceCardHeaderRight}>
const formatDateRange = (work: UserTrait): string | undefined => {
Copy link

Choose a reason for hiding this comment

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

[⚠️ performance]
The function formatDateRange uses moment for date formatting. Consider using a more modern date library like date-fns or luxon for better performance and smaller bundle size, as moment is known to be relatively large and is no longer actively maintained.

const periodFrom: string | Date | undefined = work.timePeriodFrom || work.startDate
const periodTo: string | Date | undefined = work.timePeriodTo || work.endDate
const isWorking: boolean = Boolean(work.working)

if (!periodFrom && !periodTo && !isWorking) {
return undefined
}

const formattedFrom: string = periodFrom ? moment(periodFrom)
.format('MM/YYYY') : ''
const formattedTo: string = periodTo
? moment(periodTo)
.format('MM/YYYY')
: (isWorking ? 'Present' : '')

if (formattedFrom && formattedTo) {
return `${formattedFrom} - ${formattedTo}`
}

return formattedFrom || formattedTo || undefined
}

const WorkExpirenceCard: FC<WorkExpirenceCardProps> = (props: WorkExpirenceCardProps) => {
const companyName: string | undefined = props.work.company || props.work.companyName
Copy link

Choose a reason for hiding this comment

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

[⚠️ correctness]
The variable companyName is assigned using a fallback to props.work.companyName. Ensure that companyName is a valid and expected property of UserTrait to avoid potential runtime errors.

const city: string | undefined = props.work.cityTown || props.work.city
Copy link

Choose a reason for hiding this comment

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

[⚠️ correctness]
The variable city is assigned using a fallback to props.work.city. Ensure that city is a valid and expected property of UserTrait to avoid potential runtime errors.

const industry: string | undefined = props.work.industry
const dateRange: string | undefined = formatDateRange(props.work)

const containerClassName: string = classNames(
styles.workExpirenceCard,
props.isModalView ? styles.workExpirenceCardModalView : '',
)

return (
<div className={containerClassName}>
<div className={styles.workExpirenceCardHeader}>
<div className={styles.workExpirenceCardHeaderLeft}>
<p className='body-main-bold'>
{props.work.position}
{industry ? `, ${getIndustryOptionLabel(industry)}` : undefined}
</p>
{(companyName || city) && (
<p>
{props.work.timePeriodFrom ? moment(props.work.timePeriodFrom)
.format('MM/YYYY') : ''}
{props.work.timePeriodFrom && (props.work.timePeriodTo || props.work.working) ? ' - ' : ''}
{props.work.timePeriodTo ? moment(props.work.timePeriodTo)
.format('MM/YYYY') : (props.work.working ? 'Present' : '')}
{companyName}
{city ? `, ${city}` : undefined}
</p>
)}
</div>
{dateRange ? (
<div className={styles.workExpirenceCardHeaderRight}>
<p>{dateRange}</p>
</div>
) : undefined
}
) : undefined}
</div>
</div>
</div>
)
)
}

export default WorkExpirenceCard
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ export const ChallengeDetailsContent: FC<Props> = (props: Props) => {
const targetUrl = submission.url?.trim()
if (targetUrl) {
if (typeof window !== 'undefined') {
const openedWindow = window.open(targetUrl, '_blank', 'noopener,noreferrer')
window.open(targetUrl, '_blank', 'noopener,noreferrer')
Copy link

Choose a reason for hiding this comment

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

[⚠️ maintainability]
The variable openedWindow was removed, which previously held the reference to the opened window. If there was any intention to use this reference later (e.g., to manipulate the window or check if it was successfully opened), this change could lead to issues. Ensure that the removal of this variable does not affect any other part of the code that might rely on it.

} else {
toast.error('Unable to open the submission URL from this environment.')
}
Expand Down
6 changes: 3 additions & 3 deletions start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

export ESLINT_NO_DEV_ERRORS=true
export HTTPS=true
export SSL_CRT_FILE=ssl-local/local.topcoder-dev.com+2.pem
export SSL_KEY_FILE=ssl-local/local.topcoder-dev.com+2-key.pem
export HOST=local.topcoder-dev.com
export SSL_CRT_FILE=ssl-local/local.topcoder.com.pem
export SSL_KEY_FILE=ssl-local/local.topcoder.com-key.pem
export HOST=local.topcoder.com
export REACT_APP_HOST_ENV=${REACT_APP_HOST_ENV:-dev}
export PORT=443

Expand Down