File tree Expand file tree Collapse file tree 8 files changed +26
-23
lines changed
learn/src/course-completed/course-view
libs/core/lib/xhr/xhr-functions Expand file tree Collapse file tree 8 files changed +26
-23
lines changed Original file line number Diff line number Diff line change @@ -258,6 +258,7 @@ workflows:
258
258
only :
259
259
- dev
260
260
- LVT-256
261
+ - CORE-635
261
262
262
263
- deployQa :
263
264
context : org-global
Original file line number Diff line number Diff line change
1
+ * *
Original file line number Diff line number Diff line change @@ -54,7 +54,7 @@ const CourseView: FC<CourseViewProps> = (props: CourseViewProps) => (
54
54
size = 'md'
55
55
primary
56
56
label = 'Start a new course'
57
- to = { rootRoute }
57
+ to = { rootRoute || '/' }
58
58
/>
59
59
</ div >
60
60
< p className = 'body-main' >
Original file line number Diff line number Diff line change @@ -8,11 +8,9 @@ import {
8
8
UserProfile ,
9
9
} from '~/libs/core'
10
10
import { ProfilePicture , useCheckIsMobile } from '~/libs/shared'
11
- import { Button } from '~/libs/ui'
12
11
13
12
import { AddButton , EditMemberPropertyBtn } from '../../components'
14
13
import { EDIT_MODE_QUERY_PARAM , profileEditModes } from '../../config'
15
- import { MemberProfileContextValue , useMemberProfileContext } from '../MemberProfile.context'
16
14
17
15
import { OpenForGigs } from './OpenForGigs'
18
16
import { ModifyMemberNameModal } from './ModifyMemberNameModal'
@@ -45,8 +43,6 @@ const ProfileHeader: FC<ProfileHeaderProps> = (props: ProfileHeaderProps) => {
45
43
const [ isHiringFormOpen , setIsHiringFormOpen ] : [ boolean , Dispatch < SetStateAction < boolean > > ]
46
44
= useState < boolean > ( false )
47
45
48
- const { isTalentSearch } : MemberProfileContextValue = useMemberProfileContext ( )
49
-
50
46
const { state } : Location = useLocation ( )
51
47
52
48
const searchedSkills : string [ ] = useMemo (
@@ -179,18 +175,6 @@ const ProfileHeader: FC<ProfileHeaderProps> = (props: ProfileHeaderProps) => {
179
175
. format ( 'MMM YYYY' ) }
180
176
</ p >
181
177
</ div >
182
- {
183
- ! canEdit && isTalentSearch ? (
184
- < div className = { styles . hiringClickWrap } >
185
- < Button
186
- label = 'Hire Topcoder Talent'
187
- primary
188
- size = 'lg'
189
- onClick = { handleStartHiringToggle }
190
- />
191
- </ div >
192
- ) : undefined
193
- }
194
178
</ div >
195
179
196
180
{
Original file line number Diff line number Diff line change @@ -219,6 +219,7 @@ const ListView: FC<ListViewProps> = (props: ListViewProps) => {
219
219
return confirmFlow ?. content
220
220
} , [ confirmFlow ] )
221
221
222
+ // eslint-disable-next-line complexity
222
223
const updatePayment = async ( paymentId : string ) : Promise < void > => {
223
224
const currentEditState = editStateRef . current
224
225
// Send to server only the fields that have changed
@@ -259,10 +260,15 @@ const ListView: FC<ListViewProps> = (props: ListViewProps) => {
259
260
260
261
toast . success ( 'Updating payment' , { position : toast . POSITION . BOTTOM_RIGHT } )
261
262
try {
262
- const udpateMessage = await editPayment ( updates )
263
- toast . success ( udpateMessage , { position : toast . POSITION . BOTTOM_RIGHT } )
264
- } catch ( err ) {
265
- toast . error ( 'Failed to update payment' , { position : toast . POSITION . BOTTOM_RIGHT } )
263
+ const updateMessage = await editPayment ( updates )
264
+ toast . success ( updateMessage , { position : toast . POSITION . BOTTOM_RIGHT } )
265
+ } catch ( err :any ) {
266
+ if ( err ?. message ) {
267
+ toast . error ( err ?. message , { position : toast . POSITION . BOTTOM_RIGHT } )
268
+ } else {
269
+ toast . error ( 'Failed to update payment' , { position : toast . POSITION . BOTTOM_RIGHT } )
270
+ }
271
+
266
272
return
267
273
}
268
274
Original file line number Diff line number Diff line change
1
+ import { ApiError } from './ApiError'
2
+
1
3
export default interface ApiResponse < T > {
2
4
status : 'success' | 'error'
3
5
data : T
6
+ error : ApiError
4
7
}
Original file line number Diff line number Diff line change @@ -83,6 +83,10 @@ export async function editPayment(updates: {
83
83
const response = await xhrPatchAsync < string , ApiResponse < string > > ( url , body )
84
84
85
85
if ( response . status === 'error' ) {
86
+ if ( response . error && response . error . message ) {
87
+ throw new Error ( response . error . message )
88
+ }
89
+
86
90
throw new Error ( 'Error editing payment' )
87
91
}
88
92
Original file line number Diff line number Diff line change @@ -172,10 +172,14 @@ function interceptError(instance: AxiosInstance): void {
172
172
config => config ,
173
173
( error : any ) => {
174
174
// if there is server error message, then return it inside `message` property of error
175
- error . message = error ?. response ?. data ?. message || error . message
175
+ if ( error ?. response ?. data ?. message ) {
176
+ error . message = error ?. response ?. data ?. message
177
+ } else if ( error ?. response ?. data ?. error ?. message ) {
178
+ error . message = error ?. response ?. data ?. error ?. message
179
+ }
180
+
176
181
// if there is server errors data, then return it inside `errors` property of error
177
182
error . errors = error ?. response ?. data ?. errors
178
-
179
183
return Promise . reject ( error )
180
184
} ,
181
185
)
You can’t perform that action at this time.
0 commit comments