@banch0u/core-project-test-repository 2.3.0 → 2.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.
@@ -1,7 +1,28 @@
1
- import React, { useMemo } from "react";
1
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
4
+ import React, { useMemo, useState } from "react";
5
+ import { Modal } from "antd";
6
+ import Button from "../Button";
7
+ import { useDispatch } from "react-redux";
8
+ import { requestActivation } from "../../store/slices/auth";
2
9
  var LicenseWatermark = function LicenseWatermark(_ref) {
3
10
  var companyInfo = _ref.companyInfo,
4
11
  pathname = _ref.pathname;
12
+ var _useState = useState(false),
13
+ _useState2 = _slicedToArray(_useState, 2),
14
+ open = _useState2[0],
15
+ setOpen = _useState2[1];
16
+ var _useState3 = useState(""),
17
+ _useState4 = _slicedToArray(_useState3, 2),
18
+ note = _useState4[0],
19
+ setNote = _useState4[1];
20
+ var _useState5 = useState(false),
21
+ _useState6 = _slicedToArray(_useState5, 2),
22
+ loading = _useState6[0],
23
+ setLoading = _useState6[1];
24
+ var dispatch = useDispatch();
25
+
5
26
  // ----------------------------
6
27
  // URL → project mapping
7
28
  // ----------------------------
@@ -95,11 +116,52 @@ var LicenseWatermark = function LicenseWatermark(_ref) {
95
116
  };
96
117
  }, [currentProject]);
97
118
 
119
+ // ----------------------------
120
+ // activation handler
121
+ // ----------------------------
122
+ var handleActivate = /*#__PURE__*/function () {
123
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
124
+ var _t;
125
+ return _regeneratorRuntime.wrap(function (_context) {
126
+ while (1) switch (_context.prev = _context.next) {
127
+ case 0:
128
+ _context.prev = 0;
129
+ setLoading(true);
130
+ _context.next = 1;
131
+ return dispatch(requestActivation());
132
+ case 1:
133
+ setOpen(false);
134
+ setNote("");
135
+ _context.next = 3;
136
+ break;
137
+ case 2:
138
+ _context.prev = 2;
139
+ _t = _context["catch"](0);
140
+ console.error(_t);
141
+ case 3:
142
+ _context.prev = 3;
143
+ setLoading(false);
144
+ window.location.reload();
145
+ return _context.finish(3);
146
+ case 4:
147
+ case "end":
148
+ return _context.stop();
149
+ }
150
+ }, _callee, null, [[0, 2, 3, 4]]);
151
+ }));
152
+ return function handleActivate() {
153
+ return _ref2.apply(this, arguments);
154
+ };
155
+ }();
156
+
98
157
  // ----------------------------
99
158
  // render
100
159
  // ----------------------------
101
160
  if (licenseStatus.status === "valid") return null;
102
- return /*#__PURE__*/React.createElement("div", {
161
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
162
+ onClick: function onClick() {
163
+ return setOpen(true);
164
+ },
103
165
  style: {
104
166
  position: "absolute",
105
167
  top: 0,
@@ -111,8 +173,28 @@ var LicenseWatermark = function LicenseWatermark(_ref) {
111
173
  zIndex: 9999,
112
174
  display: "flex",
113
175
  justifyContent: "center",
114
- alignItems: "center"
176
+ alignItems: "center",
177
+ cursor: "pointer"
178
+ }
179
+ }, licenseStatus.status === "expired" ? "Lisenziya müddəti bitib" : licenseStatus.text), /*#__PURE__*/React.createElement(Modal, {
180
+ title: "Lisenziyan\u0131n aktivl\u0259\u015Fdirilm\u0259si",
181
+ open: open,
182
+ onCancel: function onCancel() {
183
+ return setOpen(false);
184
+ },
185
+ footer: null
186
+ }, /*#__PURE__*/React.createElement("div", {
187
+ style: {
188
+ marginTop: 16,
189
+ textAlign: "right",
190
+ gap: 8,
191
+ display: "flex",
192
+ justifyContent: "flex-end"
115
193
  }
116
- }, licenseStatus.status === "expired" ? "Lisenziya müddəti bitib" : licenseStatus.text);
194
+ }, /*#__PURE__*/React.createElement(Button, {
195
+ color: "green",
196
+ loading: loading,
197
+ onClick: handleActivate
198
+ }, "Aktivasiya t\u0259l\u0259b et"))));
117
199
  };
118
200
  export default LicenseWatermark;
@@ -168,6 +168,36 @@ export var changePassword = createAsyncThunk("/changePassword", /*#__PURE__*/fun
168
168
  return _ref0.apply(this, arguments);
169
169
  };
170
170
  }());
171
+ export var requestActivation = createAsyncThunk("/requestActivation", /*#__PURE__*/function () {
172
+ var _ref10 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee6(_, _ref1) {
173
+ var dispatch, response, _t6;
174
+ return _regeneratorRuntime.wrap(function (_context6) {
175
+ while (1) switch (_context6.prev = _context6.next) {
176
+ case 0:
177
+ dispatch = _ref1.dispatch;
178
+ _context6.prev = 1;
179
+ dispatch(setLoading(true));
180
+ _context6.next = 2;
181
+ return AuthServices.requestActivation();
182
+ case 2:
183
+ response = _context6.sent;
184
+ dispatch(setLoading(false));
185
+ return _context6.abrupt("return", response);
186
+ case 3:
187
+ _context6.prev = 3;
188
+ _t6 = _context6["catch"](1);
189
+ errorMessage(_t6.response.data.message);
190
+ dispatch(setLoading(false));
191
+ case 4:
192
+ case "end":
193
+ return _context6.stop();
194
+ }
195
+ }, _callee6, null, [[1, 3]]);
196
+ }));
197
+ return function (_x1, _x10) {
198
+ return _ref10.apply(this, arguments);
199
+ };
200
+ }());
171
201
  export var auth = createSlice({
172
202
  name: "auth",
173
203
  initialState: initialState,
@@ -192,16 +222,16 @@ export var auth = createSlice({
192
222
  }
193
223
  },
194
224
  extraReducers: function extraReducers(builder) {
195
- builder.addCase(login.fulfilled, function (state, _ref1) {
196
- var payload = _ref1.payload;
225
+ builder.addCase(login.fulfilled, function (state, _ref11) {
226
+ var payload = _ref11.payload;
197
227
  state.user = payload;
198
228
  });
199
- builder.addCase(getProfileInfo.fulfilled, function (state, _ref10) {
200
- var payload = _ref10.payload;
229
+ builder.addCase(getProfileInfo.fulfilled, function (state, _ref12) {
230
+ var payload = _ref12.payload;
201
231
  state.profileInfo = payload;
202
232
  });
203
- builder.addCase(getLoginType.fulfilled, function (state, _ref11) {
204
- var payload = _ref11.payload;
233
+ builder.addCase(getLoginType.fulfilled, function (state, _ref13) {
234
+ var payload = _ref13.payload;
205
235
  state.loginType = payload;
206
236
  });
207
237
  }
@@ -102,4 +102,22 @@ _defineProperty(AuthServices, "changePassword", /*#__PURE__*/function () {
102
102
  return _ref5.apply(this, arguments);
103
103
  };
104
104
  }());
105
+ _defineProperty(AuthServices, "requestActivation", /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
106
+ var response;
107
+ return _regeneratorRuntime.wrap(function (_context6) {
108
+ while (1) switch (_context6.prev = _context6.next) {
109
+ case 0:
110
+ _context6.next = 1;
111
+ return api.put("/licences", {
112
+ prompt: "Request Activation"
113
+ });
114
+ case 1:
115
+ response = _context6.sent;
116
+ return _context6.abrupt("return", response);
117
+ case 2:
118
+ case "end":
119
+ return _context6.stop();
120
+ }
121
+ }, _callee6);
122
+ })));
105
123
  export default AuthServices;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@banch0u/core-project-test-repository",
3
- "version": "2.3.0",
3
+ "version": "2.3.1",
4
4
  "description": "Shared core features for all projects",
5
5
  "main": "dist/index.js",
6
6
  "files": [