generated from hackforla/.github-hackforla-base-repo-template
-
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dc25ded
commit 991722d
Showing
7 changed files
with
181 additions
and
118 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,72 @@ | ||
import React from "react"; | ||
import { Link } from "react-router-dom"; | ||
import { TextField } from "tw-components"; | ||
import { useForm, SubmitHandler } from "react-hook-form"; | ||
|
||
type Inputs = { | ||
email: string; | ||
password: string; | ||
}; | ||
|
||
/** Login Form Component | ||
* | ||
* @dev noValidate on form to disable browser vaildation so we can use react-hook-form validations instead | ||
* | ||
*/ | ||
|
||
export default function LoginForm() { | ||
const { | ||
register, | ||
handleSubmit, | ||
formState: { errors }, | ||
} = useForm<Inputs>(); | ||
const onSubmit: SubmitHandler<Inputs> = (data) => { | ||
console.log("Sending form data to server...", data); | ||
}; | ||
|
||
return ( | ||
<div> | ||
<h3 className="mb-10 text-4xl font-bold">Log in</h3> | ||
<form onSubmit={handleSubmit(onSubmit)} noValidate> | ||
<TextField | ||
label="Email" | ||
id="email" | ||
type="email" | ||
register={register} | ||
validations={{ required: "Please enter your email address" }} | ||
errors={errors.email} | ||
/> | ||
<TextField | ||
label="Password" | ||
id="password" | ||
type="password" | ||
register={register} | ||
validations={{ | ||
required: "Please enter your password", | ||
pattern: { | ||
value: /^(?=.*\d)(?=.*[!@#$%^&*]).{8,}$/, | ||
message: | ||
"Must be 8 or more characters and contain at least 1 number and 1 special character", | ||
}, | ||
}} | ||
errors={errors.password} | ||
/> | ||
<div className="flex mb-4"> | ||
<input type="checkbox" className="mr-2" /> | ||
<p className="text-grey-dark">Keep me signed in</p> | ||
</div> | ||
<button className="font-bold w-full text-white py-[12px] rounded-3xl bg-blue-dark hover:bg-blue-dark-hover hover:shadow-lg focus:bg-blue-dark-focused"> | ||
Login | ||
</button> | ||
</form> | ||
<div className="text-center mt-4"> | ||
<p> | ||
New to Civic Tech Jobs?{" "} | ||
<Link to="/signup" className="text-blue-dark font-bold underline"> | ||
Sign up | ||
</Link> | ||
</p> | ||
</div> | ||
</div> | ||
); | ||
} |
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,81 @@ | ||
import React from "react"; | ||
import { Link } from "react-router-dom"; | ||
import { TextField } from "tw-components"; | ||
import { useForm, SubmitHandler } from "react-hook-form"; | ||
|
||
type Inputs = { | ||
firstName: string; | ||
lastName: string; | ||
email: string; | ||
password: string; | ||
}; | ||
|
||
export default function SignupForm() { | ||
const { | ||
register, | ||
handleSubmit, | ||
formState: { errors }, | ||
} = useForm<Inputs>(); | ||
const onSubmit: SubmitHandler<Inputs> = (data) => { | ||
console.log("Sending form data to server...", data); | ||
}; | ||
return ( | ||
<div> | ||
<h3 className="mb-10 text-4xl font-bold">Sign up</h3> | ||
<form onSubmit={handleSubmit(onSubmit)}> | ||
<div className="grid grid-cols-1 md:grid-cols-2 md:gap-4"> | ||
<TextField | ||
label="First name" | ||
id="firstName" | ||
type="text" | ||
register={register} | ||
errors={errors.firstName} | ||
validations={{ required: "Please enter first name" }} | ||
/> | ||
<TextField | ||
label="Last Name" | ||
id="lastName" | ||
type="text" | ||
register={register} | ||
errors={errors.lastName} | ||
validations={{ required: "Please enter last name" }} | ||
/> | ||
</div> | ||
<TextField | ||
label="Email" | ||
id="email" | ||
type="email" | ||
register={register} | ||
errors={errors.email} | ||
validations={{ required: "Please enter your email address" }} | ||
/> | ||
<TextField | ||
label="Password" | ||
id="password" | ||
type="password" | ||
register={register} | ||
validations={{ | ||
required: "Please enter your password", | ||
pattern: { | ||
value: /^(?=.*\d)(?=.*[!@#$%^&*]).{8,}$/, | ||
message: | ||
"Must be 8 or more characters and contain at least 1 number and 1 special character", | ||
}, | ||
}} | ||
errors={errors.password} | ||
/> | ||
<button className="font-bold w-full text-white py-[12px] rounded-3xl bg-blue-dark hover:bg-blue-dark-hover hover:shadow-lg focus:bg-blue-dark-focused"> | ||
Sign Up | ||
</button> | ||
</form> | ||
<div className="text-center mt-4"> | ||
<p> | ||
Already on Civic Tech Jobs?{" "} | ||
<Link to="/login" className="text-blue-dark font-bold underline"> | ||
Log In | ||
</Link> | ||
</p> | ||
</div> | ||
</div> | ||
); | ||
} |
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export { default as AuthNav } from "./AuthNav"; | ||
export { default as HeaderNav } from "./HeaderNav"; | ||
export { default as InputGroup } from "./InputGroup"; | ||
export { default as TextField } from "./TextField"; |
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