@bloom-housing/ui-components 4.2.2-alpha.8 → 4.2.2-alpha.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,14 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [4.2.2-alpha.9](https://github.com/bloom-housing/bloom/compare/@bloom-housing/ui-components@4.2.2-alpha.8...@bloom-housing/ui-components@4.2.2-alpha.9) (2022-04-20)
7
+
8
+ **Note:** Version bump only for package @bloom-housing/ui-components
9
+
10
+
11
+
12
+
13
+
6
14
  ## [4.2.2-alpha.8](https://github.com/bloom-housing/bloom/compare/@bloom-housing/ui-components@4.2.2-alpha.7...@bloom-housing/ui-components@4.2.2-alpha.8) (2022-04-20)
7
15
 
8
16
 
package/index.ts CHANGED
@@ -120,6 +120,7 @@ export * from "./src/page_components/listing/listing_sidebar/WhatToExpect"
120
120
  export * from "./src/page_components/listing/listing_sidebar/events/DownloadLotteryResults"
121
121
  export * from "./src/page_components/listing/listing_sidebar/events/EventSection"
122
122
  export * from "./src/page_components/sign-in/FormTerms"
123
+ export * from "./src/page_components/sign-in/ResendConfirmationModal"
123
124
  export * from "./src/page_components/sign-in/FormSignIn"
124
125
  export * from "./src/page_components/sign-in/FormSignInMFAType"
125
126
  export * from "./src/page_components/sign-in/FormSignInMFACode"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bloom-housing/ui-components",
3
- "version": "4.2.2-alpha.8",
3
+ "version": "4.2.2-alpha.9",
4
4
  "author": "Sean Albert <sean.albert@exygy.com>",
5
5
  "description": "Shared user interface components for Bloom affordable housing system",
6
6
  "homepage": "https://github.com/bloom-housing/bloom/tree/master/shared/ui-components",
@@ -100,5 +100,5 @@
100
100
  "tailwindcss": "2.2.10",
101
101
  "typesafe-actions": "^5.1.0"
102
102
  },
103
- "gitHead": "429d0871f219e82003b424e22767ca336236046b"
103
+ "gitHead": "587e34d8810b8271e88bb855e694a443c13d9092"
104
104
  }
@@ -43,6 +43,7 @@ export type FormSignInControl = {
43
43
  errors: UseFormMethods["errors"]
44
44
  handleSubmit: UseFormMethods["handleSubmit"]
45
45
  register: UseFormMethods["register"]
46
+ watch: UseFormMethods["watch"]
46
47
  }
47
48
 
48
49
  export type FormSignInValues = {
@@ -0,0 +1,108 @@
1
+ import {
2
+ AppearanceStyleType,
3
+ Button,
4
+ Modal,
5
+ t,
6
+ Form,
7
+ Field,
8
+ emailRegex,
9
+ NavigationContext,
10
+ } from "@bloom-housing/ui-components"
11
+ import React, { useEffect, useMemo, useContext } from "react"
12
+ import { useForm } from "react-hook-form"
13
+
14
+ export type ResendConfirmationModalProps = {
15
+ isOpen: boolean
16
+ initialEmailValue: string
17
+ onClose: () => void
18
+ onSubmit: (email: string) => void
19
+ loading: boolean
20
+ }
21
+
22
+ export type ResendConfirmationModalForm = {
23
+ onSubmit: (email: string) => void
24
+ }
25
+
26
+ const ResendConfirmationModal = ({
27
+ isOpen,
28
+ initialEmailValue,
29
+ loading,
30
+ onClose,
31
+ onSubmit,
32
+ }: ResendConfirmationModalProps) => {
33
+ const { router } = useContext(NavigationContext)
34
+ // eslint-disable-next-line @typescript-eslint/unbound-method
35
+ const { register, errors, reset, getValues, trigger } = useForm({
36
+ defaultValues: useMemo(() => {
37
+ return {
38
+ emailResend: initialEmailValue,
39
+ }
40
+ }, [initialEmailValue]),
41
+ })
42
+
43
+ useEffect(() => {
44
+ reset({
45
+ emailResend: initialEmailValue,
46
+ })
47
+ }, [initialEmailValue, reset])
48
+
49
+ const onFormSubmit = async () => {
50
+ const isValid = await trigger()
51
+ if (!isValid) return
52
+
53
+ const { emailResend } = getValues()
54
+ onSubmit(emailResend)
55
+ }
56
+
57
+ return (
58
+ <Modal
59
+ open={isOpen}
60
+ title={t("authentication.signIn.yourAccountIsNotConfirmed")}
61
+ ariaDescription={t("authentication.createAccount.linkExpired")}
62
+ onClose={() => {
63
+ onClose()
64
+ window.scrollTo(0, 0)
65
+ }}
66
+ actions={[
67
+ <Button
68
+ type="button"
69
+ styleType={AppearanceStyleType.primary}
70
+ onClick={() => onFormSubmit()}
71
+ loading={loading}
72
+ >
73
+ {t("authentication.createAccount.resendTheEmail")}
74
+ </Button>,
75
+ <Button
76
+ type="button"
77
+ styleType={AppearanceStyleType.alert}
78
+ onClick={() => {
79
+ onClose()
80
+ window.scrollTo(0, 0)
81
+ }}
82
+ >
83
+ {t("t.cancel")}
84
+ </Button>,
85
+ ]}
86
+ >
87
+ <>
88
+ <Form>
89
+ <Field
90
+ caps={true}
91
+ type="email"
92
+ name="emailResend"
93
+ label={t("authentication.createAccount.resendAnEmailTo")}
94
+ placeholder="example@web.com"
95
+ validation={{ required: true, pattern: emailRegex }}
96
+ error={!!errors.emailResend}
97
+ errorMessage={t("authentication.signIn.loginError")}
98
+ register={register}
99
+ />
100
+ </Form>
101
+
102
+ <p className="pt-4">{t("authentication.createAccount.resendEmailInfo")}</p>
103
+ </>
104
+ </Modal>
105
+ )
106
+ }
107
+
108
+ export { ResendConfirmationModal as default, ResendConfirmationModal }