From d671ef0f4cfa7d17b43b265501ae595882549f17 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Fri, 6 Sep 2024 13:08:26 -0300 Subject: update to exchange v21 and merchant v17 --- .../paths/instance/kyc/list/ListPage.stories.tsx | 6 ++-- .../src/paths/instance/kyc/list/ListPage.tsx | 17 +++------- .../src/paths/instance/orders/create/index.tsx | 39 +++++++++++++++++----- .../src/paths/instance/orders/details/index.tsx | 30 ++++++++++++++--- .../src/paths/instance/orders/list/index.tsx | 32 +++++++++++++++--- .../src/paths/instance/templates/use/index.tsx | 39 +++++++++++++++++----- 6 files changed, 122 insertions(+), 41 deletions(-) (limited to 'packages/merchant-backoffice-ui') diff --git a/packages/merchant-backoffice-ui/src/paths/instance/kyc/list/ListPage.stories.tsx b/packages/merchant-backoffice-ui/src/paths/instance/kyc/list/ListPage.stories.tsx index 046636b4b..44fa429a4 100644 --- a/packages/merchant-backoffice-ui/src/paths/instance/kyc/list/ListPage.stories.tsx +++ b/packages/merchant-backoffice-ui/src/paths/instance/kyc/list/ListPage.stories.tsx @@ -37,18 +37,18 @@ export const Example = tests.createExample(TestedComponent, { timeout_kycs: [], pending_kycs: [ { - aml_status: 0, exchange_url: "http://exchange.taler", payto_uri: "payto://iban/de123123123" as PaytoString, kyc_url: "http://exchange.taler/kyc", + exchange_http_status: 0, }, { - aml_status: 1, + exchange_http_status: 1, exchange_url: "http://exchange.taler", payto_uri: "payto://iban/de123123123" as PaytoString, }, { - aml_status: 2, + exchange_http_status: 2, exchange_url: "http://exchange.taler", payto_uri: "payto://iban/de123123123" as PaytoString, }, diff --git a/packages/merchant-backoffice-ui/src/paths/instance/kyc/list/ListPage.tsx b/packages/merchant-backoffice-ui/src/paths/instance/kyc/list/ListPage.tsx index 3eeed1d7b..16bbd4b18 100644 --- a/packages/merchant-backoffice-ui/src/paths/instance/kyc/list/ListPage.tsx +++ b/packages/merchant-backoffice-ui/src/paths/instance/kyc/list/ListPage.tsx @@ -119,18 +119,11 @@ function PendingTable({ entries }: PendingTableProps): VNode { {e.exchange_url} {e.payto_uri} - {e.aml_status === 1 ? ( - - There is an anti-money laundering process pending to - complete. - - ) : ( - - The account is frozen due to the anti-money laundering - rules. Contact the exchange service provider for further - instructions. - - )} + + There is an anti-money laundering process pending to + complete. + + ); diff --git a/packages/merchant-backoffice-ui/src/paths/instance/orders/create/index.tsx b/packages/merchant-backoffice-ui/src/paths/instance/orders/create/index.tsx index 0ce2c331d..0dc125706 100644 --- a/packages/merchant-backoffice-ui/src/paths/instance/orders/create/index.tsx +++ b/packages/merchant-backoffice-ui/src/paths/instance/orders/create/index.tsx @@ -103,14 +103,37 @@ export default function OrderCreate({ onConfirm, onBack }: Props): VNode { if (resp.type === "ok") { return onConfirm(resp.body.order_id); } else { - setNotif({ - message: i18n.str`Could not create order`, - type: "ERROR", - description: - resp.case === HttpStatusCode.Gone - ? i18n.str`No more stock for product with id "${resp.body.product_id}".` - : resp.detail?.hint, - }); + switch (resp.case) { + case HttpStatusCode.UnavailableForLegalReasons: { + setNotif({ + message: i18n.str`Could not create order`, + type: "ERROR", + description: i18n.str`No exchange would accept a payment because of KYC requirements.` + }); + return; + } + case HttpStatusCode.Unauthorized: + case HttpStatusCode.NotFound: + case HttpStatusCode.Conflict: { + setNotif({ + message: i18n.str`Could not create order`, + type: "ERROR", + description: resp.detail?.hint, + }); + return; + } + case HttpStatusCode.Gone: { + setNotif({ + message: i18n.str`Could not create order`, + type: "ERROR", + description: i18n.str`No more stock for product with id "${resp.body.product_id}".` + }); + return; + } + default: { + assertUnreachable(resp) + } + } } }) .catch((error) => { diff --git a/packages/merchant-backoffice-ui/src/paths/instance/orders/details/index.tsx b/packages/merchant-backoffice-ui/src/paths/instance/orders/details/index.tsx index 5da500dc0..c7edce834 100644 --- a/packages/merchant-backoffice-ui/src/paths/instance/orders/details/index.tsx +++ b/packages/merchant-backoffice-ui/src/paths/instance/orders/details/index.tsx @@ -89,11 +89,31 @@ export default function Update({ oid, onBack }: Props): VNode { type: "SUCCESS", }); } else { - setNotif({ - message: i18n.str`Could not create the refund`, - type: "ERROR", - description: resp.detail?.hint, - }); + switch (resp.case) { + case HttpStatusCode.UnavailableForLegalReasons: { + setNotif({ + message: i18n.str`Could not create the refund`, + type: "ERROR", + description: i18n.str`There are pending KYC requirements.` + }); + return; + } + case HttpStatusCode.Unauthorized: + case HttpStatusCode.Forbidden: + case HttpStatusCode.NotFound: + case HttpStatusCode.Conflict: + case HttpStatusCode.Gone: { + setNotif({ + message: i18n.str`Could not create the refund`, + type: "ERROR", + description: resp.detail?.hint, + }); + return; + } + default: { + assertUnreachable(resp) + } + } } }) .catch((error) => diff --git a/packages/merchant-backoffice-ui/src/paths/instance/orders/list/index.tsx b/packages/merchant-backoffice-ui/src/paths/instance/orders/list/index.tsx index 450585a9f..787512e2a 100644 --- a/packages/merchant-backoffice-ui/src/paths/instance/orders/list/index.tsx +++ b/packages/merchant-backoffice-ui/src/paths/instance/orders/list/index.tsx @@ -164,11 +164,33 @@ export default function OrderList({ onCreate, onSelect }: Props): VNode { type: "SUCCESS", }); } else { - setNotif({ - message: i18n.str`Could not create the refund`, - type: "ERROR", - description: resp.detail?.hint, - }); + switch (resp.case) { + case HttpStatusCode.UnavailableForLegalReasons: { + setNotif({ + message: i18n.str`Could not create the refund`, + type: "ERROR", + description: i18n.str`There are pending KYC requirements.` + }); + return; + } + case HttpStatusCode.Unauthorized: + case HttpStatusCode.Forbidden: + case HttpStatusCode.NotFound: + case HttpStatusCode.Conflict: + case HttpStatusCode.Gone: { + setNotif({ + message: i18n.str`Could not create the refund`, + type: "ERROR", + description: resp.detail?.hint, + }); + return; + } + default: { + assertUnreachable(resp) + } + + } + } }) .catch((error) => diff --git a/packages/merchant-backoffice-ui/src/paths/instance/templates/use/index.tsx b/packages/merchant-backoffice-ui/src/paths/instance/templates/use/index.tsx index e8a0c3eba..504932ecb 100644 --- a/packages/merchant-backoffice-ui/src/paths/instance/templates/use/index.tsx +++ b/packages/merchant-backoffice-ui/src/paths/instance/templates/use/index.tsx @@ -87,14 +87,37 @@ export default function TemplateUsePage({ if (resp.type === "ok") { onOrderCreated(resp.body.order_id) } else { - setNotif({ - message: i18n.str`Could not create order from template`, - type: "ERROR", - description: - resp.case === HttpStatusCode.Gone - ? i18n.str`No more stock for product with id "${resp.body.product_id}".` - : resp.detail?.hint, - }); + switch (resp.case) { + case HttpStatusCode.UnavailableForLegalReasons: { + setNotif({ + message: i18n.str`Could not create order`, + type: "ERROR", + description: i18n.str`No exchange would accept a payment because of KYC requirements.` + }); + return; + } + case HttpStatusCode.Unauthorized: + case HttpStatusCode.NotFound: + case HttpStatusCode.Conflict: { + setNotif({ + message: i18n.str`Could not create order`, + type: "ERROR", + description: resp.detail?.hint, + }); + return; + } + case HttpStatusCode.Gone: { + setNotif({ + message: i18n.str`Could not create order`, + type: "ERROR", + description: i18n.str`No more stock for product with id "${resp.body.product_id}".` + }); + return; + } + default: { + assertUnreachable(resp) + } + } } }) .catch((error) => { -- cgit v1.2.3