-
Notifications
You must be signed in to change notification settings - Fork 24
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
02a4dbd
commit fc912c8
Showing
15 changed files
with
428 additions
and
76 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
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,76 @@ | ||
import React, { useContext } from "react" | ||
import { useRouter } from "next/router" | ||
import type { UseFormMethods } from "react-hook-form" | ||
import { Field, Form, NavigationContext, t } from "@bloom-housing/ui-components" | ||
import { Button } from "@bloom-housing/ui-seeds" | ||
import { getListingRedirectUrl } from "../../utilities/getListingRedirectUrl" | ||
import styles from "./FormSignIn.module.scss" | ||
|
||
export type FormSignInDefaultProps = { | ||
control: FormSignInDefaultControl | ||
onSubmit: (data: FormSignInDefaultValues) => void | ||
} | ||
|
||
export type FormSignInDefaultValues = { | ||
email: string | ||
password: string | ||
} | ||
|
||
export type FormSignInDefaultControl = { | ||
errors: UseFormMethods["errors"] | ||
handleSubmit: UseFormMethods["handleSubmit"] | ||
register: UseFormMethods["register"] | ||
} | ||
|
||
const FormSignInDefault = ({ | ||
onSubmit, | ||
control: { errors, register, handleSubmit }, | ||
}: FormSignInDefaultProps) => { | ||
const onError = () => { | ||
window.scrollTo(0, 0) | ||
} | ||
const { LinkComponent } = useContext(NavigationContext) | ||
const router = useRouter() | ||
const listingIdRedirect = router.query?.listingId as string | ||
const forgetPasswordURL = getListingRedirectUrl(listingIdRedirect, "/forgot-password") | ||
|
||
return ( | ||
<Form id="sign-in" onSubmit={handleSubmit(onSubmit, onError)}> | ||
<Field | ||
className={styles["sign-in-email-input"]} | ||
name="email" | ||
label={t("t.email")} | ||
labelClassName="text__caps-spaced" | ||
validation={{ required: true }} | ||
error={errors.email} | ||
errorMessage={t("authentication.signIn.enterLoginEmail")} | ||
register={register} | ||
dataTestId="sign-in-email-field" | ||
/> | ||
<aside> | ||
<LinkComponent href={forgetPasswordURL} className={styles["forgot-password"]}> | ||
{t("authentication.signIn.forgotPassword")} | ||
</LinkComponent> | ||
</aside> | ||
<Field | ||
className={styles["sign-in-password-input"]} | ||
name="password" | ||
label={t("authentication.createAccount.password")} | ||
labelClassName="text__caps-spaced" | ||
validation={{ required: true }} | ||
error={errors.password} | ||
errorMessage={t("authentication.signIn.enterLoginPassword")} | ||
register={register} | ||
type={"password"} | ||
dataTestId="sign-in-password-field" | ||
/> | ||
<div className={styles["sign-in-action"]}> | ||
<Button type="submit" variant="primary" id="sign-in-button"> | ||
{t("nav.signIn")} | ||
</Button> | ||
</div> | ||
</Form> | ||
) | ||
} | ||
|
||
export { FormSignInDefault as default, FormSignInDefault } |
Oops, something went wrong.