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(() => {
setRefCodeError.off(); if (refCode.length > 0 && refCode.length !== 6) {
setRefCodeError.on();
} else {
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,15 +107,20 @@ const LoginStepContent = ({ goNext, closeModal }: Props) => { ...@@ -103,15 +107,20 @@ const LoginStepContent = ({ goNext, closeModal }: Props) => {
/> />
</Flex> </Flex>
{ isRefCodeUsed && ( { isRefCodeUsed && (
<FormControl variant="floating" id="referral-code" mt={ 3 }> <>
<Input <FormControl variant="floating" id="referral-code" mt={ 3 }>
fontWeight="500" <Input
value={ refCode } fontWeight="500"
onChange={ handleRefCodeChange } value={ refCode }
isInvalid={ refCodeError } onChange={ handleRefCodeChange }
/> isInvalid={ refCodeError }
<InputPlaceholder text="Code"/> />
</FormControl> <InputPlaceholder text="Code"/>
</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