Skip to content

Commit

Permalink
khanhpv - remove console function buyItem
Browse files Browse the repository at this point in the history
  • Loading branch information
khanhpv5 committed May 16, 2024
1 parent 70a5223 commit 980fc3b
Showing 1 changed file with 18 additions and 21 deletions.
39 changes: 18 additions & 21 deletions packages/extension-koni-ui/src/components/Modal/Shop/ShopModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -29,7 +29,6 @@ function Component ({ className, energyConfig,
const [isLoading, setIsLoading] = useState<boolean>(false);
const notify = useNotification();


const { inactiveModal } = useContext(ModalContext);

const onClose = useCallback(() => {
Expand Down Expand Up @@ -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'
Expand All @@ -131,7 +130,7 @@ function Component ({ className, energyConfig,
});
} else {
apiSDK.buyItem(+gameItemId)
.then((response: any) => {
.then(() => {
notify({
message: 'Successfully buy Item',
type: 'success'
Expand All @@ -140,35 +139,33 @@ function Component ({ className, energyConfig,
.catch((error) => {
notify({
message: error.message,
type:'error'
type: 'error'
});
})
.finally(() => {
setIsLoading(false);
});
}
}, []);



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 (
Expand Down

0 comments on commit 980fc3b

Please sign in to comment.