Skip to content

Commit

Permalink
Uses a generic type for service unavailable when address is sanctioned.
Browse files Browse the repository at this point in the history
  • Loading branch information
jwhardwick committed Aug 1, 2024
1 parent f455d1d commit 9aa107e
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,12 @@ export enum SharedViews {
ERROR_VIEW = 'ERROR_VIEW',
SERVICE_UNAVAILABLE_ERROR_VIEW = 'SERVICE_UNAVAILABLE_ERROR_VIEW',
TOP_UP_VIEW = 'TOP_UP_VIEW',
SANCTIONED_ADDRESS_ERROR_VIEW = 'SANCTIONED_ADDRESS_ERROR_VIEW',
}

export type SharedView =
LoadingView
| ErrorView
| ServiceUnavailableErrorView
| SanctionedAddressErrorView
| TopUpView;

interface LoadingView extends ViewType {
Expand All @@ -32,16 +30,11 @@ export interface ErrorView extends ViewType {
tryAgain?: () => Promise<any>
}

export interface ServiceUnavailableErrorView extends ViewType {
interface ServiceUnavailableErrorView extends ViewType {
type: SharedViews.SERVICE_UNAVAILABLE_ERROR_VIEW;
error: Error;
}

interface SanctionedAddressErrorView extends ViewType {
type: SharedViews.SANCTIONED_ADDRESS_ERROR_VIEW;
error: Error;
}

interface TopUpView extends ViewType {
type: SharedViews.TOP_UP_VIEW,
swapData?: PrefilledSwapForm,
Expand Down
4 changes: 2 additions & 2 deletions packages/checkout/widgets-lib/src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@
"SERVICE_UNAVAILABLE_ERROR_VIEW": {
"heading": {
"swap": "Swapping is not available in your region",
"sanction": "This service is not available in your region"
"generic": "This service is not available in your region"
},
"body": {
"swap": "Please refer to <quickswapLink>Quickswap’s</quickswapLink> website for further information.",
"sanction": "For further assistance visit the <immutableSupport>Immutable</immutableSupport> support page."
"generic": "For further assistance visit the <immutableSupport>Immutable</immutableSupport> support page."
}
},
"LOADING_VIEW": {
Expand Down
4 changes: 2 additions & 2 deletions packages/checkout/widgets-lib/src/locales/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@
"SERVICE_UNAVAILABLE_ERROR_VIEW": {
"heading": {
"swap": "お住まいの地域では交換が利用できません",
"sanction": "このサービスはお住まいの地域では利用できません"
"generic": "このサービスはお住まいの地域では利用できません"
},
"body": {
"swap": "<quickswapLink>Quickswap</quickswapLink>のウェブサイトで詳細情報をご覧ください。",
"sanction": "詳しいサポートについては、<immutableSupport>Immutable</immutableSupport>サポートページをご覧ください."
"generic": "詳しいサポートについては、<immutableSupport>Immutable</immutableSupport>サポートページをご覧ください."
}
},
"LOADING_VIEW": {
Expand Down
4 changes: 2 additions & 2 deletions packages/checkout/widgets-lib/src/locales/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@
"SERVICE_UNAVAILABLE_ERROR_VIEW": {
"heading": {
"swap": "귀하의 지역에서는 스왑이 가능하지 않습니다",
"sanction": "이 서비스는 귀하의 지역에서 이용할 수 없습니다"
"generic": "이 서비스는 귀하의 지역에서 이용할 수 없습니다"
},
"body": {
"swap": "자세한 정보는 <quickswapLink>Quickswap</quickswapLink> 웹사이트를 참조하십시오.",
"sanction": "추가 지원이 필요하시면 <immutableSupport>Immutable</immutableSupport> 지원 페이지를 방문하세요."
"generic": "추가 지원이 필요하시면 <immutableSupport>Immutable</immutableSupport> 지원 페이지를 방문하세요."
}
},
"LOADING_VIEW": {
Expand Down
4 changes: 2 additions & 2 deletions packages/checkout/widgets-lib/src/locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@
"SERVICE_UNAVAILABLE_ERROR_VIEW": {
"heading": {
"swap": "您所在的地区不支持兑换",
"sanction": "该服务在您的地区不可用"
"generic": "该服务在您的地区不可用"
},
"body": {
"swap": "请参考<quickswapLink>Quickswap</quickswapLink>的网站了解更多信息。",
"sanction": "如需进一步帮助,请访问<immutableSupport>Immutable</immutableSupport>支持页面。"
"generic": "如需进一步帮助,请访问<immutableSupport>Immutable</immutableSupport>支持页面。"
}
},
"LOADING_VIEW": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export enum ServiceType {
SWAP = 'swap',
SANCTION = 'sanction',
GENERIC = 'generic',
}
Original file line number Diff line number Diff line change
Expand Up @@ -339,9 +339,9 @@ export default function BridgeWidget({
testId="claim-withdrawal-fail-view"
/>
)}
{viewState.view.type === SharedViews.SANCTIONED_ADDRESS_ERROR_VIEW && (
{viewState.view.type === SharedViews.SERVICE_UNAVAILABLE_ERROR_VIEW && (
<ServiceUnavailableErrorView
service={ServiceType.SANCTION}
service={ServiceType.GENERIC}
onCloseClick={() => sendBridgeWidgetCloseEvent(eventTarget)}
/>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ export function WalletAndNetworkSelector() {
payload: {
type: ViewActions.UPDATE_VIEW,
view: {
type: SharedViews.SANCTIONED_ADDRESS_ERROR_VIEW,
type: SharedViews.SERVICE_UNAVAILABLE_ERROR_VIEW,
error: new Error('Sanctioned address'),
},
},
Expand Down Expand Up @@ -345,7 +345,7 @@ export function WalletAndNetworkSelector() {
payload: {
type: ViewActions.UPDATE_VIEW,
view: {
type: SharedViews.SANCTIONED_ADDRESS_ERROR_VIEW,
type: SharedViews.SERVICE_UNAVAILABLE_ERROR_VIEW,
error: new Error('Sanctioned address'),
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,9 @@ export default function ConnectWidget({
onCloseClick={() => sendCloseEvent()}
/>
)}
{view.type === SharedViews.SANCTIONED_ADDRESS_ERROR_VIEW && (
{view.type === SharedViews.SERVICE_UNAVAILABLE_ERROR_VIEW && (
<ServiceUnavailableErrorView
service={ServiceType.SANCTION}
service={ServiceType.GENERIC}
onCloseClick={sendCloseEvent}
/>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ export function WalletList(props: WalletListProps) {
payload: {
type: ViewActions.UPDATE_VIEW,
view: {
type: SharedViews.SANCTIONED_ADDRESS_ERROR_VIEW,
type: SharedViews.SERVICE_UNAVAILABLE_ERROR_VIEW,
error: new Error('Sanctioned address'),
},
},
Expand Down

0 comments on commit 9aa107e

Please sign in to comment.