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:
258258 only :
259259 - dev
260260 - LVT-256
261+ - CORE-635
261262
262263 - deployQa :
263264 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) => (
5454 size = 'md'
5555 primary
5656 label = 'Start a new course'
57- to = { rootRoute }
57+ to = { rootRoute || '/' }
5858 />
5959 </ div >
6060 < p className = 'body-main' >
Original file line number Diff line number Diff line change @@ -8,11 +8,9 @@ import {
88 UserProfile ,
99} from '~/libs/core'
1010import { ProfilePicture , useCheckIsMobile } from '~/libs/shared'
11- import { Button } from '~/libs/ui'
1211
1312import { AddButton , EditMemberPropertyBtn } from '../../components'
1413import { EDIT_MODE_QUERY_PARAM , profileEditModes } from '../../config'
15- import { MemberProfileContextValue , useMemberProfileContext } from '../MemberProfile.context'
1614
1715import { OpenForGigs } from './OpenForGigs'
1816import { ModifyMemberNameModal } from './ModifyMemberNameModal'
@@ -45,8 +43,6 @@ const ProfileHeader: FC<ProfileHeaderProps> = (props: ProfileHeaderProps) => {
4543 const [ isHiringFormOpen , setIsHiringFormOpen ] : [ boolean , Dispatch < SetStateAction < boolean > > ]
4644 = useState < boolean > ( false )
4745
48- const { isTalentSearch } : MemberProfileContextValue = useMemberProfileContext ( )
49-
5046 const { state } : Location = useLocation ( )
5147
5248 const searchedSkills : string [ ] = useMemo (
@@ -179,18 +175,6 @@ const ProfileHeader: FC<ProfileHeaderProps> = (props: ProfileHeaderProps) => {
179175 . format ( 'MMM YYYY' ) }
180176 </ p >
181177 </ 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- }
194178 </ div >
195179
196180 {
Original file line number Diff line number Diff line change @@ -219,6 +219,7 @@ const ListView: FC<ListViewProps> = (props: ListViewProps) => {
219219 return confirmFlow ?. content
220220 } , [ confirmFlow ] )
221221
222+ // eslint-disable-next-line complexity
222223 const updatePayment = async ( paymentId : string ) : Promise < void > => {
223224 const currentEditState = editStateRef . current
224225 // Send to server only the fields that have changed
@@ -259,10 +260,15 @@ const ListView: FC<ListViewProps> = (props: ListViewProps) => {
259260
260261 toast . success ( 'Updating payment' , { position : toast . POSITION . BOTTOM_RIGHT } )
261262 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+
266272 return
267273 }
268274
Original file line number Diff line number Diff line change 1+ import { ApiError } from './ApiError'
2+
13export default interface ApiResponse < T > {
24 status : 'success' | 'error'
35 data : T
6+ error : ApiError
47}
Original file line number Diff line number Diff line change @@ -83,6 +83,10 @@ export async function editPayment(updates: {
8383 const response = await xhrPatchAsync < string , ApiResponse < string > > ( url , body )
8484
8585 if ( response . status === 'error' ) {
86+ if ( response . error && response . error . message ) {
87+ throw new Error ( response . error . message )
88+ }
89+
8690 throw new Error ( 'Error editing payment' )
8791 }
8892
Original file line number Diff line number Diff line change @@ -172,10 +172,14 @@ function interceptError(instance: AxiosInstance): void {
172172 config => config ,
173173 ( error : any ) => {
174174 // 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+
176181 // if there is server errors data, then return it inside `errors` property of error
177182 error . errors = error ?. response ?. data ?. errors
178-
179183 return Promise . reject ( error )
180184 } ,
181185 )
You can’t perform that action at this time.
0 commit comments