@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,173 @@
|
|
|
1
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
3
|
+
// import axios from "axios";
|
|
4
|
+
// export const ACCESS_TOKEN_KEY = "token";
|
|
5
|
+
// export const REFRESH_TOKEN_KEY = "refreshToken";
|
|
6
|
+
|
|
7
|
+
// // Base Axios instance
|
|
8
|
+
// const api = axios.create({ baseURL: process.env.REACT_APP_BASE_URL });
|
|
9
|
+
|
|
10
|
+
// // Function to refresh token
|
|
11
|
+
// const refreshAccessToken = async () => {
|
|
12
|
+
// try {
|
|
13
|
+
// const refreshToken = localStorage.getItem(REFRESH_TOKEN_KEY); // Adjust storage as needed
|
|
14
|
+
// const response = await api.post(
|
|
15
|
+
// `/profile/refresh-token`,
|
|
16
|
+
// {},
|
|
17
|
+
// {
|
|
18
|
+
// headers: {
|
|
19
|
+
// RefreshToken: `${refreshToken}`, // Send refresh token as a header
|
|
20
|
+
// },
|
|
21
|
+
// }
|
|
22
|
+
// );
|
|
23
|
+
// localStorage.setItem(ACCESS_TOKEN_KEY, response.data.accessToken);
|
|
24
|
+
// return response.data.accessToken;
|
|
25
|
+
// } catch (error) {
|
|
26
|
+
// console.error("Failed to refresh token:", error);
|
|
27
|
+
// throw error; // Handle logout or token expiration
|
|
28
|
+
// }
|
|
29
|
+
// };
|
|
30
|
+
|
|
31
|
+
// // Add Axios request interceptor
|
|
32
|
+
// api.interceptors.request.use(
|
|
33
|
+
// (config) => {
|
|
34
|
+
// const token = localStorage.getItem(ACCESS_TOKEN_KEY); // Get token from storage
|
|
35
|
+
// if (token) {
|
|
36
|
+
// config.headers.Authorization = `Bearer ${token}`;
|
|
37
|
+
// }
|
|
38
|
+
// console.log(config);
|
|
39
|
+
// return config;
|
|
40
|
+
// },
|
|
41
|
+
// (error) => Promise.reject(error)
|
|
42
|
+
// );
|
|
43
|
+
|
|
44
|
+
// // Add Axios response interceptor
|
|
45
|
+
// api.interceptors.response.use(
|
|
46
|
+
// (response) => response, // Pass through successful responses
|
|
47
|
+
// async (error) => {
|
|
48
|
+
// const originalRequest = error.config;
|
|
49
|
+
// if (error.code === "ERR_NETWORK" && !originalRequest._retry) {
|
|
50
|
+
// originalRequest._retry = true; // Prevent infinite retry loops
|
|
51
|
+
// try {
|
|
52
|
+
// const newAccessToken = await refreshAccessToken();
|
|
53
|
+
// originalRequest.headers.Authorization = `Bearer ${newAccessToken}`;
|
|
54
|
+
// return api(originalRequest); // Retry the failed request with the new token
|
|
55
|
+
// } catch (refreshError) {
|
|
56
|
+
// // Handle failed token refresh logic (e.g., logout user)
|
|
57
|
+
// console.error("Token refresh failed:", refreshError);
|
|
58
|
+
// window.location.href = "/docflow/login"; //Comment this to prevent logout
|
|
59
|
+
// return Promise.reject(refreshError);
|
|
60
|
+
// }
|
|
61
|
+
// }
|
|
62
|
+
// return Promise.reject(error); // Reject all other errors
|
|
63
|
+
// }
|
|
64
|
+
// );
|
|
65
|
+
|
|
66
|
+
// export default api;
|
|
67
|
+
|
|
68
|
+
//DEV OPTION
|
|
69
|
+
import axios from "axios";
|
|
70
|
+
export var ACCESS_TOKEN_KEY = "token";
|
|
71
|
+
export var REFRESH_TOKEN_KEY = "refreshToken";
|
|
72
|
+
var baseUrl;
|
|
73
|
+
if (window.location.hostname === "localhost") {
|
|
74
|
+
baseUrl = process.env.REACT_APP_BASE_URL;
|
|
75
|
+
} else {
|
|
76
|
+
baseUrl = window.location.origin + "/api";
|
|
77
|
+
}
|
|
78
|
+
// Base Axios instance
|
|
79
|
+
var api = axios.create({
|
|
80
|
+
baseURL: baseUrl
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
// Function to refresh token
|
|
84
|
+
var refreshAccessToken = /*#__PURE__*/function () {
|
|
85
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
86
|
+
var refreshToken, response;
|
|
87
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
88
|
+
while (1) switch (_context.prev = _context.next) {
|
|
89
|
+
case 0:
|
|
90
|
+
_context.prev = 0;
|
|
91
|
+
refreshToken = localStorage.getItem(REFRESH_TOKEN_KEY); // Adjust storage as needed
|
|
92
|
+
_context.next = 4;
|
|
93
|
+
return axios.post(baseUrl + "/profile/refresh-token", {}, {
|
|
94
|
+
headers: {
|
|
95
|
+
RefreshToken: "".concat(refreshToken) // Send refresh token as a header
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
case 4:
|
|
99
|
+
response = _context.sent;
|
|
100
|
+
localStorage.setItem(ACCESS_TOKEN_KEY, response.data.accessToken);
|
|
101
|
+
return _context.abrupt("return", response.data.accessToken);
|
|
102
|
+
case 9:
|
|
103
|
+
_context.prev = 9;
|
|
104
|
+
_context.t0 = _context["catch"](0);
|
|
105
|
+
console.error("Failed to refresh token:", _context.t0);
|
|
106
|
+
throw _context.t0;
|
|
107
|
+
case 13:
|
|
108
|
+
case "end":
|
|
109
|
+
return _context.stop();
|
|
110
|
+
}
|
|
111
|
+
}, _callee, null, [[0, 9]]);
|
|
112
|
+
}));
|
|
113
|
+
return function refreshAccessToken() {
|
|
114
|
+
return _ref.apply(this, arguments);
|
|
115
|
+
};
|
|
116
|
+
}();
|
|
117
|
+
|
|
118
|
+
// Add Axios request interceptor
|
|
119
|
+
api.interceptors.request.use(function (config) {
|
|
120
|
+
var token = localStorage.getItem(ACCESS_TOKEN_KEY); // Get token from storage
|
|
121
|
+
if (token) {
|
|
122
|
+
config.headers.Authorization = "Bearer ".concat(token);
|
|
123
|
+
}
|
|
124
|
+
return config;
|
|
125
|
+
}, function (error) {
|
|
126
|
+
return Promise.reject(error);
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
// Add Axios response interceptor
|
|
130
|
+
api.interceptors.response.use(function (response) {
|
|
131
|
+
return response;
|
|
132
|
+
},
|
|
133
|
+
/*#__PURE__*/
|
|
134
|
+
// Pass through successful responses
|
|
135
|
+
function () {
|
|
136
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(error) {
|
|
137
|
+
var originalRequest, newAccessToken;
|
|
138
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
139
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
140
|
+
case 0:
|
|
141
|
+
originalRequest = error.config;
|
|
142
|
+
if (!(error.response.status === 401 && !originalRequest._retry)) {
|
|
143
|
+
_context2.next = 16;
|
|
144
|
+
break;
|
|
145
|
+
}
|
|
146
|
+
originalRequest._retry = true; // Prevent infinite retry loops
|
|
147
|
+
_context2.prev = 3;
|
|
148
|
+
_context2.next = 6;
|
|
149
|
+
return refreshAccessToken();
|
|
150
|
+
case 6:
|
|
151
|
+
newAccessToken = _context2.sent;
|
|
152
|
+
originalRequest.headers.Authorization = "Bearer ".concat(newAccessToken);
|
|
153
|
+
return _context2.abrupt("return", api(originalRequest));
|
|
154
|
+
case 11:
|
|
155
|
+
_context2.prev = 11;
|
|
156
|
+
_context2.t0 = _context2["catch"](3);
|
|
157
|
+
// Handle failed token refresh logic (e.g., logout user)
|
|
158
|
+
console.error("Token refresh failed:", _context2.t0);
|
|
159
|
+
window.location.href = "/docflow/login"; //Comment this to prevent logout
|
|
160
|
+
return _context2.abrupt("return", Promise.reject(_context2.t0));
|
|
161
|
+
case 16:
|
|
162
|
+
return _context2.abrupt("return", Promise.reject(error));
|
|
163
|
+
case 17:
|
|
164
|
+
case "end":
|
|
165
|
+
return _context2.stop();
|
|
166
|
+
}
|
|
167
|
+
}, _callee2, null, [[3, 11]]);
|
|
168
|
+
}));
|
|
169
|
+
return function (_x) {
|
|
170
|
+
return _ref2.apply(this, arguments);
|
|
171
|
+
};
|
|
172
|
+
}());
|
|
173
|
+
export default api;
|
package/dist/utils/message.js
CHANGED
|
@@ -1,21 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.succesMessage = exports.infoMessageBottomRight = exports.errorMessage = void 0;
|
|
8
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
|
-
var _antd = require("antd");
|
|
1
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
3
|
+
import { notification } from "antd";
|
|
11
4
|
var playNotificationSound = /*#__PURE__*/function () {
|
|
12
|
-
var _ref = (
|
|
5
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
13
6
|
var audio;
|
|
14
|
-
return
|
|
7
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
15
8
|
while (1) switch (_context.prev = _context.next) {
|
|
16
9
|
case 0:
|
|
17
10
|
audio = new Audio("https://assets.mixkit.co/active_storage/sfx/2575/2575-preview.mp3");
|
|
18
|
-
audio.type = "audio/mpeg";
|
|
11
|
+
audio.type = "audio/mpeg";
|
|
19
12
|
audio.preload = "auto";
|
|
20
13
|
setTimeout(function () {
|
|
21
14
|
audio.play()["catch"](function (error) {
|
|
@@ -32,23 +25,23 @@ var playNotificationSound = /*#__PURE__*/function () {
|
|
|
32
25
|
return _ref.apply(this, arguments);
|
|
33
26
|
};
|
|
34
27
|
}();
|
|
35
|
-
var errorMessage =
|
|
28
|
+
export var errorMessage = function errorMessage(_ref2) {
|
|
36
29
|
var value = _ref2.value,
|
|
37
30
|
placeMent = _ref2.placeMent;
|
|
38
|
-
return
|
|
31
|
+
return notification.error({
|
|
39
32
|
message: "",
|
|
40
33
|
description: value || "Serverdə problem baş verdi",
|
|
41
34
|
placement: placeMent
|
|
42
35
|
});
|
|
43
36
|
};
|
|
44
|
-
var succesMessage =
|
|
45
|
-
return
|
|
37
|
+
export var succesMessage = function succesMessage(value) {
|
|
38
|
+
return notification.success({
|
|
46
39
|
message: "",
|
|
47
40
|
description: value || "Uğurla tamamlandı",
|
|
48
41
|
placement: "topRight"
|
|
49
42
|
});
|
|
50
43
|
};
|
|
51
|
-
var infoMessageBottomRight =
|
|
44
|
+
export var infoMessageBottomRight = function infoMessageBottomRight(value) {
|
|
52
45
|
playNotificationSound();
|
|
53
46
|
var projects = ["", "Sənəd dövriyyəsi", "Kadrlar sistemi", "Müqavilələr", "Şəxsi kabinet"];
|
|
54
47
|
var parsedValue;
|
|
@@ -78,8 +71,8 @@ var infoMessageBottomRight = exports.infoMessageBottomRight = function infoMessa
|
|
|
78
71
|
break;
|
|
79
72
|
}
|
|
80
73
|
};
|
|
81
|
-
return
|
|
82
|
-
message: projects[parsedValue.Project],
|
|
74
|
+
return notification.info({
|
|
75
|
+
message: projects[parsedValue.Project] || "Yeni bildiriş",
|
|
83
76
|
description: parsedValue.Text || "Bildiriş",
|
|
84
77
|
placement: "bottomRight",
|
|
85
78
|
onClick: handleClick,
|
|
@@ -87,4 +80,11 @@ var infoMessageBottomRight = exports.infoMessageBottomRight = function infoMessa
|
|
|
87
80
|
cursor: "pointer"
|
|
88
81
|
}
|
|
89
82
|
});
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
// ✅ Add this line to fix the Rollup export error
|
|
86
|
+
export default {
|
|
87
|
+
errorMessage: errorMessage,
|
|
88
|
+
succesMessage: succesMessage,
|
|
89
|
+
infoMessageBottomRight: infoMessageBottomRight
|
|
90
90
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@banch0u/core-project-test-repository",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"description": "Shared core features for all projects",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"files": [
|
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
"author": "banch0u",
|
|
15
15
|
"license": "MIT",
|
|
16
16
|
"scripts": {
|
|
17
|
-
"
|
|
17
|
+
"clean": "rimraf dist",
|
|
18
|
+
"build": "npm run clean && babel src --out-dir dist --copy-files",
|
|
18
19
|
"watch": "chokidar \"src\" -i 'dist' -c \"npm run build && yalc push --force\"",
|
|
19
20
|
"dev": "npm run watch"
|
|
20
21
|
},
|
|
@@ -36,6 +37,7 @@
|
|
|
36
37
|
"@babel/preset-react": "^7.26.3",
|
|
37
38
|
"babel-loader": "^9.2.1",
|
|
38
39
|
"chokidar-cli": "^3.0.0",
|
|
39
|
-
"npm-run-all": "^4.1.5"
|
|
40
|
+
"npm-run-all": "^4.1.5",
|
|
41
|
+
"rimraf": "^6.0.1"
|
|
40
42
|
}
|
|
41
43
|
}
|