-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: A new view was created to create a username and many more changes
- Loading branch information
Showing
14 changed files
with
235 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import React, { useState } from 'react'; | ||
import { useLocation, useNavigate } from 'react-router-dom'; | ||
import { | ||
Box, | ||
Flex, | ||
FormControl, | ||
Input, | ||
InputGroup, | ||
InputLeftAddon, | ||
Button, | ||
useColorModeValue, | ||
} from '@chakra-ui/react'; | ||
|
||
import { useUserRegister } from '@hooks/querys'; | ||
|
||
export function FormCreateUser() { | ||
const [username, setUsername] = useState<string>(''); | ||
const bgColorButton = useColorModeValue('green.500', 'green.700'); | ||
const navigate = useNavigate(); | ||
const location = useLocation(); | ||
const { token } = location.state; | ||
const { mutateAsync, data, isPending, isSuccess } = useUserRegister(username); | ||
|
||
function handleChange(e: React.ChangeEvent<HTMLInputElement>) { | ||
const { value } = e.target; | ||
|
||
setUsername(value); | ||
} | ||
|
||
function handleSubmit(e) { | ||
e.preventDefault(); | ||
mutateAsync(token); | ||
} | ||
|
||
if (isSuccess) { | ||
navigate(`/${data.username}`); | ||
} | ||
|
||
return ( | ||
<> | ||
<Flex | ||
as='form' | ||
onSubmit={handleSubmit} | ||
justify='center' | ||
p='5' | ||
mt='24' | ||
h='400px' | ||
> | ||
<Flex gap='5' direction='column'> | ||
<Box | ||
as='h1' | ||
textAlign='center' | ||
fontSize={{ base: 'lg', md: '2xl' }} | ||
mb='5' | ||
> | ||
Elegir nombre de usuario | ||
</Box> | ||
<FormControl isRequired> | ||
<InputGroup size={{ base: 'md', md: 'lg' }}> | ||
<InputLeftAddon>xbu.com/</InputLeftAddon> | ||
<Input | ||
type='text' | ||
name='username' | ||
value={username} | ||
onChange={handleChange} | ||
/> | ||
</InputGroup> | ||
</FormControl> | ||
<Button | ||
type='submit' | ||
size='lg' | ||
border='1px' | ||
bg={bgColorButton} | ||
color='black' | ||
_hover={{ bg: 'green.600' }} | ||
_active={{ bg: 'green.600' }} | ||
fontWeight='normal' | ||
loadingText='Creando cuenta...' | ||
isLoading={isPending} | ||
> | ||
Siguiente | ||
</Button> | ||
</Flex> | ||
</Flex> | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import React from 'react'; | ||
|
||
import { FormCreateUser } from '@components/forms/FormCreateUser'; | ||
import { MainHead } from '@components/Head'; | ||
|
||
export function CreateUser() { | ||
return ( | ||
<> | ||
<MainHead title='Elegir nombre de usuario | XBuniverse' /> | ||
<FormCreateUser /> | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.