@strapi/plugin-users-permissions 0.0.0-next.c8d6478ec519888ce0cd754886474c3189efc733 → 0.0.0-next.ce51df0e18404afc8a1aa7f504c1006a7a221459
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/admin/src/components/Permissions/index.js +2 -4
- package/admin/src/index.js +16 -35
- package/admin/src/pages/AdvancedSettings/index.js +46 -30
- package/admin/src/pages/EmailTemplates/index.js +64 -53
- package/admin/src/pages/Providers/index.js +64 -62
- package/admin/src/{hooks → pages/Roles/hooks}/usePlugins.js +15 -8
- package/admin/src/pages/Roles/index.js +10 -7
- package/admin/src/pages/Roles/pages/CreatePage.js +190 -0
- package/admin/src/pages/Roles/pages/EditPage.js +211 -0
- package/admin/src/pages/Roles/{ListPage → pages/ListPage}/components/TableBody.js +44 -14
- package/admin/src/pages/Roles/{ListPage → pages/ListPage}/index.js +29 -30
- package/admin/src/pages/Roles/{ListPage → pages/ListPage}/utils/api.js +2 -4
- package/admin/src/translations/zh-Hans.json +80 -80
- package/admin/src/utils/index.js +0 -1
- package/documentation/content-api.yaml +1 -1
- package/jest.config.front.js +1 -1
- package/package.json +10 -10
- package/server/bootstrap/index.js +35 -0
- package/server/controllers/auth.js +46 -13
- package/server/controllers/user.js +12 -1
- package/server/middlewares/rateLimit.js +41 -21
- package/admin/src/hooks/index.js +0 -5
- package/admin/src/hooks/useFetchRole/index.js +0 -67
- package/admin/src/hooks/useFetchRole/reducer.js +0 -31
- package/admin/src/hooks/useForm/index.js +0 -70
- package/admin/src/hooks/useForm/reducer.js +0 -40
- package/admin/src/hooks/useRolesList/index.js +0 -65
- package/admin/src/hooks/useRolesList/init.js +0 -5
- package/admin/src/hooks/useRolesList/reducer.js +0 -31
- package/admin/src/pages/AdvancedSettings/utils/api.js +0 -18
- package/admin/src/pages/EmailTemplates/utils/api.js +0 -18
- package/admin/src/pages/Providers/reducer.js +0 -54
- package/admin/src/pages/Providers/utils/api.js +0 -26
- package/admin/src/pages/Providers/utils/createProvidersArray.js +0 -21
- package/admin/src/pages/Roles/CreatePage.js +0 -185
- package/admin/src/pages/Roles/EditPage.js +0 -197
- package/admin/src/pages/Roles/ProtectedCreatePage.js +0 -15
- package/admin/src/pages/Roles/ProtectedEditPage.js +0 -15
- package/admin/src/pages/Roles/ProtectedListPage.js +0 -17
- package/admin/src/utils/getRequestURL.js +0 -5
|
@@ -1,27 +1,47 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const utils = require('@strapi/utils');
|
|
5
|
+
const { isString, has, toLower } = require('lodash/fp');
|
|
6
|
+
|
|
7
|
+
const { RateLimitError } = utils.errors;
|
|
8
|
+
|
|
3
9
|
module.exports =
|
|
4
10
|
(config, { strapi }) =>
|
|
5
11
|
async (ctx, next) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
{
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
12
|
+
let rateLimitConfig = strapi.config.get('plugin.users-permissions.ratelimit');
|
|
13
|
+
|
|
14
|
+
if (!rateLimitConfig) {
|
|
15
|
+
rateLimitConfig = {
|
|
16
|
+
enabled: true,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (!has('enabled', rateLimitConfig)) {
|
|
21
|
+
rateLimitConfig.enabled = true;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (rateLimitConfig.enabled === true) {
|
|
25
|
+
const rateLimit = require('koa2-ratelimit').RateLimit;
|
|
26
|
+
|
|
27
|
+
const userIdentifier = toLower(ctx.request.body.email) || 'unknownIdentifier';
|
|
28
|
+
const requestPath = isString(ctx.request.path)
|
|
29
|
+
? toLower(path.normalize(ctx.request.path))
|
|
30
|
+
: 'invalidPath';
|
|
31
|
+
|
|
32
|
+
const loadConfig = {
|
|
33
|
+
interval: { min: 5 },
|
|
34
|
+
max: 5,
|
|
35
|
+
prefixKey: `${userIdentifier}:${requestPath}:${ctx.request.ip}`,
|
|
36
|
+
handler() {
|
|
37
|
+
throw new RateLimitError();
|
|
38
|
+
},
|
|
39
|
+
...rateLimitConfig,
|
|
40
|
+
...config,
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
return rateLimit.middleware(loadConfig)(ctx, next);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return next();
|
|
27
47
|
};
|
package/admin/src/hooks/index.js
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { useCallback, useEffect, useReducer, useRef } from 'react';
|
|
2
|
-
|
|
3
|
-
import { useFetchClient, useNotification } from '@strapi/helper-plugin';
|
|
4
|
-
|
|
5
|
-
import pluginId from '../../pluginId';
|
|
6
|
-
|
|
7
|
-
import reducer, { initialState } from './reducer';
|
|
8
|
-
|
|
9
|
-
const useFetchRole = (id) => {
|
|
10
|
-
const [state, dispatch] = useReducer(reducer, initialState);
|
|
11
|
-
const toggleNotification = useNotification();
|
|
12
|
-
const isMounted = useRef(null);
|
|
13
|
-
const { get } = useFetchClient();
|
|
14
|
-
|
|
15
|
-
useEffect(() => {
|
|
16
|
-
isMounted.current = true;
|
|
17
|
-
|
|
18
|
-
if (id) {
|
|
19
|
-
fetchRole(id);
|
|
20
|
-
} else {
|
|
21
|
-
dispatch({
|
|
22
|
-
type: 'GET_DATA_SUCCEEDED',
|
|
23
|
-
role: {},
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return () => (isMounted.current = false);
|
|
28
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
29
|
-
}, [id]);
|
|
30
|
-
|
|
31
|
-
const fetchRole = async (roleId) => {
|
|
32
|
-
try {
|
|
33
|
-
const {
|
|
34
|
-
data: { role },
|
|
35
|
-
} = await get(`/${pluginId}/roles/${roleId}`);
|
|
36
|
-
|
|
37
|
-
// Prevent updating state on an unmounted component
|
|
38
|
-
if (isMounted.current) {
|
|
39
|
-
dispatch({
|
|
40
|
-
type: 'GET_DATA_SUCCEEDED',
|
|
41
|
-
role,
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
} catch (err) {
|
|
45
|
-
console.error(err);
|
|
46
|
-
|
|
47
|
-
dispatch({
|
|
48
|
-
type: 'GET_DATA_ERROR',
|
|
49
|
-
});
|
|
50
|
-
toggleNotification({
|
|
51
|
-
type: 'warning',
|
|
52
|
-
message: { id: 'notification.error' },
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
const handleSubmitSucceeded = useCallback((data) => {
|
|
58
|
-
dispatch({
|
|
59
|
-
type: 'ON_SUBMIT_SUCCEEDED',
|
|
60
|
-
...data,
|
|
61
|
-
});
|
|
62
|
-
}, []);
|
|
63
|
-
|
|
64
|
-
return { ...state, onSubmitSucceeded: handleSubmitSucceeded };
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
export default useFetchRole;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/* eslint-disable consistent-return */
|
|
2
|
-
import produce from 'immer';
|
|
3
|
-
|
|
4
|
-
export const initialState = {
|
|
5
|
-
role: {},
|
|
6
|
-
isLoading: true,
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
const reducer = (state, action) =>
|
|
10
|
-
produce(state, (draftState) => {
|
|
11
|
-
switch (action.type) {
|
|
12
|
-
case 'GET_DATA_SUCCEEDED': {
|
|
13
|
-
draftState.role = action.role;
|
|
14
|
-
draftState.isLoading = false;
|
|
15
|
-
break;
|
|
16
|
-
}
|
|
17
|
-
case 'GET_DATA_ERROR': {
|
|
18
|
-
draftState.isLoading = false;
|
|
19
|
-
break;
|
|
20
|
-
}
|
|
21
|
-
case 'ON_SUBMIT_SUCCEEDED': {
|
|
22
|
-
draftState.role.name = action.name;
|
|
23
|
-
draftState.role.description = action.description;
|
|
24
|
-
break;
|
|
25
|
-
}
|
|
26
|
-
default:
|
|
27
|
-
return draftState;
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
export default reducer;
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { useCallback, useEffect, useReducer, useRef } from 'react';
|
|
2
|
-
|
|
3
|
-
import { useFetchClient, useNotification, useRBAC } from '@strapi/helper-plugin';
|
|
4
|
-
|
|
5
|
-
import { getRequestURL } from '../../utils';
|
|
6
|
-
|
|
7
|
-
import reducer, { initialState } from './reducer';
|
|
8
|
-
|
|
9
|
-
const useUserForm = (endPoint, permissions) => {
|
|
10
|
-
const { isLoading: isLoadingForPermissions, allowedActions } = useRBAC(permissions);
|
|
11
|
-
const [{ isLoading, modifiedData }, dispatch] = useReducer(reducer, initialState);
|
|
12
|
-
const toggleNotification = useNotification();
|
|
13
|
-
const isMounted = useRef(true);
|
|
14
|
-
|
|
15
|
-
const { get } = useFetchClient();
|
|
16
|
-
|
|
17
|
-
useEffect(() => {
|
|
18
|
-
const getData = async () => {
|
|
19
|
-
try {
|
|
20
|
-
dispatch({
|
|
21
|
-
type: 'GET_DATA',
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
const { data } = await get(getRequestURL(endPoint));
|
|
25
|
-
|
|
26
|
-
dispatch({
|
|
27
|
-
type: 'GET_DATA_SUCCEEDED',
|
|
28
|
-
data,
|
|
29
|
-
});
|
|
30
|
-
} catch (err) {
|
|
31
|
-
// The user aborted the request
|
|
32
|
-
if (isMounted.current) {
|
|
33
|
-
dispatch({
|
|
34
|
-
type: 'GET_DATA_ERROR',
|
|
35
|
-
});
|
|
36
|
-
console.error(err);
|
|
37
|
-
toggleNotification({
|
|
38
|
-
type: 'warning',
|
|
39
|
-
message: { id: 'notification.error' },
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
if (!isLoadingForPermissions) {
|
|
46
|
-
getData();
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
return () => {
|
|
50
|
-
isMounted.current = false;
|
|
51
|
-
};
|
|
52
|
-
}, [isLoadingForPermissions, endPoint, get, toggleNotification]);
|
|
53
|
-
|
|
54
|
-
const dispatchSubmitSucceeded = useCallback((data) => {
|
|
55
|
-
dispatch({
|
|
56
|
-
type: 'ON_SUBMIT_SUCCEEDED',
|
|
57
|
-
data,
|
|
58
|
-
});
|
|
59
|
-
}, []);
|
|
60
|
-
|
|
61
|
-
return {
|
|
62
|
-
allowedActions,
|
|
63
|
-
dispatchSubmitSucceeded,
|
|
64
|
-
isLoading,
|
|
65
|
-
isLoadingForPermissions,
|
|
66
|
-
modifiedData,
|
|
67
|
-
};
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
export default useUserForm;
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import produce from 'immer';
|
|
2
|
-
|
|
3
|
-
const initialState = {
|
|
4
|
-
isLoading: true,
|
|
5
|
-
modifiedData: {},
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
const reducer = (state, action) =>
|
|
9
|
-
// eslint-disable-next-line consistent-return
|
|
10
|
-
produce(state, (draftState) => {
|
|
11
|
-
switch (action.type) {
|
|
12
|
-
case 'GET_DATA': {
|
|
13
|
-
draftState.isLoading = true;
|
|
14
|
-
draftState.modifiedData = {};
|
|
15
|
-
|
|
16
|
-
break;
|
|
17
|
-
}
|
|
18
|
-
case 'GET_DATA_SUCCEEDED': {
|
|
19
|
-
draftState.isLoading = false;
|
|
20
|
-
draftState.modifiedData = action.data;
|
|
21
|
-
|
|
22
|
-
break;
|
|
23
|
-
}
|
|
24
|
-
case 'GET_DATA_ERROR': {
|
|
25
|
-
draftState.isLoading = true;
|
|
26
|
-
break;
|
|
27
|
-
}
|
|
28
|
-
case 'ON_SUBMIT_SUCCEEDED': {
|
|
29
|
-
draftState.modifiedData = action.data;
|
|
30
|
-
|
|
31
|
-
break;
|
|
32
|
-
}
|
|
33
|
-
default: {
|
|
34
|
-
return draftState;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
export default reducer;
|
|
40
|
-
export { initialState };
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { useCallback, useEffect, useReducer, useRef } from 'react';
|
|
2
|
-
|
|
3
|
-
import { useFetchClient, useNotification } from '@strapi/helper-plugin';
|
|
4
|
-
import get from 'lodash/get';
|
|
5
|
-
|
|
6
|
-
import pluginId from '../../pluginId';
|
|
7
|
-
|
|
8
|
-
import init from './init';
|
|
9
|
-
import reducer, { initialState } from './reducer';
|
|
10
|
-
|
|
11
|
-
const useRolesList = (shouldFetchData = true) => {
|
|
12
|
-
const [{ roles, isLoading }, dispatch] = useReducer(reducer, initialState, () =>
|
|
13
|
-
init(initialState, shouldFetchData)
|
|
14
|
-
);
|
|
15
|
-
const toggleNotification = useNotification();
|
|
16
|
-
|
|
17
|
-
const isMounted = useRef(true);
|
|
18
|
-
const fetchClient = useFetchClient();
|
|
19
|
-
|
|
20
|
-
const fetchRolesList = useCallback(async () => {
|
|
21
|
-
try {
|
|
22
|
-
dispatch({
|
|
23
|
-
type: 'GET_DATA',
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
const {
|
|
27
|
-
data: { roles },
|
|
28
|
-
} = await fetchClient.get(`/${pluginId}/roles`);
|
|
29
|
-
|
|
30
|
-
dispatch({
|
|
31
|
-
type: 'GET_DATA_SUCCEEDED',
|
|
32
|
-
data: roles,
|
|
33
|
-
});
|
|
34
|
-
} catch (err) {
|
|
35
|
-
const message = get(err, ['response', 'payload', 'message'], 'An error occured');
|
|
36
|
-
|
|
37
|
-
if (isMounted.current) {
|
|
38
|
-
dispatch({
|
|
39
|
-
type: 'GET_DATA_ERROR',
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
if (message !== 'Forbidden') {
|
|
43
|
-
toggleNotification({
|
|
44
|
-
type: 'warning',
|
|
45
|
-
message,
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}, [fetchClient, toggleNotification]);
|
|
51
|
-
|
|
52
|
-
useEffect(() => {
|
|
53
|
-
if (shouldFetchData) {
|
|
54
|
-
fetchRolesList();
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
return () => {
|
|
58
|
-
isMounted.current = false;
|
|
59
|
-
};
|
|
60
|
-
}, [shouldFetchData, fetchRolesList]);
|
|
61
|
-
|
|
62
|
-
return { roles, isLoading, getData: fetchRolesList };
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
export default useRolesList;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/* eslint-disable consistent-return */
|
|
2
|
-
import produce from 'immer';
|
|
3
|
-
|
|
4
|
-
export const initialState = {
|
|
5
|
-
roles: [],
|
|
6
|
-
isLoading: true,
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
const reducer = (state, action) =>
|
|
10
|
-
produce(state, (draftState) => {
|
|
11
|
-
switch (action.type) {
|
|
12
|
-
case 'GET_DATA': {
|
|
13
|
-
draftState.isLoading = true;
|
|
14
|
-
draftState.roles = [];
|
|
15
|
-
break;
|
|
16
|
-
}
|
|
17
|
-
case 'GET_DATA_SUCCEEDED': {
|
|
18
|
-
draftState.roles = action.data;
|
|
19
|
-
draftState.isLoading = false;
|
|
20
|
-
break;
|
|
21
|
-
}
|
|
22
|
-
case 'GET_DATA_ERROR': {
|
|
23
|
-
draftState.isLoading = false;
|
|
24
|
-
break;
|
|
25
|
-
}
|
|
26
|
-
default:
|
|
27
|
-
return draftState;
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
export default reducer;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { getFetchClient } from '@strapi/helper-plugin';
|
|
2
|
-
|
|
3
|
-
import { getRequestURL } from '../../../utils';
|
|
4
|
-
|
|
5
|
-
const fetchData = async () => {
|
|
6
|
-
const { get } = getFetchClient();
|
|
7
|
-
const { data } = await get(getRequestURL('advanced'));
|
|
8
|
-
|
|
9
|
-
return data;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
const putAdvancedSettings = (body) => {
|
|
13
|
-
const { put } = getFetchClient();
|
|
14
|
-
|
|
15
|
-
return put(getRequestURL('advanced'), body);
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export { fetchData, putAdvancedSettings };
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { getFetchClient } from '@strapi/helper-plugin';
|
|
2
|
-
|
|
3
|
-
import { getRequestURL } from '../../../utils';
|
|
4
|
-
|
|
5
|
-
const fetchData = async () => {
|
|
6
|
-
const { get } = getFetchClient();
|
|
7
|
-
const { data } = await get(getRequestURL('email-templates'));
|
|
8
|
-
|
|
9
|
-
return data;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
const putEmailTemplate = (body) => {
|
|
13
|
-
const { put } = getFetchClient();
|
|
14
|
-
|
|
15
|
-
return put(getRequestURL('email-templates'), body);
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export { fetchData, putEmailTemplate };
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import produce from 'immer';
|
|
2
|
-
import set from 'lodash/set';
|
|
3
|
-
|
|
4
|
-
const initialState = {
|
|
5
|
-
formErrors: {},
|
|
6
|
-
isLoading: true,
|
|
7
|
-
initialData: {},
|
|
8
|
-
modifiedData: {},
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
const reducer = (state, action) =>
|
|
12
|
-
// eslint-disable-next-line consistent-return
|
|
13
|
-
produce(state, (draftState) => {
|
|
14
|
-
switch (action.type) {
|
|
15
|
-
case 'GET_DATA': {
|
|
16
|
-
draftState.isLoading = true;
|
|
17
|
-
draftState.initialData = {};
|
|
18
|
-
draftState.modifiedData = {};
|
|
19
|
-
|
|
20
|
-
break;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
case 'GET_DATA_SUCCEEDED': {
|
|
24
|
-
draftState.isLoading = false;
|
|
25
|
-
draftState.initialData = action.data;
|
|
26
|
-
draftState.modifiedData = action.data;
|
|
27
|
-
|
|
28
|
-
break;
|
|
29
|
-
}
|
|
30
|
-
case 'GET_DATA_ERROR': {
|
|
31
|
-
draftState.isLoading = true;
|
|
32
|
-
break;
|
|
33
|
-
}
|
|
34
|
-
case 'ON_CHANGE': {
|
|
35
|
-
set(draftState, ['modifiedData', ...action.keys.split('.')], action.value);
|
|
36
|
-
break;
|
|
37
|
-
}
|
|
38
|
-
case 'RESET_FORM': {
|
|
39
|
-
draftState.modifiedData = state.initialData;
|
|
40
|
-
draftState.formErrors = {};
|
|
41
|
-
break;
|
|
42
|
-
}
|
|
43
|
-
case 'SET_ERRORS': {
|
|
44
|
-
draftState.formErrors = action.errors;
|
|
45
|
-
break;
|
|
46
|
-
}
|
|
47
|
-
default: {
|
|
48
|
-
return draftState;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
export default reducer;
|
|
54
|
-
export { initialState };
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { getFetchClient } from '@strapi/helper-plugin';
|
|
2
|
-
|
|
3
|
-
import { getRequestURL } from '../../../utils';
|
|
4
|
-
|
|
5
|
-
// eslint-disable-next-line import/prefer-default-export
|
|
6
|
-
export const fetchData = async (toggleNotification) => {
|
|
7
|
-
try {
|
|
8
|
-
const { get } = getFetchClient();
|
|
9
|
-
const { data } = await get(getRequestURL('providers'));
|
|
10
|
-
|
|
11
|
-
return data;
|
|
12
|
-
} catch (err) {
|
|
13
|
-
toggleNotification({
|
|
14
|
-
type: 'warning',
|
|
15
|
-
message: { id: 'notification.error' },
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
throw new Error('error');
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export const putProvider = (body) => {
|
|
23
|
-
const { put } = getFetchClient();
|
|
24
|
-
|
|
25
|
-
return put(getRequestURL('providers'), body);
|
|
26
|
-
};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import sortBy from 'lodash/sortBy';
|
|
2
|
-
|
|
3
|
-
const createProvidersArray = (data) => {
|
|
4
|
-
return sortBy(
|
|
5
|
-
Object.keys(data).reduce((acc, current) => {
|
|
6
|
-
const { icon: iconName, enabled, subdomain } = data[current];
|
|
7
|
-
const icon = iconName === 'envelope' ? ['fas', 'envelope'] : ['fab', iconName];
|
|
8
|
-
|
|
9
|
-
if (subdomain !== undefined) {
|
|
10
|
-
acc.push({ name: current, icon, enabled, subdomain });
|
|
11
|
-
} else {
|
|
12
|
-
acc.push({ name: current, icon, enabled });
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
return acc;
|
|
16
|
-
}, []),
|
|
17
|
-
'name'
|
|
18
|
-
);
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export default createProvidersArray;
|