-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'next' into task/OV-27-add-studio-page
- Loading branch information
Showing
23 changed files
with
311 additions
and
35 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
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,3 @@ | ||
export { FormError } from './form-error/form-error.js'; | ||
export { FormHeader } from './form-header/form-header.js'; | ||
export { PasswordInput } from './password-input/password-input.js'; |
19 changes: 19 additions & 0 deletions
19
frontend/src/bundles/auth/components/common/form-error/form-error.tsx
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,19 @@ | ||
import { | ||
FormControl, | ||
FormErrorMessage, | ||
} from '~/bundles/common/components/components.js'; | ||
|
||
type Properties = { | ||
isVisible: boolean; | ||
message: string; | ||
}; | ||
|
||
const FormError: React.FC<Properties> = ({ isVisible, message }) => { | ||
return ( | ||
<FormControl isInvalid={isVisible}> | ||
<FormErrorMessage>{message}</FormErrorMessage> | ||
</FormControl> | ||
); | ||
}; | ||
|
||
export { FormError }; |
23 changes: 23 additions & 0 deletions
23
frontend/src/bundles/auth/components/common/form-header/form-header.tsx
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,23 @@ | ||
import { Heading, Text } from '~/bundles/common/components/components.js'; | ||
|
||
type Properties = { | ||
headerText: string; | ||
subheader: React.ReactNode; | ||
}; | ||
|
||
const FormHeader: React.FC<Properties> = ({ headerText, subheader }) => { | ||
return ( | ||
<> | ||
{/* TODO: Add logo */} | ||
<h2 style={{ marginBottom: '50px' }}>LOGO</h2> | ||
<Heading as="h1" color="white" mb="6px" fontSize="30px"> | ||
{headerText} | ||
</Heading> | ||
<Text mb="24px" fontSize="14px"> | ||
{subheader} | ||
</Text> | ||
</> | ||
); | ||
}; | ||
|
||
export { FormHeader }; |
49 changes: 49 additions & 0 deletions
49
frontend/src/bundles/auth/components/common/password-input/password-input.tsx
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,49 @@ | ||
import { | ||
IconButton, | ||
Input, | ||
InputGroup, | ||
InputRightElement, | ||
ViewIcon, | ||
ViewOffIcon, | ||
} from '~/bundles/common/components/components.js'; | ||
import { useCallback, useState } from '~/bundles/common/hooks/hooks.js'; | ||
|
||
type Properties = { | ||
label: string; | ||
name: string; | ||
hasError: boolean; | ||
}; | ||
|
||
const PasswordInput: React.FC<Properties> = ({ label, name, hasError }) => { | ||
const [isPasswordVisible, setIsPasswordVisible] = useState<boolean>(false); | ||
|
||
const handlePasswordIconClick = useCallback((): void => { | ||
setIsPasswordVisible( | ||
(previousIsPasswordVisible) => !previousIsPasswordVisible, | ||
); | ||
}, []); | ||
|
||
return ( | ||
<InputGroup size="md"> | ||
<Input | ||
type={isPasswordVisible ? 'text' : 'password'} | ||
label={label} | ||
placeholder="••••••••" | ||
name={name} | ||
icon="right" | ||
/> | ||
<InputRightElement top="unset" bottom={hasError ? '25px' : 0}> | ||
<IconButton | ||
aria-label={ | ||
isPasswordVisible ? 'Hide password' : 'Show password' | ||
} | ||
icon={isPasswordVisible ? <ViewIcon /> : <ViewOffIcon />} | ||
onClick={handlePasswordIconClick} | ||
variant="ghostIcon" | ||
/> | ||
</InputRightElement> | ||
</InputGroup> | ||
); | ||
}; | ||
|
||
export { PasswordInput }; |
8 changes: 8 additions & 0 deletions
8
frontend/src/bundles/auth/components/sign-in-form/constants/constants.ts
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,8 @@ | ||
import { type UserSignInRequestDto } from '~/bundles/users/users.js'; | ||
|
||
const DEFAULT_SIGN_IN_PAYLOAD: UserSignInRequestDto = { | ||
email: '', | ||
password: '', | ||
}; | ||
|
||
export { DEFAULT_SIGN_IN_PAYLOAD }; |
100 changes: 90 additions & 10 deletions
100
frontend/src/bundles/auth/components/sign-in-form/sign-in-form.tsx
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 |
---|---|---|
@@ -1,17 +1,97 @@ | ||
import { Button, Heading } from '~/bundles/common/components/components.js'; | ||
import { | ||
FormError, | ||
FormHeader, | ||
PasswordInput, | ||
} from '~/bundles/auth/components/common/components.js'; | ||
import { | ||
Box, | ||
Button, | ||
FormProvider, | ||
Input, | ||
Link, | ||
VStack, | ||
} from '~/bundles/common/components/components.js'; | ||
import { | ||
AppRoute, | ||
DataStatus, | ||
UserValidationMessage, | ||
} from '~/bundles/common/enums/enums.js'; | ||
import { | ||
useAppForm, | ||
useAppSelector, | ||
useMemo, | ||
} from '~/bundles/common/hooks/hooks.js'; | ||
import { | ||
type UserSignInRequestDto, | ||
userSignInValidationSchema, | ||
} from '~/bundles/users/users.js'; | ||
|
||
import { DEFAULT_SIGN_IN_PAYLOAD } from './constants/constants.js'; | ||
|
||
type Properties = { | ||
onSubmit: () => void; | ||
onSubmit: (payload: UserSignInRequestDto) => void; | ||
}; | ||
|
||
const SignInForm: React.FC<Properties> = () => ( | ||
<> | ||
<Heading as="h1">Sign In</Heading> | ||
const SignInForm: React.FC<Properties> = ({ onSubmit }) => { | ||
const { dataStatus } = useAppSelector(({ auth }) => ({ | ||
dataStatus: auth.dataStatus, | ||
})); | ||
const form = useAppForm<UserSignInRequestDto>({ | ||
initialValues: DEFAULT_SIGN_IN_PAYLOAD, | ||
validationSchema: userSignInValidationSchema, | ||
onSubmit, | ||
}); | ||
|
||
const { handleSubmit, errors, values } = form; | ||
|
||
<form> | ||
<Button label="Sign in" /> | ||
</form> | ||
</> | ||
); | ||
const isEmpty = useMemo( | ||
() => Object.values(values).some((value) => value.trim().length === 0), | ||
[values], | ||
); | ||
|
||
return ( | ||
<FormProvider value={form}> | ||
<Box w="55%" color="white"> | ||
<FormHeader | ||
headerText="Sign In" | ||
subheader={ | ||
<> | ||
Don’t have an account?{' '} | ||
<Link to={AppRoute.SIGN_UP} variant="secondary"> | ||
Go to registration | ||
</Link> | ||
</> | ||
} | ||
/> | ||
<form onSubmit={handleSubmit}> | ||
<VStack spacing="20px" align="flex-start"> | ||
<Input | ||
type="text" | ||
label="Email" | ||
placeholder="[email protected]" | ||
name="email" | ||
/> | ||
<PasswordInput | ||
label="Password" | ||
name="password" | ||
hasError={Boolean(errors.password)} | ||
/> | ||
<FormError | ||
isVisible={dataStatus === DataStatus.REJECTED} | ||
message={UserValidationMessage.INVALID_DATA} | ||
/> | ||
<Button | ||
type="submit" | ||
label="Sign in" | ||
size="lg" | ||
sx={{ mt: '16px' }} | ||
isDisabled={isEmpty} | ||
/> | ||
</VStack> | ||
</form> | ||
</Box> | ||
</FormProvider> | ||
); | ||
}; | ||
|
||
export { SignInForm }; |
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
Oops, something went wrong.