Skip to content

Commit 92b29fc

Browse files
authored
Merge pull request #978 from topcoder-platform/CORE-635
PROD DEPLOY - Core 635
2 parents a81f198 + e418389 commit 92b29fc

File tree

6 files changed

+32
-7
lines changed

6 files changed

+32
-7
lines changed

.circleci/config.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ save_cache_settings: &save_cache_settings
4444
running_yarn_eslint: &running_yarn_eslint
4545
name: Running Yarn eslint
4646
command: |
47-
yarn add eslint -g
47+
yarn add eslint@8.57.0 -g
4848
yarn lint
4949
5050
running_yarn_build: &running_yarn_build
@@ -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: 16 additions & 4 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

@@ -352,6 +360,10 @@ const ListView: FC<ListViewProps> = (props: ListViewProps) => {
352360
label: 'Cancelled',
353361
value: 'CANCELLED',
354362
},
363+
{
364+
label: 'Processing',
365+
value: 'PROCESSING',
366+
},
355367
],
356368
type: 'dropdown',
357369
},
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)