From b5dd6ffb95531c6007a5d3440dfbd64e2d85746e Mon Sep 17 00:00:00 2001 From: pietro-maximoff Date: Thu, 28 Jan 2021 16:12:12 +0300 Subject: [PATCH 1/2] [Waitlist] - saving mail to db --- .../containers/SalesPage/GetAccess/index.tsx | 254 ++++++++++-------- 1 file changed, 148 insertions(+), 106 deletions(-) diff --git a/src/app/containers/SalesPage/GetAccess/index.tsx b/src/app/containers/SalesPage/GetAccess/index.tsx index c617ea671..ded2e1a15 100644 --- a/src/app/containers/SalesPage/GetAccess/index.tsx +++ b/src/app/containers/SalesPage/GetAccess/index.tsx @@ -1,18 +1,20 @@ -import React, { useState, useRef, useEffect } from 'react'; +import React, { useCallback, useState, useRef, useEffect } from 'react'; import styled from 'styled-components/macro'; -import { useDispatch, useSelector } from 'react-redux'; +import { useSelector } from 'react-redux'; import { Slider } from '@blueprintjs/core'; import { Asset } from 'types/asset'; +import axios from 'axios'; import { validateEmail } from 'utils/helpers'; import { TradingPairDictionary } from 'utils/dictionaries/trading-pair-dictionary'; import { weiTo2 } from 'utils/blockchain/math-helpers'; +import { backendUrl, currentChainId } from 'utils/classifiers'; import { media } from 'styles/media'; -import { actions } from '../slice'; import { selectSalesPage } from '../selectors'; import Loader from '../loader'; import { useCachedAssetPrice } from '../../../hooks/trading/useCachedAssetPrice'; import { selectTradingPage } from '../../TradingPage/selectors'; import SalesButton from '../../../components/SalesButton'; +import { StyledButton } from '../../../components/SalesButton'; const StyledContent = styled.div` background: var(--sales-background); @@ -185,24 +187,37 @@ interface Props { } export default function GetAccess(props: Props) { - const dispatch = useDispatch(); const [email, setEmail] = useState(''); const [username, setUsername] = useState(''); + const [response, setResponse] = useState(''); const [enterCount, setEnterCount] = useState(false); const emailValid = validateEmail(email); const valid = !!email && emailValid; const [amount, setAmount] = useState(0); const { tradingPair } = useSelector(selectTradingPage); - const { requestAccessLoading, requestAccessError } = useSelector( - selectSalesPage, - ); - + const { requestAccessLoading } = useSelector(selectSalesPage); const pair = TradingPairDictionary.get(tradingPair); const { value: price } = useCachedAssetPrice(pair.getAsset(), Asset.DOC); const usdPrice = weiTo2(Number(price) * amount); - const maxAmount = 100; const searchInput = useRef(null as any); + const referralSrv = backendUrl[currentChainId]; + + const addtoWhitelist = useCallback(() => { + setResponse('pending'); + axios + .post(referralSrv + '/join-waitlist', { + email: email, + discord: username, + amount: amount, + }) + .then(res => { + setResponse('success'); + }) + .catch(error => { + setResponse('error'); + }); + }, [referralSrv, email, username, amount]); useEffect(() => { if (enterCount) { @@ -210,16 +225,6 @@ export default function GetAccess(props: Props) { } }, [enterCount]); - const handleSubmit = () => { - dispatch( - actions.requestAccess({ - email, - discord: username, - amount, - }), - ); - }; - const getChangeHandler = () => { return (value: number) => { if (value > maxAmount) { @@ -243,7 +248,7 @@ export default function GetAccess(props: Props) { return ( <> - {requestAccessLoading ? ( + {response === 'pending' ? ( @@ -255,104 +260,141 @@ export default function GetAccess(props: Props) { <>
-

Genesis Pre-Order has sold out!

-

- Register for whitelist access to the upcoming SOV token public - sale -

+ {response !== 'success' && ( +
+

+ Genesis Pre-Sale sold out in Minutes! +

+

+ Register for secure your place in the Origin Pre-Sale +

-
-
-
-
- - setUsername(e.target.value)} - /> +
+
+
+
+ + setUsername(e.target.value)} + /> +
+
+ + setEmail(e.target.value)} + /> + {!!email && !emailValid && ( + + Enter valid email address. + + )} +
+
-
- - setEmail(e.target.value)} - /> - {!!email && !emailValid && ( - - Enter valid email address. - - )} +
+
+
+ + {enterCount ? ( + setEnterCount(false)} + className="sliderAmount" + onChange={e => + setInputAmount(Number(e.target.value)) + } + /> + ) : ( +
{ + setEnterCount(true); + }} + > + {amount} ≈ ${usdPrice} +
+ )} + setEnterCount(false)} + onChange={getChangeHandler()} + /> +

+ Sharing with us your intended contribution is + optional. It does not constrain you to actually + participate but it helps us to better understand our + community. +

+
+
-
-
-
-
-
- - {enterCount ? ( - setEnterCount(false)} - className="sliderAmount" - onChange={e => setInputAmount(Number(e.target.value))} - /> - ) : ( -
{ - setEnterCount(true); - }} - > - {amount} ≈ ${usdPrice} +
+

+ By joining the waitlist you agree to receive the latest + news about the SOV ecosystem +

+ {response === 'error' && ( +
+ An error has occurred
)} - setEnterCount(false)} - onChange={getChangeHandler()} + -

- Sharing with us your intended contribution is optional. It - does not constrain you to actually participate but it - helps us to better understand our community. -

-
-

- By joining the waitlist you agree to receive the latest news - about the SOV ecosystem + )} + {response === 'success' && ( +

+

+ Congratulations you are on the waitlist! +

+

+ We will email you with instructions of how to participate + prior to the launch +

+

+ In the meantime why not learn about all things SOVRYN by + reading our Blackpaper

- {requestAccessError && ( -
{requestAccessError}
- )} - +
+
+ + Read Blackpaper + +
+
-
+ )} )} From fe13022ebb909f05a399d86359d3a2c908f668ae Mon Sep 17 00:00:00 2001 From: pietro-maximoff Date: Thu, 28 Jan 2021 17:58:34 +0300 Subject: [PATCH 2/2] [waitList] - change success window --- src/app/containers/SalesPage/GetAccess/index.tsx | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/app/containers/SalesPage/GetAccess/index.tsx b/src/app/containers/SalesPage/GetAccess/index.tsx index ded2e1a15..1ce6237fe 100644 --- a/src/app/containers/SalesPage/GetAccess/index.tsx +++ b/src/app/containers/SalesPage/GetAccess/index.tsx @@ -353,7 +353,7 @@ export default function GetAccess(props: Props) { news about the SOV ecosystem

{response === 'error' && ( -
+
An error has occurred
)} @@ -370,15 +370,12 @@ export default function GetAccess(props: Props) { {response === 'success' && (

- Congratulations you are on the waitlist! + Please confirm the email we just sent

- We will email you with instructions of how to participate - prior to the launch -

-

- In the meantime why not learn about all things SOVRYN by - reading our Blackpaper + To be registered you need to confirm the email we just sent + you If you do not see the email, please check your spam folder + and register us as not spam!