Skip to content
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

feat(profile): implement employment history #2259

Closed

Conversation

ThorsAngerVaNeT
Copy link
Contributor

@ThorsAngerVaNeT ThorsAngerVaNeT commented Aug 13, 2023

🟢 Add deploy label if you want to deploy this Pull Request to staging environment

🧑‍⚖️ Pull Request Naming Convention

  • Title should follow Conventional Commits
  • Do not put issue id in title
  • Do not put WIP in title. Use Draft PR functionality
  • Consider to add area:* label(s)
  • I followed naming convention rules

🤔 This is a ...

  • New feature
  • Bug fix
  • Performance optimization
  • Refactoring
  • Test Case
  • Documentation update
  • Other

🔗 Related issue link

#2202

💡 Background and solution

Add employment history block to profile so students could submit in the app their working experience.

image
image
image

☑️ Self Check before Merge

⚠️ Please check all items below before review. ⚠️

  • Database migration is added or not needed
  • Documentation is updated/provided or not needed
  • Changes are tested locally

@ThorsAngerVaNeT ThorsAngerVaNeT changed the title Feature: add job found button to profile so students could submit Feature: add job found button to profile Aug 13, 2023
@apalchys apalchys changed the title Feature: add job found button to profile feat: add job found button to profile Aug 16, 2023
@ThorsAngerVaNeT ThorsAngerVaNeT marked this pull request as draft September 9, 2023 11:50
@ThorsAngerVaNeT ThorsAngerVaNeT changed the title feat: add job found button to profile feat(profile): implement employment history Sep 26, 2023
@ThorsAngerVaNeT ThorsAngerVaNeT marked this pull request as ready for review September 26, 2023 05:41
client/src/components/Profile/MainCard.tsx Outdated Show resolved Hide resolved
Comment on lines 243 to 248
export type ProfileMainCardData = {
location: Location | null;
name: string;
githubId: string | null;
publicCvUrl: string | null;
employmentHistory: EmploymentRecordDto[] | undefined;
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like you don't need employmentHistory on the MainCardData. AFAIK MainCard do not use it.

@@ -230,13 +237,15 @@ export type ProfileInfo = {
publicFeedback?: PublicFeedback[];
stageInterviewFeedback?: StageInterviewDetailedFeedback[];
discord: Discord | null;
employmentHistory: EmploymentRecordDto[] | undefined;
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you need explicit undefind or optional would suffice?

@@ -193,6 +200,7 @@ export class ProfilePage extends React.Component<Props, State> {
name: profile?.generalInfo?.name ?? '',
githubId: profile?.generalInfo?.githubId ?? null,
publicCvUrl: profile?.publicCvUrl ?? null,
employmentHistory: profile?.employmentHistory,
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like you don't need employmentHistory on the mainInfo. AFAIK MainCard do not use it.

@@ -162,6 +168,7 @@ export class ProfilePage extends React.Component<Props, State> {
profile: {
...profile,
publicCvUrl: profile?.publicCvUrl ?? null,
employmentHistory: profile?.employmentHistory,
Copy link
Contributor

Choose a reason for hiding this comment

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

if employmentHistory is optional you don't need to set it here too.

client/src/components/Profile/EmploymentCard.tsx Outdated Show resolved Hide resolved
<Title level={5}>
{title} at {companyName}
</Title>
{dateFrom && dateTo && <Text type="secondary">{getWorkingPeriod(dateFrom, dateTo)}</Text>}
Copy link
Contributor

Choose a reason for hiding this comment

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

If you set currently working at some company, dateTo is not set yet(need to reload page, see comment on EmploymentCard), therefore this line won't show expected dateFrom - Present - duration.

I'd handle empty dateTo in getWorkingPeriod

label="Position title"
rules={[{ required: true, message: '${label} is required' }]}
>
<Input />
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you add placeholder on inputs?

return;
}

setDisplayEmployments(employments);
Copy link
Contributor

Choose a reason for hiding this comment

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

related to EmploymentHistoryDisplayItem comment
So after save, if I don't reload the page I won't see employment from-present-duration, because it relies on dateTo to be truthy,

this could solve it:

setDisplayEmployments(employments.map(( item ) => ({...item, dateTo: item.dateTo ? dayjs(item.dateTo) : dayjs() })));

but IMHO the way you set dateTo on employmentRecordDtoToFormItem seams not right, if it's not set, it should stay not set
image
image

better to handle it on EmploymentHistoryDisplayItem

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this could solve it:

setDisplayEmployments(employments.map(( item ) => ({...item, dateTo: item.dateTo ? dayjs(item.dateTo) : dayjs() })));

Yeah, I had such solution before somewhere, but for some reason I get rid of it.
Thanks I will double check this issue

@@ -33,6 +33,7 @@ export interface EmploymentRecord {
dateFrom: string;
companyName: string;
toPresent: boolean;
officeLocation?: Location;
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe just location?

nestjs/src/profile/profile.service.ts Outdated Show resolved Hide resolved
* @type {object}
* @memberof EmploymentRecordDto
*/
'officeLocation'?: object;
Copy link
Contributor

Choose a reason for hiding this comment

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

should it be object here?

client/src/components/Profile/EmploymentCard.tsx Outdated Show resolved Hide resolved
const [displayEmployments, setDisplayEmployments] = useState<EmploymentRecordFormItem[]>(
data.map(employmentRecordDtoToFormItem),
);
const [employments, setEmployments] = useState<EmploymentRecordFormItem[]>(displayEmployments);
Copy link
Contributor

Choose a reason for hiding this comment

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

IMO looks weird to have 2 states for the same data

export interface JobFoundInfo {
jobFound: boolean;
jobFoundCompanyName?: string | null;
jobFoundOfficeLocation?: string | null;
Copy link
Contributor

Choose a reason for hiding this comment

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

do you really need to repeat this jobFound in each property?


const EmploymentHistoryFormItem = ({ name, restField, remove, form }: EmploymentHistoryFormItemPros) => {
const { title, dateFrom, dateTo, toPresent, companyName, officeLocation } =
form.getFieldValue(['employmentHistory', name]) ?? {};
Copy link
Contributor

Choose a reason for hiding this comment

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

why do you need explicitly get this data rather than us form items to consume it automatically?

form.getFieldValue(['employmentHistory', name]) ?? {};
const [isToPresent, setToPresent] = useState<boolean>(toPresent);
const [isDateToRequired, setIsDateToRequired] = useState<boolean>(!toPresent);
const [locationSelectValue, setLocationSelectValue] = useState(officeLocation);
Copy link
Contributor

Choose a reason for hiding this comment

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

could u. please clarify why do you need state for them. why antd form state is not sufficient?

@ThorsAngerVaNeT ThorsAngerVaNeT marked this pull request as draft October 29, 2023 19:11
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.

5 participants