@applica-software-guru/react-admin 1.5.327 → 1.5.330
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/dist/ApplicaAdmin.d.ts +9 -1
- package/dist/ApplicaAdmin.d.ts.map +1 -1
- package/dist/components/ra-buttons/DeleteWithConfirmButton.d.ts +8 -0
- package/dist/components/ra-buttons/DeleteWithConfirmButton.d.ts.map +1 -1
- package/dist/components/ra-buttons/GoogleLoginButton.d.ts +6 -0
- package/dist/components/ra-buttons/GoogleLoginButton.d.ts.map +1 -0
- package/dist/components/ra-buttons/index.d.ts +1 -0
- package/dist/components/ra-buttons/index.d.ts.map +1 -1
- package/dist/components/ra-forms/TableForm/TableFormIterator.d.ts.map +1 -1
- package/dist/components/ra-forms/TableForm/TableFormIteratorItem.d.ts.map +1 -1
- package/dist/components/ra-pages/LoginPage.d.ts +9 -1
- package/dist/components/ra-pages/LoginPage.d.ts.map +1 -1
- package/dist/react-admin.cjs.js +82 -69
- package/dist/react-admin.cjs.js.gz +0 -0
- package/dist/react-admin.cjs.js.map +1 -1
- package/dist/react-admin.es.js +18516 -14582
- package/dist/react-admin.es.js.gz +0 -0
- package/dist/react-admin.es.js.map +1 -1
- package/dist/react-admin.umd.js +82 -69
- package/dist/react-admin.umd.js.gz +0 -0
- package/dist/react-admin.umd.js.map +1 -1
- package/package.json +2 -1
- package/src/ApplicaAdmin.tsx +20 -3
- package/src/components/ra-buttons/DeleteWithConfirmButton.tsx +26 -6
- package/src/components/ra-buttons/GoogleLoginButton.tsx +76 -0
- package/src/components/ra-buttons/index.ts +1 -0
- package/src/components/ra-forms/TableForm/TableFormIterator.tsx +7 -17
- package/src/components/ra-forms/TableForm/TableFormIteratorItem.tsx +7 -18
- package/src/components/ra-pages/LoginPage.tsx +27 -1
- package/src/components/ra-pages/RegisterPage.tsx +1 -1
- package/src/playground/App.jsx +3 -0
package/package.json
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
"@mui/icons-material": "^5.0.1",
|
|
15
15
|
"@mui/lab": "5.0.0-alpha.148",
|
|
16
16
|
"@mui/material": "5.15.17",
|
|
17
|
+
"@react-oauth/google": "^0.12.1",
|
|
17
18
|
"dayjs": "^1.11.8",
|
|
18
19
|
"framer-motion": "^10.12.17",
|
|
19
20
|
"history": "^5.1.0",
|
|
@@ -107,5 +108,5 @@
|
|
|
107
108
|
"type": "module",
|
|
108
109
|
"types": "dist/index.d.ts",
|
|
109
110
|
"typings": "dist/index.d.ts",
|
|
110
|
-
"version": "1.5.
|
|
111
|
+
"version": "1.5.330"
|
|
111
112
|
}
|
package/src/ApplicaAdmin.tsx
CHANGED
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
} from '@/components';
|
|
16
16
|
import { AppStateProvider } from '@/components/AppStateProvider';
|
|
17
17
|
import { ThemeConfig, ThemeProvider } from '@/components/Layout/ThemeProvider';
|
|
18
|
+
import { GoogleOAuthProvider } from '@react-oauth/google';
|
|
18
19
|
import React, { useMemo } from 'react';
|
|
19
20
|
import { AdminProps, AuthProvider, DataProvider, I18nProvider } from 'react-admin';
|
|
20
21
|
import { QueryClient } from 'react-query';
|
|
@@ -53,6 +54,7 @@ function ApplicaAdmin({
|
|
|
53
54
|
enablePasswordRecover = false,
|
|
54
55
|
enableThemeToggler = false,
|
|
55
56
|
enableLocaleSwitcher = false,
|
|
57
|
+
oauth = {},
|
|
56
58
|
queryClient = defaultQueryClient,
|
|
57
59
|
background,
|
|
58
60
|
notificationAPI = 'entities/notification',
|
|
@@ -93,11 +95,12 @@ function ApplicaAdmin({
|
|
|
93
95
|
version,
|
|
94
96
|
background,
|
|
95
97
|
enableRegistration,
|
|
96
|
-
enablePasswordRecover
|
|
98
|
+
enablePasswordRecover,
|
|
99
|
+
oauth
|
|
97
100
|
});
|
|
98
101
|
}
|
|
99
102
|
return loginPage;
|
|
100
|
-
}, [loginPage, name, version, copy, background, logoMain, enableRegistration, enablePasswordRecover]);
|
|
103
|
+
}, [loginPage, name, version, copy, background, logoMain, enableRegistration, enablePasswordRecover, oauth]);
|
|
101
104
|
const layout = useMemo(
|
|
102
105
|
() => (props: any) => {
|
|
103
106
|
const _logoMain = name ? <MainIcon title={name} /> : logoMain;
|
|
@@ -152,7 +155,7 @@ function ApplicaAdmin({
|
|
|
152
155
|
);
|
|
153
156
|
}
|
|
154
157
|
|
|
155
|
-
|
|
158
|
+
const appContent = (
|
|
156
159
|
<AppStateProvider>
|
|
157
160
|
<MenuConfigProvider menu={menu}>
|
|
158
161
|
<ThemeProvider initialConfig={themeConfig}>
|
|
@@ -171,6 +174,12 @@ function ApplicaAdmin({
|
|
|
171
174
|
</MenuConfigProvider>
|
|
172
175
|
</AppStateProvider>
|
|
173
176
|
);
|
|
177
|
+
|
|
178
|
+
if (oauth.google?.clientId) {
|
|
179
|
+
return <GoogleOAuthProvider clientId={oauth.google.clientId}>{appContent}</GoogleOAuthProvider>;
|
|
180
|
+
} else {
|
|
181
|
+
return appContent;
|
|
182
|
+
}
|
|
174
183
|
}
|
|
175
184
|
|
|
176
185
|
type ApplicaAdminProps = AdminProps & {
|
|
@@ -309,6 +318,14 @@ type ApplicaAdminProps = AdminProps & {
|
|
|
309
318
|
* Indicates whether the locale switcher should be displayed.
|
|
310
319
|
*/
|
|
311
320
|
enableLocaleSwitcher: boolean;
|
|
321
|
+
/**
|
|
322
|
+
* Indicates which OAuth providers to enable and configurations.
|
|
323
|
+
*/
|
|
324
|
+
oauth: {
|
|
325
|
+
google?: {
|
|
326
|
+
clientId: string;
|
|
327
|
+
};
|
|
328
|
+
};
|
|
312
329
|
};
|
|
313
330
|
|
|
314
331
|
export { ApplicaAdmin };
|
|
@@ -7,10 +7,19 @@ import { Button } from './Button';
|
|
|
7
7
|
import { Confirm, DeleteWithConfirmButtonProps as RaDeleteWithConfirmButtonProps } from 'ra-ui-materialui';
|
|
8
8
|
import { Box, SxProps, Typography, useTheme } from '@mui/material';
|
|
9
9
|
import { DeleteFilled } from '@ant-design/icons';
|
|
10
|
+
import { useCallback } from 'react';
|
|
10
11
|
|
|
11
12
|
type DeleteWithConfirmButtonProps<RecordType extends RaRecord = RaRecord> =
|
|
12
13
|
RaDeleteWithConfirmButtonProps<RecordType> & {
|
|
13
14
|
dialogSx?: SxProps;
|
|
15
|
+
/**
|
|
16
|
+
* @deprecated confirmTitle prop is deprecated, please use confirmContent instead.
|
|
17
|
+
*/
|
|
18
|
+
confirmTitle?: React.ReactNode;
|
|
19
|
+
/**
|
|
20
|
+
* onConfirm {callback} is used to handle a custom delete action when user confirms the deletion.
|
|
21
|
+
*/
|
|
22
|
+
onConfirm?: () => void;
|
|
14
23
|
};
|
|
15
24
|
|
|
16
25
|
function DeleteWithConfirmButton<RecordType extends RaRecord = any>(
|
|
@@ -30,6 +39,7 @@ function DeleteWithConfirmButton<RecordType extends RaRecord = any>(
|
|
|
30
39
|
onClick,
|
|
31
40
|
redirect = 'list',
|
|
32
41
|
translateOptions = {},
|
|
42
|
+
onConfirm,
|
|
33
43
|
...rest
|
|
34
44
|
} = props;
|
|
35
45
|
const translate = useTranslate();
|
|
@@ -46,6 +56,17 @@ function DeleteWithConfirmButton<RecordType extends RaRecord = any>(
|
|
|
46
56
|
resource
|
|
47
57
|
});
|
|
48
58
|
|
|
59
|
+
const handleOnConfirm = useCallback(
|
|
60
|
+
(event: any) => {
|
|
61
|
+
if (onConfirm) {
|
|
62
|
+
onConfirm();
|
|
63
|
+
} else {
|
|
64
|
+
handleDelete(event);
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
[handleDelete, onConfirm]
|
|
68
|
+
);
|
|
69
|
+
|
|
49
70
|
return (
|
|
50
71
|
<>
|
|
51
72
|
<Button
|
|
@@ -122,9 +143,9 @@ function DeleteWithConfirmButton<RecordType extends RaRecord = any>(
|
|
|
122
143
|
)
|
|
123
144
|
}
|
|
124
145
|
content={
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
146
|
+
<Typography maxWidth="300px" variant="h4" align="center">
|
|
147
|
+
{confirmContent ||
|
|
148
|
+
translate('ra.message.delete_content', {
|
|
128
149
|
_: 'ra.message.delete_content',
|
|
129
150
|
name: translate(`resources.${resource}.forcedCaseName`, {
|
|
130
151
|
smart_count: 1,
|
|
@@ -138,8 +159,7 @@ function DeleteWithConfirmButton<RecordType extends RaRecord = any>(
|
|
|
138
159
|
}),
|
|
139
160
|
id: record?.id
|
|
140
161
|
})}
|
|
141
|
-
|
|
142
|
-
)
|
|
162
|
+
</Typography>
|
|
143
163
|
}
|
|
144
164
|
confirmColor={confirmColor}
|
|
145
165
|
translateOptions={{
|
|
@@ -156,7 +176,7 @@ function DeleteWithConfirmButton<RecordType extends RaRecord = any>(
|
|
|
156
176
|
id: record?.id,
|
|
157
177
|
...translateOptions
|
|
158
178
|
}}
|
|
159
|
-
onConfirm={
|
|
179
|
+
onConfirm={handleOnConfirm}
|
|
160
180
|
onClose={handleDialogClose}
|
|
161
181
|
/>
|
|
162
182
|
</>
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { ApplicaAuthProvider, AuthThirdPartyProviders } from '@applica-software-guru/iam-client';
|
|
2
|
+
import { Box, useTheme } from '@mui/material';
|
|
3
|
+
import { GoogleLogin } from '@react-oauth/google';
|
|
4
|
+
import { useAuthProvider, useNotify } from 'ra-core';
|
|
5
|
+
import { useNavigate } from 'react-router-dom';
|
|
6
|
+
import { useEffect, useRef, useState } from 'react';
|
|
7
|
+
import { debounce } from 'lodash';
|
|
8
|
+
|
|
9
|
+
type GoogleLoginButtonProps = {
|
|
10
|
+
setLoading: (loading: boolean) => void;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
function GoogleLoginButton({ setLoading }: GoogleLoginButtonProps) {
|
|
14
|
+
const theme = useTheme() as any;
|
|
15
|
+
const isDark = theme.palette.mode === 'dark';
|
|
16
|
+
const authProvider = useAuthProvider<ApplicaAuthProvider>();
|
|
17
|
+
const notify = useNotify();
|
|
18
|
+
const navigate = useNavigate();
|
|
19
|
+
const [boxWidth, setBoxWidth] = useState<string | number>(395);
|
|
20
|
+
const boxRef = useRef<HTMLDivElement>(null);
|
|
21
|
+
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
const debouncedUpdateButtonWidth = debounce(() => {
|
|
24
|
+
if (boxRef?.current) {
|
|
25
|
+
setBoxWidth(boxRef.current.offsetWidth);
|
|
26
|
+
}
|
|
27
|
+
}, 100);
|
|
28
|
+
|
|
29
|
+
debouncedUpdateButtonWidth();
|
|
30
|
+
window.addEventListener('resize', debouncedUpdateButtonWidth);
|
|
31
|
+
|
|
32
|
+
return () => {
|
|
33
|
+
window.removeEventListener('resize', debouncedUpdateButtonWidth);
|
|
34
|
+
debouncedUpdateButtonWidth.cancel();
|
|
35
|
+
};
|
|
36
|
+
}, [boxRef]);
|
|
37
|
+
|
|
38
|
+
function handleSuccess(response: any) {
|
|
39
|
+
setLoading(true);
|
|
40
|
+
authProvider
|
|
41
|
+
.thirdPartyLogin({ provider: AuthThirdPartyProviders.GOOGLE, payload: { credential: response.credential } })
|
|
42
|
+
.then(() => {
|
|
43
|
+
setLoading(false);
|
|
44
|
+
navigate('/');
|
|
45
|
+
})
|
|
46
|
+
.catch((error: any) => {
|
|
47
|
+
setLoading(false);
|
|
48
|
+
notify(
|
|
49
|
+
typeof error === 'string'
|
|
50
|
+
? error
|
|
51
|
+
: typeof error === 'undefined' || !error.message
|
|
52
|
+
? 'ra.auth.sign_in_error'
|
|
53
|
+
: error.message,
|
|
54
|
+
{
|
|
55
|
+
type: 'error',
|
|
56
|
+
messageArgs: {
|
|
57
|
+
_: typeof error === 'string' ? error : error && error.message ? error.message : undefined
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
);
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function handleError() {
|
|
65
|
+
notify('ra.auth.sign_in_error', {
|
|
66
|
+
type: 'error'
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
return (
|
|
70
|
+
<Box sx={{ colorScheme: isDark ? 'light' : 'dark', width: '100%' }} ref={boxRef}>
|
|
71
|
+
<GoogleLogin theme="outline" width={boxWidth} onSuccess={handleSuccess} onError={handleError} />
|
|
72
|
+
</Box>
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export { GoogleLoginButton };
|
|
@@ -19,10 +19,11 @@ import {
|
|
|
19
19
|
import { styled, useTheme } from '@mui/material/styles';
|
|
20
20
|
import { FormDataConsumer, RaRecord, useTranslate, useTranslateLabel } from 'ra-core';
|
|
21
21
|
import * as React from 'react';
|
|
22
|
-
import { Children, ReactElement, ReactNode, useCallback, useMemo, useRef
|
|
23
|
-
import {
|
|
22
|
+
import { Children, ReactElement, ReactNode, useCallback, useMemo, useRef } from 'react';
|
|
23
|
+
import { useArrayInput } from 'react-admin';
|
|
24
24
|
import { UseFieldArrayReturn, useFormContext } from 'react-hook-form';
|
|
25
25
|
import { Tooltip } from '@/components/@extended';
|
|
26
|
+
import { DeleteWithConfirmButton } from '@/components/ra-buttons';
|
|
26
27
|
|
|
27
28
|
/**
|
|
28
29
|
* How to use TableFormIterator:
|
|
@@ -57,7 +58,6 @@ function RawTableFormIterator(props: TableFormIteratorProps): ReactElement | nul
|
|
|
57
58
|
inset,
|
|
58
59
|
sx
|
|
59
60
|
} = props;
|
|
60
|
-
const [confirmIsOpen, setConfirmIsOpen] = useState<boolean>(false);
|
|
61
61
|
const { fields, remove, replace, append } = useArrayInput(props);
|
|
62
62
|
const { resetField } = useFormContext();
|
|
63
63
|
const theme = useTheme();
|
|
@@ -129,7 +129,6 @@ function RawTableFormIterator(props: TableFormIteratorProps): ReactElement | nul
|
|
|
129
129
|
|
|
130
130
|
const handleArrayClear = useCallback(() => {
|
|
131
131
|
replace([]);
|
|
132
|
-
setConfirmIsOpen(false);
|
|
133
132
|
}, [replace]);
|
|
134
133
|
|
|
135
134
|
const context = useMemo(
|
|
@@ -217,9 +216,10 @@ function RawTableFormIterator(props: TableFormIteratorProps): ReactElement | nul
|
|
|
217
216
|
{!disableRemove && showClearAllButton ? (
|
|
218
217
|
<TableCell key="actions" sx={{ display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
|
|
219
218
|
<ActionsMenu horizontal>
|
|
220
|
-
<
|
|
221
|
-
{
|
|
222
|
-
|
|
219
|
+
<DeleteWithConfirmButton
|
|
220
|
+
onConfirm={handleArrayClear}
|
|
221
|
+
confirmContent={translate('ra.message.clear_array_input')}
|
|
222
|
+
/>
|
|
223
223
|
</ActionsMenu>
|
|
224
224
|
</TableCell>
|
|
225
225
|
) : (
|
|
@@ -264,16 +264,6 @@ function RawTableFormIterator(props: TableFormIteratorProps): ReactElement | nul
|
|
|
264
264
|
</TableBody>
|
|
265
265
|
</Table>
|
|
266
266
|
</TableContainer>
|
|
267
|
-
|
|
268
|
-
{fields.length > 0 && (
|
|
269
|
-
<Confirm
|
|
270
|
-
isOpen={confirmIsOpen}
|
|
271
|
-
title={translate('ra.action.clear_array_input')}
|
|
272
|
-
content={translate('ra.message.clear_array_input')}
|
|
273
|
-
onConfirm={handleArrayClear}
|
|
274
|
-
onClose={() => setConfirmIsOpen(false)}
|
|
275
|
-
/>
|
|
276
|
-
)}
|
|
277
267
|
</div>
|
|
278
268
|
</TableFormIteratorContext.Provider>
|
|
279
269
|
) : null;
|
|
@@ -1,25 +1,24 @@
|
|
|
1
1
|
import { EditButton } from './EditButton';
|
|
2
2
|
import { ActionsMenu } from '@/components/ActionsMenu';
|
|
3
|
+
import { DeleteWithConfirmButton } from '@/components/ra-buttons';
|
|
3
4
|
import { useTableFormIterator } from '@/components/ra-forms/TableForm/TableFormIteratorContext';
|
|
4
5
|
import {
|
|
5
6
|
TableFormIteratorItemContext,
|
|
6
7
|
TableFormIteratorItemContextValue
|
|
7
8
|
} from '@/components/ra-forms/TableForm/TableFormIteratorItemContext';
|
|
8
|
-
import {
|
|
9
|
+
import { Stack, TableCell } from '@mui/material';
|
|
9
10
|
import { RaRecord } from 'ra-core';
|
|
10
11
|
import { Children, ReactElement, ReactNode, cloneElement, isValidElement, useMemo } from 'react';
|
|
11
12
|
import * as React from 'react';
|
|
12
|
-
import {
|
|
13
|
+
import { useTranslate } from 'react-admin';
|
|
13
14
|
|
|
14
15
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
15
16
|
const TableFormIteratorItem = React.forwardRef((props: TableFormIteratorItemProps, _: any) => {
|
|
16
17
|
const { children, disabled, disableRemove = false, index, member, resource, record } = props;
|
|
17
18
|
const translate = useTranslate();
|
|
18
|
-
const [confirmIsOpen, setConfirmIsOpen] = React.useState<boolean>(false);
|
|
19
19
|
const { total, remove } = useTableFormIterator();
|
|
20
20
|
|
|
21
21
|
const handleRowDelete = React.useCallback(() => {
|
|
22
|
-
setConfirmIsOpen(false);
|
|
23
22
|
remove(index);
|
|
24
23
|
}, [index, remove]);
|
|
25
24
|
|
|
@@ -75,9 +74,10 @@ const TableFormIteratorItem = React.forwardRef((props: TableFormIteratorItemProp
|
|
|
75
74
|
<TableCell>
|
|
76
75
|
<Stack direction="row" spacing={1} justifyContent="center" alignItems="center">
|
|
77
76
|
<ActionsMenu horizontal>
|
|
78
|
-
<
|
|
79
|
-
{
|
|
80
|
-
|
|
77
|
+
<DeleteWithConfirmButton
|
|
78
|
+
onConfirm={handleRowDelete}
|
|
79
|
+
confirmContent={translate('ra.message.remove_item')}
|
|
80
|
+
/>
|
|
81
81
|
{renderEditButton}
|
|
82
82
|
</ActionsMenu>
|
|
83
83
|
</Stack>
|
|
@@ -90,17 +90,6 @@ const TableFormIteratorItem = React.forwardRef((props: TableFormIteratorItemProp
|
|
|
90
90
|
</Stack>
|
|
91
91
|
</TableCell>
|
|
92
92
|
) : null}
|
|
93
|
-
|
|
94
|
-
{/** @ts-ignore */}
|
|
95
|
-
{children.length > 0 && (
|
|
96
|
-
<Confirm
|
|
97
|
-
isOpen={confirmIsOpen}
|
|
98
|
-
title={translate('ra.action.remove_item')}
|
|
99
|
-
content={translate('ra.message.remove_item')}
|
|
100
|
-
onConfirm={handleRowDelete}
|
|
101
|
-
onClose={() => setConfirmIsOpen(false)}
|
|
102
|
-
/>
|
|
103
|
-
)}
|
|
104
93
|
</TableFormIteratorItemContext.Provider>
|
|
105
94
|
);
|
|
106
95
|
});
|
|
@@ -2,10 +2,12 @@ import { BaseAuthProps } from './types';
|
|
|
2
2
|
import { AuthBackground } from '@/components/AuthBackground';
|
|
3
3
|
import { AuthWrapper } from '@/components/AuthWrapper';
|
|
4
4
|
import { TextInput } from '@/components/ra-inputs';
|
|
5
|
-
import { Button, CircularProgress, Grid, Link, Stack, Typography } from '@mui/material';
|
|
5
|
+
import { Button, CircularProgress, Divider, Grid, Link, Stack, Typography } from '@mui/material';
|
|
6
6
|
import { Form, required, useCheckAuth, useLogin, useNotify, useSafeSetState, useTranslate } from 'ra-core';
|
|
7
7
|
import { useEffect } from 'react';
|
|
8
8
|
import { Link as RouterLink, useNavigate } from 'react-router-dom';
|
|
9
|
+
import _ from 'lodash';
|
|
10
|
+
import { GoogleLoginButton } from '@/components/ra-buttons';
|
|
9
11
|
|
|
10
12
|
type LoginPageProps = BaseAuthProps & {
|
|
11
13
|
/**
|
|
@@ -39,6 +41,14 @@ type LoginPageProps = BaseAuthProps & {
|
|
|
39
41
|
* If not specified, the react-admin home page is used.
|
|
40
42
|
*/
|
|
41
43
|
redirectTo: string;
|
|
44
|
+
/**
|
|
45
|
+
* Indicates which OAuth providers to enable and configurations.
|
|
46
|
+
*/
|
|
47
|
+
oauth?: {
|
|
48
|
+
google?: {
|
|
49
|
+
clientId: string;
|
|
50
|
+
};
|
|
51
|
+
};
|
|
42
52
|
};
|
|
43
53
|
function LoginPage({
|
|
44
54
|
version,
|
|
@@ -47,6 +57,7 @@ function LoginPage({
|
|
|
47
57
|
logo,
|
|
48
58
|
enablePasswordRecover = false,
|
|
49
59
|
enableRegistration = false,
|
|
60
|
+
oauth = {},
|
|
50
61
|
redirectTo,
|
|
51
62
|
background = <AuthBackground />
|
|
52
63
|
}: LoginPageProps): JSX.Element {
|
|
@@ -56,6 +67,7 @@ function LoginPage({
|
|
|
56
67
|
const notify = useNotify();
|
|
57
68
|
const checkAuth = useCheckAuth();
|
|
58
69
|
const navigate = useNavigate();
|
|
70
|
+
|
|
59
71
|
useEffect(() => {
|
|
60
72
|
checkAuth({}, false)
|
|
61
73
|
.then(() => {
|
|
@@ -65,6 +77,7 @@ function LoginPage({
|
|
|
65
77
|
// not authenticated, stay on the login page
|
|
66
78
|
});
|
|
67
79
|
}, [checkAuth, navigate]);
|
|
80
|
+
|
|
68
81
|
function handleSubmit(values: any) {
|
|
69
82
|
setLoading(true);
|
|
70
83
|
login(values, redirectTo)
|
|
@@ -88,6 +101,7 @@ function LoginPage({
|
|
|
88
101
|
);
|
|
89
102
|
});
|
|
90
103
|
}
|
|
104
|
+
|
|
91
105
|
return (
|
|
92
106
|
<AuthWrapper name={name} version={version} copy={copy} logo={logo} background={background}>
|
|
93
107
|
<Grid container spacing={3}>
|
|
@@ -153,6 +167,18 @@ function LoginPage({
|
|
|
153
167
|
</Button>
|
|
154
168
|
</Grid>
|
|
155
169
|
</Form>
|
|
170
|
+
{!_.isEmpty(oauth) ? (
|
|
171
|
+
<>
|
|
172
|
+
<Grid item xs={12} sx={{ mt: 2 }}>
|
|
173
|
+
<Divider />
|
|
174
|
+
</Grid>
|
|
175
|
+
{oauth.google ? (
|
|
176
|
+
<Grid item xs={12} sx={{ mt: 2, width: '100%' }}>
|
|
177
|
+
<GoogleLoginButton setLoading={setLoading} />
|
|
178
|
+
</Grid>
|
|
179
|
+
) : null}
|
|
180
|
+
</>
|
|
181
|
+
) : null}
|
|
156
182
|
</Grid>
|
|
157
183
|
</Grid>
|
|
158
184
|
</AuthWrapper>
|
|
@@ -26,7 +26,7 @@ function RegisterPage({ name, copy, version, logo, background }: BaseAuthProps)
|
|
|
26
26
|
redirect('/login');
|
|
27
27
|
})
|
|
28
28
|
.catch((error: any) => {
|
|
29
|
-
notify(error, { type: 'error' });
|
|
29
|
+
notify(error.message || error, { type: 'error' });
|
|
30
30
|
})
|
|
31
31
|
.finally(() => setLoading(false));
|
|
32
32
|
}
|
package/src/playground/App.jsx
CHANGED