Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Firebase authentication for Merchant Sign Up #54

Merged
merged 73 commits into from
Jun 29, 2020
Merged
Show file tree
Hide file tree
Changes from 70 commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
8778eda
Create Sign Up page for merchants
karenfrilya97 Jun 18, 2020
0c3ab97
Fix lint errors
karenfrilya97 Jun 18, 2020
695dd2d
Make Sign Up page resolutions smaller to fit laptops
karenfrilya97 Jun 18, 2020
78d36cd
Add JSDoc comments for exported components
karenfrilya97 Jun 19, 2020
520bb0a
rename OnboardingCard to SignUpCard to standardise
karenfrilya97 Jun 19, 2020
2f9d890
Remove params in JSDoc comment of components
karenfrilya97 Jun 19, 2020
2ef64c7
Rename MerchantLandingPage to LandingPage and MerchantSignUpPage to S…
karenfrilya97 Jun 19, 2020
ec119ba
Correct the Sign in link in Sign Up page
karenfrilya97 Jun 19, 2020
3ba1f0c
Update web/src/components/merchant/sign-up/SignUpCard.tsx
karenfrilya97 Jun 19, 2020
c8e706b
Add missing import {Link} statement in SignUpCard
karenfrilya97 Jun 19, 2020
2cdbd6b
Import gpay-logo.svg directly as React Component
karenfrilya97 Jun 19, 2020
9407acb
Strip input tag style in index.css file instead of FormRox.tsx
karenfrilya97 Jun 19, 2020
17515ed
Fix lint error
karenfrilya97 Jun 19, 2020
8470e94
Change Sign Up button from input element to MUI Button element
karenfrilya97 Jun 19, 2020
470f7c2
Merge branch 'master' of github.com:googleinterns/gpay-group-buy into…
karenfrilya97 Jun 19, 2020
7b0eb42
Vertically centralise SignUpCard in SignUpPage
karenfrilya97 Jun 19, 2020
dee7e44
Add input name in FormRow
karenfrilya97 Jun 19, 2020
1d7e6b1
Merge branch 'master' of github.com:googleinterns/gpay-group-buy into…
karenfrilya97 Jun 19, 2020
61aa094
Add handlers for merchants' sign up form
karenfrilya97 Jun 19, 2020
ecec1e2
Remove logging statements for debugging
karenfrilya97 Jun 19, 2020
35e0082
Add a new user account to Firebase for signed up merchant
karenfrilya97 Jun 19, 2020
d7afbff
fix lint errors
karenfrilya97 Jun 22, 2020
25f36e6
Use react hooks
karenfrilya97 Jun 22, 2020
ac264e8
Make Group Buy Merchant header smaller
karenfrilya97 Jun 22, 2020
3d4fb50
Show individual error for each form field
karenfrilya97 Jun 22, 2020
0252c86
Refactor constants into a separate file
karenfrilya97 Jun 22, 2020
309f11c
Fix lint error
karenfrilya97 Jun 22, 2020
5bb5928
Check form fields in handleSubmit
karenfrilya97 Jun 22, 2020
52f2bc1
Remove unused interface
karenfrilya97 Jun 22, 2020
7e9ed26
Enlarge error message font size
karenfrilya97 Jun 22, 2020
b0856f4
Align Sign Up Form labels with inputs
karenfrilya97 Jun 22, 2020
3681d50
Remove unused const
karenfrilya97 Jun 22, 2020
5ea51a1
Merge branch 'master' of github.com:googleinterns/gpay-group-buy into…
karenfrilya97 Jun 22, 2020
0d3203b
Remove unused const
karenfrilya97 Jun 22, 2020
1ea4842
Refactor function to format phrase into camelCase
karenfrilya97 Jun 22, 2020
b39a28b
Update JSDoc comment for FormRow
karenfrilya97 Jun 22, 2020
42f7018
Add comments to explain Sign Up form checks
karenfrilya97 Jun 22, 2020
cfe97f9
Merge branch 'karen/sign-up-handling' of github.com:googleinterns/gpa…
karenfrilya97 Jun 22, 2020
ed7983c
Use hooks in firebase code
karenfrilya97 Jun 22, 2020
1626701
Append REACT_APP_ in front of env var names
karenfrilya97 Jun 22, 2020
9d96fef
Readd logic that was removed due to merging
karenfrilya97 Jun 22, 2020
2e3b9c9
Readd components that were deleted due to merging
karenfrilya97 Jun 22, 2020
af6e927
Remove unused autobind-decorator
karenfrilya97 Jun 22, 2020
2f1b38d
Refactor firebase auth initialisation into src/firebase-auth.ts
karenfrilya97 Jun 22, 2020
90c2e23
Refactor firebase error messages into sign-up-errors.ts
karenfrilya97 Jun 22, 2020
8bf6aaa
Fix lint errors
karenfrilya97 Jun 22, 2020
d450e4b
Add comment about Firebase auth
karenfrilya97 Jun 22, 2020
e1599a3
Refactor Firebase config JS object out
karenfrilya97 Jun 22, 2020
134bfbf
Merge branch 'master' of github.com:googleinterns/gpay-group-buy into…
karenfrilya97 Jun 22, 2020
fd91670
Show Firebase error below relevant field
karenfrilya97 Jun 22, 2020
d1bc70f
Add environment variables to web/app.yaml
karenfrilya97 Jun 23, 2020
5a15126
Add comment to web/app.yaml
karenfrilya97 Jun 23, 2020
bbc5722
Refactor handleFirebaseSignUp into a separate function
karenfrilya97 Jun 23, 2020
5d2e852
Use async/await instead of promises
karenfrilya97 Jun 23, 2020
3cefe11
Fix typos in constants/sign-up-errors.ts
karenfrilya97 Jun 23, 2020
9bbe413
Add comment to toCamelCase function
karenfrilya97 Jun 23, 2020
ce31064
Move handleFirebaseSignUp comment to JSDoc comment
karenfrilya97 Jun 23, 2020
ef8de81
Remove typo in web/app.yaml
karenfrilya97 Jun 23, 2020
26892a7
Merge branch 'karen/sign-up-handling' of github.com:googleinterns/gpa…
karenfrilya97 Jun 23, 2020
b004e3f
Use hook to separate logic from UI in SignUpCard
karenfrilya97 Jun 25, 2020
2a6b7ba
Use react-hook-form library for Merchant SignUpForm
karenfrilya97 Jun 25, 2020
aaee377
Use to-camel-case library instead of custom function
karenfrilya97 Jun 25, 2020
147d81d
Disable Sign Up button until form is valid
karenfrilya97 Jun 25, 2020
28c137a
Create useSignUpForm hook to separate logic from UI
karenfrilya97 Jun 26, 2020
8ccdf55
Merge branch 'karen/sign-up-handling' of github.com:googleinterns/gpa…
karenfrilya97 Jun 26, 2020
7e402da
Update web/src/firebase-auth.ts
karenfrilya97 Jun 26, 2020
ec69418
Use switch-case instead of if-else when handling firebase error
karenfrilya97 Jun 26, 2020
47491fa
Merge branch 'karen/firebase-sign-up' of github.com:googleinterns/gpa…
karenfrilya97 Jun 26, 2020
4ddd868
Fix lint errors
karenfrilya97 Jun 26, 2020
2e9f2c0
Fix bug in firebase-auth
karenfrilya97 Jun 26, 2020
0661472
Merge branch 'master' of github.com:googleinterns/gpay-group-buy into…
karenfrilya97 Jun 29, 2020
893bde0
Remove unused import not removed during merge
karenfrilya97 Jun 29, 2020
0f98cfa
Rephrase sign up error message
karenfrilya97 Jun 29, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions web/app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,8 @@ handlers:
- url: /.*
static_files: build/index.html
upload: build/index.html

env_variables:
# Replace with API key and authentication domain before deployment
karenfrilya97 marked this conversation as resolved.
Show resolved Hide resolved
REACT_APP_API_KEY: '<API_KEY>'
REACT_APP_AUTH_DOMAIN: '<AUTH_DOMAIN>'
4 changes: 4 additions & 0 deletions web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,18 @@
"@types/react-dom": "^16.9.0",
"@types/react-router-dom": "^5.1.5",
"@types/styled-components": "^5.1.0",
"@types/to-camel-case": "^1.0.0",
"firebase": "^7.15.2",
"muicss": "^0.10.2",
"rc-progress": "^3.0.0",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-feather": "^2.0.8",
"react-hook-form": "^5.7.2",
"react-router-dom": "^5.2.0",
"react-scripts": "3.4.1",
"styled-components": "^5.1.1",
"to-camel-case": "^1.0.0",
"typescript": "~3.7.2"
},
"scripts": {
Expand Down
69 changes: 62 additions & 7 deletions web/src/components/common/FormRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,45 @@
* limitations under the License.
*/

import {Component, ReactElement} from 'react';
import React from 'react';

import Col from 'muicss/lib/react/col';
import Row from 'muicss/lib/react/row';
import styled from 'styled-components';
import toCamelCase from 'to-camel-case';

const StyledRow = styled(Row)`
display: flex;
flex-direction: row;
align-items: center;
align-items: top;
justify-content: center;

margin: 20px 0;
margin: 5px 0;
`;

const StyledCol = styled(Col)`
display: flex;
flex-direction: column;
align-items: left;
`;

const Label = styled.label`
width: 100px;
font-size: 14px;
height: 30px;
margin-right: 20px;

font-size: 14px;
vertical-align: middle;

display: flex;
flex-direction: column;
justify-content: center;
`;

const Input = styled.input`
height: 30px;
width: 350px;
font-size: 14px;
padding: 0 15px;

Expand All @@ -44,19 +61,57 @@ const Input = styled.input`
box-shadow: 4px 2px 4px rgba(0, 0, 0, 0.25);
`;

const ErrorContainer = styled.div`
height: 12px;
margin-left: 15px;
margin-top: 5px;

font-size: 12px;
line-height: 10px;
color: var(--bright-red);
`;

type ReactHookFormErrorMessage =
| string
| React.ReactElement<
any,
| string
| ((
props: any
) => React.ReactElement<
any,
string | any | (new (props: any) => React.Component<any, any, any>)
> | null)
| (new (props: any) => React.Component<any, any, any>)
>
| undefined;

interface FormRowProps {
label: string;
inputType: string;
forwardedRef: (ref: HTMLInputElement) => void;
error: ReactHookFormErrorMessage;
}

/**
* This is a row in a form, consisting of a label and an input field shown
* side by side.
* side by side. This also contains a container for error message which is
* displayed below the input field where applicable.
*/
const FormRow: React.FC<FormRowProps> = ({label, inputType}) => (
const FormRow: React.FC<FormRowProps> = ({
label,
inputType,
forwardedRef,
error,
}) => (
<StyledRow>
<Label>{label}</Label>
<Input type={inputType}></Input>
<StyledCol>
<Label>{label}</Label>
</StyledCol>
<StyledCol>
<Input type={inputType} name={toCamelCase(label)} ref={forwardedRef} />
<ErrorContainer>{error}</ErrorContainer>
</StyledCol>
</StyledRow>
);

Expand Down
6 changes: 3 additions & 3 deletions web/src/components/common/GroupBuyMerchantHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ const HeaderContainer = styled.div`
`;

const Logo = styled(GPayLogo)`
width: 80px;
width: 70px;
`;

const Header = styled.h1`
font-size: 32px;
font-size: 28px;
font-weight: normal;
line-height: 48px;
line-height: 42px;
margin: 0;
text-align: center;
`;
Expand Down
52 changes: 13 additions & 39 deletions web/src/components/merchant/sign-up/SignUpCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@

import React from 'react';

import FormRow from 'components/common/FormRow';
import GroupBuyMerchantHeader from 'components/common/GroupBuyMerchantHeader';
import Button from 'muicss/lib/react/button';
import Form from 'muicss/lib/react/form';
import SignUpForm from 'components/merchant/sign-up/SignUpForm';
import Row from 'muicss/lib/react/row';
import {Link} from 'react-router-dom';
import styled from 'styled-components';
Expand All @@ -37,50 +35,26 @@ const CardContainer: React.FC = styled.div`
`;

const StyledRow = styled(Row)`
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;

margin: 15px 0;
`;

const StyledButton = styled(Button)`
height: 40px;
width: 200px;
border-radius: 20px;
border: none;

background: var(--dark-gray);
color: white;
font-size: 18px;
font-weight: bolder;
text-transform: uppercase;

margin-top: 30px;
display: block;
line-height: 40px;
`;

/**
* This is the card containing the sign up form for the Merchant app.
* It is displayed in the Sign Up page.
*/
const SignUpCard: React.FC = () => (
<CardContainer>
<GroupBuyMerchantHeader />
<Form>
<FormRow label="Name" inputType="text" />
<FormRow label="Email" inputType="email" />
<FormRow label="Password" inputType="password" />
<FormRow label="Confirm Password" inputType="password" />
<FormRow label="VPA" inputType="email" />
const SignUpCard: React.FC = () => {
return (
<CardContainer>
<GroupBuyMerchantHeader />
<SignUpForm />
<StyledRow>
<StyledButton>Sign Up</StyledButton>
Already have an account? <Link to="/merchant/sign-in">Sign in</Link>{' '}
now!
</StyledRow>
</Form>
<div>
Already have an account? <Link to="/merchant/sign-in">Sign in</Link> now!
</div>
</CardContainer>
);
</CardContainer>
);
};

export default SignUpCard;
86 changes: 86 additions & 0 deletions web/src/components/merchant/sign-up/SignUpForm.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/**
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import React from 'react';

import FormRow from 'components/common/FormRow';
import useSignUpForm from 'components/merchant/sign-up/hooks/useSignUpForm';
import Button from 'muicss/lib/react/button';
import Form from 'muicss/lib/react/form';
import styled from 'styled-components';

const StyledForm = styled(Form)`
display: flex;
flex-direction: column;
align-items: center;
`;

const StyledButton = styled(Button)`
height: 40px;
width: 200px;
border-radius: 20px;
border: none;

background: var(--dark-gray);
color: white;
font-size: 18px;
font-weight: bolder;
text-transform: uppercase;
margin-top: 20px;
`;

const SignUpForm = () => {
const {disabled, errors, onSubmit, validations} = useSignUpForm();
return (
<StyledForm>
<FormRow
label="Name"
inputType="text"
forwardedRef={validations.name}
error={errors?.name?.message}
/>
<FormRow
label="Email"
inputType="email"
forwardedRef={validations.email}
error={errors?.email?.message}
/>
<FormRow
label="Password"
inputType="password"
forwardedRef={validations.password}
error={errors?.password?.message}
/>
<FormRow
label="Confirm Password"
inputType="password"
forwardedRef={validations.confirmPassword}
error={errors?.confirmPassword?.message}
/>
<FormRow
label="VPA"
inputType="text"
forwardedRef={validations.vpa}
error={errors?.vpa?.message}
/>
<StyledButton onClick={onSubmit} disabled={disabled}>
Sign Up
</StyledButton>
</StyledForm>
);
};

export default SignUpForm;
Loading