@banch0u/core-project-test-repository 1.8.3 → 1.9.0

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.
Files changed (69) hide show
  1. package/dist/assets/css/antd.css +836 -0
  2. package/dist/assets/css/variables.css +6 -0
  3. package/dist/assets/icons/index.js +424 -1
  4. package/dist/components/Button/index.module.scss +14 -2
  5. package/dist/components/Delete/Delete.js +22 -0
  6. package/dist/components/Delete/Delete.module.scss +22 -0
  7. package/dist/components/DeleteModal/DeleteModal.js +31 -0
  8. package/dist/components/DeleteModal/DeleteModal.module.scss +11 -0
  9. package/dist/components/Filter/index.js +1 -1
  10. package/dist/components/Input/index.js +1 -2
  11. package/dist/components/Input/index.module.scss +21 -12
  12. package/dist/components/ProfileOptions/index.js +109 -66
  13. package/dist/components/ProfileOptions/index.module.scss +144 -12
  14. package/dist/components/Success/Success.js +19 -0
  15. package/dist/components/Success/Success.module.scss +26 -0
  16. package/dist/components/Table/index.js +4 -2
  17. package/dist/components/ViewModal/index.js +30 -0
  18. package/dist/helpers/paginationLength.js +3 -0
  19. package/dist/helpers/querySearch.js +22 -0
  20. package/dist/index.js +6 -0
  21. package/dist/layout/Header/AppSelect/index.js +107 -0
  22. package/dist/layout/Header/AppSelect/index.module.scss +68 -0
  23. package/dist/layout/Header/index.js +6 -84
  24. package/dist/layout/Header/index.module.scss +8 -12
  25. package/dist/layout/Portal/index.js +23 -0
  26. package/dist/layout/QuestionnairesLayout/index.js +17 -0
  27. package/dist/layout/QuestionnairesLayout/index.module.scss +0 -0
  28. package/dist/layout/QuestionnairesSidebar/index.js +126 -0
  29. package/dist/layout/QuestionnairesSidebar/index.module.scss +76 -0
  30. package/dist/layout/Sidebar/index.js +147 -0
  31. package/dist/layout/Sidebar/index.module.scss +50 -0
  32. package/dist/pages/Platform/constant.js +29 -2
  33. package/dist/pages/Platform/index.js +19 -30
  34. package/dist/pages/Platform/index.module.scss +20 -5
  35. package/dist/pages/Questionnnaires/Questionnaires.module.scss +194 -0
  36. package/dist/pages/Questionnnaires/QuestionnairesApplicationFormContent/constant.js +58 -0
  37. package/dist/pages/Questionnnaires/QuestionnairesApplicationFormContent/index.js +255 -0
  38. package/dist/pages/Questionnnaires/QuestionnairesCountriesContent/constant.js +58 -0
  39. package/dist/pages/Questionnnaires/QuestionnairesCountriesContent/index.js +247 -0
  40. package/dist/pages/Questionnnaires/QuestionnairesDeliveryMethodContent/constant.js +58 -0
  41. package/dist/pages/Questionnnaires/QuestionnairesDeliveryMethodContent/index.js +247 -0
  42. package/dist/pages/Questionnnaires/QuestionnairesDocumentRecieveMethodsContent/constant.js +58 -0
  43. package/dist/pages/Questionnnaires/QuestionnairesDocumentRecieveMethodsContent/index.js +258 -0
  44. package/dist/pages/Questionnnaires/QuestionnairesDocumentTypeContent/constant.js +58 -0
  45. package/dist/pages/Questionnnaires/QuestionnairesDocumentTypeContent/index.js +284 -0
  46. package/dist/pages/Questionnnaires/QuestionnairesDocumentWhomContent/constant.js +82 -0
  47. package/dist/pages/Questionnnaires/QuestionnairesDocumentWhomContent/index.js +331 -0
  48. package/dist/pages/Questionnnaires/QuestionnairesExecutionRulesContent/constant.js +58 -0
  49. package/dist/pages/Questionnnaires/QuestionnairesExecutionRulesContent/index.js +258 -0
  50. package/dist/pages/Questionnnaires/QuestionnairesMarginNoteTextsContent/constant.js +58 -0
  51. package/dist/pages/Questionnnaires/QuestionnairesMarginNoteTextsContent/index.js +249 -0
  52. package/dist/pages/Questionnnaires/QuestionnairesOrganizationsContent/constant.js +88 -0
  53. package/dist/pages/Questionnnaires/QuestionnairesOrganizationsContent/index.js +320 -0
  54. package/dist/pages/Questionnnaires/QuestionnairesStreetsContent/constant.js +58 -0
  55. package/dist/pages/Questionnnaires/QuestionnairesStreetsContent/index.js +240 -0
  56. package/dist/pages/Questionnnaires/QuestionnairesStructuresContent/constant.js +58 -0
  57. package/dist/pages/Questionnnaires/QuestionnairesStructuresContent/index.js +247 -0
  58. package/dist/pages/Questionnnaires/QuestionnairesSubtopicContent/constant.js +58 -0
  59. package/dist/pages/Questionnnaires/QuestionnairesSubtopicContent/index.js +317 -0
  60. package/dist/pages/Questionnnaires/QuestionnairesTopicContent/constant.js +58 -0
  61. package/dist/pages/Questionnnaires/QuestionnairesTopicContent/index.js +271 -0
  62. package/dist/pages/Questionnnaires/index.js +5 -0
  63. package/dist/routes/QuestionnaireRoutes.js +108 -0
  64. package/dist/store/slices/global/index.js +96 -3
  65. package/dist/store/slices/questionnaire/index.js +2500 -0
  66. package/dist/store/slices/questionnaire/service.js +1557 -0
  67. package/dist/store/store.js +2 -1
  68. package/dist/utils/path.js +30 -1
  69. package/package.json +2 -2
@@ -0,0 +1,331 @@
1
+ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
4
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
5
+ import Select from "../../../components/Select";
6
+ import React from "react";
7
+ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
8
+ import Cookies from "js-cookie";
9
+ import style from "../Questionnaires.module.scss";
10
+ import { Form, Input, Layout, Select as AntdSelect } from "antd";
11
+ import { PlusIcon } from "../../../assets/icons";
12
+ import FormModal from "../../../components/FormModal";
13
+ import { useDispatch, useSelector } from "react-redux";
14
+ import Delete from "../../../components/Delete/Delete";
15
+ import DeleteModal from "../../../components/DeleteModal/DeleteModal";
16
+ import Success from "../../../components/Success/Success";
17
+ import { setDeleteModalVisible, setViewModalVisible } from "../../../store/slices/global";
18
+ import ViewModal from "../../../components/ViewModal";
19
+ import { getStreetColumns } from "./constant";
20
+ import Pagination from "../../../components/Pagination";
21
+ import ColSort from "../../../components/ColSort";
22
+ import { setPaginationLength } from "../../../helpers/paginationLength";
23
+ import Button from "../../../components/Button";
24
+ import Loading from "../../../components/Loading";
25
+ import Table from "../../../components/Table";
26
+ import Filter from "../../../components/Filter";
27
+ import { addDocumentWhom, deleteTopic, documentWhomVisibility, editDocumentWhom, getDocumentWhom } from "../../../store/slices/questionnaire";
28
+ var Content = Layout.Content;
29
+ var Item = Form.Item;
30
+ var Option = AntdSelect.Option;
31
+ var QuestionnairesDocumentWhomContent = function QuestionnairesDocumentWhomContent() {
32
+ var _useState = useState(null),
33
+ _useState2 = _slicedToArray(_useState, 2),
34
+ innerW = _useState2[0],
35
+ setInnerW = _useState2[1];
36
+ var ref = useRef();
37
+ var dispatch = useDispatch();
38
+ var _useState3 = useState(0),
39
+ _useState4 = _slicedToArray(_useState3, 2),
40
+ id = _useState4[0],
41
+ setId = _useState4[1];
42
+ var _useState5 = useState(1),
43
+ _useState6 = _slicedToArray(_useState5, 2),
44
+ page = _useState6[0],
45
+ setPage = _useState6[1];
46
+ var _useState7 = useState(Cookies.get("pagination-size-questionnaire-document-whom") ? JSON.parse(Cookies.get("pagination-size-questionnaire-document-whom")) : 20),
47
+ _useState8 = _slicedToArray(_useState7, 2),
48
+ size = _useState8[0],
49
+ setSize = _useState8[1];
50
+ var _useState9 = useState({
51
+ name: ""
52
+ }),
53
+ _useState10 = _slicedToArray(_useState9, 2),
54
+ query = _useState10[0],
55
+ setQuery = _useState10[1];
56
+ var _useState11 = useState(1),
57
+ _useState12 = _slicedToArray(_useState11, 2),
58
+ typeSelect = _useState12[0],
59
+ setTypeSelect = _useState12[1];
60
+ var _useSelector = useSelector(function (state) {
61
+ return state.global;
62
+ }),
63
+ loading = _useSelector.loading,
64
+ documentWhomRender = _useSelector.documentWhomRender;
65
+ var documentWhom = useSelector(function (state) {
66
+ return state.questionnaire.documentWhom;
67
+ });
68
+ var paginationLength = setPaginationLength(documentWhom === null || documentWhom === void 0 ? void 0 : documentWhom.count, documentWhom === null || documentWhom === void 0 ? void 0 : documentWhom.size);
69
+ var onSubmit = useCallback(/*#__PURE__*/function () {
70
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(data) {
71
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
72
+ while (1) switch (_context.prev = _context.next) {
73
+ case 0:
74
+ dispatch(addDocumentWhom({
75
+ name: data === null || data === void 0 ? void 0 : data.name,
76
+ surname: data === null || data === void 0 ? void 0 : data.surname,
77
+ patronymic: data === null || data === void 0 ? void 0 : data.patronymic,
78
+ departmentname: data === null || data === void 0 ? void 0 : data.departmentname,
79
+ organisationname: data === null || data === void 0 ? void 0 : data.organisationname,
80
+ AddressType: typeSelect
81
+ }));
82
+ case 1:
83
+ case "end":
84
+ return _context.stop();
85
+ }
86
+ }, _callee);
87
+ }));
88
+ return function (_x) {
89
+ return _ref.apply(this, arguments);
90
+ };
91
+ }(), [dispatch, typeSelect]);
92
+ var onEdit = useCallback(function (id, record) {
93
+ var data = {
94
+ id: id,
95
+ name: record === null || record === void 0 ? void 0 : record.name,
96
+ surname: record === null || record === void 0 ? void 0 : record.surname,
97
+ patronymic: record === null || record === void 0 ? void 0 : record.patronymic,
98
+ departmentname: record === null || record === void 0 ? void 0 : record.departmentname,
99
+ organisationname: record === null || record === void 0 ? void 0 : record.organisationname,
100
+ AddressType: typeSelect
101
+ };
102
+ dispatch(editDocumentWhom(data));
103
+ }, [dispatch, typeSelect]);
104
+ var onStatusChange = useCallback(function (data, checked) {
105
+ var data_ = {
106
+ id: data === null || data === void 0 ? void 0 : data.id,
107
+ checked: checked
108
+ };
109
+ dispatch(documentWhomVisibility(data_));
110
+ }, [dispatch]);
111
+ var closeOnViewModal = useCallback(function () {
112
+ dispatch(setViewModalVisible(false));
113
+ }, [dispatch]);
114
+ var onClickModal = function onClickModal() {
115
+ var _ref$current;
116
+ ref === null || ref === void 0 || (_ref$current = ref.current) === null || _ref$current === void 0 || _ref$current.open();
117
+ };
118
+ var onEditClick = useCallback(function (data) {
119
+ var _ref$current2;
120
+ ref === null || ref === void 0 || (_ref$current2 = ref.current) === null || _ref$current2 === void 0 || _ref$current2.setEdit(data);
121
+ }, []);
122
+ var onDelete = useCallback(function (id) {
123
+ setId(id);
124
+ }, []);
125
+ var handleColumnToggle = function handleColumnToggle(checked, dataIndex) {
126
+ setSelectedColumns(function (prevSelected) {
127
+ if (checked) {
128
+ return [].concat(_toConsumableArray(prevSelected), [dataIndex]);
129
+ } else {
130
+ return prevSelected.filter(function (col) {
131
+ return col !== dataIndex;
132
+ });
133
+ }
134
+ });
135
+ };
136
+ var data = [];
137
+ if (documentWhom !== null && documentWhom !== void 0 && documentWhom.items) {
138
+ var _documentWhom$items;
139
+ data = documentWhom === null || documentWhom === void 0 || (_documentWhom$items = documentWhom.items) === null || _documentWhom$items === void 0 ? void 0 : _documentWhom$items.map(function (dataObj, i) {
140
+ return {
141
+ num: (documentWhom === null || documentWhom === void 0 ? void 0 : documentWhom.size) * (documentWhom === null || documentWhom === void 0 ? void 0 : documentWhom.page) + i + 1 - (documentWhom === null || documentWhom === void 0 ? void 0 : documentWhom.size),
142
+ id: dataObj === null || dataObj === void 0 ? void 0 : dataObj.id,
143
+ name: dataObj === null || dataObj === void 0 ? void 0 : dataObj.name,
144
+ surname: dataObj === null || dataObj === void 0 ? void 0 : dataObj.surname,
145
+ patronymic: dataObj === null || dataObj === void 0 ? void 0 : dataObj.patronymic,
146
+ organisationName: dataObj === null || dataObj === void 0 ? void 0 : dataObj.organisationName,
147
+ departmentName: dataObj === null || dataObj === void 0 ? void 0 : dataObj.departmentName,
148
+ isActive: dataObj === null || dataObj === void 0 ? void 0 : dataObj.isActive,
149
+ className: "rowClassName1"
150
+ };
151
+ });
152
+ }
153
+ var columns = useMemo(function () {
154
+ return getStreetColumns(onEditClick, onDelete, onStatusChange, dispatch);
155
+ }, [onEditClick, onDelete, onStatusChange, dispatch]);
156
+ var _useState13 = useState(columns.map(function (col) {
157
+ return col.dataIndex;
158
+ })),
159
+ _useState14 = _slicedToArray(_useState13, 2),
160
+ selectedColumns = _useState14[0],
161
+ setSelectedColumns = _useState14[1];
162
+ useEffect(function () {
163
+ if (window.innerWidth >= 1900) {
164
+ setInnerW(210);
165
+ } else {
166
+ setInnerW(155);
167
+ }
168
+ var data = {
169
+ page: page,
170
+ size: size,
171
+ query: query,
172
+ visibility: "nondeleted",
173
+ types: typeSelect
174
+ };
175
+ dispatch(getDocumentWhom(data));
176
+ }, [dispatch, page, documentWhomRender, size, query, typeSelect]);
177
+ var updateSize = function updateSize(newSize) {
178
+ setSize(newSize); // Update state
179
+ Cookies.set("pagination-size-questionnaire-document-whom", JSON.stringify(newSize), {
180
+ expires: 7
181
+ }); // Save to cookies
182
+ };
183
+ return /*#__PURE__*/React.createElement(React.Fragment, null, loading ? /*#__PURE__*/React.createElement(Loading, null) : null, /*#__PURE__*/React.createElement(Layout, {
184
+ className: style.layout
185
+ }, /*#__PURE__*/React.createElement(Content, {
186
+ className: style.content
187
+ }, /*#__PURE__*/React.createElement("header", {
188
+ className: style.header
189
+ }, /*#__PURE__*/React.createElement(Button, {
190
+ onClick: onClickModal,
191
+ color: "green"
192
+ }, " ", /*#__PURE__*/React.createElement(PlusIcon, null), " Soraq\xE7a \u0259lav\u0259 et"), /*#__PURE__*/React.createElement(Filter, {
193
+ columns: columns,
194
+ selectedColumns: selectedColumns,
195
+ setQuery: setQuery,
196
+ disabledElementCount: 3,
197
+ setPage: setPage
198
+ }))), /*#__PURE__*/React.createElement(Layout, {
199
+ className: style.layout1
200
+ }, /*#__PURE__*/React.createElement(Content, {
201
+ className: style.content
202
+ }, /*#__PURE__*/React.createElement("div", {
203
+ className: style.table_header
204
+ }, /*#__PURE__*/React.createElement("h2", null, "\u015E\u0259xsl\u0259r"), /*#__PURE__*/React.createElement("div", {
205
+ className: style.buttons
206
+ }, /*#__PURE__*/React.createElement(Select, {
207
+ size: "sm",
208
+ width: 200,
209
+ allowClear: false,
210
+ value: typeSelect,
211
+ defaultValue: "",
212
+ onChange: function onChange(value) {
213
+ setTypeSelect(value);
214
+ }
215
+ }, /*#__PURE__*/React.createElement(Option, {
216
+ value: 1
217
+ }, "\u015E\u0259xs"), /*#__PURE__*/React.createElement(Option, {
218
+ value: 2
219
+ }, "M\xFC\u0259ssis\u0259")), /*#__PURE__*/React.createElement(ColSort, {
220
+ columns: columns,
221
+ selectedColumns: selectedColumns,
222
+ handleColumnToggle: handleColumnToggle
223
+ }))), /*#__PURE__*/React.createElement("div", {
224
+ className: "bigTable"
225
+ }, /*#__PURE__*/React.createElement(Table, {
226
+ selectedColumns: selectedColumns,
227
+ innerW: innerW,
228
+ dataSource: data,
229
+ columns: columns,
230
+ disableDrag: true
231
+ })), /*#__PURE__*/React.createElement("div", {
232
+ className: style.pagination
233
+ }, /*#__PURE__*/React.createElement(Pagination, {
234
+ size: size,
235
+ setSize: updateSize,
236
+ total: paginationLength,
237
+ page: page,
238
+ onChange: setPage
239
+ })), /*#__PURE__*/React.createElement(FormModal, {
240
+ ref: ref,
241
+ width: 454,
242
+ title: "Yeni soraqça yaratma",
243
+ titleEdit: "Soraqça redaktə etmə",
244
+ okText: "Yadda saxla",
245
+ cancelText: "Bağla",
246
+ onSubmit: onSubmit,
247
+ onEdit: onEdit,
248
+ className: "absolute",
249
+ centered: false
250
+ }, /*#__PURE__*/React.createElement(Item, {
251
+ rules: [{
252
+ required: false,
253
+ message: ""
254
+ }, {
255
+ min: 3,
256
+ message: "Ən azından 3 simvol olmalıdır"
257
+ }],
258
+ name: "name",
259
+ label: "Ad"
260
+ }, /*#__PURE__*/React.createElement(Input, {
261
+ className: style.modal_input
262
+ })), /*#__PURE__*/React.createElement(Item, {
263
+ rules: [{
264
+ required: false,
265
+ message: ""
266
+ }, {
267
+ min: 3,
268
+ message: "Ən azından 3 simvol olmalıdır"
269
+ }],
270
+ name: "surname",
271
+ label: "Soyad"
272
+ }, /*#__PURE__*/React.createElement(Input, {
273
+ className: style.modal_input
274
+ })), /*#__PURE__*/React.createElement(Item, {
275
+ rules: [{
276
+ required: false,
277
+ message: ""
278
+ }, {
279
+ min: 3,
280
+ message: "Ən azından 3 simvol olmalıdır"
281
+ }],
282
+ name: "patronymic",
283
+ label: "Ata Adı"
284
+ }, /*#__PURE__*/React.createElement(Input, {
285
+ className: style.modal_input
286
+ })), /*#__PURE__*/React.createElement(Item, {
287
+ rules: [{
288
+ required: false,
289
+ message: ""
290
+ }, {
291
+ min: 3,
292
+ message: "Ən azından 3 simvol olmalıdır"
293
+ }],
294
+ name: "organisationName",
295
+ label: "Müəssə"
296
+ }, /*#__PURE__*/React.createElement(Input, {
297
+ className: style.modal_input
298
+ })), /*#__PURE__*/React.createElement(Item, {
299
+ rules: [{
300
+ required: false,
301
+ message: ""
302
+ }, {
303
+ min: 3,
304
+ message: "Ən azından 3 simvol olmalıdır"
305
+ }],
306
+ name: "departmentName",
307
+ label: "Şöbə"
308
+ }, /*#__PURE__*/React.createElement(Input, {
309
+ className: style.modal_input
310
+ }))), /*#__PURE__*/React.createElement(DeleteModal, {
311
+ onCancel: function onCancel() {
312
+ return dispatch(setDeleteModalVisible(false));
313
+ },
314
+ width: 280
315
+ }, /*#__PURE__*/React.createElement(Delete, {
316
+ onDelete: function onDelete() {
317
+ return dispatch(deleteTopic(id));
318
+ },
319
+ onCancel: function onCancel() {
320
+ return dispatch(setDeleteModalVisible(false));
321
+ },
322
+ value: "Soraqçanı"
323
+ })), /*#__PURE__*/React.createElement(ViewModal, {
324
+ onCancel: closeOnViewModal,
325
+ width: 695
326
+ }, /*#__PURE__*/React.createElement(Success, {
327
+ onClick: closeOnViewModal,
328
+ value: "Soraqça"
329
+ }))))));
330
+ };
331
+ export default QuestionnairesDocumentWhomContent;
@@ -0,0 +1,58 @@
1
+ import React from "react";
2
+ import { Switch, Tooltip } from "antd";
3
+ import style from "../Questionnaires.module.scss";
4
+ import { setDeleteModalVisible } from "../../../store/slices/global";
5
+ import { DeleteIconQ, EditIcon } from "../../../assets/icons";
6
+ export var getStreetColumns = function getStreetColumns(onEditClick, onDelete, onStatusChange, dispatch, innerW) {
7
+ return [{
8
+ title: "№",
9
+ dataIndex: "num",
10
+ showCheckbox: false,
11
+ ellipsis: true,
12
+ width: 35
13
+ }, {
14
+ title: "İcra qaydası",
15
+ dataIndex: "name",
16
+ width: innerW,
17
+ disabled: true,
18
+ ellipsis: true
19
+ }, {
20
+ title: "Status",
21
+ key: "status",
22
+ disabled: true,
23
+ filter: false,
24
+ render: function render(data) {
25
+ return /*#__PURE__*/React.createElement(Tooltip, {
26
+ placement: "top",
27
+ title: "Statusu d\u0259yi\u015F"
28
+ }, /*#__PURE__*/React.createElement(Switch, {
29
+ size: "medium",
30
+ checked: data === null || data === void 0 ? void 0 : data.isActive,
31
+ onChange: function onChange(checked) {
32
+ return onStatusChange(data, checked, dispatch);
33
+ }
34
+ }));
35
+ }
36
+ }, {
37
+ title: "",
38
+ key: "actions",
39
+ showCheckbox: false,
40
+ width: 80,
41
+ render: function render(data) {
42
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
43
+ className: style.number
44
+ }, /*#__PURE__*/React.createElement("div", {
45
+ className: style.actions
46
+ }, /*#__PURE__*/React.createElement("div", {
47
+ onClick: function onClick() {
48
+ return onEditClick(data);
49
+ }
50
+ }, /*#__PURE__*/React.createElement(EditIcon, null)), /*#__PURE__*/React.createElement("div", {
51
+ onClick: function onClick() {
52
+ onDelete(data === null || data === void 0 ? void 0 : data.id);
53
+ dispatch(setDeleteModalVisible(true));
54
+ }
55
+ }, /*#__PURE__*/React.createElement(DeleteIconQ, null)))));
56
+ }
57
+ }];
58
+ };
@@ -0,0 +1,258 @@
1
+ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
4
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
5
+ import React from "react";
6
+ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
7
+ import Cookies from "js-cookie";
8
+ import style from "../Questionnaires.module.scss";
9
+ import { Form, Input, Layout } from "antd";
10
+ import { PlusIcon } from "../../../assets/icons";
11
+ import FormModal from "../../../components/FormModal";
12
+ import { useDispatch, useSelector } from "react-redux";
13
+ import Delete from "../../../components/Delete/Delete";
14
+ import DeleteModal from "../../../components/DeleteModal/DeleteModal";
15
+ import Success from "../../../components/Success/Success";
16
+ import { setDeleteModalVisible, setViewModalVisible } from "../../../store/slices/global";
17
+ import ViewModal from "../../../components/ViewModal";
18
+ import { getStreetColumns } from "./constant";
19
+ import Pagination from "../../../components/Pagination";
20
+ import ColSort from "../../../components/ColSort";
21
+ import { setPaginationLength } from "../../../helpers/paginationLength";
22
+ import Button from "../../../components/Button";
23
+ import Loading from "../../../components/Loading";
24
+ import Table from "../../../components/Table";
25
+ import Filter from "../../../components/Filter";
26
+ import { addExecutionRule, deleteExecutionRule, editExecutionRule, executionRuleVisibility, getExecutionRules } from "../../../store/slices/questionnaire";
27
+ var Content = Layout.Content;
28
+ var Item = Form.Item;
29
+ var QuestionnairesExecutionRulesContent = function QuestionnairesExecutionRulesContent() {
30
+ var _useState = useState(null),
31
+ _useState2 = _slicedToArray(_useState, 2),
32
+ innerW = _useState2[0],
33
+ setInnerW = _useState2[1];
34
+ var ref = useRef();
35
+ var dispatch = useDispatch();
36
+ var _useState3 = useState(0),
37
+ _useState4 = _slicedToArray(_useState3, 2),
38
+ id = _useState4[0],
39
+ setId = _useState4[1];
40
+ var _useState5 = useState(1),
41
+ _useState6 = _slicedToArray(_useState5, 2),
42
+ page = _useState6[0],
43
+ setPage = _useState6[1];
44
+ var _useState7 = useState(Cookies.get("pagination-size-questionnaire-execution-rules") ? JSON.parse(Cookies.get("pagination-size-questionnaire-execution-rules")) : 20),
45
+ _useState8 = _slicedToArray(_useState7, 2),
46
+ size = _useState8[0],
47
+ setSize = _useState8[1];
48
+ var _useState9 = useState({
49
+ name: ""
50
+ }),
51
+ _useState10 = _slicedToArray(_useState9, 2),
52
+ query = _useState10[0],
53
+ setQuery = _useState10[1];
54
+ var _useSelector = useSelector(function (state) {
55
+ return state.global;
56
+ }),
57
+ loading = _useSelector.loading,
58
+ executionRulesRender = _useSelector.executionRulesRender;
59
+ var executionRules = useSelector(function (state) {
60
+ return state.questionnaire.executionRules;
61
+ });
62
+ var paginationLength = setPaginationLength(executionRules === null || executionRules === void 0 ? void 0 : executionRules.count, executionRules === null || executionRules === void 0 ? void 0 : executionRules.size);
63
+ var onSubmit = useCallback(/*#__PURE__*/function () {
64
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(data) {
65
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
66
+ while (1) switch (_context.prev = _context.next) {
67
+ case 0:
68
+ dispatch(addExecutionRule(data));
69
+ case 1:
70
+ case "end":
71
+ return _context.stop();
72
+ }
73
+ }, _callee);
74
+ }));
75
+ return function (_x) {
76
+ return _ref.apply(this, arguments);
77
+ };
78
+ }(), [dispatch]);
79
+ var onEdit = useCallback(function (id, record) {
80
+ var data = {
81
+ id: id,
82
+ name: record === null || record === void 0 ? void 0 : record.name
83
+ };
84
+ dispatch(editExecutionRule(data));
85
+ }, [dispatch]);
86
+ var closeOnViewModal = useCallback(function () {
87
+ dispatch(setViewModalVisible(false));
88
+ }, [dispatch]);
89
+ var onClickModal = function onClickModal() {
90
+ var _ref$current;
91
+ ref === null || ref === void 0 || (_ref$current = ref.current) === null || _ref$current === void 0 || _ref$current.open();
92
+ };
93
+ var onEditClick = useCallback(function (data) {
94
+ var _ref$current2;
95
+ ref === null || ref === void 0 || (_ref$current2 = ref.current) === null || _ref$current2 === void 0 || _ref$current2.setEdit(data);
96
+ }, []);
97
+ var onDelete = useCallback(function (id) {
98
+ setId(id);
99
+ }, []);
100
+ var onStatusChange = useCallback(function (data, checked) {
101
+ var data_ = {
102
+ id: data === null || data === void 0 ? void 0 : data.id,
103
+ checked: checked
104
+ };
105
+ dispatch(executionRuleVisibility(data_));
106
+ }, [dispatch]);
107
+ var handleSearch = function handleSearch(value) {
108
+ setQuery({
109
+ name: value
110
+ });
111
+ setPage(1);
112
+ };
113
+ var handleKeyDown = function handleKeyDown(e) {
114
+ if (e.key === "Enter") {
115
+ handleSearch(e.target.value);
116
+ }
117
+ };
118
+ var handleColumnToggle = function handleColumnToggle(checked, dataIndex) {
119
+ setSelectedColumns(function (prevSelected) {
120
+ if (checked) {
121
+ return [].concat(_toConsumableArray(prevSelected), [dataIndex]);
122
+ } else {
123
+ return prevSelected.filter(function (col) {
124
+ return col !== dataIndex;
125
+ });
126
+ }
127
+ });
128
+ };
129
+ var data = [];
130
+ if (executionRules !== null && executionRules !== void 0 && executionRules.items) {
131
+ var _executionRules$items;
132
+ data = executionRules === null || executionRules === void 0 || (_executionRules$items = executionRules.items) === null || _executionRules$items === void 0 ? void 0 : _executionRules$items.map(function (dataObj, i) {
133
+ return {
134
+ num: (executionRules === null || executionRules === void 0 ? void 0 : executionRules.size) * (executionRules === null || executionRules === void 0 ? void 0 : executionRules.page) + i + 1 - (executionRules === null || executionRules === void 0 ? void 0 : executionRules.size),
135
+ id: dataObj === null || dataObj === void 0 ? void 0 : dataObj.id,
136
+ name: dataObj === null || dataObj === void 0 ? void 0 : dataObj.name,
137
+ isActive: dataObj === null || dataObj === void 0 ? void 0 : dataObj.isActive,
138
+ className: "rowClassName1"
139
+ };
140
+ });
141
+ }
142
+ var columns = useMemo(function () {
143
+ return getStreetColumns(onEditClick, onDelete, onStatusChange, dispatch);
144
+ }, [onEditClick, onDelete, onStatusChange, dispatch]);
145
+ var _useState11 = useState(columns.map(function (col) {
146
+ return col.dataIndex;
147
+ })),
148
+ _useState12 = _slicedToArray(_useState11, 2),
149
+ selectedColumns = _useState12[0],
150
+ setSelectedColumns = _useState12[1];
151
+ useEffect(function () {
152
+ if (window.innerWidth >= 1900) {
153
+ setInnerW(210);
154
+ } else {
155
+ setInnerW(155);
156
+ }
157
+ var data = {
158
+ page: page,
159
+ size: size,
160
+ query: query,
161
+ visibility: "nondeleted"
162
+ };
163
+ dispatch(getExecutionRules(data));
164
+ }, [dispatch, page, executionRulesRender, query, size]);
165
+ var updateSize = function updateSize(newSize) {
166
+ setSize(newSize); // Update state
167
+ Cookies.set("pagination-size-questionnaire-execution-rules", JSON.stringify(newSize), {
168
+ expires: 7
169
+ }); // Save to cookies
170
+ };
171
+ return /*#__PURE__*/React.createElement(React.Fragment, null, loading ? /*#__PURE__*/React.createElement(Loading, null) : null, /*#__PURE__*/React.createElement(Layout, {
172
+ className: style.layout
173
+ }, /*#__PURE__*/React.createElement(Content, {
174
+ className: style.content
175
+ }, /*#__PURE__*/React.createElement("header", {
176
+ className: style.header
177
+ }, /*#__PURE__*/React.createElement(Button, {
178
+ onClick: onClickModal,
179
+ color: "green"
180
+ }, " ", /*#__PURE__*/React.createElement(PlusIcon, null), " Soraq\xE7a \u0259lav\u0259 et"), /*#__PURE__*/React.createElement(Filter, {
181
+ columns: columns,
182
+ selectedColumns: selectedColumns,
183
+ setQuery: setQuery,
184
+ disabledElementCount: 3,
185
+ setPage: setPage
186
+ }))), /*#__PURE__*/React.createElement(Layout, {
187
+ className: style.layout1
188
+ }, /*#__PURE__*/React.createElement(Content, {
189
+ className: style.content
190
+ }, /*#__PURE__*/React.createElement("div", {
191
+ className: style.table_header
192
+ }, /*#__PURE__*/React.createElement("h2", null, "\u0130cra qaydalar\u0131"), /*#__PURE__*/React.createElement("div", {
193
+ className: style.buttons
194
+ }, /*#__PURE__*/React.createElement(ColSort, {
195
+ columns: columns,
196
+ selectedColumns: selectedColumns,
197
+ handleColumnToggle: handleColumnToggle
198
+ }))), /*#__PURE__*/React.createElement("div", {
199
+ className: "bigTable"
200
+ }, /*#__PURE__*/React.createElement(Table, {
201
+ selectedColumns: selectedColumns,
202
+ innerW: innerW,
203
+ dataSource: data,
204
+ columns: columns,
205
+ disableDrag: true
206
+ })), /*#__PURE__*/React.createElement("div", {
207
+ className: style.pagination
208
+ }, /*#__PURE__*/React.createElement(Pagination, {
209
+ size: size,
210
+ setSize: updateSize,
211
+ total: paginationLength,
212
+ page: page,
213
+ onChange: setPage
214
+ })), /*#__PURE__*/React.createElement(FormModal, {
215
+ ref: ref,
216
+ width: 454,
217
+ title: "Yeni soraqça yaratma",
218
+ titleEdit: "Soraqça redaktə etmə",
219
+ okText: "Yadda saxla",
220
+ cancelText: "Bağla",
221
+ onSubmit: onSubmit,
222
+ onEdit: onEdit,
223
+ className: "absolute",
224
+ centered: false
225
+ }, /*#__PURE__*/React.createElement(Item, {
226
+ rules: [{
227
+ required: true,
228
+ message: ""
229
+ }, {
230
+ min: 3,
231
+ message: "Ən azından 3 simvol olmalıdır"
232
+ }],
233
+ name: "name",
234
+ label: "Ad"
235
+ }, /*#__PURE__*/React.createElement(Input, {
236
+ className: style.modal_input
237
+ }))), /*#__PURE__*/React.createElement(DeleteModal, {
238
+ onCancel: function onCancel() {
239
+ return dispatch(setDeleteModalVisible(false));
240
+ },
241
+ width: 280
242
+ }, /*#__PURE__*/React.createElement(Delete, {
243
+ onDelete: function onDelete() {
244
+ return dispatch(deleteExecutionRule(id));
245
+ },
246
+ onCancel: function onCancel() {
247
+ return dispatch(setDeleteModalVisible(false));
248
+ },
249
+ value: "Soraqçanı"
250
+ })), /*#__PURE__*/React.createElement(ViewModal, {
251
+ onCancel: closeOnViewModal,
252
+ width: 695
253
+ }, /*#__PURE__*/React.createElement(Success, {
254
+ onClick: closeOnViewModal,
255
+ value: "Soraqça"
256
+ }))))));
257
+ };
258
+ export default QuestionnairesExecutionRulesContent;