@banch0u/core-project-test-repository 1.2.3 → 1.3.1
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/README.md +23 -10
- package/dist/assets/balakhaniLogo.png +0 -0
- package/dist/assets/css/variables.css +9 -0
- package/dist/assets/icons/AsanImza.png +0 -0
- package/dist/assets/icons/Ldap.png +0 -0
- package/dist/assets/icons/Sima.png +0 -0
- package/dist/assets/icons/index.js +134 -19
- package/dist/components/Button/index.js +18 -20
- package/dist/components/Button/index.module.scss +3 -3
- package/dist/components/ColSort/index.js +19 -29
- package/dist/components/Filter/index.js +47 -57
- package/dist/components/Loading/index.js +9 -16
- package/dist/components/Pagination/Select.js +8 -15
- package/dist/components/Pagination/constant.js +1 -7
- package/dist/components/Pagination/index.js +11 -18
- package/dist/hooks/useNotification.js +9 -20
- package/dist/index.js +12 -56
- package/dist/pages/Login/index.js +113 -0
- package/dist/pages/Login/index.module.scss +121 -0
- package/dist/pages/Platform/constant.js +27 -0
- package/dist/pages/Platform/index.js +80 -0
- package/dist/pages/Platform/index.module.scss +110 -0
- package/dist/store/slices/auth/index.js +141 -0
- package/dist/store/slices/auth/service.js +68 -0
- package/dist/store/slices/global/index.js +16 -0
- package/dist/store/store.js +8 -0
- package/dist/utils/axios.js +173 -0
- package/dist/utils/message.js +20 -20
- package/dist/utils/path.js +4 -0
- package/package.json +5 -3
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
.login {
|
|
2
|
+
display: flex;
|
|
3
|
+
width: 100%;
|
|
4
|
+
align-items: center;
|
|
5
|
+
flex-direction: column;
|
|
6
|
+
padding-top: 87px;
|
|
7
|
+
height: 100vh;
|
|
8
|
+
background: #f8f8f8;
|
|
9
|
+
.logo {
|
|
10
|
+
svg {
|
|
11
|
+
width: 250px;
|
|
12
|
+
height: auto;
|
|
13
|
+
margin-bottom: 165px;
|
|
14
|
+
}
|
|
15
|
+
img {
|
|
16
|
+
width: 250px;
|
|
17
|
+
height: auto;
|
|
18
|
+
margin-bottom: 55px;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
.form {
|
|
22
|
+
width: 448px;
|
|
23
|
+
background: #fff;
|
|
24
|
+
padding: 30px 24px;
|
|
25
|
+
border-radius: 20px;
|
|
26
|
+
.title {
|
|
27
|
+
font-size: 30px;
|
|
28
|
+
font-weight: 500;
|
|
29
|
+
line-height: 36.31px;
|
|
30
|
+
text-align: center;
|
|
31
|
+
margin-bottom: 20px;
|
|
32
|
+
}
|
|
33
|
+
.control {
|
|
34
|
+
width: 100%;
|
|
35
|
+
.control_input {
|
|
36
|
+
display: flex;
|
|
37
|
+
align-items: center;
|
|
38
|
+
border-radius: 8px;
|
|
39
|
+
width: 100%;
|
|
40
|
+
background: #fff;
|
|
41
|
+
svg {
|
|
42
|
+
margin-right: 12px;
|
|
43
|
+
cursor: pointer;
|
|
44
|
+
width: 20px;
|
|
45
|
+
height: auto;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
input::placeholder {
|
|
50
|
+
color: #6f6f6f;
|
|
51
|
+
opacity: 1;
|
|
52
|
+
}
|
|
53
|
+
.control :where(input, select, textarea) {
|
|
54
|
+
background-color: transparent;
|
|
55
|
+
width: 100%;
|
|
56
|
+
outline: none;
|
|
57
|
+
padding: 15px 10px !important;
|
|
58
|
+
font-size: 18px;
|
|
59
|
+
font-family: Inter;
|
|
60
|
+
font-size: 18px;
|
|
61
|
+
font-weight: 400;
|
|
62
|
+
line-height: 21.78px;
|
|
63
|
+
text-align: left;
|
|
64
|
+
}
|
|
65
|
+
a {
|
|
66
|
+
display: block;
|
|
67
|
+
text-decoration: none;
|
|
68
|
+
color: #6f6f6f;
|
|
69
|
+
margin-bottom: 34px;
|
|
70
|
+
}
|
|
71
|
+
.button {
|
|
72
|
+
display: flex;
|
|
73
|
+
justify-content: center;
|
|
74
|
+
margin-bottom: 42px;
|
|
75
|
+
.border {
|
|
76
|
+
width: 228px;
|
|
77
|
+
padding: 2px;
|
|
78
|
+
border: 1px solid #016daf;
|
|
79
|
+
border-radius: 14px;
|
|
80
|
+
button {
|
|
81
|
+
width: 100%;
|
|
82
|
+
padding: 13px;
|
|
83
|
+
border-radius: 14px;
|
|
84
|
+
border: none;
|
|
85
|
+
background: var(--darkBlueColor);
|
|
86
|
+
color: #fff;
|
|
87
|
+
font-family: Inter;
|
|
88
|
+
font-size: 22px;
|
|
89
|
+
font-weight: 500;
|
|
90
|
+
line-height: 26.63px;
|
|
91
|
+
text-align: center;
|
|
92
|
+
cursor: pointer;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
.alternative_login {
|
|
98
|
+
display: flex;
|
|
99
|
+
justify-content: space-between;
|
|
100
|
+
align-items: center;
|
|
101
|
+
margin: 0 30px;
|
|
102
|
+
.background {
|
|
103
|
+
border: 1px solid #b9b9b9;
|
|
104
|
+
padding: 14px 20px;
|
|
105
|
+
background: #efefef;
|
|
106
|
+
border-radius: 10px;
|
|
107
|
+
display: flex;
|
|
108
|
+
justify-content: center;
|
|
109
|
+
align-items: center;
|
|
110
|
+
}
|
|
111
|
+
h3 {
|
|
112
|
+
font-family: Inter;
|
|
113
|
+
font-size: 18px;
|
|
114
|
+
font-weight: 400;
|
|
115
|
+
line-height: 21.78px;
|
|
116
|
+
text-align: center;
|
|
117
|
+
color: #535353;
|
|
118
|
+
margin-top: 10px;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { ContractsIcon, DocumentCirculationIcon, HRIcon } from "../../assets/icons";
|
|
3
|
+
var rootUrl;
|
|
4
|
+
if (window.location.hostname === "localhost") {
|
|
5
|
+
rootUrl = "http://localhost:" + window.location.port;
|
|
6
|
+
} else {
|
|
7
|
+
rootUrl = window.location.origin;
|
|
8
|
+
}
|
|
9
|
+
export var entryData = [{
|
|
10
|
+
id: 1,
|
|
11
|
+
value: "Sənəd Dövriyyəsi",
|
|
12
|
+
pathname: "".concat(rootUrl, "/docflow/document-circulation/unread-docs"),
|
|
13
|
+
icon: /*#__PURE__*/React.createElement(DocumentCirculationIcon, null),
|
|
14
|
+
scopes: "docflow"
|
|
15
|
+
}, {
|
|
16
|
+
id: 2,
|
|
17
|
+
value: " Kadrlar sistemi",
|
|
18
|
+
pathname: "".concat(rootUrl, "/hr/hr"),
|
|
19
|
+
icon: /*#__PURE__*/React.createElement(HRIcon, null),
|
|
20
|
+
scopes: "hr"
|
|
21
|
+
}, {
|
|
22
|
+
id: 3,
|
|
23
|
+
value: "Müqavilələr",
|
|
24
|
+
pathname: "".concat(rootUrl, "/contracts/unread-contract"),
|
|
25
|
+
icon: /*#__PURE__*/React.createElement(ContractsIcon, null),
|
|
26
|
+
scopes: "contracts"
|
|
27
|
+
}];
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import React, { useEffect } from "react";
|
|
2
|
+
import style from "./index.module.scss";
|
|
3
|
+
import { entryData } from "./constant";
|
|
4
|
+
import { Link } from "react-router-dom";
|
|
5
|
+
import { getProfileInfo, scopes } from "../../store/slices/auth";
|
|
6
|
+
import { useSelector } from "react-redux";
|
|
7
|
+
import { useDispatch } from "react-redux";
|
|
8
|
+
import { DsgLogo, SettingsCogIcon, UserIcon } from "../../assets/icons";
|
|
9
|
+
import { SETTINGS_PERMISSIONS } from "../../utils/path";
|
|
10
|
+
import Logo from "../../assets/balakhaniLogo.png";
|
|
11
|
+
var Platform = function Platform() {
|
|
12
|
+
var dispatch = useDispatch();
|
|
13
|
+
var rootUrl;
|
|
14
|
+
if (window.location.hostname === "localhost") {
|
|
15
|
+
rootUrl = "http://localhost:" + window.location.port;
|
|
16
|
+
} else {
|
|
17
|
+
rootUrl = window.location.origin;
|
|
18
|
+
}
|
|
19
|
+
var _useSelector = useSelector(function (state) {
|
|
20
|
+
return state.auth;
|
|
21
|
+
}),
|
|
22
|
+
scopesData = _useSelector.scopesData;
|
|
23
|
+
useEffect(function () {
|
|
24
|
+
dispatch(scopes());
|
|
25
|
+
dispatch(getProfileInfo());
|
|
26
|
+
}, []);
|
|
27
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
28
|
+
className: style.platform
|
|
29
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
30
|
+
className: style.logo
|
|
31
|
+
}, rootUrl.includes("balakhanioc") ? /*#__PURE__*/React.createElement("img", {
|
|
32
|
+
src: Logo,
|
|
33
|
+
alt: ""
|
|
34
|
+
}) : localStorage.getItem("theme") === "dark" ? /*#__PURE__*/React.createElement(DsgLogo, {
|
|
35
|
+
dark: true
|
|
36
|
+
}) : /*#__PURE__*/React.createElement(DsgLogo, null)), /*#__PURE__*/React.createElement("div", {
|
|
37
|
+
className: style.buttons
|
|
38
|
+
}, /*#__PURE__*/React.createElement("h2", {
|
|
39
|
+
className: style.title
|
|
40
|
+
}, "Data Platform"), /*#__PURE__*/React.createElement("div", {
|
|
41
|
+
className: style.links
|
|
42
|
+
}, entryData === null || entryData === void 0 ? void 0 : entryData.map(function (item) {
|
|
43
|
+
if (scopesData === "*") {
|
|
44
|
+
return /*#__PURE__*/React.createElement(Link, {
|
|
45
|
+
to: item === null || item === void 0 ? void 0 : item.pathname,
|
|
46
|
+
key: item === null || item === void 0 ? void 0 : item.id
|
|
47
|
+
}, item === null || item === void 0 ? void 0 : item.icon, /*#__PURE__*/React.createElement("div", {
|
|
48
|
+
"data-no-invert": true
|
|
49
|
+
}, item === null || item === void 0 ? void 0 : item.value));
|
|
50
|
+
} else {
|
|
51
|
+
if (!(scopesData !== null && scopesData !== void 0 && scopesData.includes(item.scopes))) {
|
|
52
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
53
|
+
className: style.disableMenu,
|
|
54
|
+
key: item === null || item === void 0 ? void 0 : item.id
|
|
55
|
+
}, item === null || item === void 0 ? void 0 : item.icon, /*#__PURE__*/React.createElement("div", {
|
|
56
|
+
"data-no-invert": true
|
|
57
|
+
}, item === null || item === void 0 ? void 0 : item.value));
|
|
58
|
+
} else {
|
|
59
|
+
return /*#__PURE__*/React.createElement(Link, {
|
|
60
|
+
to: item === null || item === void 0 ? void 0 : item.pathname,
|
|
61
|
+
key: item === null || item === void 0 ? void 0 : item.id
|
|
62
|
+
}, item === null || item === void 0 ? void 0 : item.icon, /*#__PURE__*/React.createElement("div", {
|
|
63
|
+
"data-no-invert": true
|
|
64
|
+
}, item === null || item === void 0 ? void 0 : item.value));
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}), /*#__PURE__*/React.createElement(Link, {
|
|
68
|
+
to: "".concat(rootUrl, "/accounts/private")
|
|
69
|
+
}, /*#__PURE__*/React.createElement(UserIcon, null), /*#__PURE__*/React.createElement("div", {
|
|
70
|
+
"data-no-invert": true
|
|
71
|
+
}, "\u015E\u0259xsi kabinet")))), /*#__PURE__*/React.createElement("div", {
|
|
72
|
+
className: style.settings_button,
|
|
73
|
+
"data-no-invert-2": true
|
|
74
|
+
}, scopesData === "*" ? /*#__PURE__*/React.createElement(Link, {
|
|
75
|
+
to: "".concat(rootUrl, "/docflow/").concat(SETTINGS_PERMISSIONS)
|
|
76
|
+
}, /*#__PURE__*/React.createElement(SettingsCogIcon, null), /*#__PURE__*/React.createElement("div", {
|
|
77
|
+
"data-no-invert": true
|
|
78
|
+
}, "T\u0259nziml\u0259m\u0259l\u0259r")) : null));
|
|
79
|
+
};
|
|
80
|
+
export default Platform;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
.platform {
|
|
2
|
+
display: flex;
|
|
3
|
+
width: 100%;
|
|
4
|
+
align-items: center;
|
|
5
|
+
flex-direction: column;
|
|
6
|
+
padding-top: 87px;
|
|
7
|
+
height: 100vh;
|
|
8
|
+
background: #f8f8f8;
|
|
9
|
+
.logo {
|
|
10
|
+
svg {
|
|
11
|
+
width: 250px;
|
|
12
|
+
height: auto;
|
|
13
|
+
margin-bottom: 165px;
|
|
14
|
+
}
|
|
15
|
+
img {
|
|
16
|
+
width: 250px;
|
|
17
|
+
height: auto;
|
|
18
|
+
margin-bottom: 85px;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
.buttons {
|
|
22
|
+
// width: 774px;
|
|
23
|
+
padding: 29px 30px;
|
|
24
|
+
background: #ffffff;
|
|
25
|
+
border: 1px solid #e1e1e1;
|
|
26
|
+
border-radius: 20px;
|
|
27
|
+
|
|
28
|
+
.title {
|
|
29
|
+
font-family: Inter;
|
|
30
|
+
font-size: 30px;
|
|
31
|
+
font-weight: 500;
|
|
32
|
+
line-height: 36.31px;
|
|
33
|
+
text-align: center;
|
|
34
|
+
margin-bottom: 37px;
|
|
35
|
+
}
|
|
36
|
+
.links {
|
|
37
|
+
display: flex;
|
|
38
|
+
justify-content: space-between;
|
|
39
|
+
gap: 30px;
|
|
40
|
+
a {
|
|
41
|
+
display: flex;
|
|
42
|
+
flex-direction: column;
|
|
43
|
+
justify-content: center;
|
|
44
|
+
align-items: center;
|
|
45
|
+
gap: 21px;
|
|
46
|
+
width: 218px;
|
|
47
|
+
height: 218px;
|
|
48
|
+
border-radius: 8px;
|
|
49
|
+
background: #f8f8f8;
|
|
50
|
+
font-size: 22px;
|
|
51
|
+
font-weight: 500;
|
|
52
|
+
line-height: 26.63px;
|
|
53
|
+
text-align: left;
|
|
54
|
+
cursor: pointer;
|
|
55
|
+
text-align: center;
|
|
56
|
+
text-decoration: none;
|
|
57
|
+
color: var(--darkBlueColor);
|
|
58
|
+
svg {
|
|
59
|
+
margin-top: 45px;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
.disableMenu {
|
|
63
|
+
display: flex;
|
|
64
|
+
flex-direction: column;
|
|
65
|
+
justify-content: center;
|
|
66
|
+
align-items: center;
|
|
67
|
+
gap: 21px;
|
|
68
|
+
width: 218px;
|
|
69
|
+
height: 218px;
|
|
70
|
+
border-radius: 8px;
|
|
71
|
+
background: #f8f8f8b9;
|
|
72
|
+
font-size: 22px;
|
|
73
|
+
font-weight: 500;
|
|
74
|
+
line-height: 26.63px;
|
|
75
|
+
text-align: left;
|
|
76
|
+
text-align: center;
|
|
77
|
+
text-decoration: none;
|
|
78
|
+
color: #979797;
|
|
79
|
+
svg {
|
|
80
|
+
margin-top: 45px;
|
|
81
|
+
path {
|
|
82
|
+
fill: #979797;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
.settings_button {
|
|
89
|
+
position: absolute;
|
|
90
|
+
right: 42px;
|
|
91
|
+
bottom: 62px;
|
|
92
|
+
a {
|
|
93
|
+
border: 1px solid #e2e2e2;
|
|
94
|
+
color: var(--darkBlueColor);
|
|
95
|
+
background: #fff;
|
|
96
|
+
display: flex;
|
|
97
|
+
align-items: center;
|
|
98
|
+
gap: 15px;
|
|
99
|
+
padding: 10px 21px;
|
|
100
|
+
font-family: Inter;
|
|
101
|
+
font-size: 20px;
|
|
102
|
+
font-weight: 400;
|
|
103
|
+
line-height: 24.2px;
|
|
104
|
+
text-align: center;
|
|
105
|
+
border-radius: 12px;
|
|
106
|
+
cursor: pointer;
|
|
107
|
+
text-decoration: none;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
3
|
+
import { createAsyncThunk, createSlice } from "@reduxjs/toolkit";
|
|
4
|
+
import { setLoading } from "../global";
|
|
5
|
+
import AuthServices from "./service";
|
|
6
|
+
import { errorMessage, succesMessage } from "../../../utils/message";
|
|
7
|
+
import { LOGIN_PATH, PLATFORM_PATH } from "../../../utils/path";
|
|
8
|
+
var initialState = {
|
|
9
|
+
user: {}
|
|
10
|
+
};
|
|
11
|
+
export var refreshToken = createAsyncThunk("/refreshToken", /*#__PURE__*/function () {
|
|
12
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(token, _ref) {
|
|
13
|
+
var dispatch;
|
|
14
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
15
|
+
while (1) switch (_context.prev = _context.next) {
|
|
16
|
+
case 0:
|
|
17
|
+
dispatch = _ref.dispatch;
|
|
18
|
+
_context.prev = 1;
|
|
19
|
+
_context.next = 4;
|
|
20
|
+
return AuthServices.refreshToken(token);
|
|
21
|
+
case 4:
|
|
22
|
+
_context.next = 8;
|
|
23
|
+
break;
|
|
24
|
+
case 6:
|
|
25
|
+
_context.prev = 6;
|
|
26
|
+
_context.t0 = _context["catch"](1);
|
|
27
|
+
case 8:
|
|
28
|
+
case "end":
|
|
29
|
+
return _context.stop();
|
|
30
|
+
}
|
|
31
|
+
}, _callee, null, [[1, 6]]);
|
|
32
|
+
}));
|
|
33
|
+
return function (_x, _x2) {
|
|
34
|
+
return _ref2.apply(this, arguments);
|
|
35
|
+
};
|
|
36
|
+
}());
|
|
37
|
+
export var login = createAsyncThunk("/login", /*#__PURE__*/function () {
|
|
38
|
+
var _ref4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(data, _ref3) {
|
|
39
|
+
var dispatch, response;
|
|
40
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
41
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
42
|
+
case 0:
|
|
43
|
+
dispatch = _ref3.dispatch;
|
|
44
|
+
_context2.prev = 1;
|
|
45
|
+
dispatch(setLoading(true));
|
|
46
|
+
_context2.next = 5;
|
|
47
|
+
return AuthServices.login(data === null || data === void 0 ? void 0 : data.formdata);
|
|
48
|
+
case 5:
|
|
49
|
+
response = _context2.sent;
|
|
50
|
+
localStorage.setItem("token", response === null || response === void 0 ? void 0 : response.data.accessToken);
|
|
51
|
+
localStorage.setItem("refreshToken", response === null || response === void 0 ? void 0 : response.data.refreshToken);
|
|
52
|
+
succesMessage("Sistemə daxil olunur...");
|
|
53
|
+
dispatch(setLoading(false));
|
|
54
|
+
data === null || data === void 0 || data.navigate(PLATFORM_PATH);
|
|
55
|
+
return _context2.abrupt("return", response === null || response === void 0 ? void 0 : response.data);
|
|
56
|
+
case 14:
|
|
57
|
+
_context2.prev = 14;
|
|
58
|
+
_context2.t0 = _context2["catch"](1);
|
|
59
|
+
dispatch(setLoading(false));
|
|
60
|
+
if (_context2.t0.response && _context2.t0.response.status === 500) {
|
|
61
|
+
errorMessage("Giriş uğursuz oldu. Zəhmət olmasa məlumatlarınızı yoxlayın.");
|
|
62
|
+
} else {
|
|
63
|
+
errorMessage("Xəta baş verdi. Zəhmət olmasa, yenidən cəhd edin.");
|
|
64
|
+
}
|
|
65
|
+
data === null || data === void 0 || data.navigate(LOGIN_PATH);
|
|
66
|
+
case 19:
|
|
67
|
+
case "end":
|
|
68
|
+
return _context2.stop();
|
|
69
|
+
}
|
|
70
|
+
}, _callee2, null, [[1, 14]]);
|
|
71
|
+
}));
|
|
72
|
+
return function (_x3, _x4) {
|
|
73
|
+
return _ref4.apply(this, arguments);
|
|
74
|
+
};
|
|
75
|
+
}());
|
|
76
|
+
export var getProfileInfo = createAsyncThunk("/getProfileInfo", /*#__PURE__*/function () {
|
|
77
|
+
var _ref6 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(_, _ref5) {
|
|
78
|
+
var dispatch, response;
|
|
79
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
80
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
81
|
+
case 0:
|
|
82
|
+
dispatch = _ref5.dispatch;
|
|
83
|
+
_context3.prev = 1;
|
|
84
|
+
dispatch(setLoading(true));
|
|
85
|
+
_context3.next = 5;
|
|
86
|
+
return AuthServices.getProfileInfo();
|
|
87
|
+
case 5:
|
|
88
|
+
response = _context3.sent;
|
|
89
|
+
dispatch(setLoading(false));
|
|
90
|
+
return _context3.abrupt("return", response === null || response === void 0 ? void 0 : response.data);
|
|
91
|
+
case 10:
|
|
92
|
+
_context3.prev = 10;
|
|
93
|
+
_context3.t0 = _context3["catch"](1);
|
|
94
|
+
errorMessage(_context3.t0.response.data.message);
|
|
95
|
+
dispatch(setLoading(false));
|
|
96
|
+
case 14:
|
|
97
|
+
case "end":
|
|
98
|
+
return _context3.stop();
|
|
99
|
+
}
|
|
100
|
+
}, _callee3, null, [[1, 10]]);
|
|
101
|
+
}));
|
|
102
|
+
return function (_x5, _x6) {
|
|
103
|
+
return _ref6.apply(this, arguments);
|
|
104
|
+
};
|
|
105
|
+
}());
|
|
106
|
+
export var auth = createSlice({
|
|
107
|
+
name: "auth",
|
|
108
|
+
initialState: initialState,
|
|
109
|
+
reducers: {
|
|
110
|
+
scopes: function scopes(state) {
|
|
111
|
+
try {
|
|
112
|
+
var token = localStorage.getItem("token");
|
|
113
|
+
if (!token) {
|
|
114
|
+
state.scopesData = null;
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
var base64Url = token.split(".")[1];
|
|
118
|
+
if (!base64Url) {
|
|
119
|
+
throw new Error("Invalid token format");
|
|
120
|
+
}
|
|
121
|
+
var decodedPayload = JSON.parse(atob(base64Url));
|
|
122
|
+
state.scopesData = (decodedPayload === null || decodedPayload === void 0 ? void 0 : decodedPayload.scopes) || null;
|
|
123
|
+
} catch (error) {
|
|
124
|
+
console.error("Error decoding token:", error);
|
|
125
|
+
state.scopesData = null; // Reset state if there's an error
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
extraReducers: function extraReducers(builder) {
|
|
130
|
+
builder.addCase(login.fulfilled, function (state, _ref7) {
|
|
131
|
+
var payload = _ref7.payload;
|
|
132
|
+
state.user = payload;
|
|
133
|
+
});
|
|
134
|
+
builder.addCase(getProfileInfo.fulfilled, function (state, _ref8) {
|
|
135
|
+
var payload = _ref8.payload;
|
|
136
|
+
state.profileInfo = payload;
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
var scopes = auth.actions.scopes;
|
|
141
|
+
export { scopes };
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
4
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
5
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
6
|
+
import api from "../../../utils/axios";
|
|
7
|
+
var AuthServices = /*#__PURE__*/_createClass(function AuthServices() {
|
|
8
|
+
_classCallCheck(this, AuthServices);
|
|
9
|
+
});
|
|
10
|
+
_defineProperty(AuthServices, "login", /*#__PURE__*/function () {
|
|
11
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(formdata) {
|
|
12
|
+
var response;
|
|
13
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
14
|
+
while (1) switch (_context.prev = _context.next) {
|
|
15
|
+
case 0:
|
|
16
|
+
_context.next = 2;
|
|
17
|
+
return api.post("/profile/signin", formdata);
|
|
18
|
+
case 2:
|
|
19
|
+
response = _context.sent;
|
|
20
|
+
return _context.abrupt("return", response === null || response === void 0 ? void 0 : response.data);
|
|
21
|
+
case 4:
|
|
22
|
+
case "end":
|
|
23
|
+
return _context.stop();
|
|
24
|
+
}
|
|
25
|
+
}, _callee);
|
|
26
|
+
}));
|
|
27
|
+
return function (_x) {
|
|
28
|
+
return _ref.apply(this, arguments);
|
|
29
|
+
};
|
|
30
|
+
}());
|
|
31
|
+
_defineProperty(AuthServices, "refreshToken", /*#__PURE__*/function () {
|
|
32
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(token) {
|
|
33
|
+
var response;
|
|
34
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
35
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
36
|
+
case 0:
|
|
37
|
+
_context2.next = 2;
|
|
38
|
+
return api.post("/profile/refresh-token", token);
|
|
39
|
+
case 2:
|
|
40
|
+
response = _context2.sent;
|
|
41
|
+
return _context2.abrupt("return", response === null || response === void 0 ? void 0 : response.data);
|
|
42
|
+
case 4:
|
|
43
|
+
case "end":
|
|
44
|
+
return _context2.stop();
|
|
45
|
+
}
|
|
46
|
+
}, _callee2);
|
|
47
|
+
}));
|
|
48
|
+
return function (_x2) {
|
|
49
|
+
return _ref2.apply(this, arguments);
|
|
50
|
+
};
|
|
51
|
+
}());
|
|
52
|
+
_defineProperty(AuthServices, "getProfileInfo", /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
53
|
+
var response;
|
|
54
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
55
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
56
|
+
case 0:
|
|
57
|
+
_context3.next = 2;
|
|
58
|
+
return api.get("/profile/info");
|
|
59
|
+
case 2:
|
|
60
|
+
response = _context3.sent;
|
|
61
|
+
return _context3.abrupt("return", response === null || response === void 0 ? void 0 : response.data);
|
|
62
|
+
case 4:
|
|
63
|
+
case "end":
|
|
64
|
+
return _context3.stop();
|
|
65
|
+
}
|
|
66
|
+
}, _callee3);
|
|
67
|
+
})));
|
|
68
|
+
export default AuthServices;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { createSlice } from "@reduxjs/toolkit";
|
|
2
|
+
var initialState = {
|
|
3
|
+
loading: false
|
|
4
|
+
};
|
|
5
|
+
export var global = createSlice({
|
|
6
|
+
name: "global",
|
|
7
|
+
initialState: initialState,
|
|
8
|
+
reducers: {
|
|
9
|
+
setLoading: function setLoading(state, _ref) {
|
|
10
|
+
var payload = _ref.payload;
|
|
11
|
+
state.loading = payload;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
var setLoading = global.actions.setLoading;
|
|
16
|
+
export { setLoading };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import { configureStore } from "@reduxjs/toolkit";
|
|
3
|
+
import { global } from "./slices/global";
|
|
4
|
+
import { auth } from "./slices/auth";
|
|
5
|
+
export var store = configureStore({
|
|
6
|
+
reducer: _defineProperty(_defineProperty({}, global.name, global.reducer), auth.name, auth.reducer)
|
|
7
|
+
});
|
|
8
|
+
export default store;
|