@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.
- package/dist/assets/css/variables.css +1 -1
- package/dist/assets/icons/index.js +37 -0
- package/dist/components/FormModal/index.js +142 -0
- package/dist/components/FormModal/index.module.scss +14 -0
- package/dist/components/NotificationDropdown/index.js +163 -0
- package/dist/components/NotificationDropdown/index.module.scss +83 -0
- package/dist/components/NotificationSettingsContent/index.js +232 -0
- package/dist/components/NotificationSettingsContent/index.module.scss +70 -0
- package/dist/components/ProfileOptions/index.js +131 -0
- package/dist/components/ProfileOptions/index.module.scss +131 -0
- package/dist/hooks/useNotification.js +5 -12
- package/dist/index.js +14 -5
- package/dist/layout/Header/index.js +36 -0
- package/dist/layout/Header/index.module.scss +19 -0
- package/dist/store/coreProvider.js +9 -0
- package/dist/store/slices/global/index.js +9 -3
- package/dist/store/slices/notification/index.js +207 -0
- package/dist/store/slices/notification/service.js +123 -0
- package/dist/store/store.js +2 -1
- package/package.json +1 -1
|
@@ -178,4 +178,41 @@ export var UserIcon = function UserIcon() {
|
|
|
178
178
|
d: "M39.82 57.3401H17.67L0 51.4901L18.42 45.3801H36.25L36.28 45.4001L17.88 51.4901L28.89 55.1301L41.11 45.3801H63.19L81.62 51.4901L63.94 57.3401H46.05L63.73 51.4901L52.03 47.6101",
|
|
179
179
|
fill: "#0E6AA9"
|
|
180
180
|
}));
|
|
181
|
+
};
|
|
182
|
+
export var CategoryIcon = function CategoryIcon() {
|
|
183
|
+
return /*#__PURE__*/React.createElement("svg", {
|
|
184
|
+
width: "30",
|
|
185
|
+
height: "30",
|
|
186
|
+
viewBox: "0 0 30 30",
|
|
187
|
+
fill: "none",
|
|
188
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
189
|
+
}, /*#__PURE__*/React.createElement("path", {
|
|
190
|
+
d: "M6.25 12.5H8.75C11.25 12.5 12.5 11.25 12.5 8.75V6.25C12.5 3.75 11.25 2.5 8.75 2.5H6.25C3.75 2.5 2.5 3.75 2.5 6.25V8.75C2.5 11.25 3.75 12.5 6.25 12.5Z",
|
|
191
|
+
stroke: "#141522",
|
|
192
|
+
strokeWidth: "1.875",
|
|
193
|
+
strokeMiterlimit: "10",
|
|
194
|
+
strokeLinecap: "round",
|
|
195
|
+
strokeLinejoin: "round"
|
|
196
|
+
}), /*#__PURE__*/React.createElement("path", {
|
|
197
|
+
d: "M21.25 12.5H23.75C26.25 12.5 27.5 11.25 27.5 8.75V6.25C27.5 3.75 26.25 2.5 23.75 2.5H21.25C18.75 2.5 17.5 3.75 17.5 6.25V8.75C17.5 11.25 18.75 12.5 21.25 12.5Z",
|
|
198
|
+
stroke: "#141522",
|
|
199
|
+
strokeWidth: "1.875",
|
|
200
|
+
strokeMiterlimit: "10",
|
|
201
|
+
strokeLinecap: "round",
|
|
202
|
+
strokeLinejoin: "round"
|
|
203
|
+
}), /*#__PURE__*/React.createElement("path", {
|
|
204
|
+
d: "M21.25 27.5H23.75C26.25 27.5 27.5 26.25 27.5 23.75V21.25C27.5 18.75 26.25 17.5 23.75 17.5H21.25C18.75 17.5 17.5 18.75 17.5 21.25V23.75C17.5 26.25 18.75 27.5 21.25 27.5Z",
|
|
205
|
+
stroke: "#141522",
|
|
206
|
+
strokeWidth: "1.875",
|
|
207
|
+
strokeMiterlimit: "10",
|
|
208
|
+
strokeLinecap: "round",
|
|
209
|
+
strokeLinejoin: "round"
|
|
210
|
+
}), /*#__PURE__*/React.createElement("path", {
|
|
211
|
+
d: "M6.25 27.5H8.75C11.25 27.5 12.5 26.25 12.5 23.75V21.25C12.5 18.75 11.25 17.5 8.75 17.5H6.25C3.75 17.5 2.5 18.75 2.5 21.25V23.75C2.5 26.25 3.75 27.5 6.25 27.5Z",
|
|
212
|
+
stroke: "#141522",
|
|
213
|
+
strokeWidth: "1.875",
|
|
214
|
+
strokeMiterlimit: "10",
|
|
215
|
+
strokeLinecap: "round",
|
|
216
|
+
strokeLinejoin: "round"
|
|
217
|
+
}));
|
|
181
218
|
};
|
|
@@ -0,0 +1,142 @@
|
|
|
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 { Form, Modal } from "antd";
|
|
5
|
+
import React, { forwardRef, useCallback, useImperativeHandle, useState } from "react";
|
|
6
|
+
import { useDispatch, useSelector } from "react-redux";
|
|
7
|
+
import { setCitizenSearchId, setSubtopicSelectDisabled } from "../../store/slices/global";
|
|
8
|
+
import style from "./index.module.scss";
|
|
9
|
+
import { Button } from "@banch0u/core-project-test-repository";
|
|
10
|
+
var FormModal = function FormModal(_ref, ref) {
|
|
11
|
+
var okText = _ref.okText,
|
|
12
|
+
cancelText = _ref.cancelText,
|
|
13
|
+
title = _ref.title,
|
|
14
|
+
titleEdit = _ref.titleEdit,
|
|
15
|
+
children = _ref.children,
|
|
16
|
+
width = _ref.width,
|
|
17
|
+
onSubmit = _ref.onSubmit,
|
|
18
|
+
onEdit = _ref.onEdit,
|
|
19
|
+
_ref$showButtons = _ref.showButtons,
|
|
20
|
+
showButtons = _ref$showButtons === void 0 ? true : _ref$showButtons,
|
|
21
|
+
customForm = _ref.customForm,
|
|
22
|
+
_ref$centered = _ref.centered,
|
|
23
|
+
centered = _ref$centered === void 0 ? true : _ref$centered,
|
|
24
|
+
className = _ref.className,
|
|
25
|
+
onCloseModal = _ref.onCloseModal,
|
|
26
|
+
setKey = _ref.setKey,
|
|
27
|
+
_ref$overlayClosable = _ref.overlayClosable,
|
|
28
|
+
overlayClosable = _ref$overlayClosable === void 0 ? true : _ref$overlayClosable,
|
|
29
|
+
_ref$closable = _ref.closable,
|
|
30
|
+
closable = _ref$closable === void 0 ? true : _ref$closable;
|
|
31
|
+
var useForm = Form.useForm;
|
|
32
|
+
var _useForm = useForm(),
|
|
33
|
+
_useForm2 = _slicedToArray(_useForm, 1),
|
|
34
|
+
form = _useForm2[0];
|
|
35
|
+
var dispatch = useDispatch();
|
|
36
|
+
if (customForm) {
|
|
37
|
+
customForm(form);
|
|
38
|
+
}
|
|
39
|
+
var _useState = useState(false),
|
|
40
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
41
|
+
isVisible = _useState2[0],
|
|
42
|
+
setIsVisible = _useState2[1];
|
|
43
|
+
var _useState3 = useState(false),
|
|
44
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
45
|
+
_isEditing = _useState4[0],
|
|
46
|
+
setIsEditing = _useState4[1];
|
|
47
|
+
var loading = useSelector(function (state) {
|
|
48
|
+
return state.global.loading;
|
|
49
|
+
});
|
|
50
|
+
useImperativeHandle(ref, function () {
|
|
51
|
+
return {
|
|
52
|
+
open: function open() {
|
|
53
|
+
setIsVisible(true);
|
|
54
|
+
setIsEditing(false);
|
|
55
|
+
form.resetFields();
|
|
56
|
+
},
|
|
57
|
+
close: function close() {
|
|
58
|
+
closeModal();
|
|
59
|
+
},
|
|
60
|
+
setEdit: function setEdit(data) {
|
|
61
|
+
setIsVisible(true);
|
|
62
|
+
setIsEditing(true);
|
|
63
|
+
form.setFieldsValue(data);
|
|
64
|
+
},
|
|
65
|
+
isEditing: function isEditing() {
|
|
66
|
+
return _isEditing;
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
});
|
|
70
|
+
var closeModal = function closeModal() {
|
|
71
|
+
if (onCloseModal) onCloseModal();
|
|
72
|
+
if (setKey) setKey(function (prevKey) {
|
|
73
|
+
return prevKey + 1;
|
|
74
|
+
});
|
|
75
|
+
setIsVisible(false);
|
|
76
|
+
};
|
|
77
|
+
var onFormSubmit = useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
78
|
+
var data;
|
|
79
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
80
|
+
while (1) switch (_context.prev = _context.next) {
|
|
81
|
+
case 0:
|
|
82
|
+
_context.prev = 0;
|
|
83
|
+
data = form.getFieldsValue();
|
|
84
|
+
if (!(_isEditing && onEdit !== undefined)) {
|
|
85
|
+
_context.next = 7;
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
_context.next = 5;
|
|
89
|
+
return onEdit(form.getFieldValue("id"), data);
|
|
90
|
+
case 5:
|
|
91
|
+
_context.next = 9;
|
|
92
|
+
break;
|
|
93
|
+
case 7:
|
|
94
|
+
_context.next = 9;
|
|
95
|
+
return onSubmit(data);
|
|
96
|
+
case 9:
|
|
97
|
+
form.resetFields();
|
|
98
|
+
setIsVisible(false);
|
|
99
|
+
_context.next = 15;
|
|
100
|
+
break;
|
|
101
|
+
case 13:
|
|
102
|
+
_context.prev = 13;
|
|
103
|
+
_context.t0 = _context["catch"](0);
|
|
104
|
+
case 15:
|
|
105
|
+
case "end":
|
|
106
|
+
return _context.stop();
|
|
107
|
+
}
|
|
108
|
+
}, _callee, null, [[0, 13]]);
|
|
109
|
+
})), [form, _isEditing, onEdit, onSubmit]);
|
|
110
|
+
var onDelete = useCallback(function (id) {
|
|
111
|
+
onDelete(id);
|
|
112
|
+
}, []);
|
|
113
|
+
return /*#__PURE__*/React.createElement(Modal, {
|
|
114
|
+
className: className === "absolute" ? style.absolute : null,
|
|
115
|
+
open: isVisible,
|
|
116
|
+
width: width,
|
|
117
|
+
title: _isEditing ? titleEdit : title,
|
|
118
|
+
okText: okText,
|
|
119
|
+
cancelText: cancelText,
|
|
120
|
+
onOk: form.submit,
|
|
121
|
+
onCancel: closeModal,
|
|
122
|
+
maskClosable: overlayClosable,
|
|
123
|
+
closable: closable,
|
|
124
|
+
footer: showButtons ? /*#__PURE__*/React.createElement("div", {
|
|
125
|
+
className: style.buttons
|
|
126
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
127
|
+
color: "white",
|
|
128
|
+
onClick: closeModal
|
|
129
|
+
}, cancelText), /*#__PURE__*/React.createElement(Button, {
|
|
130
|
+
color: "green",
|
|
131
|
+
onClick: form.submit
|
|
132
|
+
}, okText)) : null,
|
|
133
|
+
centered: centered
|
|
134
|
+
}, /*#__PURE__*/React.createElement(Form, {
|
|
135
|
+
disabled: loading,
|
|
136
|
+
onFinish: onFormSubmit,
|
|
137
|
+
form: form,
|
|
138
|
+
layout: "vertical",
|
|
139
|
+
requiredMark: false
|
|
140
|
+
}, children));
|
|
141
|
+
};
|
|
142
|
+
export default /*#__PURE__*/forwardRef(FormModal);
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
3
|
+
import React, { useRef, useState } from "react";
|
|
4
|
+
import { useDispatch, useSelector } from "react-redux";
|
|
5
|
+
import { readNotification, readNotificationAll } from "../../store/slices/notification";
|
|
6
|
+
import { Button, List, Tooltip, Typography } from "antd";
|
|
7
|
+
import { CheckOutlined, EyeOutlined, SettingOutlined } from "@ant-design/icons";
|
|
8
|
+
import style from "./index.module.scss";
|
|
9
|
+
import NotificationSettingsContent from "../NotificationSettingsContent";
|
|
10
|
+
import FormModal from "../FormModal";
|
|
11
|
+
var NotificationDropdown = function NotificationDropdown(_ref) {
|
|
12
|
+
var _notifications$notifi;
|
|
13
|
+
var size = _ref.size,
|
|
14
|
+
page = _ref.page,
|
|
15
|
+
setSize = _ref.setSize,
|
|
16
|
+
setPage = _ref.setPage;
|
|
17
|
+
var dispatch = useDispatch();
|
|
18
|
+
var modalRef = useRef(); // ⬅️ Modal ref
|
|
19
|
+
var contentRef = useRef(); // ⬅️ NotificationSettingsContent ref
|
|
20
|
+
|
|
21
|
+
var notifications = useSelector(function (state) {
|
|
22
|
+
return state.notification.notifications;
|
|
23
|
+
});
|
|
24
|
+
var notReadenCount = notifications === null || notifications === void 0 ? void 0 : notifications.notReadenCount;
|
|
25
|
+
var totalCount = notifications === null || notifications === void 0 ? void 0 : notifications.totalCount;
|
|
26
|
+
var items = (notifications === null || notifications === void 0 || (_notifications$notifi = notifications.notifications) === null || _notifications$notifi === void 0 ? void 0 : _notifications$notifi.items) || [];
|
|
27
|
+
var hasMore = items.length < totalCount;
|
|
28
|
+
var projects = ["", "Sənəd dövriyyəsi", "Kadrlar sistemi", "Müqavilələr", "Şəxsi kabinet"];
|
|
29
|
+
var parseNotification = function parseNotification(value) {
|
|
30
|
+
try {
|
|
31
|
+
return JSON.parse(value);
|
|
32
|
+
} catch (e) {
|
|
33
|
+
console.error("Invalid JSON in notification:", value);
|
|
34
|
+
return {
|
|
35
|
+
Text: value
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
var handleRead = function handleRead(id) {
|
|
40
|
+
return dispatch(readNotification({
|
|
41
|
+
id: id
|
|
42
|
+
}));
|
|
43
|
+
};
|
|
44
|
+
var handleReadAll = function handleReadAll() {
|
|
45
|
+
return dispatch(readNotificationAll());
|
|
46
|
+
};
|
|
47
|
+
var handleNotificationClick = /*#__PURE__*/function () {
|
|
48
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(value, id) {
|
|
49
|
+
var parsed, redirectByProject, url;
|
|
50
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
51
|
+
while (1) switch (_context.prev = _context.next) {
|
|
52
|
+
case 0:
|
|
53
|
+
parsed = parseNotification(value);
|
|
54
|
+
_context.next = 3;
|
|
55
|
+
return handleRead(id);
|
|
56
|
+
case 3:
|
|
57
|
+
redirectByProject = {
|
|
58
|
+
1: "/docflow/document-circulation/unread-docs",
|
|
59
|
+
2: "/hr/hr",
|
|
60
|
+
3: "/contracts/unread-contract",
|
|
61
|
+
4: "/accounts/private"
|
|
62
|
+
};
|
|
63
|
+
url = redirectByProject[parsed.Project];
|
|
64
|
+
if (url) {
|
|
65
|
+
window.location.href = "".concat(window.location.origin).concat(url);
|
|
66
|
+
}
|
|
67
|
+
case 6:
|
|
68
|
+
case "end":
|
|
69
|
+
return _context.stop();
|
|
70
|
+
}
|
|
71
|
+
}, _callee);
|
|
72
|
+
}));
|
|
73
|
+
return function handleNotificationClick(_x, _x2) {
|
|
74
|
+
return _ref2.apply(this, arguments);
|
|
75
|
+
};
|
|
76
|
+
}();
|
|
77
|
+
var handleLoadMore = function handleLoadMore() {
|
|
78
|
+
var newSize = size + 20;
|
|
79
|
+
setSize(newSize);
|
|
80
|
+
setPage(1);
|
|
81
|
+
};
|
|
82
|
+
var onOpenModal = function onOpenModal() {
|
|
83
|
+
var _contentRef$current, _contentRef$current$r, _modalRef$current, _modalRef$current$ope;
|
|
84
|
+
contentRef === null || contentRef === void 0 || (_contentRef$current = contentRef.current) === null || _contentRef$current === void 0 || (_contentRef$current$r = _contentRef$current.refresh) === null || _contentRef$current$r === void 0 || _contentRef$current$r.call(_contentRef$current); // ⬅️ Trigger getNotificationSettings()
|
|
85
|
+
modalRef === null || modalRef === void 0 || (_modalRef$current = modalRef.current) === null || _modalRef$current === void 0 || (_modalRef$current$ope = _modalRef$current.open) === null || _modalRef$current$ope === void 0 || _modalRef$current$ope.call(_modalRef$current); // ⬅️ Open modal
|
|
86
|
+
};
|
|
87
|
+
var onCloseModal = function onCloseModal() {
|
|
88
|
+
var _modalRef$current2, _modalRef$current2$cl;
|
|
89
|
+
modalRef === null || modalRef === void 0 || (_modalRef$current2 = modalRef.current) === null || _modalRef$current2 === void 0 || (_modalRef$current2$cl = _modalRef$current2.close) === null || _modalRef$current2$cl === void 0 || _modalRef$current2$cl.call(_modalRef$current2); // ⬅️ Open modal
|
|
90
|
+
};
|
|
91
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
92
|
+
className: style.dropdownWrapper
|
|
93
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
94
|
+
className: style.header
|
|
95
|
+
}, /*#__PURE__*/React.createElement(Typography.Text, {
|
|
96
|
+
strong: true
|
|
97
|
+
}, "Bildiri\u015Fl\u0259r (", totalCount, ")"), /*#__PURE__*/React.createElement("div", {
|
|
98
|
+
className: style.headerActions
|
|
99
|
+
}, notReadenCount > 0 && /*#__PURE__*/React.createElement(Button, {
|
|
100
|
+
size: "small",
|
|
101
|
+
icon: /*#__PURE__*/React.createElement(CheckOutlined, null),
|
|
102
|
+
onClick: handleReadAll,
|
|
103
|
+
type: "text"
|
|
104
|
+
}, "Ham\u0131s\u0131n\u0131 oxu"), /*#__PURE__*/React.createElement(Button, {
|
|
105
|
+
size: "small",
|
|
106
|
+
icon: /*#__PURE__*/React.createElement(SettingOutlined, null),
|
|
107
|
+
type: "text",
|
|
108
|
+
onClick: onOpenModal
|
|
109
|
+
}))), /*#__PURE__*/React.createElement(List, {
|
|
110
|
+
dataSource: items,
|
|
111
|
+
locale: {
|
|
112
|
+
emptyText: "Bildiriş yoxdur"
|
|
113
|
+
},
|
|
114
|
+
renderItem: function renderItem(item) {
|
|
115
|
+
var parsed = parseNotification(item.text);
|
|
116
|
+
return /*#__PURE__*/React.createElement(List.Item, {
|
|
117
|
+
className: "".concat(style.notificationItem, " ").concat(item.isReaden ? style.read : style.unread),
|
|
118
|
+
actions: [!item.isReaden && /*#__PURE__*/React.createElement(Tooltip, {
|
|
119
|
+
title: "Oxu"
|
|
120
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
121
|
+
size: "small",
|
|
122
|
+
type: "link",
|
|
123
|
+
icon: /*#__PURE__*/React.createElement(EyeOutlined, null),
|
|
124
|
+
onClick: function onClick() {
|
|
125
|
+
return handleRead(item.id);
|
|
126
|
+
}
|
|
127
|
+
}))]
|
|
128
|
+
}, /*#__PURE__*/React.createElement(List.Item.Meta, {
|
|
129
|
+
title: /*#__PURE__*/React.createElement("div", {
|
|
130
|
+
onClick: function onClick() {
|
|
131
|
+
return handleNotificationClick(item.text, item.id);
|
|
132
|
+
},
|
|
133
|
+
style: {
|
|
134
|
+
cursor: "pointer"
|
|
135
|
+
}
|
|
136
|
+
}, projects[parsed.Project] || "Bildiriş"),
|
|
137
|
+
description: /*#__PURE__*/React.createElement("div", {
|
|
138
|
+
className: style.ellipsisText,
|
|
139
|
+
onClick: function onClick() {
|
|
140
|
+
return handleNotificationClick(item.text, item.id);
|
|
141
|
+
},
|
|
142
|
+
style: {
|
|
143
|
+
cursor: "pointer"
|
|
144
|
+
}
|
|
145
|
+
}, parsed.Text || "Bildiriş")
|
|
146
|
+
}));
|
|
147
|
+
}
|
|
148
|
+
}), hasMore && /*#__PURE__*/React.createElement("div", {
|
|
149
|
+
className: style.loadMore
|
|
150
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
151
|
+
size: "small",
|
|
152
|
+
type: "text",
|
|
153
|
+
onClick: handleLoadMore
|
|
154
|
+
}, "Daha \xE7ox g\xF6st\u0259r"))), /*#__PURE__*/React.createElement(FormModal, {
|
|
155
|
+
ref: modalRef,
|
|
156
|
+
width: 695,
|
|
157
|
+
showButtons: false
|
|
158
|
+
}, /*#__PURE__*/React.createElement(NotificationSettingsContent, {
|
|
159
|
+
ref: contentRef,
|
|
160
|
+
onClose: onCloseModal
|
|
161
|
+
})));
|
|
162
|
+
};
|
|
163
|
+
export default NotificationDropdown;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
.dropdownWrapper {
|
|
2
|
+
width: 320px;
|
|
3
|
+
max-height: 420px;
|
|
4
|
+
overflow-y: auto;
|
|
5
|
+
overflow-x: hidden;
|
|
6
|
+
// padding: 10px;
|
|
7
|
+
background-color: #ffffff;
|
|
8
|
+
background-clip: padding-box;
|
|
9
|
+
border-radius: 8px;
|
|
10
|
+
outline: none;
|
|
11
|
+
scrollbar-gutter: stable;
|
|
12
|
+
box-shadow: 0 6px 16px 0 rgba(0, 0, 0, 0.08),
|
|
13
|
+
0 3px 6px -4px rgba(0, 0, 0, 0.12), 0 9px 28px 8px rgba(0, 0, 0, 0.05);
|
|
14
|
+
|
|
15
|
+
ul {
|
|
16
|
+
padding: 0 !important;
|
|
17
|
+
margin: 0 !important;
|
|
18
|
+
list-style: none;
|
|
19
|
+
li {
|
|
20
|
+
padding: 12px 10px !important;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
&::-webkit-scrollbar {
|
|
25
|
+
width: 6px;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
&::-webkit-scrollbar-thumb {
|
|
29
|
+
background-color: rgba(0, 0, 0, 0.2);
|
|
30
|
+
border-radius: 3px;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.header {
|
|
35
|
+
position: sticky;
|
|
36
|
+
top: 0;
|
|
37
|
+
z-index: 10;
|
|
38
|
+
background: #fff;
|
|
39
|
+
padding: 10px 12px;
|
|
40
|
+
display: flex;
|
|
41
|
+
justify-content: space-between;
|
|
42
|
+
align-items: center;
|
|
43
|
+
border-bottom: 1px solid #f0f0f0;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.notificationItem {
|
|
47
|
+
transition: background 0.3s;
|
|
48
|
+
|
|
49
|
+
&:hover {
|
|
50
|
+
background-color: #deeaf5;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
.read {
|
|
54
|
+
background-color: white;
|
|
55
|
+
font-weight: 500;
|
|
56
|
+
}
|
|
57
|
+
.unread {
|
|
58
|
+
background-color: #f6f6f6;
|
|
59
|
+
font-weight: 700;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.loadMore {
|
|
63
|
+
text-align: center;
|
|
64
|
+
margin: 10px 0;
|
|
65
|
+
button {
|
|
66
|
+
color: var(--darkBlueColor);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
.ellipsisText {
|
|
70
|
+
display: -webkit-box;
|
|
71
|
+
-webkit-line-clamp: 3; // max 3 lines
|
|
72
|
+
-webkit-box-orient: vertical;
|
|
73
|
+
overflow: hidden;
|
|
74
|
+
text-overflow: ellipsis;
|
|
75
|
+
word-break: break-word;
|
|
76
|
+
line-height: 1.5;
|
|
77
|
+
max-height: calc(1.5em * 3); // 3 lines
|
|
78
|
+
}
|
|
79
|
+
.headerActions {
|
|
80
|
+
display: flex;
|
|
81
|
+
align-items: center;
|
|
82
|
+
gap: 8px;
|
|
83
|
+
}
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
+
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
|
|
3
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
4
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
5
|
+
import React, { useCallback, useEffect, useState, useImperativeHandle } from "react";
|
|
6
|
+
import { Form, Switch, Typography, Row, Col, Select } from "antd";
|
|
7
|
+
import { useDispatch, useSelector } from "react-redux";
|
|
8
|
+
import { editNotificationSettings, getNotificationSettings } from "../../store/slices/notification";
|
|
9
|
+
import { useLocation } from "react-router-dom";
|
|
10
|
+
import style from "./index.module.scss";
|
|
11
|
+
import Button from "../Button";
|
|
12
|
+
var Title = Typography.Title,
|
|
13
|
+
Text = Typography.Text;
|
|
14
|
+
var Option = Select.Option;
|
|
15
|
+
var labels = {
|
|
16
|
+
internalIsActive: "Daxili bildirişlər",
|
|
17
|
+
emailIsActive: "Email bildirişləri",
|
|
18
|
+
visa: "Viza üçün",
|
|
19
|
+
sign: "İmza üçün",
|
|
20
|
+
reject: "İmtina üçün",
|
|
21
|
+
print: "Çap üçün"
|
|
22
|
+
};
|
|
23
|
+
var projectOptions = {
|
|
24
|
+
docFlowSettings: {
|
|
25
|
+
label: "Sənəd Dövriyyəsi",
|
|
26
|
+
keys: ["visa", "sign", "reject", "print"]
|
|
27
|
+
},
|
|
28
|
+
contractSettings: {
|
|
29
|
+
label: "Müqavilələr",
|
|
30
|
+
keys: ["visa", "sign", "reject"]
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
var NotificationSettingsContent = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
34
|
+
var _allValues$generalSet, _allValues$generalSet2, _allValues$generalSet3, _allValues$generalSet4;
|
|
35
|
+
var _Form$useForm = Form.useForm(),
|
|
36
|
+
_Form$useForm2 = _slicedToArray(_Form$useForm, 1),
|
|
37
|
+
form = _Form$useForm2[0];
|
|
38
|
+
var dispatch = useDispatch();
|
|
39
|
+
var location = useLocation();
|
|
40
|
+
var initialValues = useSelector(function (state) {
|
|
41
|
+
return state.notification.notificationSettings;
|
|
42
|
+
});
|
|
43
|
+
var getDefaultProjectFromPath = function getDefaultProjectFromPath(path) {
|
|
44
|
+
if (path.includes("/contract")) return "contractSettings";
|
|
45
|
+
return "docFlowSettings";
|
|
46
|
+
};
|
|
47
|
+
var _useState = useState(function () {
|
|
48
|
+
return getDefaultProjectFromPath(location.pathname);
|
|
49
|
+
}),
|
|
50
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
51
|
+
selectedProject = _useState2[0],
|
|
52
|
+
setSelectedProject = _useState2[1];
|
|
53
|
+
var _useState3 = useState({}),
|
|
54
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
55
|
+
allValues = _useState4[0],
|
|
56
|
+
setAllValues = _useState4[1];
|
|
57
|
+
useImperativeHandle(ref, function () {
|
|
58
|
+
return {
|
|
59
|
+
refresh: function refresh() {
|
|
60
|
+
var projectFromPath = getDefaultProjectFromPath(location.pathname);
|
|
61
|
+
setSelectedProject(projectFromPath);
|
|
62
|
+
dispatch(getNotificationSettings());
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
});
|
|
66
|
+
useEffect(function () {
|
|
67
|
+
dispatch(getNotificationSettings());
|
|
68
|
+
}, [dispatch]);
|
|
69
|
+
useEffect(function () {
|
|
70
|
+
if (initialValues) {
|
|
71
|
+
setAllValues(initialValues);
|
|
72
|
+
form.setFieldsValue(initialValues);
|
|
73
|
+
}
|
|
74
|
+
}, [initialValues, form]);
|
|
75
|
+
var handleSwitchChange = function handleSwitchChange(namePath, checked) {
|
|
76
|
+
var updated = structuredClone(allValues);
|
|
77
|
+
var target = updated;
|
|
78
|
+
namePath.forEach(function (key, i) {
|
|
79
|
+
if (i === namePath.length - 1) {
|
|
80
|
+
target[key] = checked;
|
|
81
|
+
} else {
|
|
82
|
+
target = target[key];
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
// Toggle all child switches if general toggle is used
|
|
87
|
+
if (namePath[0] === "generalSettings" && (namePath[1] === "internalIsActive" || namePath[1] === "emailIsActive")) {
|
|
88
|
+
var typeToChange = namePath[1] === "internalIsActive" ? "internalSettings" : "emailSettings";
|
|
89
|
+
Object.keys(projectOptions).forEach(function (projectKey) {
|
|
90
|
+
if (!updated[projectKey]) updated[projectKey] = {};
|
|
91
|
+
if (!updated[projectKey][typeToChange]) updated[projectKey][typeToChange] = {};
|
|
92
|
+
projectOptions[projectKey].keys.forEach(function (key) {
|
|
93
|
+
updated[projectKey][typeToChange][key] = checked;
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// If any child switch is turned ON → set general ON
|
|
99
|
+
if (namePath.length === 3 && (namePath[1] === "internalSettings" || namePath[1] === "emailSettings") && checked === true) {
|
|
100
|
+
var generalKey = namePath[1] === "internalSettings" ? "internalIsActive" : "emailIsActive";
|
|
101
|
+
if (!updated.generalSettings) updated.generalSettings = {};
|
|
102
|
+
updated.generalSettings[generalKey] = true;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// If child turned OFF → check if all children are OFF → turn OFF general
|
|
106
|
+
if (namePath.length === 3 && (namePath[1] === "internalSettings" || namePath[1] === "emailSettings")) {
|
|
107
|
+
var type = namePath[1];
|
|
108
|
+
var _generalKey = type === "internalSettings" ? "internalIsActive" : "emailIsActive";
|
|
109
|
+
var anyOn = false;
|
|
110
|
+
Object.keys(projectOptions).forEach(function (projectKey) {
|
|
111
|
+
var _updated$projectKey;
|
|
112
|
+
var settings = ((_updated$projectKey = updated[projectKey]) === null || _updated$projectKey === void 0 ? void 0 : _updated$projectKey[type]) || {};
|
|
113
|
+
var _iterator = _createForOfIteratorHelper(projectOptions[projectKey].keys),
|
|
114
|
+
_step;
|
|
115
|
+
try {
|
|
116
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
117
|
+
var key = _step.value;
|
|
118
|
+
if (settings[key]) {
|
|
119
|
+
anyOn = true;
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
} catch (err) {
|
|
124
|
+
_iterator.e(err);
|
|
125
|
+
} finally {
|
|
126
|
+
_iterator.f();
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
if (!anyOn) {
|
|
130
|
+
if (!updated.generalSettings) updated.generalSettings = {};
|
|
131
|
+
updated.generalSettings[_generalKey] = false;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
setAllValues(updated);
|
|
135
|
+
form.setFieldsValue(updated);
|
|
136
|
+
};
|
|
137
|
+
var renderSwitches = function renderSwitches(type) {
|
|
138
|
+
return projectOptions[selectedProject].keys.map(function (key) {
|
|
139
|
+
var _allValues$selectedPr, _allValues$selectedPr2;
|
|
140
|
+
return /*#__PURE__*/React.createElement(Col, {
|
|
141
|
+
span: 6,
|
|
142
|
+
key: "".concat(selectedProject, "-").concat(type, "-").concat(key)
|
|
143
|
+
}, /*#__PURE__*/React.createElement(Form.Item, {
|
|
144
|
+
className: style.inlineSwitch,
|
|
145
|
+
label: /*#__PURE__*/React.createElement("span", {
|
|
146
|
+
className: style.formLabel
|
|
147
|
+
}, labels[key])
|
|
148
|
+
}, /*#__PURE__*/React.createElement(Switch, {
|
|
149
|
+
checked: (_allValues$selectedPr = allValues === null || allValues === void 0 || (_allValues$selectedPr2 = allValues[selectedProject]) === null || _allValues$selectedPr2 === void 0 || (_allValues$selectedPr2 = _allValues$selectedPr2[type]) === null || _allValues$selectedPr2 === void 0 ? void 0 : _allValues$selectedPr2[key]) !== null && _allValues$selectedPr !== void 0 ? _allValues$selectedPr : false,
|
|
150
|
+
onChange: function onChange(checked) {
|
|
151
|
+
return handleSwitchChange([selectedProject, type, key], checked);
|
|
152
|
+
}
|
|
153
|
+
})));
|
|
154
|
+
});
|
|
155
|
+
};
|
|
156
|
+
var onSubmit = useCallback(function (data) {
|
|
157
|
+
var _props$onClose;
|
|
158
|
+
dispatch(editNotificationSettings(data));
|
|
159
|
+
props === null || props === void 0 || (_props$onClose = props.onClose) === null || _props$onClose === void 0 || _props$onClose.call(props);
|
|
160
|
+
}, [dispatch]);
|
|
161
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
162
|
+
className: style.settingsWrapper
|
|
163
|
+
}, /*#__PURE__*/React.createElement(Title, {
|
|
164
|
+
level: 5,
|
|
165
|
+
className: style.sectionTitle
|
|
166
|
+
}, "\xDCmumi Bildiri\u015F Ayarlar\u0131"), /*#__PURE__*/React.createElement(Row, {
|
|
167
|
+
gutter: [40, 0]
|
|
168
|
+
}, /*#__PURE__*/React.createElement(Col, {
|
|
169
|
+
span: 12
|
|
170
|
+
}, /*#__PURE__*/React.createElement(Form.Item, {
|
|
171
|
+
className: style.inlineSwitch,
|
|
172
|
+
label: /*#__PURE__*/React.createElement("span", {
|
|
173
|
+
className: style.formLabel
|
|
174
|
+
}, labels.internalIsActive)
|
|
175
|
+
}, /*#__PURE__*/React.createElement(Switch, {
|
|
176
|
+
checked: (_allValues$generalSet = allValues === null || allValues === void 0 || (_allValues$generalSet2 = allValues.generalSettings) === null || _allValues$generalSet2 === void 0 ? void 0 : _allValues$generalSet2.internalIsActive) !== null && _allValues$generalSet !== void 0 ? _allValues$generalSet : false,
|
|
177
|
+
onChange: function onChange(checked) {
|
|
178
|
+
return handleSwitchChange(["generalSettings", "internalIsActive"], checked);
|
|
179
|
+
}
|
|
180
|
+
}))), /*#__PURE__*/React.createElement(Col, {
|
|
181
|
+
span: 12
|
|
182
|
+
}, /*#__PURE__*/React.createElement(Form.Item, {
|
|
183
|
+
className: style.inlineSwitch,
|
|
184
|
+
label: /*#__PURE__*/React.createElement("span", {
|
|
185
|
+
className: style.formLabel
|
|
186
|
+
}, labels.emailIsActive)
|
|
187
|
+
}, /*#__PURE__*/React.createElement(Switch, {
|
|
188
|
+
checked: (_allValues$generalSet3 = allValues === null || allValues === void 0 || (_allValues$generalSet4 = allValues.generalSettings) === null || _allValues$generalSet4 === void 0 ? void 0 : _allValues$generalSet4.emailIsActive) !== null && _allValues$generalSet3 !== void 0 ? _allValues$generalSet3 : false,
|
|
189
|
+
onChange: function onChange(checked) {
|
|
190
|
+
return handleSwitchChange(["generalSettings", "emailIsActive"], checked);
|
|
191
|
+
}
|
|
192
|
+
})))), /*#__PURE__*/React.createElement(Form.Item, {
|
|
193
|
+
label: ""
|
|
194
|
+
}, /*#__PURE__*/React.createElement(Select, {
|
|
195
|
+
value: selectedProject,
|
|
196
|
+
onChange: function onChange(val) {
|
|
197
|
+
return setSelectedProject(val);
|
|
198
|
+
},
|
|
199
|
+
className: style.modal_select
|
|
200
|
+
}, Object.entries(projectOptions).map(function (_ref) {
|
|
201
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
202
|
+
key = _ref2[0],
|
|
203
|
+
label = _ref2[1].label;
|
|
204
|
+
return /*#__PURE__*/React.createElement(Option, {
|
|
205
|
+
key: key,
|
|
206
|
+
value: key
|
|
207
|
+
}, label);
|
|
208
|
+
}))), /*#__PURE__*/React.createElement(Text, {
|
|
209
|
+
className: style.settingGroupTitle
|
|
210
|
+
}, "Daxili"), /*#__PURE__*/React.createElement(Row, {
|
|
211
|
+
gutter: [24, 24]
|
|
212
|
+
}, renderSwitches("internalSettings")), /*#__PURE__*/React.createElement(Text, {
|
|
213
|
+
className: style.settingGroupTitle
|
|
214
|
+
}, "Email"), /*#__PURE__*/React.createElement(Row, {
|
|
215
|
+
gutter: [24, 24]
|
|
216
|
+
}, renderSwitches("emailSettings")), /*#__PURE__*/React.createElement("div", {
|
|
217
|
+
className: style.next_buttons_
|
|
218
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
219
|
+
onClick: function onClick(e) {
|
|
220
|
+
var _props$onClose2;
|
|
221
|
+
props === null || props === void 0 || (_props$onClose2 = props.onClose) === null || _props$onClose2 === void 0 || _props$onClose2.call(props);
|
|
222
|
+
e.preventDefault();
|
|
223
|
+
},
|
|
224
|
+
color: "white"
|
|
225
|
+
}, "L\u0259\u011Fv et"), /*#__PURE__*/React.createElement(Button, {
|
|
226
|
+
color: "green",
|
|
227
|
+
onClick: function onClick() {
|
|
228
|
+
return onSubmit(allValues);
|
|
229
|
+
}
|
|
230
|
+
}, "Yadda saxla")));
|
|
231
|
+
});
|
|
232
|
+
export default NotificationSettingsContent;
|