Color and I18n support
This commit is contained in:
parent
523f537aa4
commit
ba82c13fe1
19 changed files with 630 additions and 303 deletions
|
|
@ -1,12 +1,14 @@
|
|||
import React, { useState } from 'react';
|
||||
import {
|
||||
Button, FormControl, FormLabel, Input, Heading, Text, FormHelperText,
|
||||
Button, Heading, Text, Box,
|
||||
} from '@chakra-ui/react';
|
||||
import { MdAlternateEmail, MdPassword, MdSend } from 'react-icons/md';
|
||||
import { BiRename } from 'react-icons/bi';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import store from '../../redux/store';
|
||||
import IconTextDuo from '../../global/components/IconTextDuo';
|
||||
import { Register as i18n } from '../../global/i18n';
|
||||
import StandardInput from '../../global/components/FormControl/StandardInput';
|
||||
|
||||
export default () => {
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
|
@ -25,105 +27,115 @@ export default () => {
|
|||
});
|
||||
|
||||
const data = await resp.json();
|
||||
const message = {
|
||||
header: resp.ok ? 'Account Created!' : 'Unable to Create Account',
|
||||
content: resp.ok ? 'You will receive an account confirmation email shortly! Sit tight until you have verified your account.' : data.error,
|
||||
};
|
||||
|
||||
const message = resp.ok ? i18n.createAccountSuccess : i18n.createAccountFailure(data);
|
||||
store.dispatch({ type: 'SET_ALERT', data: message });
|
||||
resp.ok && navigate('/login', { replace: true });
|
||||
setLoading(false);
|
||||
};
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Heading textAlign="center" marginBottom="1rem">Account Setup</Heading>
|
||||
<Text textAlign="center" marginBottom="0.5rem">
|
||||
Already have an account? Sign in
|
||||
{' '}
|
||||
<a href="/login">here!</a>
|
||||
<Text
|
||||
color="purple.600"
|
||||
cursor="pointer"
|
||||
transition="all"
|
||||
textAlign="center"
|
||||
marginBottom="0.5rem"
|
||||
onClick={() => navigate('/login', { replace: true })}
|
||||
_hover={{ fontWeight: 600, color: 'var(--chakra-colors-purple-500) !important' }}
|
||||
>
|
||||
{i18n.labels.login}
|
||||
</Text>
|
||||
|
||||
<FormControl
|
||||
onKeyPress={(e) => e.key === 'Enter' && register()}
|
||||
onSubmit={register}
|
||||
backgroundColor="gray.100"
|
||||
<Box
|
||||
borderRadius="2xl"
|
||||
padding="2rem"
|
||||
borderRadius="8px"
|
||||
maxW="50%"
|
||||
backgroundColor="blackAlpha.200"
|
||||
w="100%"
|
||||
maxW="768px"
|
||||
margin="auto"
|
||||
>
|
||||
<FormHelperText marginBottom="0.5rem" marginTop="0 !important">None of this information will be shared</FormHelperText>
|
||||
|
||||
<FormLabel htmlFor="first">
|
||||
<IconTextDuo icon={(<BiRename />)} text="First Name " />
|
||||
</FormLabel>
|
||||
<Input
|
||||
id="first"
|
||||
type="text"
|
||||
<StandardInput
|
||||
required
|
||||
type="text"
|
||||
propSubmitEvt={register}
|
||||
propKeyPressEvt={(e) => e.key === 'Enter' && register()}
|
||||
propChangeEvt={(e) => setState({ ...state, first: e.target.value })}
|
||||
value={state.first}
|
||||
background="gray.50"
|
||||
onChange={(e) => setState({ ...state, first: e.target.value })}
|
||||
labelText={i18n.labels.first}
|
||||
labelIcon={(<BiRename />)}
|
||||
error={!state.first.length ? i18n.labels.required : null}
|
||||
/>
|
||||
|
||||
<FormLabel htmlFor="last">
|
||||
<IconTextDuo icon={(<BiRename />)} text="Last Name" />
|
||||
</FormLabel>
|
||||
<Input
|
||||
id="last"
|
||||
<StandardInput
|
||||
required
|
||||
type="text"
|
||||
required
|
||||
propSubmitEvt={register}
|
||||
propKeyPressEvt={(e) => e.key === 'Enter' && register()}
|
||||
propChangeEvt={(e) => setState({ ...state, last: e.target.value })}
|
||||
value={state.last}
|
||||
background="gray.50"
|
||||
onChange={(e) => setState({ ...state, last: e.target.value })}
|
||||
labelText={i18n.labels.last}
|
||||
labelIcon={(<BiRename />)}
|
||||
error={!state.last.length ? i18n.labels.required : null}
|
||||
/>
|
||||
|
||||
<FormLabel htmlFor="email">
|
||||
<IconTextDuo icon={(<MdAlternateEmail />)} text="Email" />
|
||||
</FormLabel>
|
||||
<Input
|
||||
id="email"
|
||||
<StandardInput
|
||||
required
|
||||
type="email"
|
||||
required
|
||||
propSubmitEvt={register}
|
||||
propKeyPressEvt={(e) => e.key === 'Enter' && register()}
|
||||
propChangeEvt={(e) => setState({ ...state, email: e.target.value })}
|
||||
value={state.email}
|
||||
background="gray.50"
|
||||
onChange={(e) => setState({ ...state, email: e.target.value })}
|
||||
labelText={i18n.labels.email}
|
||||
labelIcon={(<MdAlternateEmail />)}
|
||||
error={!state.email.length ? i18n.labels.required : null}
|
||||
/>
|
||||
|
||||
<FormLabel htmlFor="password">
|
||||
<IconTextDuo icon={(<MdPassword />)} text="Password" />
|
||||
</FormLabel>
|
||||
<Input
|
||||
id="password"
|
||||
type="Password"
|
||||
<StandardInput
|
||||
required
|
||||
value={state.password}
|
||||
background="gray.50"
|
||||
onChange={(e) => setState({ ...state, password: e.target.value })}
|
||||
/>
|
||||
|
||||
<FormLabel htmlFor="conf">
|
||||
<IconTextDuo icon={(<MdPassword />)} text="Verify Password" />
|
||||
</FormLabel>
|
||||
<Input
|
||||
id="conf"
|
||||
type="password"
|
||||
propSubmitEvt={register}
|
||||
propKeyPressEvt={(e) => e.key === 'Enter' && register()}
|
||||
propChangeEvt={(e) => setState({ ...state, password: e.target.value })}
|
||||
value={state.password}
|
||||
labelText={i18n.labels.password}
|
||||
labelIcon={(<MdPassword />)}
|
||||
error={(!state.password.length && i18n.labels.required)
|
||||
|| (state.password !== state.conf && i18n.labels.match)
|
||||
|| null}
|
||||
/>
|
||||
|
||||
<StandardInput
|
||||
required
|
||||
type="password"
|
||||
propSubmitEvt={register}
|
||||
propKeyPressEvt={(e) => e.key === 'Enter' && register()}
|
||||
propChangeEvt={(e) => setState({ ...state, conf: e.target.value })}
|
||||
value={state.conf}
|
||||
background="gray.50"
|
||||
onChange={(e) => setState({ ...state, conf: e.target.value })}
|
||||
labelText={i18n.labels.conf}
|
||||
labelIcon={(<MdPassword />)}
|
||||
error={(!state.conf.length && i18n.labels.required)
|
||||
|| (state.password !== state.conf && i18n.labels.match)
|
||||
|| null}
|
||||
/>
|
||||
|
||||
<Button
|
||||
display="block"
|
||||
mt={4}
|
||||
colorScheme="blue"
|
||||
mx="auto"
|
||||
colorScheme="green"
|
||||
isLoading={loading}
|
||||
type="submit"
|
||||
onClick={register}
|
||||
>
|
||||
<IconTextDuo iconOnRight icon={(<MdSend />)} text="Register" />
|
||||
<IconTextDuo
|
||||
iconOnRight
|
||||
icon={<MdSend />}
|
||||
text={i18n.labels.register}
|
||||
/>
|
||||
</Button>
|
||||
</FormControl>
|
||||
</Box>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue