@banch0u/core-project-test-repository 1.3.2 → 1.4.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.
@@ -0,0 +1,207 @@
1
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
3
+ import { createAsyncThunk, createSlice } from "@reduxjs/toolkit";
4
+ import Services from "./service";
5
+ import { setNotificationsRender, setLoading, setViewModalVisible } from "../global";
6
+ import { errorMessage } from "../../../utils/message";
7
+ var initialState = {
8
+ notification: []
9
+ };
10
+ export var getNotifications = createAsyncThunk("/getNotifications", /*#__PURE__*/function () {
11
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(data, _ref) {
12
+ var dispatch, response;
13
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
14
+ while (1) switch (_context.prev = _context.next) {
15
+ case 0:
16
+ dispatch = _ref.dispatch;
17
+ _context.prev = 1;
18
+ _context.next = 4;
19
+ return Services.getNotifications(data === null || data === void 0 ? void 0 : data.size, data === null || data === void 0 ? void 0 : data.page);
20
+ case 4:
21
+ response = _context.sent;
22
+ return _context.abrupt("return", response);
23
+ case 8:
24
+ _context.prev = 8;
25
+ _context.t0 = _context["catch"](1);
26
+ errorMessage(_context.t0.response.data.message);
27
+ // dispatch(setLoading(false));
28
+ case 11:
29
+ case "end":
30
+ return _context.stop();
31
+ }
32
+ }, _callee, null, [[1, 8]]);
33
+ }));
34
+ return function (_x, _x2) {
35
+ return _ref2.apply(this, arguments);
36
+ };
37
+ }());
38
+ export var readNotification = createAsyncThunk("/readNotification", /*#__PURE__*/function () {
39
+ var _ref4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(data, _ref3) {
40
+ var dispatch, response;
41
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
42
+ while (1) switch (_context2.prev = _context2.next) {
43
+ case 0:
44
+ dispatch = _ref3.dispatch;
45
+ _context2.prev = 1;
46
+ _context2.next = 4;
47
+ return Services.readNotification(data);
48
+ case 4:
49
+ response = _context2.sent;
50
+ // dispatch(setLoading(false));
51
+ dispatch(setNotificationsRender(function (prev) {
52
+ return !prev;
53
+ }));
54
+ return _context2.abrupt("return", response === null || response === void 0 ? void 0 : response.data);
55
+ case 9:
56
+ _context2.prev = 9;
57
+ _context2.t0 = _context2["catch"](1);
58
+ errorMessage(_context2.t0.response.data.message);
59
+ // dispatch(setLoading(false));
60
+ case 12:
61
+ case "end":
62
+ return _context2.stop();
63
+ }
64
+ }, _callee2, null, [[1, 9]]);
65
+ }));
66
+ return function (_x3, _x4) {
67
+ return _ref4.apply(this, arguments);
68
+ };
69
+ }());
70
+ export var readNotificationAll = createAsyncThunk("/readNotificationAll", /*#__PURE__*/function () {
71
+ var _ref6 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(_, _ref5) {
72
+ var dispatch, response;
73
+ return _regeneratorRuntime.wrap(function _callee3$(_context3) {
74
+ while (1) switch (_context3.prev = _context3.next) {
75
+ case 0:
76
+ dispatch = _ref5.dispatch;
77
+ _context3.prev = 1;
78
+ _context3.next = 4;
79
+ return Services.readNotificationAll();
80
+ case 4:
81
+ response = _context3.sent;
82
+ // dispatch(setLoading(false));
83
+ dispatch(setNotificationsRender(function (prev) {
84
+ return !prev;
85
+ }));
86
+ return _context3.abrupt("return", response === null || response === void 0 ? void 0 : response.data);
87
+ case 9:
88
+ _context3.prev = 9;
89
+ _context3.t0 = _context3["catch"](1);
90
+ errorMessage(_context3.t0.response.data.message);
91
+ // dispatch(setLoading(false));
92
+ case 12:
93
+ case "end":
94
+ return _context3.stop();
95
+ }
96
+ }, _callee3, null, [[1, 9]]);
97
+ }));
98
+ return function (_x5, _x6) {
99
+ return _ref6.apply(this, arguments);
100
+ };
101
+ }());
102
+ export var checkNotification = createAsyncThunk("/checkNotification", /*#__PURE__*/function () {
103
+ var _ref8 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4(_, _ref7) {
104
+ var dispatch, response;
105
+ return _regeneratorRuntime.wrap(function _callee4$(_context4) {
106
+ while (1) switch (_context4.prev = _context4.next) {
107
+ case 0:
108
+ dispatch = _ref7.dispatch;
109
+ _context4.prev = 1;
110
+ _context4.next = 4;
111
+ return Services.checkNotification();
112
+ case 4:
113
+ response = _context4.sent;
114
+ return _context4.abrupt("return", response === null || response === void 0 ? void 0 : response.data);
115
+ case 8:
116
+ _context4.prev = 8;
117
+ _context4.t0 = _context4["catch"](1);
118
+ errorMessage(_context4.t0.response.data.message);
119
+ // dispatch(setLoading(false));
120
+ case 11:
121
+ case "end":
122
+ return _context4.stop();
123
+ }
124
+ }, _callee4, null, [[1, 8]]);
125
+ }));
126
+ return function (_x7, _x8) {
127
+ return _ref8.apply(this, arguments);
128
+ };
129
+ }());
130
+ export var getNotificationSettings = createAsyncThunk("/getNotificationSettings", /*#__PURE__*/function () {
131
+ var _ref10 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee5(_, _ref9) {
132
+ var dispatch, response;
133
+ return _regeneratorRuntime.wrap(function _callee5$(_context5) {
134
+ while (1) switch (_context5.prev = _context5.next) {
135
+ case 0:
136
+ dispatch = _ref9.dispatch;
137
+ _context5.prev = 1;
138
+ _context5.next = 4;
139
+ return Services.getNotificationSettings();
140
+ case 4:
141
+ response = _context5.sent;
142
+ return _context5.abrupt("return", response);
143
+ case 8:
144
+ _context5.prev = 8;
145
+ _context5.t0 = _context5["catch"](1);
146
+ errorMessage(_context5.t0.response.data.message);
147
+ // dispatch(setLoading(false));
148
+ case 11:
149
+ case "end":
150
+ return _context5.stop();
151
+ }
152
+ }, _callee5, null, [[1, 8]]);
153
+ }));
154
+ return function (_x9, _x10) {
155
+ return _ref10.apply(this, arguments);
156
+ };
157
+ }());
158
+ export var editNotificationSettings = createAsyncThunk("/editNotificationSettings", /*#__PURE__*/function () {
159
+ var _ref12 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee6(data, _ref11) {
160
+ var dispatch, response;
161
+ return _regeneratorRuntime.wrap(function _callee6$(_context6) {
162
+ while (1) switch (_context6.prev = _context6.next) {
163
+ case 0:
164
+ dispatch = _ref11.dispatch;
165
+ _context6.prev = 1;
166
+ _context6.next = 4;
167
+ return Services.editNotificationSettings(data);
168
+ case 4:
169
+ response = _context6.sent;
170
+ // dispatch(setLoading(false));
171
+ dispatch(setNotificationsRender(function (prev) {
172
+ return !prev;
173
+ }));
174
+ return _context6.abrupt("return", response === null || response === void 0 ? void 0 : response.data);
175
+ case 9:
176
+ _context6.prev = 9;
177
+ _context6.t0 = _context6["catch"](1);
178
+ errorMessage(_context6.t0.response.data.message);
179
+ // dispatch(setLoading(false));
180
+ case 12:
181
+ case "end":
182
+ return _context6.stop();
183
+ }
184
+ }, _callee6, null, [[1, 9]]);
185
+ }));
186
+ return function (_x11, _x12) {
187
+ return _ref12.apply(this, arguments);
188
+ };
189
+ }());
190
+ export var notification = createSlice({
191
+ name: "notification",
192
+ initialState: initialState,
193
+ extraReducers: function extraReducers(builder) {
194
+ builder.addCase(getNotifications.fulfilled, function (state, _ref13) {
195
+ var payload = _ref13.payload;
196
+ state.notifications = payload;
197
+ }).addCase(checkNotification.fulfilled, function (state, _ref14) {
198
+ var payload = _ref14.payload;
199
+ state.checkNotification = payload;
200
+ }).addCase(getNotificationSettings.fulfilled, function (state, _ref15) {
201
+ var payload = _ref15.payload;
202
+ state.notificationSettings = payload;
203
+ });
204
+ }
205
+ });
206
+ var setPage = notification.actions.setPage;
207
+ export { setPage };
@@ -0,0 +1,123 @@
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 Services = /*#__PURE__*/_createClass(function Services() {
8
+ _classCallCheck(this, Services);
9
+ });
10
+ _defineProperty(Services, "getNotifications", /*#__PURE__*/function () {
11
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(size, page) {
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.get("/NotificationDetails/".concat(size, "/page/").concat(page));
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, _x2) {
28
+ return _ref.apply(this, arguments);
29
+ };
30
+ }());
31
+ _defineProperty(Services, "readNotification", /*#__PURE__*/function () {
32
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(data) {
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.put("/NotificationDetails", data);
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 (_x3) {
49
+ return _ref2.apply(this, arguments);
50
+ };
51
+ }());
52
+ _defineProperty(Services, "readNotificationAll", /*#__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.put("/NotificationDetails/ReadAll", {
59
+ id: ""
60
+ });
61
+ case 2:
62
+ response = _context3.sent;
63
+ return _context3.abrupt("return", response === null || response === void 0 ? void 0 : response.data);
64
+ case 4:
65
+ case "end":
66
+ return _context3.stop();
67
+ }
68
+ }, _callee3);
69
+ })));
70
+ _defineProperty(Services, "checkNotification", /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
71
+ var response;
72
+ return _regeneratorRuntime.wrap(function _callee4$(_context4) {
73
+ while (1) switch (_context4.prev = _context4.next) {
74
+ case 0:
75
+ _context4.next = 2;
76
+ return api.get("/notificationusersettings/check");
77
+ case 2:
78
+ response = _context4.sent;
79
+ return _context4.abrupt("return", response === null || response === void 0 ? void 0 : response.data);
80
+ case 4:
81
+ case "end":
82
+ return _context4.stop();
83
+ }
84
+ }, _callee4);
85
+ })));
86
+ _defineProperty(Services, "getNotificationSettings", /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
87
+ var response;
88
+ return _regeneratorRuntime.wrap(function _callee5$(_context5) {
89
+ while (1) switch (_context5.prev = _context5.next) {
90
+ case 0:
91
+ _context5.next = 2;
92
+ return api.get("/notificationusersettings");
93
+ case 2:
94
+ response = _context5.sent;
95
+ return _context5.abrupt("return", response === null || response === void 0 ? void 0 : response.data);
96
+ case 4:
97
+ case "end":
98
+ return _context5.stop();
99
+ }
100
+ }, _callee5);
101
+ })));
102
+ _defineProperty(Services, "editNotificationSettings", /*#__PURE__*/function () {
103
+ var _ref6 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee6(data) {
104
+ var response;
105
+ return _regeneratorRuntime.wrap(function _callee6$(_context6) {
106
+ while (1) switch (_context6.prev = _context6.next) {
107
+ case 0:
108
+ _context6.next = 2;
109
+ return api.put("/notificationusersettings", data);
110
+ case 2:
111
+ response = _context6.sent;
112
+ return _context6.abrupt("return", response === null || response === void 0 ? void 0 : response.data);
113
+ case 4:
114
+ case "end":
115
+ return _context6.stop();
116
+ }
117
+ }, _callee6);
118
+ }));
119
+ return function (_x4) {
120
+ return _ref6.apply(this, arguments);
121
+ };
122
+ }());
123
+ export default Services;
@@ -2,7 +2,8 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import { configureStore } from "@reduxjs/toolkit";
3
3
  import { global } from "./slices/global";
4
4
  import { auth } from "./slices/auth";
5
+ import { notification } from "./slices/notification";
5
6
  export var store = configureStore({
6
- reducer: _defineProperty(_defineProperty({}, global.name, global.reducer), auth.name, auth.reducer)
7
+ reducer: _defineProperty(_defineProperty(_defineProperty({}, notification.name, notification.reducer), global.name, global.reducer), auth.name, auth.reducer)
7
8
  });
8
9
  export default store;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@banch0u/core-project-test-repository",
3
- "version": "1.3.2",
3
+ "version": "1.4.1",
4
4
  "description": "Shared core features for all projects",
5
5
  "main": "dist/index.js",
6
6
  "files": [