Skip to content

Commit cde9241

Browse files
committed
fix: existing date not loaded properly
1 parent afd10db commit cde9241

File tree

7 files changed

+40
-41
lines changed

7 files changed

+40
-41
lines changed

src/apps/onboarding/src/components/modal-add-education/index.tsx

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const ModalAddEducation: FC<ModalAddEducationProps> = (props: ModalAddEducationP
2828
const [educationInfo, setEducationInfo] = useState(emptyEducationInfo())
2929
const [formErrors, setFormErrors] = useState<any>({
3030
collegeName: undefined,
31-
endDate: undefined,
31+
endYear: undefined,
3232
major: undefined,
3333
})
3434

@@ -42,8 +42,8 @@ const ModalAddEducation: FC<ModalAddEducationProps> = (props: ModalAddEducationP
4242
errorTmp.major = 'Required'
4343
}
4444

45-
if (!educationInfo.endDate) {
46-
errorTmp.endDate = 'Required'
45+
if (!educationInfo.endYear) {
46+
errorTmp.endYear = 'Required'
4747
}
4848

4949
setFormErrors(errorTmp)
@@ -123,19 +123,16 @@ const ModalAddEducation: FC<ModalAddEducationProps> = (props: ModalAddEducationP
123123
<InputSelect
124124
tabIndex={0}
125125
options={yearOptions}
126-
value={educationInfo.endDate ? `${getYear(educationInfo.endDate)}` : undefined}
126+
value={educationInfo.endYear?.toString()}
127127
onChange={function onChange(event: any) {
128128
setEducationInfo({
129129
...educationInfo,
130-
endDate: setYear(
131-
new Date(),
132-
parseInt(event.target.value, 10),
133-
),
130+
endYear: event.target.value,
134131
})
135132
}}
136133
dirty
137-
error={formErrors.endDate}
138-
name='endDate'
134+
error={formErrors.endYear}
135+
name='endYear'
139136
label='End Year or Expected *'
140137
placeholder='Select year'
141138
/>

src/apps/onboarding/src/components/modal-add-work/index.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const industryOptions: any = _.sortBy(INDUSTRIES_OPTIONS)
3030
const ModalAddWork: FC<ModalAddWorkProps> = (props: ModalAddWorkProps) => {
3131
const [workInfo, setWorkInfo] = useState(emptyWorkInfo())
3232
const [formErrors, setFormErrors] = useState<any>({
33-
company: undefined,
33+
companyName: undefined,
3434
endDate: undefined,
3535
position: undefined,
3636
startDate: undefined,
@@ -46,8 +46,8 @@ const ModalAddWork: FC<ModalAddWorkProps> = (props: ModalAddWorkProps) => {
4646

4747
const validateField: any = () => {
4848
const errorTmp: any = {}
49-
if (!workInfo.company) {
50-
errorTmp.company = 'Required'
49+
if (!workInfo.companyName) {
50+
errorTmp.companyName = 'Required'
5151
}
5252

5353
if (!workInfo.position) {
@@ -121,20 +121,20 @@ const ModalAddWork: FC<ModalAddWorkProps> = (props: ModalAddWorkProps) => {
121121
<div className={classNames(styles.modalContent, 'd-flex flex-column align-items-start mobile-gap-16')}>
122122
<div className='full-width'>
123123
<InputText
124-
name='company'
124+
name='companyName'
125125
label='Company *'
126-
value={workInfo.company}
126+
value={workInfo.companyName}
127127
onChange={function onChange(event: any) {
128128
setWorkInfo({
129129
...workInfo,
130-
company: event.target.value,
130+
companyName: event.target.value,
131131
})
132132
}}
133133
placeholder='Enter company'
134134
tabIndex={0}
135135
type='text'
136136
dirty
137-
error={formErrors.company}
137+
error={formErrors.companyName}
138138
/>
139139
</div>
140140
<div className='full-width'>

src/apps/onboarding/src/models/EducationInfo.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@ export default interface EducationInfo {
22
collegeName: string
33
major: string
44
dateDescription: string
5-
endDate?: Date
6-
id: number
5+
endYear?: string
6+
id: number,
7+
traitId: string,
78
}
89

910
export const emptyEducationInfo: () => EducationInfo = () => ({
1011
collegeName: '',
1112
dateDescription: '',
12-
endDate: undefined,
13+
endYear: undefined,
1314
id: 0,
1415
major: '',
16+
traitId: '',
1517
})

src/apps/onboarding/src/models/WorkInfo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export default interface WorkInfo {
2-
company?: string
2+
companyName?: string
33
position?: string
44
industry?: string
55
startDate?: Date

src/apps/onboarding/src/pages/educations/index.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,10 @@ export const PageEducationsContent: FC<{
5757
}, [educations])
5858

5959
const displayEducations = useMemo(() => (educations || []).map(educationItem => {
60-
const endDate: Date | undefined = educationItem.endDate
61-
const endDateString: string = endDate ? moment(endDate)
62-
.format('YYYY') : ''
60+
const endYear: string = educationItem.endYear as string
6361
return {
6462
...educationItem,
65-
dateDescription: endDateString || '',
63+
dateDescription: endYear || '',
6664
}
6765
}), [educations])
6866

src/apps/onboarding/src/pages/works/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export const PageWorksContent: FC<{
7373
...(startDateString ? [startDateString] : []),
7474
...(endDateString ? [endDateString] : []),
7575
].join('-'),
76-
description: workItem.company,
76+
description: workItem.companyName,
7777
}
7878
}), [works])
7979

src/apps/onboarding/src/redux/actions/member.ts

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,10 @@ export const fetchMemberTraits: any = () => async (dispatch: any) => {
117117
if (workExpValue) {
118118
// workExpValue is array of works. fill it to state
119119
const works: WorkInfo[] = workExpValue.map((j: any, index: number) => {
120-
const startDate: Date | undefined = dateTimeToDate(j.timePeriodFrom)
121-
const endDate: Date | undefined = dateTimeToDate(j.timePeriodTo)
120+
const startDate: Date | undefined = dateTimeToDate(j.startDate)
121+
const endDate: Date | undefined = dateTimeToDate(j.endDate)
122122
return ({
123-
company: j.company,
123+
companyName: j.companyName,
124124
currentlyWorking: j.working,
125125
endDate,
126126
id: index + 1,
@@ -142,10 +142,11 @@ export const fetchMemberTraits: any = () => async (dispatch: any) => {
142142
const startDate: Date | undefined = dateTimeToDate(e.timePeriodFrom)
143143
const endDate: Date | undefined = dateTimeToDate(e.timePeriodTo)
144144
return ({
145-
collegeName: e.schoolCollegeName,
145+
collegeName: e.collegeName,
146146
endDate,
147147
id: index + 1,
148-
major: e.major,
148+
major: e.degree,
149+
endYear: e.endYear,
149150
startDate,
150151
})
151152
})
@@ -192,11 +193,11 @@ const createWorksPayloadData: any = (works: WorkInfo[]) => {
192193
currentlyWorking,
193194
}: any = work
194195
return {
195-
company,
196+
companyName: company || '',
196197
industry,
197198
position,
198-
timePeriodFrom: startDate ? startDate.toISOString() : '',
199-
timePeriodTo: endDate ? endDate.toISOString() : '',
199+
startDate: startDate ? startDate.toISOString() : null,
200+
endDate: endDate ? endDate.toISOString() : null,
200201
working: currentlyWorking,
201202
}
202203
})
@@ -205,6 +206,7 @@ const createWorksPayloadData: any = (works: WorkInfo[]) => {
205206
categoryName: UserTraitCategoryNames.work,
206207
traitId: UserTraitIds.work,
207208
traits: {
209+
traitId: UserTraitIds.work,
208210
data,
209211
},
210212
}
@@ -242,21 +244,20 @@ const createEducationsPayloadData: any = (educations: EducationInfo[]) => {
242244
const {
243245
collegeName,
244246
major,
245-
startDate,
246-
endDate,
247+
endYear,
247248
}: any = education
248249
return {
249-
major,
250-
schoolCollegeName: collegeName,
251-
timePeriodFrom: startDate ? startDate.toISOString() : '',
252-
timePeriodTo: endDate ? endDate.toISOString() : '',
250+
degree: major,
251+
collegeName,
252+
endYear: parseInt(endYear, 10),
253253
}
254254
})
255255

256256
const payload: any = {
257257
categoryName: UserTraitCategoryNames.education,
258258
traitId: UserTraitIds.education,
259259
traits: {
260+
traitId: UserTraitIds.education,
260261
data,
261262
},
262263
}
@@ -266,7 +267,7 @@ const createEducationsPayloadData: any = (educations: EducationInfo[]) => {
266267
export const updateMemberEducations: any = (educations: EducationInfo[]) => async (dispatch: any) => {
267268
try {
268269
const tokenInfo: TokenModel = await getAsyncToken()
269-
270+
console.log(createEducationsPayloadData(educations), 'createEducationsPayloadData(educations)')
270271
await updateMemberTraits(tokenInfo.handle || '', createEducationsPayloadData(educations))
271272
dispatch(updateEducations(educations))
272273
} catch (error) {
@@ -310,6 +311,7 @@ const createPersonalizationsPayloadData: any = (personalizations: Personalizatio
310311
categoryName: UserTraitCategoryNames.personalization,
311312
traitId: UserTraitIds.personalization,
312313
traits: {
314+
traitId: UserTraitIds.personalization,
313315
data,
314316
},
315317
}

0 commit comments

Comments
 (0)