Skip to content

Commit

Permalink
KhanhPV - update airdrop raffle
Browse files Browse the repository at this point in the history
  • Loading branch information
khanhpv195 committed Jun 12, 2024
1 parent 9f49711 commit db0b166
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import React, { Context, useCallback, useContext, useEffect, useMemo, useState }
import { useNavigate, useParams } from 'react-router-dom';
import styled, { ThemeContext } from 'styled-components';
import useNotification from '@subwallet/extension-koni-ui/hooks/common/useNotification';

import DefaultLogosMap from '@subwallet/extension-koni-ui/assets/logo';
type WrapperProps = ThemeProps;
type Props = ThemeProps & {
currentAirdrop: AirdropCampaign;
Expand Down Expand Up @@ -49,6 +49,23 @@ const enum AirdropCampaignProcess {

const rewardModalId = AIRDROP_REWARD_MODAL_ID;

const LoadingGIF = styled.div`
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5);
display: flex;
justify-content: center;
align-items: center;
z-index: 9999;
img {
max-width: 100%;
max-height: 100%;
}
`;

const Component: React.FC<Props> = ({ className, currentAirdrop }: Props) => {
const navigate = useNavigate();
const notify = useNotification();
Expand All @@ -61,6 +78,7 @@ const Component: React.FC<Props> = ({ className, currentAirdrop }: Props) => {
const [isLoading, setIsLoading] = useState<boolean>(false);
const [claim, setClaim] = useState<boolean>(false);
const [airdropHistory, setAirdropHistory] = useState<AirdropRewardHistoryLog | null>(null);
const [loadingRaffle, showLoadingRaffle] = useState<boolean>(false);

const tabGroupItems = useMemo<TabGroupItemType[]>(() => {
return [
Expand Down Expand Up @@ -157,7 +175,12 @@ const Component: React.FC<Props> = ({ className, currentAirdrop }: Props) => {
try {
const result = await apiSDK.subscribeAirdropRaffle(currentAirdrop.airdrop_campaign_id) as unknown as AirdropRaffle;
setRaffle(result);
activeModal(rewardModalId);
showLoadingRaffle(true);
setTimeout(() => {
showLoadingRaffle(false);
activeModal(rewardModalId);
},3000);

} catch (error) {
setRaffle(null);
console.log('error', error);
Expand Down Expand Up @@ -349,6 +372,12 @@ const Component: React.FC<Props> = ({ className, currentAirdrop }: Props) => {
raffle={raffle}
isLoading={isLoading}
/>
{loadingRaffle && (
<LoadingGIF>
<img src={DefaultLogosMap.boxGift} alt="Loading..." />
</LoadingGIF>)
}

</Layout.WithSubHeaderOnly>
);
};
Expand Down
3 changes: 2 additions & 1 deletion packages/extension-koni-ui/src/assets/logo/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ export const DefaultLogosMap: Record<string, string> = {
stellaswap: '/images/projects/stellaswap.png',
xtwitter: '/images/projects/xtwitter.png',
game_background_image: '/images/subwallet/game-background-image.png',
token_icon: '/images/games/token-icon.png'
token_icon: '/images/games/token-icon.png',
boxGift: '/images/box.gif',
};

export const IconMap = {
Expand Down
Binary file added packages/webapp/public/images/box.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit db0b166

Please sign in to comment.