Skip to content

Commit

Permalink
fix: change AWS_REGION secret name, fix ResendConfirmationCodeButton …
Browse files Browse the repository at this point in the history
…styles, fix typos
  • Loading branch information
Jozwiaczek committed Nov 12, 2020
1 parent 00240f3 commit de2426c
Show file tree
Hide file tree
Showing 12 changed files with 29 additions and 31 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
NODE_ENV=development

# AWS Amplify
AWS_DEFAULT_REGION=
COGNITO_AWS_REGION=
COGNITO_USER_POOL_ID=
COGNITO_USER_POOL_CLIENT_ID=
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module.exports = {
'no-alert': 0,
'no-console': 0,
'no-unused-vars': [
2,
1,
{
vars: 'all',
args: 'after-used',
Expand Down
2 changes: 1 addition & 1 deletion .storybook/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { IntentbaseProvider } from '../src/providers/IntentbaseProvider';
export const decorators = [
(Story) => (
<IntentbaseProvider
region={process.env.AWS_DEFAULT_REGION}
region={process.env.COGNITO_AWS_REGION}
userPoolId={process.env.COGNITO_USER_POOL_ID}
userPoolWebClientId={process.env.COGNITO_USER_POOL_CLIENT_ID}
>
Expand Down
8 changes: 8 additions & 0 deletions src/common/interfaces/MaterialUI.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export type TypographyColor =
| 'initial'
| 'inherit'
| 'primary'
| 'secondary'
| 'textPrimary'
| 'textSecondary'
| 'error';
2 changes: 1 addition & 1 deletion src/components/FormInput/MuiFormTextField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const MuiFormTextField: FC<MuiFormTextFieldProps> = ({
if (inputProps.type === 'password' && passwordPreview) {
return (
<StyledTextField
error={!!(touched && error)}
error={Boolean(touched && error)}
helperText={touched && error}
{...inputProps}
{...rest}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import styled from 'styled-components';
import { FormActionsContainer } from '../../components/Form/Form.styled';

export const FormActionsContainer = styled.div`
export const StyledFormActionsContainer = styled(FormActionsContainer)`
margin-bottom: 20px;
width: 100%;
`;
10 changes: 6 additions & 4 deletions src/containers/ConfirmSignUp/ResendConfirmationCodeButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ import { FormActionsProps } from '../../components/Form/Form';
import { useSnackbar } from '../../hooks/useSnackbar';
import { CognitoError } from '../../common/interfaces/CognitoError';
import { FormButton } from '../../components/FormButton';
import { FormActionsContainer } from '../../components/Form/Form.styled';
import { StyledFormActionsContainer } from './ResendConfirmationCodeButton.styled';

export interface ResendConfirmationCodeBaseProps {
resendCodeLabel?: string;
onSuccessResendMsg?: string;
resendButtonColor?: PropTypes.Color;
fullWidth?: boolean;
}

type ResendConfirmationCodeProps = ResendConfirmationCodeBaseProps & FormActionsProps;
Expand All @@ -19,6 +20,7 @@ export const ResendConfirmationCodeButton: FC<ResendConfirmationCodeProps> = ({
resendCodeLabel = 'Resend confirmation code',
onSuccessResendMsg = 'Confirmation code resend successfully.',
resendButtonColor = 'default',
fullWidth = true,
values,
loading,
}) => {
Expand All @@ -40,15 +42,15 @@ export const ResendConfirmationCodeButton: FC<ResendConfirmationCodeProps> = ({
}, [values.email]);

return (
<FormActionsContainer>
<StyledFormActionsContainer>
<FormButton
color={resendButtonColor}
disabled={loading || internalLoading}
fullWidth
fullWidth={fullWidth}
onClick={resendCode}
>
{resendCodeLabel}
</FormButton>
</FormActionsContainer>
</StyledFormActionsContainer>
);
};
2 changes: 1 addition & 1 deletion src/containers/ResetPassword/ResetPassword.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Form, FormWithDefaultsProps } from '../../components/Form/Form';
export const ResetPassword: FC<FormWithDefaultsProps> = ({
onSubmitResult,
title = 'Reset your password',
subheaderTitle = 'Please check your email for the ont-time code to rest your password.',
subheaderTitle = 'Please check your email for the one-time code to reset your password.',
subheaderTitleVariant = 'body1',
confirmButtonLabel = 'Reset password',
codeLabel = 'Code',
Expand Down
9 changes: 1 addition & 8 deletions src/containers/SignIn/SignIn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,10 @@ export const SignIn: FC<SignInProps> = ({
const [cognitoUserSession, setCognitoUserSession] = useState<CognitoUser>();
const [loggedIn, setLoggedIn] = useState(false);

console.log(
'L:71 | cognitoUser, cognitoUserSession, loggedIn: ',
cognitoUser,
cognitoUserSession,
loggedIn,
);

const signIn = useCallback(
async (values): Promise<string> =>
Auth.signIn({
username: values.email,
username: values.email.trim().toLowerCase(),
password: values.password,
}).then(async (user) => {
setCognitoUser(user);
Expand Down
12 changes: 4 additions & 8 deletions src/containers/SignUp/SignUp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ import { Typography } from '@material-ui/core';
import { Form, FormWithDefaultsProps } from '../../components/Form/Form';
import { FormInput } from '../../components/FormInput/FormInput';
import { FormLink } from '../../components/Form/Form.styled';
import { TypographyColor } from '../../common/interfaces/MaterialUI';

export interface SignUpProps extends FormWithDefaultsProps {
onClickSignIn?: () => void;
subheaderHaveAnAccount?: string;
subheaderSignIn?: string;
subheaderSignInBtnColor?: TypographyColor;
}

export const SignUp: FC<SignUpProps> = ({
Expand All @@ -27,19 +29,13 @@ export const SignUp: FC<SignUpProps> = ({
passwordPreview = true,
children,
className,
subheaderSignInBtnColor = 'primary',
...rest
}) => {
const [cognitoUser, setCognitoUser] = useState<any>();
const [cognitoUserSession, setCognitoUserSession] = useState<any>();
const [loggedIn, setLoggedIn] = useState(false);

console.log(
'L:71 | cognitoUser, cognitoUserSession, loggedIn: ',
cognitoUser,
cognitoUserSession,
loggedIn,
);

const signUp = useCallback(
async (values: any): Promise<string> =>
Auth.signUp({
Expand Down Expand Up @@ -68,7 +64,7 @@ export const SignUp: FC<SignUpProps> = ({
&nbsp;
{onClickSignIn && subheaderSignIn && (
<FormLink
color="primary"
color={subheaderSignInBtnColor}
className="signUp__subheader__section--link"
onClick={onClickSignIn}
>
Expand Down
2 changes: 1 addition & 1 deletion src/providers/IntentbaseProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ interface IntentbaseProps {

export const IntentbaseProvider: FC<IntentbaseProps> = ({
children,
region = 'eu-central-1',
region = 'us-east-1',
userPoolId,
userPoolWebClientId,
theme = defaultTheme,
Expand Down
6 changes: 2 additions & 4 deletions src/utils/validations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,8 @@ export const defaultAuthValidation = (
}
}

if (validate.includes('code')) {
if (!values.code) {
errors.password = requiredMessage;
}
if (validate.includes('code') && !values.code) {
errors.password = requiredMessage;
}

return errors;
Expand Down

0 comments on commit de2426c

Please sign in to comment.