@bloom-housing/ui-components 4.1.2-alpha.2 → 4.1.2-alpha.3
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 +8 -0
- package/package.json +3 -3
- package/src/helpers/useMutate.ts +11 -1
- package/src/locales/general.json +2 -1
- package/src/page_components/forgot-password/FormForgotPassword.tsx +3 -9
- package/src/page_components/sign-in/FormSignIn.tsx +4 -9
- package/src/page_components/sign-in/FormSignInAddPhone.tsx +3 -3
- package/src/page_components/sign-in/FormSignInErrorBox.tsx +21 -9
- package/src/page_components/sign-in/FormSignInMFACode.tsx +8 -3
- package/src/page_components/sign-in/FormSignInMFAType.tsx +7 -3
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.1.2-alpha.3](https://github.com/bloom-housing/bloom/compare/@bloom-housing/ui-components@4.1.2-alpha.2...@bloom-housing/ui-components@4.1.2-alpha.3) (2022-03-29)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @bloom-housing/ui-components
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
6
14
|
## [4.1.2-alpha.2](https://github.com/bloom-housing/bloom/compare/@bloom-housing/ui-components@4.1.2-alpha.1...@bloom-housing/ui-components@4.1.2-alpha.2) (2022-03-29)
|
|
7
15
|
|
|
8
16
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bloom-housing/ui-components",
|
|
3
|
-
"version": "4.1.2-alpha.
|
|
3
|
+
"version": "4.1.2-alpha.3",
|
|
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",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"webpack": "^4.44.2"
|
|
70
70
|
},
|
|
71
71
|
"dependencies": {
|
|
72
|
-
"@bloom-housing/backend-core": "^4.1.1-alpha.
|
|
72
|
+
"@bloom-housing/backend-core": "^4.1.1-alpha.3",
|
|
73
73
|
"@mapbox/mapbox-sdk": "^0.13.0",
|
|
74
74
|
"@types/body-scroll-lock": "^2.6.1",
|
|
75
75
|
"@types/jwt-decode": "^2.2.1",
|
|
@@ -100,5 +100,5 @@
|
|
|
100
100
|
"tailwindcss": "2.2.10",
|
|
101
101
|
"typesafe-actions": "^5.1.0"
|
|
102
102
|
},
|
|
103
|
-
"gitHead": "
|
|
103
|
+
"gitHead": "1544f7dedf6b0cb06b9ea78f34282e8537c07f8c"
|
|
104
104
|
}
|
package/src/helpers/useMutate.ts
CHANGED
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
import { useState } from "react"
|
|
2
2
|
|
|
3
|
+
export type UseMutateOptions = {
|
|
4
|
+
onSuccess?: () => void
|
|
5
|
+
onError?: (err: any) => void
|
|
6
|
+
}
|
|
7
|
+
|
|
3
8
|
const useMutate = <UseMutateResponse>() => {
|
|
4
9
|
const [data, setData] = useState<UseMutateResponse | undefined>(undefined)
|
|
5
10
|
const [isSuccess, setSuccess] = useState(false)
|
|
6
11
|
const [isLoading, setLoading] = useState(false)
|
|
7
12
|
const [isError, setError] = useState<unknown>(null)
|
|
8
13
|
|
|
9
|
-
const mutate = async (
|
|
14
|
+
const mutate = async (
|
|
15
|
+
mutateFn: (args?: unknown) => Promise<UseMutateResponse>,
|
|
16
|
+
options?: UseMutateOptions
|
|
17
|
+
) => {
|
|
10
18
|
let response: UseMutateResponse | undefined = undefined
|
|
11
19
|
|
|
12
20
|
try {
|
|
@@ -14,11 +22,13 @@ const useMutate = <UseMutateResponse>() => {
|
|
|
14
22
|
response = await mutateFn()
|
|
15
23
|
setData(response)
|
|
16
24
|
setSuccess(true)
|
|
25
|
+
options?.onSuccess?.()
|
|
17
26
|
setLoading(false)
|
|
18
27
|
} catch (err) {
|
|
19
28
|
setSuccess(false)
|
|
20
29
|
setLoading(false)
|
|
21
30
|
setError(err)
|
|
31
|
+
options?.onError?.(err)
|
|
22
32
|
}
|
|
23
33
|
|
|
24
34
|
return response
|
package/src/locales/general.json
CHANGED
|
@@ -980,7 +980,8 @@
|
|
|
980
980
|
"dontHaveAccount": "Don't have an account",
|
|
981
981
|
"enterLoginPassword": "Please enter your login password",
|
|
982
982
|
"enterLoginEmail": "Please enter your login email",
|
|
983
|
-
"changeYourPassword": "You can change your password"
|
|
983
|
+
"changeYourPassword": "You can change your password",
|
|
984
|
+
"yourAccountIsNotConfirmed": "Your account is not confirmed"
|
|
984
985
|
},
|
|
985
986
|
"createAccount": {
|
|
986
987
|
"accountConfirmed": "Your account was successfully confirmed.",
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
ErrorMessage,
|
|
14
14
|
emailRegex,
|
|
15
15
|
} from "@bloom-housing/ui-components"
|
|
16
|
+
import { NetworkErrorReset, NetworkStatusContent } from "@bloom-housing/shared-helpers"
|
|
16
17
|
import { NavigationContext } from "../../config/NavigationContext"
|
|
17
18
|
import type { UseFormMethods } from "react-hook-form"
|
|
18
19
|
|
|
@@ -22,15 +23,8 @@ export type FormForgotPasswordProps = {
|
|
|
22
23
|
networkError: FormForgotPasswordNetworkError
|
|
23
24
|
}
|
|
24
25
|
|
|
25
|
-
export type NetworkErrorReset = () => void
|
|
26
|
-
|
|
27
|
-
export type NetworkErrorValue = {
|
|
28
|
-
title: string
|
|
29
|
-
content: string
|
|
30
|
-
} | null
|
|
31
|
-
|
|
32
26
|
export type FormForgotPasswordNetworkError = {
|
|
33
|
-
error:
|
|
27
|
+
error: NetworkStatusContent
|
|
34
28
|
reset: NetworkErrorReset
|
|
35
29
|
}
|
|
36
30
|
|
|
@@ -75,7 +69,7 @@ const FormForgotPassword = ({
|
|
|
75
69
|
</AlertBox>
|
|
76
70
|
|
|
77
71
|
<AlertNotice title="" type="alert" inverted>
|
|
78
|
-
{networkError.error.
|
|
72
|
+
{networkError.error.description}
|
|
79
73
|
</AlertNotice>
|
|
80
74
|
</ErrorMessage>
|
|
81
75
|
)}
|
|
@@ -12,22 +12,17 @@ import {
|
|
|
12
12
|
} from "@bloom-housing/ui-components"
|
|
13
13
|
import type { UseFormMethods } from "react-hook-form"
|
|
14
14
|
import { NavigationContext } from "../../config/NavigationContext"
|
|
15
|
-
import
|
|
15
|
+
import { NetworkStatus } from "@bloom-housing/shared-helpers"
|
|
16
16
|
|
|
17
17
|
export type NetworkErrorDetermineError = (status: number, error: Error) => void
|
|
18
18
|
|
|
19
19
|
export type FormSignInProps = {
|
|
20
20
|
control: FormSignInControl
|
|
21
21
|
onSubmit: (data: FormSignInValues) => void
|
|
22
|
-
|
|
22
|
+
networkStatus: NetworkStatus
|
|
23
23
|
showRegisterBtn?: boolean
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
export type FormSignInNetworkError = {
|
|
27
|
-
error: NetworkErrorValue
|
|
28
|
-
reset: NetworkErrorReset
|
|
29
|
-
}
|
|
30
|
-
|
|
31
26
|
export type FormSignInControl = {
|
|
32
27
|
errors: UseFormMethods["errors"]
|
|
33
28
|
handleSubmit: UseFormMethods["handleSubmit"]
|
|
@@ -41,7 +36,7 @@ export type FormSignInValues = {
|
|
|
41
36
|
|
|
42
37
|
const FormSignIn = ({
|
|
43
38
|
onSubmit,
|
|
44
|
-
|
|
39
|
+
networkStatus,
|
|
45
40
|
showRegisterBtn,
|
|
46
41
|
control: { errors, register, handleSubmit },
|
|
47
42
|
}: FormSignInProps) => {
|
|
@@ -58,7 +53,7 @@ const FormSignIn = ({
|
|
|
58
53
|
</div>
|
|
59
54
|
<FormSignInErrorBox
|
|
60
55
|
errors={errors}
|
|
61
|
-
|
|
56
|
+
networkStatus={networkStatus}
|
|
62
57
|
errorMessageId={"main-sign-in"}
|
|
63
58
|
/>
|
|
64
59
|
<div className="form-card__group pt-0">
|
|
@@ -11,12 +11,12 @@ import {
|
|
|
11
11
|
FormSignInErrorBox,
|
|
12
12
|
} from "@bloom-housing/ui-components"
|
|
13
13
|
import type { UseFormMethods } from "react-hook-form"
|
|
14
|
-
import {
|
|
14
|
+
import { NetworkStatus } from "@bloom-housing/shared-helpers"
|
|
15
15
|
|
|
16
16
|
export type FormSignInAddPhoneProps = {
|
|
17
17
|
control: FormSignInAddPhoneControl
|
|
18
18
|
onSubmit: (data: FormSignInAddPhoneValues) => void
|
|
19
|
-
networkError:
|
|
19
|
+
networkError: NetworkStatus
|
|
20
20
|
phoneNumber: string
|
|
21
21
|
}
|
|
22
22
|
|
|
@@ -49,7 +49,7 @@ const FormSignInAddPhone = ({
|
|
|
49
49
|
</div>
|
|
50
50
|
<FormSignInErrorBox
|
|
51
51
|
errors={errors}
|
|
52
|
-
|
|
52
|
+
networkStatus={networkError}
|
|
53
53
|
errorMessageId={"add-phone"}
|
|
54
54
|
/>
|
|
55
55
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import React from "react"
|
|
2
2
|
import { t, AlertBox, SiteAlert, AlertNotice, ErrorMessage } from "@bloom-housing/ui-components"
|
|
3
3
|
import type { UseFormMethods } from "react-hook-form"
|
|
4
|
-
import {
|
|
4
|
+
import { NetworkStatus } from "@bloom-housing/shared-helpers"
|
|
5
5
|
|
|
6
6
|
export type FormSignInErrorBoxProps = {
|
|
7
7
|
errors: FormSignInErrorBoxControl["errors"]
|
|
8
|
-
|
|
8
|
+
networkStatus: NetworkStatus
|
|
9
9
|
errorMessageId: string
|
|
10
10
|
}
|
|
11
11
|
|
|
@@ -14,27 +14,39 @@ export type FormSignInErrorBoxControl = {
|
|
|
14
14
|
control: UseFormMethods["control"]
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
const FormSignInErrorBox = ({
|
|
17
|
+
const FormSignInErrorBox = ({ networkStatus, errors, errorMessageId }: FormSignInErrorBoxProps) => {
|
|
18
18
|
return (
|
|
19
19
|
<div className="border-b">
|
|
20
|
-
{Object.entries(errors).length > 0 && !
|
|
20
|
+
{Object.entries(errors).length > 0 && !networkStatus.content && (
|
|
21
21
|
<AlertBox type="alert" inverted closeable>
|
|
22
22
|
{errors.authentication ? errors.authentication.message : t("errors.errorsToResolve")}
|
|
23
23
|
</AlertBox>
|
|
24
24
|
)}
|
|
25
25
|
|
|
26
|
-
{
|
|
27
|
-
<ErrorMessage id={`form-sign-in-${errorMessageId}-error`} error={!!
|
|
28
|
-
<AlertBox type="alert" inverted onClose={() =>
|
|
29
|
-
{
|
|
26
|
+
{networkStatus.content?.error && Object.entries(errors).length === 0 && (
|
|
27
|
+
<ErrorMessage id={`form-sign-in-${errorMessageId}-error`} error={!!networkStatus.content}>
|
|
28
|
+
<AlertBox type={"alert"} inverted onClose={() => networkStatus.reset()}>
|
|
29
|
+
{networkStatus.content.title}
|
|
30
30
|
</AlertBox>
|
|
31
31
|
|
|
32
32
|
<AlertNotice title="" type="alert" inverted>
|
|
33
|
-
{
|
|
33
|
+
{networkStatus.content.description}
|
|
34
34
|
</AlertNotice>
|
|
35
35
|
</ErrorMessage>
|
|
36
36
|
)}
|
|
37
37
|
|
|
38
|
+
{networkStatus.type === "success" && (
|
|
39
|
+
<>
|
|
40
|
+
<AlertBox type="success" inverted onClose={() => networkStatus.reset()}>
|
|
41
|
+
{networkStatus.content?.title}
|
|
42
|
+
</AlertBox>
|
|
43
|
+
|
|
44
|
+
<AlertNotice title="" type="success" inverted>
|
|
45
|
+
{networkStatus.content?.description}
|
|
46
|
+
</AlertNotice>
|
|
47
|
+
</>
|
|
48
|
+
)}
|
|
49
|
+
|
|
38
50
|
<SiteAlert type="notice" dismissable />
|
|
39
51
|
</div>
|
|
40
52
|
)
|
|
@@ -10,13 +10,14 @@ import {
|
|
|
10
10
|
SiteAlert,
|
|
11
11
|
FormSignInErrorBox,
|
|
12
12
|
} from "@bloom-housing/ui-components"
|
|
13
|
-
import {
|
|
13
|
+
import { NetworkStatus } from "@bloom-housing/shared-helpers"
|
|
14
|
+
import { FormSignInControl } from "./FormSignIn"
|
|
14
15
|
import { EnumRequestMfaCodeMfaType } from "@bloom-housing/backend-core/types"
|
|
15
16
|
|
|
16
17
|
export type FormSignInMFACodeProps = {
|
|
17
18
|
control: FormSignInControl
|
|
18
19
|
onSubmit: (data: FormSignInMFACodeValues) => void
|
|
19
|
-
networkError:
|
|
20
|
+
networkError: NetworkStatus
|
|
20
21
|
mfaType: EnumRequestMfaCodeMfaType
|
|
21
22
|
allowPhoneNumberEdit: boolean
|
|
22
23
|
phoneNumber: string
|
|
@@ -68,7 +69,11 @@ const FormSignInMFACode = ({
|
|
|
68
69
|
: t("nav.signInMFA.haveSentCodeToEmail")}
|
|
69
70
|
</p>
|
|
70
71
|
</div>
|
|
71
|
-
<FormSignInErrorBox
|
|
72
|
+
<FormSignInErrorBox
|
|
73
|
+
errors={errors}
|
|
74
|
+
networkStatus={networkError}
|
|
75
|
+
errorMessageId={"mfa-code"}
|
|
76
|
+
/>
|
|
72
77
|
|
|
73
78
|
<SiteAlert type="notice" dismissable />
|
|
74
79
|
<div className="form-card__group pt-0">
|
|
@@ -11,13 +11,13 @@ import {
|
|
|
11
11
|
FormSignInErrorBox,
|
|
12
12
|
} from "@bloom-housing/ui-components"
|
|
13
13
|
import type { UseFormMethods } from "react-hook-form"
|
|
14
|
-
import {
|
|
14
|
+
import { NetworkStatus } from "@bloom-housing/shared-helpers"
|
|
15
15
|
import { EnumRequestMfaCodeMfaType } from "@bloom-housing/backend-core/types"
|
|
16
16
|
|
|
17
17
|
export type FormSignInMFAProps = {
|
|
18
18
|
control: FormSignInMFAControl
|
|
19
19
|
onSubmit: (data: FormSignInMFAValues) => void
|
|
20
|
-
networkError:
|
|
20
|
+
networkError: NetworkStatus
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
export type FormSignInMFAControl = {
|
|
@@ -51,7 +51,11 @@ const FormSignInMFAType = ({
|
|
|
51
51
|
{t("nav.signInMFA.verificationChoiceSecondaryTitle")}
|
|
52
52
|
</p>
|
|
53
53
|
</div>
|
|
54
|
-
<FormSignInErrorBox
|
|
54
|
+
<FormSignInErrorBox
|
|
55
|
+
errors={errors}
|
|
56
|
+
networkStatus={networkError}
|
|
57
|
+
errorMessageId={"mfa-type"}
|
|
58
|
+
/>
|
|
55
59
|
|
|
56
60
|
<SiteAlert type="notice" dismissable />
|
|
57
61
|
<div className="form-card__group pt-0">
|