Commit 3ead00d4 authored by Max Alekseenko's avatar Max Alekseenko

add ref code validation and example format

parent b0cda74d
...@@ -52,7 +52,11 @@ const LoginStepContent = ({ goNext, closeModal }: Props) => { ...@@ -52,7 +52,11 @@ const LoginStepContent = ({ goNext, closeModal }: Props) => {
}, [ login, goNext, setIsLoading, router, closeModal, refCode, setRefCodeError, isRefCodeUsed ]); }, [ login, goNext, setIsLoading, router, closeModal, refCode, setRefCodeError, isRefCodeUsed ]);
useEffect(() => { useEffect(() => {
if (refCode.length > 0 && refCode.length !== 6) {
setRefCodeError.on();
} else {
setRefCodeError.off(); setRefCodeError.off();
}
}, [ refCode ]); // eslint-disable-line react-hooks/exhaustive-deps }, [ refCode ]); // eslint-disable-line react-hooks/exhaustive-deps
const { start: loginToAccount } = useSignInWithWallet({ const { start: loginToAccount } = useSignInWithWallet({
...@@ -103,6 +107,7 @@ const LoginStepContent = ({ goNext, closeModal }: Props) => { ...@@ -103,6 +107,7 @@ const LoginStepContent = ({ goNext, closeModal }: Props) => {
/> />
</Flex> </Flex>
{ isRefCodeUsed && ( { isRefCodeUsed && (
<>
<FormControl variant="floating" id="referral-code" mt={ 3 }> <FormControl variant="floating" id="referral-code" mt={ 3 }>
<Input <Input
fontWeight="500" fontWeight="500"
...@@ -112,6 +117,10 @@ const LoginStepContent = ({ goNext, closeModal }: Props) => { ...@@ -112,6 +117,10 @@ const LoginStepContent = ({ goNext, closeModal }: Props) => {
/> />
<InputPlaceholder text="Code"/> <InputPlaceholder text="Code"/>
</FormControl> </FormControl>
<Text fontSize="sm" variant="secondary" mt={ 1 } color={ refCodeError ? 'red.500' : undefined }>
{ refCodeError ? 'Incorrect code or format' : 'The code should be in format XXXXXX' }
</Text>
</>
) } ) }
</Box> </Box>
) } ) }
...@@ -129,7 +138,7 @@ const LoginStepContent = ({ goNext, closeModal }: Props) => { ...@@ -129,7 +138,7 @@ const LoginStepContent = ({ goNext, closeModal }: Props) => {
onClick={ isConnected ? handleLogin : connect } onClick={ isConnected ? handleLogin : connect }
isLoading={ isLoading || profileQuery.isLoading || checkUserQuery.isFetching } isLoading={ isLoading || profileQuery.isLoading || checkUserQuery.isFetching }
loadingText={ isLoading ? 'Sign message in your wallet' : undefined } loadingText={ isLoading ? 'Sign message in your wallet' : undefined }
isDisabled={ isAddressMismatch } isDisabled={ isAddressMismatch || refCodeError }
> >
{ isConnected ? 'Get started' : 'Connect wallet' } { isConnected ? 'Get started' : 'Connect wallet' }
</Button> </Button>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment