From 980fc3b310f80804ab91bdc9082c99c838118418 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pha=CC=A3m=20Va=CC=86n=20Kha=CC=81nh?= Date: Thu, 16 May 2024 15:25:44 +0700 Subject: [PATCH] khanhpv - remove console function buyItem --- .../src/components/Modal/Shop/ShopModal.tsx | 39 +++++++++---------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/packages/extension-koni-ui/src/components/Modal/Shop/ShopModal.tsx b/packages/extension-koni-ui/src/components/Modal/Shop/ShopModal.tsx index 20daf4fcfe..75c2d5b8d1 100644 --- a/packages/extension-koni-ui/src/components/Modal/Shop/ShopModal.tsx +++ b/packages/extension-koni-ui/src/components/Modal/Shop/ShopModal.tsx @@ -4,11 +4,11 @@ import { ShopItem } from '@subwallet/extension-koni-ui/components'; import { BookaSdk } from '@subwallet/extension-koni-ui/connector/booka/sdk'; import { EnergyConfig, GameInventoryItem, GameItem } from '@subwallet/extension-koni-ui/connector/booka/types'; +import useNotification from '@subwallet/extension-koni-ui/hooks/common/useNotification'; import useTranslation from '@subwallet/extension-koni-ui/hooks/common/useTranslation'; import { ThemeProps } from '@subwallet/extension-koni-ui/types'; import { ShopItemInfo } from '@subwallet/extension-koni-ui/types/shop'; import { ModalContext, SwModal } from '@subwallet/react-ui'; -import useNotification from '@subwallet/extension-koni-ui/hooks/common/useNotification'; import React, { useCallback, useContext, useMemo, useState } from 'react'; import styled from 'styled-components'; @@ -29,7 +29,6 @@ function Component ({ className, energyConfig, const [isLoading, setIsLoading] = useState(false); const notify = useNotification(); - const { inactiveModal } = useContext(ModalContext); const onClose = useCallback(() => { @@ -114,7 +113,7 @@ function Component ({ className, energyConfig, setIsLoading(true); if (gameItemId === 'buy-energy-id') { apiSDK.buyEnergy() - .then((response: any) => { + .then(() => { notify({ message: 'Successfully buy Energy', type: 'success' @@ -131,7 +130,7 @@ function Component ({ className, energyConfig, }); } else { apiSDK.buyItem(+gameItemId) - .then((response: any) => { + .then(() => { notify({ message: 'Successfully buy Item', type: 'success' @@ -140,7 +139,7 @@ function Component ({ className, energyConfig, .catch((error) => { notify({ message: error.message, - type:'error' + type: 'error' }); }) .finally(() => { @@ -148,27 +147,25 @@ function Component ({ className, energyConfig, }); } }, []); - - const onUse = useCallback((gameItemId: string) => { setIsLoading(true); apiSDK.useInventoryItem(+gameItemId) - .then((response: any) => { - notify({ - message: 'Successfully use item', - type: 'success' - }); - }) - .catch((e) => { - console.log('onUse error', e); - notify({ - message: "Error", - type: e.error, + .then(() => { + notify({ + message: 'Successfully use item', + type: 'success' + }); + }) + .catch((e) => { + console.log('onUse error', e); + notify({ + message: 'Error', + type: e.error + }); + }).finally(() => { + setIsLoading(false); }); - }).finally(() => { - setIsLoading(false); - }); }, []); return (