Skip to content

Commit 6bb73da

Browse files
authored
Merge pull request #671 from topcoder-platform/issue-661
onboarding: "+" button is disable for new user
2 parents 9fe8c10 + 796f12c commit 6bb73da

File tree

5 files changed

+25
-4
lines changed

5 files changed

+25
-4
lines changed

src/apps/onboarding/src/config/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@ export const ACTIONS: {
55
UPDATE_MEMBER_SKILLS: string;
66
SET_WORKS: string;
77
SET_EDUCATIONS: string;
8+
SET_LOADING_MEMBER_TRAITS: string;
89
};
910
} = {
1011
MEMBER: {
1112
GET_MEMBER: 'GET_MEMBER',
1213
UPDATE_MEMBER_SKILLS: 'UPDATE_MEMBER_SKILLS',
1314
SET_WORKS: 'SET_WORKS',
1415
SET_EDUCATIONS: 'SET_EDUCATIONS',
16+
SET_LOADING_MEMBER_TRAITS: 'SET_LOADING_MEMBER_TRAITS',
1517
},
1618
}
1719

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export const PageEducationsContent: FC<{
2121
reduxEducations: EducationInfo[] | null
2222
updateMemberEducations: (educations: EducationInfo[]) => void
2323
createMemberEducations: (educations: EducationInfo[]) => void
24+
loadingMemberTraits: boolean
2425
}> = props => {
2526
const navigate: any = useNavigate()
2627
const [editingEducation, setEditingEducation] = useState<EducationInfo | null>(null)
@@ -77,7 +78,7 @@ export const PageEducationsContent: FC<{
7778
secondary
7879
iconToLeft
7980
onClick={() => setShowAddEducationModal(true)}
80-
disabled={!educations}
81+
disabled={props.loadingMemberTraits}
8182
>
8283
+ add education
8384
</Button>
@@ -108,7 +109,7 @@ export const PageEducationsContent: FC<{
108109
size='lg'
109110
primary
110111
iconToLeft
111-
disabled={loading || !educations}
112+
disabled={loading || props.loadingMemberTraits}
112113
onClick={async () => {
113114
setLoading(true)
114115
if (!_.isEqual(props.reduxEducations, educations)) {
@@ -151,9 +152,11 @@ export const PageEducationsContent: FC<{
151152
const mapStateToProps: any = (state: any) => {
152153
const {
153154
educations,
155+
loadingMemberTraits,
154156
}: any = state.member
155157

156158
return {
159+
loadingMemberTraits,
157160
reduxEducations: educations,
158161
}
159162
}

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export const PageWorksContent: FC<{
2222
reduxWorks: WorkInfo[] | null
2323
updateMemberWorks: (works: WorkInfo[]) => void
2424
createMemberWorks: (works: WorkInfo[]) => void
25+
loadingMemberTraits: boolean
2526
}> = props => {
2627
const navigate: any = useNavigate()
2728
const [editingWork, setEditingWork] = useState<WorkInfo | null>(null)
@@ -87,7 +88,7 @@ export const PageWorksContent: FC<{
8788
secondary
8889
iconToLeft
8990
onClick={() => setShowAddWorkModal(true)}
90-
disabled={!works}
91+
disabled={props.loadingMemberTraits}
9192
>
9293
+ add work experience
9394
</Button>
@@ -120,7 +121,7 @@ export const PageWorksContent: FC<{
120121
size='lg'
121122
primary
122123
iconToLeft
123-
disabled={loading || !works}
124+
disabled={loading || props.loadingMemberTraits}
124125
onClick={async () => {
125126
setLoading(true)
126127
if (!_.isEqual(props.reduxWorks, works)) {
@@ -165,10 +166,12 @@ export const PageWorksContent: FC<{
165166

166167
const mapStateToProps: any = (state: any) => {
167168
const {
169+
loadingMemberTraits,
168170
works,
169171
}: any = state.member
170172

171173
return {
174+
loadingMemberTraits,
172175
reduxWorks: works,
173176
}
174177
}

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ export const updateEducations: any = (educations: EducationInfo[]) => ({
3131
payload: educations,
3232
})
3333

34+
export const updateLoadingMemberTraits: any = (loading: boolean) => ({
35+
type: ACTIONS.MEMBER.SET_LOADING_MEMBER_TRAITS,
36+
payload: loading,
37+
})
38+
3439
export const fetchMemberInfo: any = () => async (dispatch: any) => {
3540
try {
3641
const tokenInfo: TokenModel = await getAsyncToken()
@@ -44,11 +49,14 @@ const dateTimeToDate: any = (s: string) => (s ? new Date(s) : undefined)
4449
export const fetchMemberTraits: any = () => async (dispatch: any) => {
4550
const tokenInfo: TokenModel = await getAsyncToken()
4651
let memberTraits: any = []
52+
dispatch(updateLoadingMemberTraits(true))
4753
try {
4854
memberTraits = await getMemberTraits(tokenInfo.handle || '')
4955
} catch (error) {
5056
}
5157

58+
dispatch(updateLoadingMemberTraits(false))
59+
5260
const workExp: any = memberTraits.find((t: any) => t.traitId === 'work')
5361
const workExpValue: any = workExp?.traits?.data
5462
if (workExpValue) {

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ const memberReducer: any = (state = initialState, action: { type: any; payload:
2525
...state,
2626
works: action.payload,
2727
}
28+
case ACTIONS.MEMBER.SET_LOADING_MEMBER_TRAITS:
29+
return {
30+
...state,
31+
loadingMemberTraits: action.payload,
32+
}
2833
case ACTIONS.MEMBER.SET_EDUCATIONS:
2934
return {
3035
...state,

0 commit comments

Comments
 (0)