Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:TrustlessComputer/bvm-website in…
Browse files Browse the repository at this point in the history
…to develop
  • Loading branch information
camewell071 committed Jan 29, 2024
2 parents 17c560e + f2f811c commit fb6c4b4
Show file tree
Hide file tree
Showing 8 changed files with 106 additions and 33 deletions.
11 changes: 8 additions & 3 deletions src/modules/PublicSale/AuthForBuy/btnCreateGuest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { generateTOkenWithSecretCode } from '@/services/public-sale';
import AuthenStorage from '@/utils/storage/authen.storage';
import { setGuestSecretCode } from '@/stores/states/user/reducer';
import { useDispatch } from 'react-redux';
import cs from 'classnames';

const BtnCreateGuest = () => {
const dispatch = useDispatch();
Expand Down Expand Up @@ -47,14 +48,18 @@ const BtnCreateGuest = () => {
<Button
loadingText={'Processing'}
type="button"
className={s.btnTweetToSign}
className={cs(s.btnTweetToSign, s.btnPrimary)}
onClick={createNewSecretCode}
>
<Center className={s.boxIcon}>
<Center className={cs(s.boxIcon, s.boxIconWhite)}>
{loading ? (
<Spinner color="#fa4e0e" width={'16px'} height={'16px'} />
) : (
<SvgInset svgUrl="/icons/ic_guest.svg" size={16} />
<SvgInset
className={s.iconBlack}
svgUrl="/icons/ic_guest.svg"
size={16}
/>
)}
</Center>
<Text>Buy as guest</Text>
Expand Down
47 changes: 32 additions & 15 deletions src/modules/PublicSale/AuthForBuy/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -188,13 +188,13 @@ const AuthForBuy: React.FC<IAuthForBuy> = ({ children }) => {
className={s.btnContainer}
>
<SvgInset svgUrl="/icons/ic_twitter.svg" />
Buy $BVM
Back $BVM
</Button>
</Flex>
<BaseModal
isShow={isOpen}
onHide={onClose}
title={isSigned ? 'Buy $BVM' : 'Sign to Buy $BVM'}
title={isSigned ? 'Back $BVM' : 'Back $BVM'}
headerClassName={s.modalHeader}
className={cs(s.modalContent, isSigned ? s.deposit : s.notSignModal)}
// size={modalSize}
Expand All @@ -215,7 +215,35 @@ const AuthForBuy: React.FC<IAuthForBuy> = ({ children }) => {
alignItems={'center'}
gap={'16px'}
>
<Button
<GoogleReCaptchaProvider
reCaptchaKey="6LdrclkpAAAAAD1Xu6EVj_QB3e7SFtMVCKBuHb24"
scriptProps={{
async: false,
defer: false,
appendTo: 'head',
nonce: undefined,
}}
>
<BtnCreateGuest />
</GoogleReCaptchaProvider>
<Flex
alignItems={'center'}
gap={'12px'}
justifyContent={'center'}
width={'100%'}
mt={'5px'}
>
<Text onClick={handleShareTw} className={s.link}>
Post to sign-in
</Text>
<Text fontSize={'12px'} opacity={0.7}>
Or
</Text>
<Text onClick={getTwitterOauthUrl} className={s.link}>
Authorize to sign-in
</Text>
</Flex>
{/* <Button
isDisabled={submitting && !isCopy}
loadingText={'Processing'}
type="button"
Expand Down Expand Up @@ -249,18 +277,7 @@ const AuthForBuy: React.FC<IAuthForBuy> = ({ children }) => {
/>
</Center>
<Text>Auth to sign</Text>
</Button>
<GoogleReCaptchaProvider
reCaptchaKey="6LdrclkpAAAAAD1Xu6EVj_QB3e7SFtMVCKBuHb24"
scriptProps={{
async: false,
defer: false,
appendTo: 'head',
nonce: undefined,
}}
>
<BtnCreateGuest />
</GoogleReCaptchaProvider>
</Button> */}

<Box />
</Flex>
Expand Down
17 changes: 17 additions & 0 deletions src/modules/PublicSale/AuthForBuy/styles.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,26 @@
fill: #fff;
}
}
.iconBlack {
color: #000000;
path {
fill: #000000;
}
}
}
}

.btnImport {
background: #fa4e0e !important;
}

.link {
font-size: 14px;
opacity: 0.7;
text-decoration: underline;
cursor: pointer;
&:hover {
color: white;
opacity: 1;
}
}
45 changes: 33 additions & 12 deletions src/modules/PublicSale/depositModal/deposit.content.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import AppLoading from '@/components/AppLoading';
import SvgInset from '@/components/SvgInset';
import { PublicSaleWalletTokenDeposit } from '@/interfaces/vc';
import { getPublicsaleWalletInfo } from '@/services/public-sale';
import { getLocation, getPublicsaleWalletInfo } from '@/services/public-sale';
import { useAppSelector } from '@/stores/hooks';
import { commonSelector } from '@/stores/states/common/selector';
import { userSelector } from '@/stores/states/user/selector';
import { formatCurrency } from '@/utils/format';
import AuthenStorage from '@/utils/storage/authen.storage';
import { compareString } from '@/utils/string';
import {
Box,
Expand All @@ -26,32 +27,31 @@ import {
import BigNumber from 'bignumber.js';
import copy from 'copy-to-clipboard';
import React, { useEffect, useMemo, useState } from 'react';
import { isMobile } from 'react-device-detect';
import { GoogleReCaptchaProvider } from 'react-google-recaptcha-v3';
import toast from 'react-hot-toast';
import QRCode from 'react-qr-code';
import { useSelector } from 'react-redux';
import ImportOrCreate from '../AuthForBuy/importOrCreate';
import DepositCheck from './deposit.check';
import DepositContentItem, {
DepositContentItem2,
} from './deposit.content.item';
import s from './styles.module.scss';
import { isMobile } from 'react-device-detect';
import AuthenStorage from '@/utils/storage/authen.storage';
import BaseModal from '@/components/BaseModal';
import AuthForBuy from '../AuthForBuy';
import BuyAsGuest from '../AuthForBuy/buyAsGuest';
import ImportOrCreate from '../AuthForBuy/importOrCreate';
import { GoogleReCaptchaProvider } from 'react-google-recaptcha-v3';
import DepositCheck from './deposit.check';
import { FormikProvider } from 'formik';

interface IDepositContent {
amount_usd?: string;
onHide?: any;
}

const COUNTRY_BANNED: any[] = ['US'];

const DepositContent: React.FC<IDepositContent> = ({ amount_usd, onHide }) => {
const { onClose, onOpen, isOpen } = useDisclosure();
const user = useAppSelector(userSelector);
const [loading, setLoading] = useState(true);
const [checkingLocation, setCheckingLocation] = useState(true);
const [isBanned, setIsBanned] = useState(false);
const [tokens, setTokens] = useState<PublicSaleWalletTokenDeposit[]>([]);
const [selectToken, setSelectToken] = useState<
PublicSaleWalletTokenDeposit | undefined
Expand All @@ -63,10 +63,25 @@ const DepositContent: React.FC<IDepositContent> = ({ amount_usd, onHide }) => {

const coinPrices = useSelector(commonSelector).coinPrices;

useEffect(() => {
checkLocation();
}, []);

useEffect(() => {
getTokens();
}, [user]);

const checkLocation = async () => {
try {
const rs = await getLocation();
const country_code = rs?.data?.country_code;
setIsBanned(COUNTRY_BANNED.includes(country_code));
} catch (error) {
} finally {
setCheckingLocation(false);
}
};

const getTokens = async () => {
try {
const rs = await getPublicsaleWalletInfo();
Expand Down Expand Up @@ -103,20 +118,26 @@ const DepositContent: React.FC<IDepositContent> = ({ amount_usd, onHide }) => {
return '0';
}, [coinPrices, amount_usd, selectToken]);

if (loading) {
if (loading || checkingLocation) {
return (
<Center>
<AppLoading />
</Center>
);
}

if (isBanned) {
return <Center><Text>Not Available in Your Region</Text></Center>
}

return (
<Flex className={s.depositContent}>
{secretCode && (
<>
<Flex className={s.wrapSecretKey}>
<Text>Your secret key. Backup now</Text>
<Text className={s.titleCopy}>
Use this code to claim. copy now
</Text>
<Flex
className={s.backupNow}
onClick={() => {
Expand Down
9 changes: 8 additions & 1 deletion src/modules/PublicSale/depositModal/styles.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,16 @@
align-items: center;
justify-content: center;
gap: 34px;
.titleCopy {
font-size: 16px;
font-weight: 400;
line-height: 26px;
letter-spacing: 0em;
text-align: left;
}
.backupNow {
align-items: center;
gap: 50px;
gap: 40px;
background: linear-gradient(
0deg,
rgba(250, 78, 14, 0.4),
Expand Down
2 changes: 1 addition & 1 deletion src/modules/PublicSale/leaderBoard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ const LeaderBoard = (props: IProps) => {
letterSpacing: '-0.5px',
},
render(data: ILeaderBoardPoint) {
return (
return data?.need_active && (
<Flex justifyContent="flex-start" alignItems="center">
<Flex
flexDirection="row"
Expand Down
2 changes: 1 addition & 1 deletion src/modules/PublicSale/leaderBoardVisual/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ const LeaderBoardVisual = (props: IProps) => {
});

if(newRes?.length > 0) {
latestContributors.current = newRes.concat(latestContributors.current);
latestContributors.current = [...newRes].concat(latestContributors.current);
animatedLatestContributors.current = newRes;
dispatch(setAnimatedLatestContributors(newRes));
}
Expand Down
6 changes: 6 additions & 0 deletions src/services/public-sale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
import createAxiosInstance from '@/services/http-client';
import { PERP_API_URL } from '@/config';
import { ILeaderBoardPoint } from '@/interfaces/leader-board-point';
import axios from 'axios';

const apiClient = createAxiosInstance({
baseURL: `${PERP_API_URL}/api`,
Expand Down Expand Up @@ -75,6 +76,11 @@ export const saleManualCheck = async (recaptcha: string): Promise<any> => {
return res;
};

export const getLocation = async (): Promise<any> => {
const res = (await axios.get(`https://geolocation-db.com/json/`)) as unknown as any;
return res;
};

export interface IPublicSalePrograme {
id: number;
title: string;
Expand Down

0 comments on commit fb6c4b4

Please sign in to comment.