gatsby-theme-q3 4.5.17 → 4.5.21
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/.eslintrc.js +12 -12
- package/CHANGELOG.md +1216 -1200
- package/LICENSE +21 -21
- package/__fixtures__/en/titles.json +2 -2
- package/__fixtures__/fr/titles.json +2 -2
- package/gatsby-browser.js +38 -38
- package/gatsby-config.js +62 -62
- package/gatsby-node.js +77 -77
- package/gatsby-ssr.js +11 -11
- package/index.js +1 -1
- package/lib/components/AccountPublicGateway.js +2 -3
- package/lib/components/AdminLoader.js +2 -3
- package/lib/components/AdminPrivateGateway.js +3 -4
- package/lib/components/AdminPublicGateway.js +3 -4
- package/lib/components/AdminRouter.js +3 -4
- package/lib/components/BlogArchiveTemplate.js +2 -3
- package/lib/components/BlogTemplate.js +2 -3
- package/lib/components/FormBox.js +2 -3
- package/lib/components/FormBoxContent.js +2 -3
- package/lib/components/FormBoxNotice.js +2 -3
- package/lib/components/IsBrowserReady.js +2 -3
- package/lib/components/PageWrapper.js +2 -3
- package/lib/components/PublicTemplate.js +2 -3
- package/lib/components/Redirect.js +2 -3
- package/lib/components/RedirectToIndex.js +2 -3
- package/lib/components/RichText.js +2 -3
- package/lib/components/SearchEngine.js +4 -7
- package/lib/components/ShareButton.js +2 -3
- package/lib/components/Wrapper.js +2 -3
- package/lib/components/__tests__/useSiteMetaData.test.js +44 -44
- package/lib/components/__tests__/withAuthenticate.test.js +2 -2
- package/lib/components/__tests__/withSuccessOp.test.js +4 -4
- package/lib/components/index.js +2 -3
- package/lib/components/useSiteMetaData.js +1 -1
- package/lib/components/utils.js +2 -3
- package/lib/components/withAuthenticate.js +2 -2
- package/lib/components/withPublicTemplate.js +2 -3
- package/lib/components/withSuccessOp.js +3 -4
- package/lib/pages/404.js +2 -3
- package/lib/pages/login.js +2 -3
- package/lib/pages/password-change.js +2 -3
- package/lib/pages/password-reset.js +2 -3
- package/lib/pages/reverify.js +2 -3
- package/lib/pages/verify.js +2 -3
- package/package.json +5 -5
- package/src/components/AccountPublicGateway.jsx +18 -18
- package/src/components/AdminLoader.jsx +16 -16
- package/src/components/AdminPrivateGateway.jsx +37 -37
- package/src/components/AdminPublicGateway.jsx +34 -34
- package/src/components/AdminRouter.jsx +44 -44
- package/src/components/BlogArchiveTemplate.jsx +55 -55
- package/src/components/BlogTemplate.jsx +104 -104
- package/src/components/FormBox.jsx +22 -22
- package/src/components/FormBoxContent.jsx +26 -26
- package/src/components/FormBoxNotice.jsx +21 -21
- package/src/components/IsBrowserReady.jsx +13 -13
- package/src/components/PageWrapper.jsx +20 -20
- package/src/components/PublicTemplate.jsx +198 -198
- package/src/components/Redirect.jsx +13 -13
- package/src/components/RedirectToIndex.jsx +9 -9
- package/src/components/RichText.jsx +196 -196
- package/src/components/SearchEngine.jsx +124 -124
- package/src/components/ShareButton.jsx +80 -80
- package/src/components/Wrapper.jsx +14 -14
- package/src/components/__tests__/SearchEngine.test.jsx +58 -58
- package/src/components/__tests__/useSiteMetaData.test.js +44 -44
- package/src/components/__tests__/withAuthenticate.test.jsx +52 -52
- package/src/components/__tests__/withSuccessOp.test.jsx +57 -57
- package/src/components/index.js +16 -16
- package/src/components/useSiteMetaData.js +35 -35
- package/src/components/utils.js +23 -23
- package/src/components/withAuthenticate.jsx +20 -20
- package/src/components/withPublicTemplate.jsx +11 -11
- package/src/components/withSuccessOp.jsx +43 -43
- package/src/pages/404.jsx +31 -31
- package/src/pages/login.jsx +71 -71
- package/src/pages/password-change.jsx +72 -72
- package/src/pages/password-reset.jsx +47 -47
- package/src/pages/reverify.jsx +72 -72
- package/src/pages/verify.jsx +70 -70
@@ -1,35 +1,35 @@
|
|
1
|
-
import { get, merge, isObject, isNil } from 'lodash';
|
2
|
-
import { useStaticQuery, graphql } from 'gatsby';
|
3
|
-
import useRunTime from 'gatsby-theme-q3-mui/src/components/useRunTime';
|
4
|
-
|
5
|
-
export default (defaultValues = {}) => {
|
6
|
-
const output = merge(
|
7
|
-
get(
|
8
|
-
useStaticQuery(graphql`
|
9
|
-
query {
|
10
|
-
site {
|
11
|
-
siteMetadata {
|
12
|
-
appDirectory
|
13
|
-
description
|
14
|
-
title
|
15
|
-
}
|
16
|
-
}
|
17
|
-
}
|
18
|
-
`),
|
19
|
-
'site.siteMetadata',
|
20
|
-
{},
|
21
|
-
),
|
22
|
-
useRunTime(),
|
23
|
-
);
|
24
|
-
|
25
|
-
if (isObject(output) && isObject(defaultValues))
|
26
|
-
Object.entries(defaultValues).forEach(
|
27
|
-
([key, value]) => {
|
28
|
-
if (isNil(output[key])) {
|
29
|
-
output[key] = value;
|
30
|
-
}
|
31
|
-
},
|
32
|
-
);
|
33
|
-
|
34
|
-
return output;
|
35
|
-
};
|
1
|
+
import { get, merge, isObject, isNil } from 'lodash';
|
2
|
+
import { useStaticQuery, graphql } from 'gatsby';
|
3
|
+
import useRunTime from 'gatsby-theme-q3-mui/src/components/useRunTime';
|
4
|
+
|
5
|
+
export default (defaultValues = {}) => {
|
6
|
+
const output = merge(
|
7
|
+
get(
|
8
|
+
useStaticQuery(graphql`
|
9
|
+
query {
|
10
|
+
site {
|
11
|
+
siteMetadata {
|
12
|
+
appDirectory
|
13
|
+
description
|
14
|
+
title
|
15
|
+
}
|
16
|
+
}
|
17
|
+
}
|
18
|
+
`),
|
19
|
+
'site.siteMetadata',
|
20
|
+
{},
|
21
|
+
),
|
22
|
+
useRunTime(),
|
23
|
+
);
|
24
|
+
|
25
|
+
if (isObject(output) && isObject(defaultValues))
|
26
|
+
Object.entries(defaultValues).forEach(
|
27
|
+
([key, value]) => {
|
28
|
+
if (isNil(output[key])) {
|
29
|
+
output[key] = value;
|
30
|
+
}
|
31
|
+
},
|
32
|
+
);
|
33
|
+
|
34
|
+
return output;
|
35
|
+
};
|
package/src/components/utils.js
CHANGED
@@ -1,23 +1,23 @@
|
|
1
|
-
import axios from 'axios';
|
2
|
-
import { navigate } from 'gatsby';
|
3
|
-
import { setSession } from 'q3-ui-permissions';
|
4
|
-
|
5
|
-
export const OP = '?op=success';
|
6
|
-
|
7
|
-
export const authenticate = (
|
8
|
-
credentials,
|
9
|
-
redirectPath = '/',
|
10
|
-
) =>
|
11
|
-
axios
|
12
|
-
.post('/authenticate', credentials)
|
13
|
-
.then(({ data }) => {
|
14
|
-
setSession(data);
|
15
|
-
window.location.replace(redirectPath);
|
16
|
-
return data;
|
17
|
-
});
|
18
|
-
|
19
|
-
export const hasOp = (search) =>
|
20
|
-
search && search.includes(OP);
|
21
|
-
|
22
|
-
export const toOp = (pathname) => () =>
|
23
|
-
navigate(`${pathname}${OP}`);
|
1
|
+
import axios from 'axios';
|
2
|
+
import { navigate } from 'gatsby';
|
3
|
+
import { setSession } from 'q3-ui-permissions';
|
4
|
+
|
5
|
+
export const OP = '?op=success';
|
6
|
+
|
7
|
+
export const authenticate = (
|
8
|
+
credentials,
|
9
|
+
redirectPath = '/',
|
10
|
+
) =>
|
11
|
+
axios
|
12
|
+
.post('/authenticate', credentials)
|
13
|
+
.then(({ data }) => {
|
14
|
+
setSession(data);
|
15
|
+
window.location.replace(redirectPath);
|
16
|
+
return data;
|
17
|
+
});
|
18
|
+
|
19
|
+
export const hasOp = (search) =>
|
20
|
+
search && search.includes(OP);
|
21
|
+
|
22
|
+
export const toOp = (pathname) => () =>
|
23
|
+
navigate(`${pathname}${OP}`);
|
@@ -1,20 +1,20 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
import { useLocation } from '@reach/router';
|
3
|
-
import useSiteMetaData from './useSiteMetaData';
|
4
|
-
import { authenticate } from './utils';
|
5
|
-
|
6
|
-
export default (Component) => (props) => {
|
7
|
-
const { appDirectory } = useSiteMetaData();
|
8
|
-
|
9
|
-
const redirectionPath =
|
10
|
-
useLocation()?.state?.gatekeeper || appDirectory;
|
11
|
-
|
12
|
-
return (
|
13
|
-
<Component
|
14
|
-
{...props}
|
15
|
-
authenticate={(formValues) =>
|
16
|
-
authenticate(formValues, redirectionPath)
|
17
|
-
}
|
18
|
-
/>
|
19
|
-
);
|
20
|
-
};
|
1
|
+
import React from 'react';
|
2
|
+
import { useLocation } from '@reach/router';
|
3
|
+
import useSiteMetaData from './useSiteMetaData';
|
4
|
+
import { authenticate } from './utils';
|
5
|
+
|
6
|
+
export default (Component) => (props) => {
|
7
|
+
const { appDirectory } = useSiteMetaData();
|
8
|
+
|
9
|
+
const redirectionPath =
|
10
|
+
useLocation()?.state?.gatekeeper || appDirectory;
|
11
|
+
|
12
|
+
return (
|
13
|
+
<Component
|
14
|
+
{...props}
|
15
|
+
authenticate={(formValues) =>
|
16
|
+
authenticate(formValues, redirectionPath)
|
17
|
+
}
|
18
|
+
/>
|
19
|
+
);
|
20
|
+
};
|
@@ -1,11 +1,11 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
import PublicTemplate from './PublicTemplate';
|
3
|
-
|
4
|
-
const withPublicTemplate = (Component) => (props) =>
|
5
|
-
(
|
6
|
-
<PublicTemplate {...props}>
|
7
|
-
<Component {...props} />
|
8
|
-
</PublicTemplate>
|
9
|
-
);
|
10
|
-
|
11
|
-
export default withPublicTemplate;
|
1
|
+
import React from 'react';
|
2
|
+
import PublicTemplate from './PublicTemplate';
|
3
|
+
|
4
|
+
const withPublicTemplate = (Component) => (props) =>
|
5
|
+
(
|
6
|
+
<PublicTemplate {...props}>
|
7
|
+
<Component {...props} />
|
8
|
+
</PublicTemplate>
|
9
|
+
);
|
10
|
+
|
11
|
+
export default withPublicTemplate;
|
@@ -1,43 +1,43 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
import { useTranslation } from 'q3-ui-locale';
|
3
|
-
import PropTypes from 'prop-types';
|
4
|
-
import { Link } from 'gatsby';
|
5
|
-
import Button from '@material-ui/core/Button';
|
6
|
-
import FormBoxNotice from './FormBoxNotice';
|
7
|
-
import { hasOp, toOp } from './utils';
|
8
|
-
|
9
|
-
const withSuccessOp = (Component, msg) => {
|
10
|
-
const SuccessOpMessage = (props) => {
|
11
|
-
const {
|
12
|
-
location: { search, pathname },
|
13
|
-
} = props;
|
14
|
-
|
15
|
-
const { t } = useTranslation();
|
16
|
-
|
17
|
-
return hasOp(search) ? (
|
18
|
-
<FormBoxNotice title={msg} description={msg}>
|
19
|
-
<Button
|
20
|
-
component={Link}
|
21
|
-
to="/login"
|
22
|
-
variant="contained"
|
23
|
-
color="secondary"
|
24
|
-
>
|
25
|
-
{t('labels:login')}
|
26
|
-
</Button>
|
27
|
-
</FormBoxNotice>
|
28
|
-
) : (
|
29
|
-
<Component {...props} onSuccess={toOp(pathname)} />
|
30
|
-
);
|
31
|
-
};
|
32
|
-
|
33
|
-
SuccessOpMessage.propTypes = {
|
34
|
-
location: PropTypes.shape({
|
35
|
-
search: PropTypes.string,
|
36
|
-
pathname: PropTypes.string,
|
37
|
-
}).isRequired,
|
38
|
-
};
|
39
|
-
|
40
|
-
return SuccessOpMessage;
|
41
|
-
};
|
42
|
-
|
43
|
-
export default withSuccessOp;
|
1
|
+
import React from 'react';
|
2
|
+
import { useTranslation } from 'q3-ui-locale';
|
3
|
+
import PropTypes from 'prop-types';
|
4
|
+
import { Link } from 'gatsby';
|
5
|
+
import Button from '@material-ui/core/Button';
|
6
|
+
import FormBoxNotice from './FormBoxNotice';
|
7
|
+
import { hasOp, toOp } from './utils';
|
8
|
+
|
9
|
+
const withSuccessOp = (Component, msg) => {
|
10
|
+
const SuccessOpMessage = (props) => {
|
11
|
+
const {
|
12
|
+
location: { search, pathname },
|
13
|
+
} = props;
|
14
|
+
|
15
|
+
const { t } = useTranslation();
|
16
|
+
|
17
|
+
return hasOp(search) ? (
|
18
|
+
<FormBoxNotice title={msg} description={msg}>
|
19
|
+
<Button
|
20
|
+
component={Link}
|
21
|
+
to="/login"
|
22
|
+
variant="contained"
|
23
|
+
color="secondary"
|
24
|
+
>
|
25
|
+
{t('labels:login')}
|
26
|
+
</Button>
|
27
|
+
</FormBoxNotice>
|
28
|
+
) : (
|
29
|
+
<Component {...props} onSuccess={toOp(pathname)} />
|
30
|
+
);
|
31
|
+
};
|
32
|
+
|
33
|
+
SuccessOpMessage.propTypes = {
|
34
|
+
location: PropTypes.shape({
|
35
|
+
search: PropTypes.string,
|
36
|
+
pathname: PropTypes.string,
|
37
|
+
}).isRequired,
|
38
|
+
};
|
39
|
+
|
40
|
+
return SuccessOpMessage;
|
41
|
+
};
|
42
|
+
|
43
|
+
export default withSuccessOp;
|
package/src/pages/404.jsx
CHANGED
@@ -1,31 +1,31 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
import Graphic from 'q3-ui-assets';
|
3
|
-
import Box from '@material-ui/core/Box';
|
4
|
-
import Button from '@material-ui/core/Button';
|
5
|
-
import Wrapper from 'q3-ui/lib/wrapper';
|
6
|
-
import { Link } from 'gatsby';
|
7
|
-
|
8
|
-
const NotFound = () => (
|
9
|
-
<Wrapper backgroundColor="transparent">
|
10
|
-
<Graphic
|
11
|
-
h1
|
12
|
-
title="missing"
|
13
|
-
icon="Missing"
|
14
|
-
renderBottom={() => (
|
15
|
-
<Box mt={1}>
|
16
|
-
<Button
|
17
|
-
component={Link}
|
18
|
-
to="/"
|
19
|
-
variant="contained"
|
20
|
-
color="secondary"
|
21
|
-
size="large"
|
22
|
-
>
|
23
|
-
Go home
|
24
|
-
</Button>
|
25
|
-
</Box>
|
26
|
-
)}
|
27
|
-
/>
|
28
|
-
</Wrapper>
|
29
|
-
);
|
30
|
-
|
31
|
-
export default NotFound;
|
1
|
+
import React from 'react';
|
2
|
+
import Graphic from 'q3-ui-assets';
|
3
|
+
import Box from '@material-ui/core/Box';
|
4
|
+
import Button from '@material-ui/core/Button';
|
5
|
+
import Wrapper from 'q3-ui/lib/wrapper';
|
6
|
+
import { Link } from 'gatsby';
|
7
|
+
|
8
|
+
const NotFound = () => (
|
9
|
+
<Wrapper backgroundColor="transparent">
|
10
|
+
<Graphic
|
11
|
+
h1
|
12
|
+
title="missing"
|
13
|
+
icon="Missing"
|
14
|
+
renderBottom={() => (
|
15
|
+
<Box mt={1}>
|
16
|
+
<Button
|
17
|
+
component={Link}
|
18
|
+
to="/"
|
19
|
+
variant="contained"
|
20
|
+
color="secondary"
|
21
|
+
size="large"
|
22
|
+
>
|
23
|
+
Go home
|
24
|
+
</Button>
|
25
|
+
</Box>
|
26
|
+
)}
|
27
|
+
/>
|
28
|
+
</Wrapper>
|
29
|
+
);
|
30
|
+
|
31
|
+
export default NotFound;
|
package/src/pages/login.jsx
CHANGED
@@ -1,71 +1,71 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
import { Link } from 'gatsby';
|
3
|
-
import MuiLink from '@material-ui/core/Button';
|
4
|
-
import { useTranslation } from 'q3-ui-locale';
|
5
|
-
import Typography from '@material-ui/core/Typography';
|
6
|
-
import Divider from '@material-ui/core/Divider';
|
7
|
-
import Grid from '@material-ui/core/Grid';
|
8
|
-
import Box from '@material-ui/core/Box';
|
9
|
-
import { Form, Field } from 'q3-ui-forms/lib/builders';
|
10
|
-
import FormBox from '../components/FormBox';
|
11
|
-
import withAuthenticate from '../components/withAuthenticate';
|
12
|
-
import withPublicTemplate from '../components/withPublicTemplate';
|
13
|
-
|
14
|
-
const Login = withPublicTemplate(
|
15
|
-
withAuthenticate(({ authenticate }) => {
|
16
|
-
const { t } = useTranslation();
|
17
|
-
|
18
|
-
return (
|
19
|
-
<FormBox
|
20
|
-
renderBottom={
|
21
|
-
<>
|
22
|
-
<Form
|
23
|
-
submitLabel="login"
|
24
|
-
onSubmit={authenticate}
|
25
|
-
>
|
26
|
-
<Field
|
27
|
-
name="email"
|
28
|
-
type="email"
|
29
|
-
required
|
30
|
-
xl={12}
|
31
|
-
lg={12}
|
32
|
-
/>
|
33
|
-
<Field
|
34
|
-
required
|
35
|
-
name="password"
|
36
|
-
type="password"
|
37
|
-
xl={12}
|
38
|
-
lg={12}
|
39
|
-
/>
|
40
|
-
</Form>
|
41
|
-
<Box mt={2} mb={1}>
|
42
|
-
<Divider />
|
43
|
-
</Box>
|
44
|
-
<Grid container spacing={1}>
|
45
|
-
<MuiLink
|
46
|
-
component={Link}
|
47
|
-
to="/password-reset"
|
48
|
-
>
|
49
|
-
{t('labels:requestNewPassword')}
|
50
|
-
</MuiLink>
|
51
|
-
<MuiLink component={Link} to="/reverify">
|
52
|
-
{t('labels:reverifyLink')}
|
53
|
-
</MuiLink>
|
54
|
-
</Grid>
|
55
|
-
</>
|
56
|
-
}
|
57
|
-
renderTop={
|
58
|
-
<Typography
|
59
|
-
component="h1"
|
60
|
-
variant="h2"
|
61
|
-
gutterBottom
|
62
|
-
>
|
63
|
-
{t('titles:login')}
|
64
|
-
</Typography>
|
65
|
-
}
|
66
|
-
/>
|
67
|
-
);
|
68
|
-
}),
|
69
|
-
);
|
70
|
-
|
71
|
-
export default Login;
|
1
|
+
import React from 'react';
|
2
|
+
import { Link } from 'gatsby';
|
3
|
+
import MuiLink from '@material-ui/core/Button';
|
4
|
+
import { useTranslation } from 'q3-ui-locale';
|
5
|
+
import Typography from '@material-ui/core/Typography';
|
6
|
+
import Divider from '@material-ui/core/Divider';
|
7
|
+
import Grid from '@material-ui/core/Grid';
|
8
|
+
import Box from '@material-ui/core/Box';
|
9
|
+
import { Form, Field } from 'q3-ui-forms/lib/builders';
|
10
|
+
import FormBox from '../components/FormBox';
|
11
|
+
import withAuthenticate from '../components/withAuthenticate';
|
12
|
+
import withPublicTemplate from '../components/withPublicTemplate';
|
13
|
+
|
14
|
+
const Login = withPublicTemplate(
|
15
|
+
withAuthenticate(({ authenticate }) => {
|
16
|
+
const { t } = useTranslation();
|
17
|
+
|
18
|
+
return (
|
19
|
+
<FormBox
|
20
|
+
renderBottom={
|
21
|
+
<>
|
22
|
+
<Form
|
23
|
+
submitLabel="login"
|
24
|
+
onSubmit={authenticate}
|
25
|
+
>
|
26
|
+
<Field
|
27
|
+
name="email"
|
28
|
+
type="email"
|
29
|
+
required
|
30
|
+
xl={12}
|
31
|
+
lg={12}
|
32
|
+
/>
|
33
|
+
<Field
|
34
|
+
required
|
35
|
+
name="password"
|
36
|
+
type="password"
|
37
|
+
xl={12}
|
38
|
+
lg={12}
|
39
|
+
/>
|
40
|
+
</Form>
|
41
|
+
<Box mt={2} mb={1}>
|
42
|
+
<Divider />
|
43
|
+
</Box>
|
44
|
+
<Grid container spacing={1}>
|
45
|
+
<MuiLink
|
46
|
+
component={Link}
|
47
|
+
to="/password-reset"
|
48
|
+
>
|
49
|
+
{t('labels:requestNewPassword')}
|
50
|
+
</MuiLink>
|
51
|
+
<MuiLink component={Link} to="/reverify">
|
52
|
+
{t('labels:reverifyLink')}
|
53
|
+
</MuiLink>
|
54
|
+
</Grid>
|
55
|
+
</>
|
56
|
+
}
|
57
|
+
renderTop={
|
58
|
+
<Typography
|
59
|
+
component="h1"
|
60
|
+
variant="h2"
|
61
|
+
gutterBottom
|
62
|
+
>
|
63
|
+
{t('titles:login')}
|
64
|
+
</Typography>
|
65
|
+
}
|
66
|
+
/>
|
67
|
+
);
|
68
|
+
}),
|
69
|
+
);
|
70
|
+
|
71
|
+
export default Login;
|
@@ -1,72 +1,72 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
import PropTypes from 'prop-types';
|
3
|
-
import queryString from 'query-string';
|
4
|
-
import { get } from 'lodash';
|
5
|
-
import axios from 'axios';
|
6
|
-
import { NewPasswordFields } from 'q3-ui-forms/lib/presets';
|
7
|
-
import { Form, Field } from 'q3-ui-forms/lib/builders';
|
8
|
-
import FormBoxContent from '../components/FormBoxContent';
|
9
|
-
import FormBox from '../components/FormBox';
|
10
|
-
import withSuccessOp from '../components/withSuccessOp';
|
11
|
-
import withPublicTemplate from '../components/withPublicTemplate';
|
12
|
-
|
13
|
-
const PasswordChange = ({ onSuccess, location }) => {
|
14
|
-
const { passwordResetToken, email } = queryString.parse(
|
15
|
-
get(location, 'search', ''),
|
16
|
-
{
|
17
|
-
decode: false,
|
18
|
-
},
|
19
|
-
);
|
20
|
-
|
21
|
-
return (
|
22
|
-
<FormBox
|
23
|
-
renderBottom={
|
24
|
-
<Form
|
25
|
-
onSubmit={(passwords) =>
|
26
|
-
axios
|
27
|
-
.post('/password-change', passwords)
|
28
|
-
.then(onSuccess)
|
29
|
-
}
|
30
|
-
initialValues={{
|
31
|
-
passwordResetToken,
|
32
|
-
email,
|
33
|
-
}}
|
34
|
-
>
|
35
|
-
{(values) => (
|
36
|
-
<>
|
37
|
-
{!passwordResetToken && (
|
38
|
-
<Field
|
39
|
-
name="previousPassword"
|
40
|
-
type="password"
|
41
|
-
required
|
42
|
-
xl={12}
|
43
|
-
lg={12}
|
44
|
-
/>
|
45
|
-
)}
|
46
|
-
<NewPasswordFields {...values} />
|
47
|
-
</>
|
48
|
-
)}
|
49
|
-
</Form>
|
50
|
-
}
|
51
|
-
renderTop={
|
52
|
-
<FormBoxContent
|
53
|
-
title="passwordChange"
|
54
|
-
description="passwordChange"
|
55
|
-
/>
|
56
|
-
}
|
57
|
-
/>
|
58
|
-
);
|
59
|
-
};
|
60
|
-
|
61
|
-
PasswordChange.propTypes = {
|
62
|
-
onSuccess: PropTypes.func.isRequired,
|
63
|
-
location: PropTypes.shape({
|
64
|
-
search: PropTypes.string,
|
65
|
-
}).isRequired,
|
66
|
-
};
|
67
|
-
|
68
|
-
const PasswordChangeWithTemplate = withPublicTemplate(
|
69
|
-
withSuccessOp(PasswordChange, 'passwordChangeNotice'),
|
70
|
-
);
|
71
|
-
|
72
|
-
export default PasswordChangeWithTemplate;
|
1
|
+
import React from 'react';
|
2
|
+
import PropTypes from 'prop-types';
|
3
|
+
import queryString from 'query-string';
|
4
|
+
import { get } from 'lodash';
|
5
|
+
import axios from 'axios';
|
6
|
+
import { NewPasswordFields } from 'q3-ui-forms/lib/presets';
|
7
|
+
import { Form, Field } from 'q3-ui-forms/lib/builders';
|
8
|
+
import FormBoxContent from '../components/FormBoxContent';
|
9
|
+
import FormBox from '../components/FormBox';
|
10
|
+
import withSuccessOp from '../components/withSuccessOp';
|
11
|
+
import withPublicTemplate from '../components/withPublicTemplate';
|
12
|
+
|
13
|
+
const PasswordChange = ({ onSuccess, location }) => {
|
14
|
+
const { passwordResetToken, email } = queryString.parse(
|
15
|
+
get(location, 'search', ''),
|
16
|
+
{
|
17
|
+
decode: false,
|
18
|
+
},
|
19
|
+
);
|
20
|
+
|
21
|
+
return (
|
22
|
+
<FormBox
|
23
|
+
renderBottom={
|
24
|
+
<Form
|
25
|
+
onSubmit={(passwords) =>
|
26
|
+
axios
|
27
|
+
.post('/password-change', passwords)
|
28
|
+
.then(onSuccess)
|
29
|
+
}
|
30
|
+
initialValues={{
|
31
|
+
passwordResetToken,
|
32
|
+
email,
|
33
|
+
}}
|
34
|
+
>
|
35
|
+
{(values) => (
|
36
|
+
<>
|
37
|
+
{!passwordResetToken && (
|
38
|
+
<Field
|
39
|
+
name="previousPassword"
|
40
|
+
type="password"
|
41
|
+
required
|
42
|
+
xl={12}
|
43
|
+
lg={12}
|
44
|
+
/>
|
45
|
+
)}
|
46
|
+
<NewPasswordFields {...values} />
|
47
|
+
</>
|
48
|
+
)}
|
49
|
+
</Form>
|
50
|
+
}
|
51
|
+
renderTop={
|
52
|
+
<FormBoxContent
|
53
|
+
title="passwordChange"
|
54
|
+
description="passwordChange"
|
55
|
+
/>
|
56
|
+
}
|
57
|
+
/>
|
58
|
+
);
|
59
|
+
};
|
60
|
+
|
61
|
+
PasswordChange.propTypes = {
|
62
|
+
onSuccess: PropTypes.func.isRequired,
|
63
|
+
location: PropTypes.shape({
|
64
|
+
search: PropTypes.string,
|
65
|
+
}).isRequired,
|
66
|
+
};
|
67
|
+
|
68
|
+
const PasswordChangeWithTemplate = withPublicTemplate(
|
69
|
+
withSuccessOp(PasswordChange, 'passwordChangeNotice'),
|
70
|
+
);
|
71
|
+
|
72
|
+
export default PasswordChangeWithTemplate;
|