Skip to content

Commit 87cfec7

Browse files
authored
Merge pull request #976 from topcoder-platform/CORE-635
Minor wallet admin updates (CORE-635)
2 parents ccb85cc + cc2ab74 commit 87cfec7

File tree

6 files changed

+28
-7
lines changed

6 files changed

+28
-7
lines changed

.circleci/config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ workflows:
258258
only:
259259
- dev
260260
- LVT-256
261+
- CORE-635
261262

262263
- deployQa:
263264
context: org-global

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* *

src/apps/wallet-admin/src/home/tabs/payments/PaymentsTab.tsx

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ function formatStatus(status: string): string {
3737
return 'Paid'
3838
case 'CANCELLED':
3939
return 'Cancel'
40+
case 'PROCESSING':
41+
return 'Processing'
4042
default:
4143
return status.replaceAll('_', ' ')
4244
}
@@ -217,6 +219,7 @@ const ListView: FC<ListViewProps> = (props: ListViewProps) => {
217219
return confirmFlow?.content
218220
}, [confirmFlow])
219221

222+
// eslint-disable-next-line complexity
220223
const updatePayment = async (paymentId: string): Promise<void> => {
221224
const currentEditState = editStateRef.current
222225
// Send to server only the fields that have changed
@@ -257,10 +260,15 @@ const ListView: FC<ListViewProps> = (props: ListViewProps) => {
257260

258261
toast.success('Updating payment', { position: toast.POSITION.BOTTOM_RIGHT })
259262
try {
260-
const udpateMessage = await editPayment(updates)
261-
toast.success(udpateMessage, { position: toast.POSITION.BOTTOM_RIGHT })
262-
} catch (err) {
263-
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+
264272
return
265273
}
266274

@@ -354,7 +362,7 @@ const ListView: FC<ListViewProps> = (props: ListViewProps) => {
354362
},
355363
{
356364
label: 'Processing',
357-
value: 'Processing',
365+
value: 'PROCESSING',
358366
},
359367
],
360368
type: 'dropdown',
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1+
import { ApiError } from './ApiError'
2+
13
export default interface ApiResponse<T> {
24
status: 'success' | 'error'
35
data: T
6+
error: ApiError
47
}

src/apps/wallet-admin/src/lib/services/wallet.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff 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

src/libs/core/lib/xhr/xhr-functions/xhr.functions.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff 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
)

0 commit comments

Comments
 (0)