@blaze-cms/react-page-builder 0.125.0-f-admin-updates.5 → 0.126.0-admin-updates.0
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 +70 -3
- package/README.md +14 -4
- package/example.env +1 -0
- package/lib/components/Button.js +14 -5
- package/lib/components/Button.js.map +1 -1
- package/lib/components/Card/Card.js +53 -25
- package/lib/components/Card/Card.js.map +1 -1
- package/lib/components/Card/CardContainer.js +2 -1
- package/lib/components/Card/CardContainer.js.map +1 -1
- package/lib/components/Card/constants.js +3 -1
- package/lib/components/Card/constants.js.map +1 -1
- package/lib/components/ContentGroup/ContentGroup.js +29 -0
- package/lib/components/ContentGroup/ContentGroup.js.map +1 -0
- package/lib/components/ContentGroup/ContentGroupTabs.js +94 -0
- package/lib/components/ContentGroup/ContentGroupTabs.js.map +1 -0
- package/lib/components/{Login → ContentGroup}/index.js +2 -2
- package/lib/components/ContentGroup/index.js.map +1 -0
- package/lib/components/ContentGroupSection/ContentGroupSection.js +30 -0
- package/lib/components/ContentGroupSection/ContentGroupSection.js.map +1 -0
- package/lib/components/{PasswordReset → ContentGroupSection}/index.js +2 -2
- package/lib/components/ContentGroupSection/index.js.map +1 -0
- package/lib/components/List/ListRender.js.map +1 -1
- package/lib/components/List/components/Cards/CardsRender.js.map +1 -1
- package/lib/components/List/components/Cards/CardsRenderItem.js +2 -1
- package/lib/components/List/components/Cards/CardsRenderItem.js.map +1 -1
- package/lib/components/Video/providers/Vimeo/VimeoProvider.js +100 -21
- package/lib/components/Video/providers/Vimeo/VimeoProvider.js.map +1 -1
- package/lib/components/Video/providers/Vimeo/helpers/add-extra-params-to-url.js +34 -0
- package/lib/components/Video/providers/Vimeo/helpers/add-extra-params-to-url.js.map +1 -0
- package/lib/components/{PasswordReset → Video/providers/Vimeo}/helpers/index.js +3 -3
- package/lib/components/Video/providers/Vimeo/helpers/index.js.map +1 -0
- package/lib/components/index.js +10 -15
- package/lib/components/index.js.map +1 -1
- package/lib/constants/index.js +4 -14
- package/lib/constants/index.js.map +1 -1
- package/lib/helpers/build-search-values-text.js +11 -1
- package/lib/helpers/build-search-values-text.js.map +1 -1
- package/lib/hooks/helpers/get-banners-by-type.js +1 -1
- package/lib/hooks/helpers/get-banners-by-type.js.map +1 -1
- package/lib/index.js +6 -0
- package/lib/index.js.map +1 -1
- package/lib-es/components/Button.js +13 -6
- package/lib-es/components/Button.js.map +1 -1
- package/lib-es/components/Card/Card.js +34 -8
- package/lib-es/components/Card/Card.js.map +1 -1
- package/lib-es/components/Card/CardContainer.js +2 -1
- package/lib-es/components/Card/CardContainer.js.map +1 -1
- package/lib-es/components/Card/constants.js +2 -1
- package/lib-es/components/Card/constants.js.map +1 -1
- package/lib-es/components/ContentGroup/ContentGroup.js +22 -0
- package/lib-es/components/ContentGroup/ContentGroup.js.map +1 -0
- package/lib-es/components/ContentGroup/ContentGroupTabs.js +72 -0
- package/lib-es/components/ContentGroup/ContentGroupTabs.js.map +1 -0
- package/lib-es/components/ContentGroup/index.js +3 -0
- package/lib-es/components/ContentGroup/index.js.map +1 -0
- package/lib-es/components/ContentGroupSection/ContentGroupSection.js +23 -0
- package/lib-es/components/ContentGroupSection/ContentGroupSection.js.map +1 -0
- package/lib-es/components/ContentGroupSection/index.js +3 -0
- package/lib-es/components/ContentGroupSection/index.js.map +1 -0
- package/lib-es/components/List/ListRender.js.map +1 -1
- package/lib-es/components/List/components/Cards/CardsRender.js.map +1 -1
- package/lib-es/components/List/components/Cards/CardsRenderItem.js +2 -1
- package/lib-es/components/List/components/Cards/CardsRenderItem.js.map +1 -1
- package/lib-es/components/Video/providers/Vimeo/VimeoProvider.js +50 -21
- package/lib-es/components/Video/providers/Vimeo/VimeoProvider.js.map +1 -1
- package/lib-es/components/Video/providers/Vimeo/helpers/add-extra-params-to-url.js +14 -0
- package/lib-es/components/Video/providers/Vimeo/helpers/add-extra-params-to-url.js.map +1 -0
- package/lib-es/components/Video/providers/Vimeo/helpers/index.js +3 -0
- package/lib-es/components/Video/providers/Vimeo/helpers/index.js.map +1 -0
- package/lib-es/components/index.js +3 -4
- package/lib-es/components/index.js.map +1 -1
- package/lib-es/constants/index.js +2 -7
- package/lib-es/constants/index.js.map +1 -1
- package/lib-es/helpers/build-search-values-text.js +11 -1
- package/lib-es/helpers/build-search-values-text.js.map +1 -1
- package/lib-es/hooks/helpers/get-banners-by-type.js +1 -1
- package/lib-es/hooks/helpers/get-banners-by-type.js.map +1 -1
- package/lib-es/index.js +1 -1
- package/lib-es/index.js.map +1 -1
- package/package.json +7 -6
- package/src/components/Button.js +11 -4
- package/src/components/Card/Card.js +37 -5
- package/src/components/Card/CardContainer.js +2 -1
- package/src/components/Card/constants.js +2 -1
- package/src/components/ContentGroup/ContentGroup.js +17 -0
- package/src/components/ContentGroup/ContentGroupTabs.js +74 -0
- package/src/components/ContentGroup/index.js +3 -0
- package/src/components/ContentGroupSection/ContentGroupSection.js +17 -0
- package/src/components/ContentGroupSection/index.js +3 -0
- package/src/components/List/ListRender.js +0 -1
- package/src/components/List/components/Cards/CardsRender.js +1 -0
- package/src/components/List/components/Cards/CardsRenderItem.js +2 -1
- package/src/components/Video/providers/Vimeo/VimeoProvider.js +56 -15
- package/src/components/Video/providers/Vimeo/helpers/add-extra-params-to-url.js +15 -0
- package/src/components/Video/providers/Vimeo/helpers/index.js +3 -0
- package/src/components/index.js +8 -8
- package/src/constants/index.js +3 -14
- package/src/helpers/build-search-values-text.js +12 -1
- package/src/hooks/helpers/get-banners-by-type.js +1 -1
- package/src/index.js +1 -1
- package/tests/unit/src/components/Button.test.js +7 -0
- package/tests/unit/src/components/Card/Card.test.js +18 -7
- package/tests/unit/src/components/Card/__snapshots__/Card.test.js.snap +5 -0
- package/tests/unit/src/components/ContentGroup/ContentGroup.test.js +13 -0
- package/tests/unit/src/components/ContentGroup/ContentGroupTabs.test.js +16 -0
- package/tests/unit/src/components/ContentGroup/__snapshots__/ContentGroup.test.js.snap +5 -0
- package/tests/unit/src/components/ContentGroup/__snapshots__/ContentGroupTabs.test.js.snap +5 -0
- package/tests/unit/src/components/ContentGroupSection/ContentGroupSection.test.js +17 -0
- package/tests/unit/src/components/ContentGroupSection/__snapshots__/ContentGroupSection.test.js.snap +15 -0
- package/tests/unit/src/components/Video/providers/Vimeo/{Vimeo.js → Vimeo.test.js} +1 -3
- package/tests/unit/src/components/Video/providers/Vimeo/__snapshots__/Vimeo.test.js.snap +10 -0
- package/tests/unit/src/components/Video/providers/Vimeo/helpers/add-extra-params-to-url.test.js +24 -0
- package/tests/unit/src/components/__snapshots__/index.test.js.snap +8 -12
- package/tests/unit/src/helpers/build-search-values-text.test.js +2 -5
- package/lib/components/Login/LoggedInMessage.js +0 -28
- package/lib/components/Login/LoggedInMessage.js.map +0 -1
- package/lib/components/Login/Login.js +0 -135
- package/lib/components/Login/Login.js.map +0 -1
- package/lib/components/Login/LoginForm.js +0 -112
- package/lib/components/Login/LoginForm.js.map +0 -1
- package/lib/components/Login/helpers/check-gtm-children.js +0 -42
- package/lib/components/Login/helpers/check-gtm-children.js.map +0 -1
- package/lib/components/Login/helpers/get-url-to-use.js +0 -18
- package/lib/components/Login/helpers/get-url-to-use.js.map +0 -1
- package/lib/components/Login/helpers/index.js +0 -22
- package/lib/components/Login/helpers/index.js.map +0 -1
- package/lib/components/Login/index.js.map +0 -1
- package/lib/components/PasswordReset/PasswordReset.js +0 -172
- package/lib/components/PasswordReset/PasswordReset.js.map +0 -1
- package/lib/components/PasswordReset/helpers/index.js.map +0 -1
- package/lib/components/PasswordReset/helpers/validatePassword.js +0 -16
- package/lib/components/PasswordReset/helpers/validatePassword.js.map +0 -1
- package/lib/components/PasswordReset/index.js.map +0 -1
- package/lib/components/PasswordResetRequest/PasswordResetRequest.js +0 -114
- package/lib/components/PasswordResetRequest/PasswordResetRequest.js.map +0 -1
- package/lib/components/PasswordResetRequest/index.js +0 -12
- package/lib/components/PasswordResetRequest/index.js.map +0 -1
- package/lib-es/components/Login/LoggedInMessage.js +0 -18
- package/lib-es/components/Login/LoggedInMessage.js.map +0 -1
- package/lib-es/components/Login/Login.js +0 -83
- package/lib-es/components/Login/Login.js.map +0 -1
- package/lib-es/components/Login/LoginForm.js +0 -89
- package/lib-es/components/Login/LoginForm.js.map +0 -1
- package/lib-es/components/Login/helpers/check-gtm-children.js +0 -35
- package/lib-es/components/Login/helpers/check-gtm-children.js.map +0 -1
- package/lib-es/components/Login/helpers/get-url-to-use.js +0 -10
- package/lib-es/components/Login/helpers/get-url-to-use.js.map +0 -1
- package/lib-es/components/Login/helpers/index.js +0 -4
- package/lib-es/components/Login/helpers/index.js.map +0 -1
- package/lib-es/components/Login/index.js +0 -3
- package/lib-es/components/Login/index.js.map +0 -1
- package/lib-es/components/PasswordReset/PasswordReset.js +0 -144
- package/lib-es/components/PasswordReset/PasswordReset.js.map +0 -1
- package/lib-es/components/PasswordReset/helpers/index.js +0 -3
- package/lib-es/components/PasswordReset/helpers/index.js.map +0 -1
- package/lib-es/components/PasswordReset/helpers/validatePassword.js +0 -7
- package/lib-es/components/PasswordReset/helpers/validatePassword.js.map +0 -1
- package/lib-es/components/PasswordReset/index.js +0 -3
- package/lib-es/components/PasswordReset/index.js.map +0 -1
- package/lib-es/components/PasswordResetRequest/PasswordResetRequest.js +0 -92
- package/lib-es/components/PasswordResetRequest/PasswordResetRequest.js.map +0 -1
- package/lib-es/components/PasswordResetRequest/index.js +0 -3
- package/lib-es/components/PasswordResetRequest/index.js.map +0 -1
- package/src/components/Login/LoggedInMessage.js +0 -24
- package/src/components/Login/Login.js +0 -74
- package/src/components/Login/LoginForm.js +0 -81
- package/src/components/Login/helpers/check-gtm-children.js +0 -30
- package/src/components/Login/helpers/get-url-to-use.js +0 -6
- package/src/components/Login/helpers/index.js +0 -4
- package/src/components/Login/index.js +0 -3
- package/src/components/PasswordReset/PasswordReset.js +0 -120
- package/src/components/PasswordReset/helpers/index.js +0 -3
- package/src/components/PasswordReset/helpers/validatePassword.js +0 -8
- package/src/components/PasswordReset/index.js +0 -3
- package/src/components/PasswordResetRequest/PasswordResetRequest.js +0 -82
- package/src/components/PasswordResetRequest/index.js +0 -3
- package/tests/unit/src/components/Login/Login.test.js +0 -36
- package/tests/unit/src/components/Login/__snapshots__/Login.test.js.snap +0 -103
- package/tests/unit/src/components/Login/helpers/check-gtm-children.test.js +0 -60
- package/tests/unit/src/components/Login/helpers/get-url-to-use.test.js +0 -15
- package/tests/unit/src/components/PasswordReset/PasswordReset.test.js +0 -85
- package/tests/unit/src/components/PasswordReset/__snapshots__/PasswordReset.test.js.snap +0 -83
- package/tests/unit/src/components/PasswordReset/helpers/validatePassword.test.js +0 -21
- package/tests/unit/src/components/PasswordResetRequest/PasswordResetRequest.test.js +0 -79
- package/tests/unit/src/components/PasswordResetRequest/__snapshots__/PasswordResetRequest.test.js.snap +0 -39
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["PasswordReset"],"sources":["../../../src/components/PasswordReset/index.js"],"sourcesContent":["import PasswordReset from './PasswordReset';\n\nexport default PasswordReset;\n"],"mappings":"AAAA,OAAOA,aAAa,MAAM,iBAAiB;AAE3C,eAAeA,aAAa"}
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import React, { useState } from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import Input from '@blaze-react/input';
|
|
4
|
-
import Button from '@blaze-react/button';
|
|
5
|
-
import { useMutation } from '@apollo/client';
|
|
6
|
-
import { useRouter } from 'next/router';
|
|
7
|
-
import { checkIfLoggedIn, REQUEST_USER_PASSWORD_RESET_MUTATION } from '@blaze-cms/core-auth-ui';
|
|
8
|
-
import { GRAPH_QL_ERROR } from '../../constants';
|
|
9
|
-
import { hasChildren } from '../../helpers';
|
|
10
|
-
const PasswordResetRequest = ({
|
|
11
|
-
children,
|
|
12
|
-
modifier
|
|
13
|
-
}) => {
|
|
14
|
-
const {
|
|
15
|
-
id: userId
|
|
16
|
-
} = checkIfLoggedIn();
|
|
17
|
-
const router = useRouter();
|
|
18
|
-
const {
|
|
19
|
-
asPath
|
|
20
|
-
} = router;
|
|
21
|
-
const [displayChildren, setShouldDisplayChildren] = useState(false);
|
|
22
|
-
const [errorMessageToDisplay, setErrorMessage] = useState(null);
|
|
23
|
-
const [email, setEmail] = useState('');
|
|
24
|
-
const [requestUserPasswordResetMutation] = useMutation(REQUEST_USER_PASSWORD_RESET_MUTATION, {
|
|
25
|
-
onCompleted: () => {
|
|
26
|
-
setShouldDisplayChildren(true);
|
|
27
|
-
setErrorMessage(null);
|
|
28
|
-
},
|
|
29
|
-
onError: ({
|
|
30
|
-
message
|
|
31
|
-
}) => {
|
|
32
|
-
const parsedMessage = message.replace(GRAPH_QL_ERROR, '');
|
|
33
|
-
setErrorMessage(parsedMessage);
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
const isDisabled = !email;
|
|
37
|
-
const displayValidChildren = displayChildren && hasChildren(children);
|
|
38
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
39
|
-
className: modifier
|
|
40
|
-
}, !displayChildren && /*#__PURE__*/React.createElement("form", {
|
|
41
|
-
id: "passwordResetRequest",
|
|
42
|
-
onSubmit: e => {
|
|
43
|
-
e.preventDefault();
|
|
44
|
-
if (isDisabled) return;
|
|
45
|
-
requestUserPasswordResetMutation({
|
|
46
|
-
variables: {
|
|
47
|
-
input: {
|
|
48
|
-
email,
|
|
49
|
-
userId,
|
|
50
|
-
extras: {
|
|
51
|
-
redirectUrl: asPath
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
}, /*#__PURE__*/React.createElement(Input, {
|
|
58
|
-
key: "email",
|
|
59
|
-
type: "email",
|
|
60
|
-
name: "email",
|
|
61
|
-
label: "Email",
|
|
62
|
-
required: true,
|
|
63
|
-
onChange: ({
|
|
64
|
-
event
|
|
65
|
-
}) => {
|
|
66
|
-
const {
|
|
67
|
-
target: {
|
|
68
|
-
value
|
|
69
|
-
}
|
|
70
|
-
} = event;
|
|
71
|
-
setEmail(value);
|
|
72
|
-
},
|
|
73
|
-
value: email
|
|
74
|
-
})), !displayChildren && /*#__PURE__*/React.createElement(Button, {
|
|
75
|
-
type: "submit",
|
|
76
|
-
name: "button",
|
|
77
|
-
form: "passwordResetRequest",
|
|
78
|
-
disabled: isDisabled
|
|
79
|
-
}, "Request Password Reset"), !!errorMessageToDisplay && /*#__PURE__*/React.createElement("div", {
|
|
80
|
-
className: "error_message"
|
|
81
|
-
}, errorMessageToDisplay), displayValidChildren && /*#__PURE__*/React.createElement("div", null, children));
|
|
82
|
-
};
|
|
83
|
-
PasswordResetRequest.propTypes = {
|
|
84
|
-
modifier: PropTypes.string,
|
|
85
|
-
children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node])
|
|
86
|
-
};
|
|
87
|
-
PasswordResetRequest.defaultProps = {
|
|
88
|
-
modifier: '',
|
|
89
|
-
children: null
|
|
90
|
-
};
|
|
91
|
-
export default PasswordResetRequest;
|
|
92
|
-
//# sourceMappingURL=PasswordResetRequest.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PasswordResetRequest.js","names":["React","useState","PropTypes","Input","Button","useMutation","useRouter","checkIfLoggedIn","REQUEST_USER_PASSWORD_RESET_MUTATION","GRAPH_QL_ERROR","hasChildren","PasswordResetRequest","children","modifier","id","userId","router","asPath","displayChildren","setShouldDisplayChildren","errorMessageToDisplay","setErrorMessage","email","setEmail","requestUserPasswordResetMutation","onCompleted","onError","message","parsedMessage","replace","isDisabled","displayValidChildren","e","preventDefault","variables","input","extras","redirectUrl","event","target","value","propTypes","string","oneOfType","arrayOf","node","defaultProps"],"sources":["../../../src/components/PasswordResetRequest/PasswordResetRequest.js"],"sourcesContent":["import React, { useState } from 'react';\nimport PropTypes from 'prop-types';\nimport Input from '@blaze-react/input';\nimport Button from '@blaze-react/button';\nimport { useMutation } from '@apollo/client';\nimport { useRouter } from 'next/router';\nimport { checkIfLoggedIn, REQUEST_USER_PASSWORD_RESET_MUTATION } from '@blaze-cms/core-auth-ui';\nimport { GRAPH_QL_ERROR } from '../../constants';\nimport { hasChildren } from '../../helpers';\n\nconst PasswordResetRequest = ({ children, modifier }) => {\n const { id: userId } = checkIfLoggedIn();\n const router = useRouter();\n const { asPath } = router;\n const [displayChildren, setShouldDisplayChildren] = useState(false);\n const [errorMessageToDisplay, setErrorMessage] = useState(null);\n const [email, setEmail] = useState('');\n\n const [requestUserPasswordResetMutation] = useMutation(REQUEST_USER_PASSWORD_RESET_MUTATION, {\n onCompleted: () => {\n setShouldDisplayChildren(true);\n setErrorMessage(null);\n },\n onError: ({ message }) => {\n const parsedMessage = message.replace(GRAPH_QL_ERROR, '');\n setErrorMessage(parsedMessage);\n }\n });\n\n const isDisabled = !email;\n const displayValidChildren = displayChildren && hasChildren(children);\n\n return (\n <div className={modifier}>\n {!displayChildren && (\n <form\n id=\"passwordResetRequest\"\n onSubmit={e => {\n e.preventDefault();\n if (isDisabled) return;\n requestUserPasswordResetMutation({\n variables: { input: { email, userId, extras: { redirectUrl: asPath } } }\n });\n }}>\n <Input\n key=\"email\"\n type=\"email\"\n name=\"email\"\n label=\"Email\"\n required\n onChange={({ event }) => {\n const {\n target: { value }\n } = event;\n setEmail(value);\n }}\n value={email}\n />\n </form>\n )}\n {!displayChildren && (\n <Button type=\"submit\" name=\"button\" form=\"passwordResetRequest\" disabled={isDisabled}>\n Request Password Reset\n </Button>\n )}\n {!!errorMessageToDisplay && <div className=\"error_message\">{errorMessageToDisplay}</div>}\n {displayValidChildren && <div>{children}</div>}\n </div>\n );\n};\n\nPasswordResetRequest.propTypes = {\n modifier: PropTypes.string,\n children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node])\n};\n\nPasswordResetRequest.defaultProps = {\n modifier: '',\n children: null\n};\n\nexport default PasswordResetRequest;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,QAAQ,QAAQ,OAAO;AACvC,OAAOC,SAAS,MAAM,YAAY;AAClC,OAAOC,KAAK,MAAM,oBAAoB;AACtC,OAAOC,MAAM,MAAM,qBAAqB;AACxC,SAASC,WAAW,QAAQ,gBAAgB;AAC5C,SAASC,SAAS,QAAQ,aAAa;AACvC,SAASC,eAAe,EAAEC,oCAAoC,QAAQ,yBAAyB;AAC/F,SAASC,cAAc,QAAQ,iBAAiB;AAChD,SAASC,WAAW,QAAQ,eAAe;AAE3C,MAAMC,oBAAoB,GAAG,CAAC;EAAEC,QAAQ;EAAEC;AAAS,CAAC,KAAK;EACvD,MAAM;IAAEC,EAAE,EAAEC;EAAO,CAAC,GAAGR,eAAe,EAAE;EACxC,MAAMS,MAAM,GAAGV,SAAS,EAAE;EAC1B,MAAM;IAAEW;EAAO,CAAC,GAAGD,MAAM;EACzB,MAAM,CAACE,eAAe,EAAEC,wBAAwB,CAAC,GAAGlB,QAAQ,CAAC,KAAK,CAAC;EACnE,MAAM,CAACmB,qBAAqB,EAAEC,eAAe,CAAC,GAAGpB,QAAQ,CAAC,IAAI,CAAC;EAC/D,MAAM,CAACqB,KAAK,EAAEC,QAAQ,CAAC,GAAGtB,QAAQ,CAAC,EAAE,CAAC;EAEtC,MAAM,CAACuB,gCAAgC,CAAC,GAAGnB,WAAW,CAACG,oCAAoC,EAAE;IAC3FiB,WAAW,EAAE,MAAM;MACjBN,wBAAwB,CAAC,IAAI,CAAC;MAC9BE,eAAe,CAAC,IAAI,CAAC;IACvB,CAAC;IACDK,OAAO,EAAE,CAAC;MAAEC;IAAQ,CAAC,KAAK;MACxB,MAAMC,aAAa,GAAGD,OAAO,CAACE,OAAO,CAACpB,cAAc,EAAE,EAAE,CAAC;MACzDY,eAAe,CAACO,aAAa,CAAC;IAChC;EACF,CAAC,CAAC;EAEF,MAAME,UAAU,GAAG,CAACR,KAAK;EACzB,MAAMS,oBAAoB,GAAGb,eAAe,IAAIR,WAAW,CAACE,QAAQ,CAAC;EAErE,oBACE;IAAK,SAAS,EAAEC;EAAS,GACtB,CAACK,eAAe,iBACf;IACE,EAAE,EAAC,sBAAsB;IACzB,QAAQ,EAAEc,CAAC,IAAI;MACbA,CAAC,CAACC,cAAc,EAAE;MAClB,IAAIH,UAAU,EAAE;MAChBN,gCAAgC,CAAC;QAC/BU,SAAS,EAAE;UAAEC,KAAK,EAAE;YAAEb,KAAK;YAAEP,MAAM;YAAEqB,MAAM,EAAE;cAAEC,WAAW,EAAEpB;YAAO;UAAE;QAAE;MACzE,CAAC,CAAC;IACJ;EAAE,gBACF,oBAAC,KAAK;IACJ,GAAG,EAAC,OAAO;IACX,IAAI,EAAC,OAAO;IACZ,IAAI,EAAC,OAAO;IACZ,KAAK,EAAC,OAAO;IACb,QAAQ;IACR,QAAQ,EAAE,CAAC;MAAEqB;IAAM,CAAC,KAAK;MACvB,MAAM;QACJC,MAAM,EAAE;UAAEC;QAAM;MAClB,CAAC,GAAGF,KAAK;MACTf,QAAQ,CAACiB,KAAK,CAAC;IACjB,CAAE;IACF,KAAK,EAAElB;EAAM,EACb,CAEL,EACA,CAACJ,eAAe,iBACf,oBAAC,MAAM;IAAC,IAAI,EAAC,QAAQ;IAAC,IAAI,EAAC,QAAQ;IAAC,IAAI,EAAC,sBAAsB;IAAC,QAAQ,EAAEY;EAAW,4BAGtF,EACA,CAAC,CAACV,qBAAqB,iBAAI;IAAK,SAAS,EAAC;EAAe,GAAEA,qBAAqB,CAAO,EACvFW,oBAAoB,iBAAI,iCAAMnB,QAAQ,CAAO,CAC1C;AAEV,CAAC;AAEDD,oBAAoB,CAAC8B,SAAS,GAAG;EAC/B5B,QAAQ,EAAEX,SAAS,CAACwC,MAAM;EAC1B9B,QAAQ,EAAEV,SAAS,CAACyC,SAAS,CAAC,CAACzC,SAAS,CAAC0C,OAAO,CAAC1C,SAAS,CAAC2C,IAAI,CAAC,EAAE3C,SAAS,CAAC2C,IAAI,CAAC;AACnF,CAAC;AAEDlC,oBAAoB,CAACmC,YAAY,GAAG;EAClCjC,QAAQ,EAAE,EAAE;EACZD,QAAQ,EAAE;AACZ,CAAC;AAED,eAAeD,oBAAoB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["PasswordResetRequest"],"sources":["../../../src/components/PasswordResetRequest/index.js"],"sourcesContent":["import PasswordResetRequest from './PasswordResetRequest';\n\nexport default PasswordResetRequest;\n"],"mappings":"AAAA,OAAOA,oBAAoB,MAAM,wBAAwB;AAEzD,eAAeA,oBAAoB"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
|
|
4
|
-
const LoggedInMessage = ({ goToUrl, urlToUse }) => (
|
|
5
|
-
<span>
|
|
6
|
-
You are already logged in please{' '}
|
|
7
|
-
<a
|
|
8
|
-
onClick={e => {
|
|
9
|
-
e.preventDefault();
|
|
10
|
-
goToUrl(true);
|
|
11
|
-
}}
|
|
12
|
-
href={urlToUse}>
|
|
13
|
-
click here
|
|
14
|
-
</a>{' '}
|
|
15
|
-
to reload your content access
|
|
16
|
-
</span>
|
|
17
|
-
);
|
|
18
|
-
|
|
19
|
-
LoggedInMessage.propTypes = {
|
|
20
|
-
goToUrl: PropTypes.func.isRequired,
|
|
21
|
-
urlToUse: PropTypes.string.isRequired
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export default LoggedInMessage;
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import React, { useState } from 'react';
|
|
2
|
-
import { handleLogin, checkIfLoggedIn, LOGIN_MUTATION } from '@blaze-cms/core-auth-ui';
|
|
3
|
-
import PropTypes from 'prop-types';
|
|
4
|
-
import { useMutation } from '@apollo/client';
|
|
5
|
-
import { useRouter } from 'next/router';
|
|
6
|
-
import { parseUrl } from 'query-string';
|
|
7
|
-
import LoggedInMessage from './LoggedInMessage';
|
|
8
|
-
import LoginForm from './LoginForm';
|
|
9
|
-
import { checkGtmChildren, getUrlToUse } from './helpers';
|
|
10
|
-
import { GRAPH_QL_ERROR } from '../../constants';
|
|
11
|
-
|
|
12
|
-
function shouldShowAlreadyLoggedInMessage(called) {
|
|
13
|
-
const { isLoggedIn } = checkIfLoggedIn();
|
|
14
|
-
return !called && isLoggedIn;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const Login = ({ modifier, url, children }) => {
|
|
18
|
-
const router = useRouter();
|
|
19
|
-
const { asPath } = router;
|
|
20
|
-
const { query: { redirectUrl } = {} } = parseUrl(asPath);
|
|
21
|
-
|
|
22
|
-
const [isLoginDone, setIsLoginDone] = useState(false);
|
|
23
|
-
const [errorMessageToDisplay, setErrorMessage] = useState(null);
|
|
24
|
-
const urlToUse = getUrlToUse({ redirectUrl, url, asPath });
|
|
25
|
-
const goToUrl = reload => {
|
|
26
|
-
urlToUse === asPath && reload ? router.reload() : router.push('/Resolver', urlToUse);
|
|
27
|
-
};
|
|
28
|
-
const [hasOnSuccessChildren, updatedChildren] = checkGtmChildren(children, goToUrl);
|
|
29
|
-
|
|
30
|
-
const [loginMutation, { client, called }] = useMutation(LOGIN_MUTATION, {
|
|
31
|
-
update: (cache, { data }) => afterLogin(data),
|
|
32
|
-
onError: ({ message }) => {
|
|
33
|
-
const parsedMessage = message.replace(GRAPH_QL_ERROR, '');
|
|
34
|
-
setErrorMessage(parsedMessage);
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
const afterLogin = async data => {
|
|
39
|
-
if (!(await handleLogin(data, client))) return;
|
|
40
|
-
if (!hasOnSuccessChildren) goToUrl();
|
|
41
|
-
setIsLoginDone(true);
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
const showAlreadyLoggedInMessage = shouldShowAlreadyLoggedInMessage(called);
|
|
45
|
-
const shouldRenderForm = !showAlreadyLoggedInMessage && !isLoginDone;
|
|
46
|
-
|
|
47
|
-
return (
|
|
48
|
-
<>
|
|
49
|
-
{showAlreadyLoggedInMessage && <LoggedInMessage goToUrl={goToUrl} urlToUse={urlToUse} />}
|
|
50
|
-
{shouldRenderForm && (
|
|
51
|
-
<LoginForm
|
|
52
|
-
errorMessageToDisplay={errorMessageToDisplay}
|
|
53
|
-
loginMutation={loginMutation}
|
|
54
|
-
modifier={modifier}
|
|
55
|
-
/>
|
|
56
|
-
)}
|
|
57
|
-
{isLoginDone && updatedChildren}
|
|
58
|
-
</>
|
|
59
|
-
);
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
Login.propTypes = {
|
|
63
|
-
modifier: PropTypes.string,
|
|
64
|
-
url: PropTypes.string,
|
|
65
|
-
children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node])
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
Login.defaultProps = {
|
|
69
|
-
modifier: '',
|
|
70
|
-
url: '',
|
|
71
|
-
children: null
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
export default Login;
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import React, { useState } from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import Input from '@blaze-react/input';
|
|
4
|
-
import Button from '@blaze-react/button';
|
|
5
|
-
import { Checkbox } from '@blaze-react/checkboxes';
|
|
6
|
-
import { EMAIL, PASSWORD, LOGIN_FORM } from '../../constants';
|
|
7
|
-
|
|
8
|
-
const LoginForm = ({ errorMessageToDisplay, loginMutation, modifier }) => {
|
|
9
|
-
const [email, setEmail] = useState('');
|
|
10
|
-
const [password, setPassword] = useState('');
|
|
11
|
-
const [rememberMe, setRememberMe] = useState(false);
|
|
12
|
-
|
|
13
|
-
const handleChange = ({ event }) => {
|
|
14
|
-
const {
|
|
15
|
-
target: { name: iName, value: iValue }
|
|
16
|
-
} = event;
|
|
17
|
-
|
|
18
|
-
if (iName === EMAIL) setEmail(iValue);
|
|
19
|
-
if (iName === PASSWORD) setPassword(iValue);
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
const isDisabled = !email || !password;
|
|
23
|
-
|
|
24
|
-
return (
|
|
25
|
-
<>
|
|
26
|
-
<form
|
|
27
|
-
id={LOGIN_FORM}
|
|
28
|
-
className={modifier}
|
|
29
|
-
onSubmit={e => {
|
|
30
|
-
e.preventDefault();
|
|
31
|
-
if (isDisabled) return;
|
|
32
|
-
loginMutation({
|
|
33
|
-
variables: { input: { identity: email, password, rememberMe } }
|
|
34
|
-
});
|
|
35
|
-
}}>
|
|
36
|
-
<Input
|
|
37
|
-
key="email"
|
|
38
|
-
type="email"
|
|
39
|
-
name="email"
|
|
40
|
-
placeholder="example@email.com"
|
|
41
|
-
label="Email"
|
|
42
|
-
required
|
|
43
|
-
onChange={handleChange}
|
|
44
|
-
value={email}
|
|
45
|
-
/>
|
|
46
|
-
<Input
|
|
47
|
-
key="password"
|
|
48
|
-
type="password"
|
|
49
|
-
name="password"
|
|
50
|
-
label="Password"
|
|
51
|
-
required
|
|
52
|
-
onChange={handleChange}
|
|
53
|
-
value={password}
|
|
54
|
-
/>
|
|
55
|
-
<Checkbox
|
|
56
|
-
checked={rememberMe}
|
|
57
|
-
label="Remember Me"
|
|
58
|
-
name="rememberme"
|
|
59
|
-
id="remember-me"
|
|
60
|
-
onChange={({ value: { checked } }) => setRememberMe(checked)}
|
|
61
|
-
/>
|
|
62
|
-
{!!errorMessageToDisplay && <div className="error_message">{errorMessageToDisplay}</div>}
|
|
63
|
-
</form>
|
|
64
|
-
<Button type="submit" name="button" form={LOGIN_FORM} disabled={isDisabled}>
|
|
65
|
-
Login
|
|
66
|
-
</Button>
|
|
67
|
-
</>
|
|
68
|
-
);
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
LoginForm.propTypes = {
|
|
72
|
-
errorMessageToDisplay: PropTypes.string,
|
|
73
|
-
modifier: PropTypes.string.isRequired,
|
|
74
|
-
loginMutation: PropTypes.func.isRequired
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
LoginForm.defaultProps = {
|
|
78
|
-
errorMessageToDisplay: PropTypes.string.isRequired
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
export default LoginForm;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
const checkGtmChildren = (children, handleOnSuccess) => {
|
|
2
|
-
let hasOnSuccessChildren = false;
|
|
3
|
-
if (!children || Array.isArray(children)) return [hasOnSuccessChildren, children];
|
|
4
|
-
const {
|
|
5
|
-
props: {
|
|
6
|
-
children: [, allChildren]
|
|
7
|
-
}
|
|
8
|
-
} = children;
|
|
9
|
-
|
|
10
|
-
if (allChildren && allChildren.length) {
|
|
11
|
-
allChildren.forEach(({ props }) => {
|
|
12
|
-
let { component: { settings: { gtmEvents } } = {} } = props;
|
|
13
|
-
if (gtmEvents) {
|
|
14
|
-
gtmEvents = gtmEvents.map(gtmEvent => {
|
|
15
|
-
const updatedEvent = gtmEvent;
|
|
16
|
-
if (gtmEvent.eventTrigger === 'onSuccess') {
|
|
17
|
-
updatedEvent.handleOnSuccess = handleOnSuccess;
|
|
18
|
-
hasOnSuccessChildren = true;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
return updatedEvent;
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return [hasOnSuccessChildren, children];
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
export default checkGtmChildren;
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import React, { useState } from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import Input from '@blaze-react/input';
|
|
4
|
-
import Button from '@blaze-react/button';
|
|
5
|
-
import { useMutation } from '@apollo/client';
|
|
6
|
-
import { useRouter } from 'next/router';
|
|
7
|
-
import { parseUrl } from 'query-string';
|
|
8
|
-
import { RESET_USER_PASSWORD_MUTATION } from '@blaze-cms/core-auth-ui';
|
|
9
|
-
import { validatePassword } from './helpers';
|
|
10
|
-
import { withTitle } from '../../HOC';
|
|
11
|
-
import {
|
|
12
|
-
GRAPH_QL_ERROR,
|
|
13
|
-
PASSWORD_CONFIRM_MESSAGE,
|
|
14
|
-
PASSWORD_VALIDATION_MESSAGE
|
|
15
|
-
} from '../../constants';
|
|
16
|
-
import { hasChildren } from '../../helpers';
|
|
17
|
-
|
|
18
|
-
const PasswordReset = ({ children, modifier }) => {
|
|
19
|
-
const router = useRouter();
|
|
20
|
-
const { asPath } = router;
|
|
21
|
-
const { query: { token } = {} } = parseUrl(asPath);
|
|
22
|
-
const [displayChildren, setShouldDisplayChildren] = useState(false);
|
|
23
|
-
const [formValues, setFormValues] = useState({ password: '', passwordConfirm: '' });
|
|
24
|
-
const [validationErrors, setValidationErrors] = useState([]);
|
|
25
|
-
const [errorMessageToDisplay, setErrorMessage] = useState(null);
|
|
26
|
-
const { password, passwordConfirm } = formValues;
|
|
27
|
-
|
|
28
|
-
const [passwordResetMutation] = useMutation(RESET_USER_PASSWORD_MUTATION, {
|
|
29
|
-
onCompleted: ({ resetUserPasswordResult }) => {
|
|
30
|
-
const {
|
|
31
|
-
result: { extras }
|
|
32
|
-
} =
|
|
33
|
-
resetUserPasswordResult || {};
|
|
34
|
-
const { redirectUrl } = extras || {};
|
|
35
|
-
setShouldDisplayChildren(true);
|
|
36
|
-
setErrorMessage(null);
|
|
37
|
-
setValidationErrors([false, false]);
|
|
38
|
-
if (redirectUrl) {
|
|
39
|
-
router.push(`/Resolver`, `${asPath}&redirectUrl=${redirectUrl}`, { shallow: true });
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
onError: ({ message }) => {
|
|
43
|
-
const parsedMessage = message.replace(GRAPH_QL_ERROR, '');
|
|
44
|
-
setErrorMessage(parsedMessage);
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
const handleChange = ({ event }) => {
|
|
49
|
-
const {
|
|
50
|
-
target: { name: iName, value: iValue }
|
|
51
|
-
} = event;
|
|
52
|
-
|
|
53
|
-
if (iName === 'password') setFormValues({ ...formValues, password: iValue });
|
|
54
|
-
if (iName === 'passwordConfirm') setFormValues({ ...formValues, passwordConfirm: iValue });
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
const handleSubmit = e => {
|
|
58
|
-
e.preventDefault();
|
|
59
|
-
const isPasswordValid = validatePassword(password);
|
|
60
|
-
if (!isPasswordValid) return setValidationErrors([true, false]);
|
|
61
|
-
if (password !== passwordConfirm) return setValidationErrors([false, true]);
|
|
62
|
-
passwordResetMutation({
|
|
63
|
-
variables: { input: { token, password } }
|
|
64
|
-
});
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
const isDisabled = !passwordConfirm || !password;
|
|
68
|
-
const shouldDisplayChildren = displayChildren && hasChildren(children);
|
|
69
|
-
if (!token) return null;
|
|
70
|
-
|
|
71
|
-
return (
|
|
72
|
-
<div className={modifier}>
|
|
73
|
-
{!displayChildren && (
|
|
74
|
-
<form id="passwordReset" onSubmit={handleSubmit}>
|
|
75
|
-
<Input
|
|
76
|
-
id="password"
|
|
77
|
-
type="password"
|
|
78
|
-
name="password"
|
|
79
|
-
label="Password"
|
|
80
|
-
required
|
|
81
|
-
error={validationErrors[0]}
|
|
82
|
-
validationMessage={PASSWORD_VALIDATION_MESSAGE}
|
|
83
|
-
onChange={handleChange}
|
|
84
|
-
value={password}
|
|
85
|
-
/>
|
|
86
|
-
<Input
|
|
87
|
-
id="passwordConfirm"
|
|
88
|
-
type="password"
|
|
89
|
-
name="passwordConfirm"
|
|
90
|
-
label="Confirm New Password"
|
|
91
|
-
required
|
|
92
|
-
error={validationErrors[1]}
|
|
93
|
-
validationMessage={PASSWORD_CONFIRM_MESSAGE}
|
|
94
|
-
onChange={handleChange}
|
|
95
|
-
value={passwordConfirm}
|
|
96
|
-
/>
|
|
97
|
-
</form>
|
|
98
|
-
)}
|
|
99
|
-
{!displayChildren && (
|
|
100
|
-
<Button type="submit" name="button" form="passwordReset" disabled={isDisabled}>
|
|
101
|
-
Reset Password
|
|
102
|
-
</Button>
|
|
103
|
-
)}
|
|
104
|
-
{!!errorMessageToDisplay && <div className="error_message">{errorMessageToDisplay}</div>}
|
|
105
|
-
{shouldDisplayChildren && <div>{children}</div>}
|
|
106
|
-
</div>
|
|
107
|
-
);
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
PasswordReset.propTypes = {
|
|
111
|
-
modifier: PropTypes.string,
|
|
112
|
-
children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node])
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
PasswordReset.defaultProps = {
|
|
116
|
-
modifier: '',
|
|
117
|
-
children: null
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
export default withTitle(PasswordReset);
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import React, { useState } from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import Input from '@blaze-react/input';
|
|
4
|
-
import Button from '@blaze-react/button';
|
|
5
|
-
import { useMutation } from '@apollo/client';
|
|
6
|
-
import { useRouter } from 'next/router';
|
|
7
|
-
import { checkIfLoggedIn, REQUEST_USER_PASSWORD_RESET_MUTATION } from '@blaze-cms/core-auth-ui';
|
|
8
|
-
import { GRAPH_QL_ERROR } from '../../constants';
|
|
9
|
-
import { hasChildren } from '../../helpers';
|
|
10
|
-
|
|
11
|
-
const PasswordResetRequest = ({ children, modifier }) => {
|
|
12
|
-
const { id: userId } = checkIfLoggedIn();
|
|
13
|
-
const router = useRouter();
|
|
14
|
-
const { asPath } = router;
|
|
15
|
-
const [displayChildren, setShouldDisplayChildren] = useState(false);
|
|
16
|
-
const [errorMessageToDisplay, setErrorMessage] = useState(null);
|
|
17
|
-
const [email, setEmail] = useState('');
|
|
18
|
-
|
|
19
|
-
const [requestUserPasswordResetMutation] = useMutation(REQUEST_USER_PASSWORD_RESET_MUTATION, {
|
|
20
|
-
onCompleted: () => {
|
|
21
|
-
setShouldDisplayChildren(true);
|
|
22
|
-
setErrorMessage(null);
|
|
23
|
-
},
|
|
24
|
-
onError: ({ message }) => {
|
|
25
|
-
const parsedMessage = message.replace(GRAPH_QL_ERROR, '');
|
|
26
|
-
setErrorMessage(parsedMessage);
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
const isDisabled = !email;
|
|
31
|
-
const displayValidChildren = displayChildren && hasChildren(children);
|
|
32
|
-
|
|
33
|
-
return (
|
|
34
|
-
<div className={modifier}>
|
|
35
|
-
{!displayChildren && (
|
|
36
|
-
<form
|
|
37
|
-
id="passwordResetRequest"
|
|
38
|
-
onSubmit={e => {
|
|
39
|
-
e.preventDefault();
|
|
40
|
-
if (isDisabled) return;
|
|
41
|
-
requestUserPasswordResetMutation({
|
|
42
|
-
variables: { input: { email, userId, extras: { redirectUrl: asPath } } }
|
|
43
|
-
});
|
|
44
|
-
}}>
|
|
45
|
-
<Input
|
|
46
|
-
key="email"
|
|
47
|
-
type="email"
|
|
48
|
-
name="email"
|
|
49
|
-
label="Email"
|
|
50
|
-
required
|
|
51
|
-
onChange={({ event }) => {
|
|
52
|
-
const {
|
|
53
|
-
target: { value }
|
|
54
|
-
} = event;
|
|
55
|
-
setEmail(value);
|
|
56
|
-
}}
|
|
57
|
-
value={email}
|
|
58
|
-
/>
|
|
59
|
-
</form>
|
|
60
|
-
)}
|
|
61
|
-
{!displayChildren && (
|
|
62
|
-
<Button type="submit" name="button" form="passwordResetRequest" disabled={isDisabled}>
|
|
63
|
-
Request Password Reset
|
|
64
|
-
</Button>
|
|
65
|
-
)}
|
|
66
|
-
{!!errorMessageToDisplay && <div className="error_message">{errorMessageToDisplay}</div>}
|
|
67
|
-
{displayValidChildren && <div>{children}</div>}
|
|
68
|
-
</div>
|
|
69
|
-
);
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
PasswordResetRequest.propTypes = {
|
|
73
|
-
modifier: PropTypes.string,
|
|
74
|
-
children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node])
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
PasswordResetRequest.defaultProps = {
|
|
78
|
-
modifier: '',
|
|
79
|
-
children: null
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
export default PasswordResetRequest;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { render } from '@blaze-cms/tools/test-helpers/test-functions';
|
|
2
|
-
import '@testing-library/jest-dom/extend-expect';
|
|
3
|
-
import Login from '../../../../../src/components/Login';
|
|
4
|
-
|
|
5
|
-
jest.mock('@blaze-cms/core-auth-ui', () => ({
|
|
6
|
-
checkIfLoggedIn: jest
|
|
7
|
-
.fn()
|
|
8
|
-
.mockImplementationOnce(() => ({ isLoggedIn: false }))
|
|
9
|
-
.mockImplementationOnce(() => ({ isLoggedIn: true }))
|
|
10
|
-
}));
|
|
11
|
-
|
|
12
|
-
jest.mock('@apollo/client', () => ({
|
|
13
|
-
...jest.requireActual('@apollo/client'),
|
|
14
|
-
useMutation: jest.fn(() => [variables => variables, { client: { resetStore: null } }])
|
|
15
|
-
}));
|
|
16
|
-
|
|
17
|
-
jest.mock('next/router', () => ({
|
|
18
|
-
useRouter: jest.fn().mockImplementation(() => ({
|
|
19
|
-
asPath: ''
|
|
20
|
-
}))
|
|
21
|
-
}));
|
|
22
|
-
|
|
23
|
-
const props = {};
|
|
24
|
-
|
|
25
|
-
describe('Login component', () => {
|
|
26
|
-
it('should render without throwing an error and match snapshot', () => {
|
|
27
|
-
const { asFragment } = render(Login, props);
|
|
28
|
-
expect(asFragment()).toMatchSnapshot();
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it('should render rederict link if logged in', () => {
|
|
32
|
-
const { asFragment, container } = render(Login, props);
|
|
33
|
-
expect(asFragment()).toMatchSnapshot();
|
|
34
|
-
expect(container.firstChild).toContainHTML('span');
|
|
35
|
-
});
|
|
36
|
-
});
|