-
Notifications
You must be signed in to change notification settings - Fork 21
Fixes for work experience display with imported traits #1286
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -164,13 +164,24 @@ const ModifyWorkExpirenceModal: FC<ModifyWorkExpirenceModalProps> = (props: Modi | |
| } | ||
| } | ||
|
|
||
| const companyName: string | undefined = formValues.company as string | undefined | ||
| 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, | ||
| } | ||
|
|
||
|
|
@@ -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), | ||
| }) | ||
| } | ||
|
|
||
|
|
@@ -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 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [ |
||
| 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}`} | ||
| > | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [ |
||
| <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} | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [ |
||
| const uniqueKey: string = [ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [❗❗ |
||
| companyName, | ||
| work.industry, | ||
| work.position, | ||
| work.timePeriodFrom || work.startDate, | ||
| ].filter(Boolean) | ||
| .join('-') | ||
|
|
||
| return ( | ||
| <WorkExpirenceCard | ||
| key={uniqueKey || `${work.position || 'experience'}-${index}`} | ||
| work={work} | ||
| /> | ||
| ) | ||
| }) | ||
| : ( | ||
| <EmptySection | ||
| selfMessage={ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 => { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [ |
||
| 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 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [ |
||
| const city: string | undefined = props.work.cityTown || props.work.city | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [ |
||
| 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 |
|---|---|---|
|
|
@@ -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') | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [ |
||
| } else { | ||
| toast.error('Unable to open the submission URL from this environment.') | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[💡
maintainability]The variable
companyNameis assigned the value offormValues.companycast tostring | undefined. However,formValues.companyis already typed asstring | undefined, making the cast redundant.