@banch0u/core-project-test-repository 1.9.1 → 1.9.3

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 (66) hide show
  1. package/dist/assets/css/antd.css +3 -3
  2. package/dist/assets/css/variables.css +2 -0
  3. package/dist/assets/icons/index.js +33 -0
  4. package/dist/components/ImagePreviewModal/index.js +129 -0
  5. package/dist/components/ImagePreviewModal/index.module.scss +27 -0
  6. package/dist/components/ViewMoreModal/index.js +30 -0
  7. package/dist/index.js +1 -0
  8. package/dist/layout/QuestionnairesLayout/index.module.scss +3 -0
  9. package/dist/layout/QuestionnairesSidebar/index.js +97 -5
  10. package/dist/layout/QuestionnairesSidebar/index.module.scss +4 -3
  11. package/dist/pages/Questionnnaires/Questionnaires.module.scss +4 -3
  12. package/dist/pages/Questionnnaires/{QuestionnairesStreetsContent → QuestionnairesAcademicdegreesContent}/constant.js +1 -1
  13. package/dist/pages/Questionnnaires/QuestionnairesAcademicdegreesContent/index.js +269 -0
  14. package/dist/pages/Questionnnaires/QuestionnairesAreasContent/constant.js +63 -0
  15. package/dist/pages/Questionnnaires/QuestionnairesAreasContent/index.js +271 -0
  16. package/dist/pages/Questionnnaires/QuestionnairesCategoriesContent/constant.js +69 -0
  17. package/dist/pages/Questionnnaires/QuestionnairesCategoriesContent/index.js +304 -0
  18. package/dist/pages/Questionnnaires/QuestionnairesCompaniesContent/constant.js +62 -0
  19. package/dist/pages/Questionnnaires/QuestionnairesCompaniesContent/index.js +278 -0
  20. package/dist/pages/Questionnnaires/QuestionnairesDisabilitystatusesContent/constant.js +58 -0
  21. package/dist/pages/Questionnnaires/QuestionnairesDisabilitystatusesContent/index.js +269 -0
  22. package/dist/pages/Questionnnaires/QuestionnairesDocumentTypeContent/constant.js +1 -1
  23. package/dist/pages/Questionnnaires/QuestionnairesDrivingcategoriesContent/constant.js +58 -0
  24. package/dist/pages/Questionnnaires/{QuestionnairesStreetsContent → QuestionnairesDrivingcategoriesContent}/index.js +41 -31
  25. package/dist/pages/Questionnnaires/QuestionnairesEducationinstitutionsContent/constant.js +58 -0
  26. package/dist/pages/Questionnnaires/QuestionnairesEducationinstitutionsContent/index.js +269 -0
  27. package/dist/pages/Questionnnaires/QuestionnairesEducationlevelsContent/constant.js +58 -0
  28. package/dist/pages/Questionnnaires/QuestionnairesEducationlevelsContent/index.js +269 -0
  29. package/dist/pages/Questionnnaires/QuestionnairesEducationpaymentsContent/constant.js +58 -0
  30. package/dist/pages/Questionnnaires/QuestionnairesEducationpaymentsContent/index.js +269 -0
  31. package/dist/pages/Questionnnaires/QuestionnairesGeneralstructurestatusesContent/constant.js +58 -0
  32. package/dist/pages/Questionnnaires/QuestionnairesGeneralstructurestatusesContent/index.js +269 -0
  33. package/dist/pages/Questionnnaires/QuestionnairesGeneralstructuretypesContent/constant.js +58 -0
  34. package/dist/pages/Questionnnaires/QuestionnairesGeneralstructuretypesContent/index.js +269 -0
  35. package/dist/pages/Questionnnaires/QuestionnairesHallsContent/constant.js +67 -0
  36. package/dist/pages/Questionnnaires/QuestionnairesHallsContent/index.js +294 -0
  37. package/dist/pages/Questionnnaires/QuestionnairesHonorarytitlesContent/constant.js +58 -0
  38. package/dist/pages/Questionnnaires/QuestionnairesHonorarytitlesContent/index.js +269 -0
  39. package/dist/pages/Questionnnaires/QuestionnairesMilitarycategoriesContent/constant.js +58 -0
  40. package/dist/pages/Questionnnaires/QuestionnairesMilitarycategoriesContent/index.js +269 -0
  41. package/dist/pages/Questionnnaires/QuestionnairesMilitarygroupsContent/constant.js +58 -0
  42. package/dist/pages/Questionnnaires/QuestionnairesMilitarygroupsContent/index.js +269 -0
  43. package/dist/pages/Questionnnaires/QuestionnairesMilitaryranksContent/constant.js +58 -0
  44. package/dist/pages/Questionnnaires/QuestionnairesMilitaryranksContent/index.js +269 -0
  45. package/dist/pages/Questionnnaires/QuestionnairesMilitarystaffsContent/constant.js +58 -0
  46. package/dist/pages/Questionnnaires/QuestionnairesMilitarystaffsContent/index.js +269 -0
  47. package/dist/pages/Questionnnaires/QuestionnairesPositionsContent/constant.js +72 -0
  48. package/dist/pages/Questionnnaires/QuestionnairesPositionsContent/index.js +428 -0
  49. package/dist/pages/Questionnnaires/QuestionnairesRegionsContent/constant.js +68 -0
  50. package/dist/pages/Questionnnaires/QuestionnairesRegionsContent/index.js +320 -0
  51. package/dist/pages/Questionnnaires/QuestionnairesReprimandtypesContent/constant.js +58 -0
  52. package/dist/pages/Questionnnaires/QuestionnairesReprimandtypesContent/index.js +269 -0
  53. package/dist/pages/Questionnnaires/QuestionnairesSpecialdaysContent/constant.js +58 -0
  54. package/dist/pages/Questionnnaires/QuestionnairesSpecialdaysContent/index.js +269 -0
  55. package/dist/pages/Questionnnaires/QuestionnairesSpecializationsContent/constant.js +58 -0
  56. package/dist/pages/Questionnnaires/QuestionnairesSpecializationsContent/index.js +269 -0
  57. package/dist/pages/Questionnnaires/QuestionnairesWarparticipantsContent/constant.js +58 -0
  58. package/dist/pages/Questionnnaires/QuestionnairesWarparticipantsContent/index.js +269 -0
  59. package/dist/pages/Questionnnaires/QuestionnairesWorkschedulesContent/constant.js +58 -0
  60. package/dist/pages/Questionnnaires/QuestionnairesWorkschedulesContent/index.js +269 -0
  61. package/dist/routes/QuestionnaireRoutes.js +169 -8
  62. package/dist/store/slices/global/index.js +147 -3
  63. package/dist/store/slices/questionnaire/index.js +5005 -99
  64. package/dist/store/slices/questionnaire/service.js +2446 -0
  65. package/dist/utils/path.js +49 -1
  66. package/package.json +1 -1
@@ -0,0 +1,269 @@
1
+ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
4
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
5
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
6
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
7
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
8
+ import React from "react";
9
+ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
10
+ import Cookies from "js-cookie";
11
+ import style from "../Questionnaires.module.scss";
12
+ import { Form, Input, Layout } from "antd";
13
+ import { PlusIcon } from "../../../assets/icons";
14
+ import FormModal from "../../../components/FormModal";
15
+ import { useDispatch, useSelector } from "react-redux";
16
+ import Delete from "../../../components/Delete/Delete";
17
+ import DeleteModal from "../../../components/DeleteModal/DeleteModal";
18
+ import Success from "../../../components/Success/Success";
19
+ import { setDeleteModalVisible, setViewModalVisible } from "../../../store/slices/global";
20
+ import ViewModal from "../../../components/ViewModal";
21
+ import { getStreetColumns } from "./constant";
22
+ import Pagination from "../../../components/Pagination";
23
+ import ColSort from "../../../components/ColSort";
24
+ import { setPaginationLength } from "../../../helpers/paginationLength";
25
+ import Button from "../../../components/Button";
26
+ import Loading from "../../../components/Loading";
27
+ import Table from "../../../components/Table";
28
+ import Filter from "../../../components/Filter";
29
+ import { addHonorarytitles, deleteHonorarytitles, honorarytitlesVisibility, editHonorarytitles, getHonorarytitles } from "../../../store/slices/questionnaire";
30
+ var Content = Layout.Content;
31
+ var Item = Form.Item;
32
+ var QuestionnairesDocumentTypeContent = function QuestionnairesDocumentTypeContent() {
33
+ var _useState = useState(null),
34
+ _useState2 = _slicedToArray(_useState, 2),
35
+ innerW = _useState2[0],
36
+ setInnerW = _useState2[1];
37
+ var ref = useRef();
38
+ var dispatch = useDispatch();
39
+ var _useState3 = useState(0),
40
+ _useState4 = _slicedToArray(_useState3, 2),
41
+ id = _useState4[0],
42
+ setId = _useState4[1];
43
+ var _useState5 = useState(1),
44
+ _useState6 = _slicedToArray(_useState5, 2),
45
+ page = _useState6[0],
46
+ setPage = _useState6[1];
47
+ var _useState7 = useState(Cookies.get("pagination-size-questionnaire-document-type") ? JSON.parse(Cookies.get("pagination-size-questionnaire-document-type")) : 20),
48
+ _useState8 = _slicedToArray(_useState7, 2),
49
+ size = _useState8[0],
50
+ setSize = _useState8[1];
51
+ var _useState9 = useState({
52
+ name: ""
53
+ }),
54
+ _useState10 = _slicedToArray(_useState9, 2),
55
+ query = _useState10[0],
56
+ setQuery = _useState10[1];
57
+ var _useState11 = useState(1),
58
+ _useState12 = _slicedToArray(_useState11, 2),
59
+ typeSelect = _useState12[0],
60
+ setTypeSelect = _useState12[1];
61
+ var _useSelector = useSelector(function (state) {
62
+ return state.global;
63
+ }),
64
+ loading = _useSelector.loading,
65
+ honorarytitlesRender = _useSelector.honorarytitlesRender;
66
+ var honorarytitles = useSelector(function (state) {
67
+ return state.questionnaire.honorarytitles;
68
+ });
69
+ var paginationLength = setPaginationLength(honorarytitles === null || honorarytitles === void 0 ? void 0 : honorarytitles.count, honorarytitles === null || honorarytitles === void 0 ? void 0 : honorarytitles.size);
70
+ var onSubmit = useCallback(/*#__PURE__*/function () {
71
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(data) {
72
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
73
+ while (1) switch (_context.prev = _context.next) {
74
+ case 0:
75
+ dispatch(addHonorarytitles(_objectSpread(_objectSpread({}, data), {}, {
76
+ category: typeSelect
77
+ })));
78
+ case 1:
79
+ case "end":
80
+ return _context.stop();
81
+ }
82
+ }, _callee);
83
+ }));
84
+ return function (_x) {
85
+ return _ref.apply(this, arguments);
86
+ };
87
+ }(), [dispatch, typeSelect]);
88
+ var onEdit = useCallback(function (id, record) {
89
+ var data = {
90
+ id: id,
91
+ name: record === null || record === void 0 ? void 0 : record.name,
92
+ category: typeSelect
93
+ };
94
+ dispatch(editHonorarytitles(data));
95
+ }, [dispatch, typeSelect]);
96
+ var onStatusChange = useCallback(function (data, checked) {
97
+ var data_ = {
98
+ id: data === null || data === void 0 ? void 0 : data.id,
99
+ checked: checked
100
+ };
101
+ dispatch(honorarytitlesVisibility(data_));
102
+ }, [dispatch]);
103
+ var closeOnViewModal = useCallback(function () {
104
+ dispatch(setViewModalVisible(false));
105
+ }, [dispatch]);
106
+ var onClickModal = function onClickModal() {
107
+ var _ref$current;
108
+ ref === null || ref === void 0 || (_ref$current = ref.current) === null || _ref$current === void 0 || _ref$current.open();
109
+ };
110
+ var onEditClick = useCallback(function (data) {
111
+ var _ref$current2;
112
+ ref === null || ref === void 0 || (_ref$current2 = ref.current) === null || _ref$current2 === void 0 || _ref$current2.setEdit(data);
113
+ }, []);
114
+ var onDelete = useCallback(function (id) {
115
+ setId(id);
116
+ }, []);
117
+ var handleSearch = function handleSearch(value) {
118
+ setQuery({
119
+ name: value
120
+ });
121
+ setPage(1);
122
+ };
123
+ var handleKeyDown = function handleKeyDown(e) {
124
+ if (e.key === "Enter") {
125
+ handleSearch(e.target.value);
126
+ }
127
+ };
128
+ var handleColumnToggle = function handleColumnToggle(checked, dataIndex) {
129
+ setSelectedColumns(function (prevSelected) {
130
+ if (checked) {
131
+ return [].concat(_toConsumableArray(prevSelected), [dataIndex]);
132
+ } else {
133
+ return prevSelected.filter(function (col) {
134
+ return col !== dataIndex;
135
+ });
136
+ }
137
+ });
138
+ };
139
+ var data = [];
140
+ if (honorarytitles !== null && honorarytitles !== void 0 && honorarytitles.items) {
141
+ var _honorarytitles$items;
142
+ data = honorarytitles === null || honorarytitles === void 0 || (_honorarytitles$items = honorarytitles.items) === null || _honorarytitles$items === void 0 ? void 0 : _honorarytitles$items.map(function (dataObj, i) {
143
+ return {
144
+ num: (honorarytitles === null || honorarytitles === void 0 ? void 0 : honorarytitles.size) * (honorarytitles === null || honorarytitles === void 0 ? void 0 : honorarytitles.page) + i + 1 - (honorarytitles === null || honorarytitles === void 0 ? void 0 : honorarytitles.size),
145
+ id: dataObj === null || dataObj === void 0 ? void 0 : dataObj.id,
146
+ name: dataObj === null || dataObj === void 0 ? void 0 : dataObj.name,
147
+ isActive: dataObj === null || dataObj === void 0 ? void 0 : dataObj.isActive,
148
+ className: "rowClassName1"
149
+ };
150
+ });
151
+ }
152
+ var columns = useMemo(function () {
153
+ return getStreetColumns(onEditClick, onDelete, onStatusChange, dispatch);
154
+ }, [onEditClick, onDelete, onStatusChange, dispatch]);
155
+ var _useState13 = useState(columns.map(function (col) {
156
+ return col.dataIndex;
157
+ })),
158
+ _useState14 = _slicedToArray(_useState13, 2),
159
+ selectedColumns = _useState14[0],
160
+ setSelectedColumns = _useState14[1];
161
+ useEffect(function () {
162
+ if (window.innerWidth >= 1900) {
163
+ setInnerW(210);
164
+ } else {
165
+ setInnerW(155);
166
+ }
167
+ var data = {
168
+ page: page,
169
+ size: size,
170
+ query: query,
171
+ visibility: "nondeleted",
172
+ category: typeSelect
173
+ };
174
+ dispatch(getHonorarytitles(data));
175
+ }, [dispatch, page, honorarytitlesRender, typeSelect, size, query]);
176
+ var updateSize = function updateSize(newSize) {
177
+ setSize(newSize); // Update state
178
+ Cookies.set("pagination-size-questionnaire-document-type", JSON.stringify(newSize), {
179
+ expires: 7
180
+ }); // Save to cookies
181
+ };
182
+ return /*#__PURE__*/React.createElement(React.Fragment, null, loading ? /*#__PURE__*/React.createElement(Loading, null) : null, /*#__PURE__*/React.createElement(Layout, {
183
+ className: style.layout
184
+ }, /*#__PURE__*/React.createElement(Content, {
185
+ className: style.content
186
+ }, /*#__PURE__*/React.createElement("header", {
187
+ className: style.header
188
+ }, /*#__PURE__*/React.createElement(Button, {
189
+ onClick: onClickModal,
190
+ color: "green"
191
+ }, " ", /*#__PURE__*/React.createElement(PlusIcon, null), " Soraq\xE7a \u0259lav\u0259 et"), /*#__PURE__*/React.createElement(Filter, {
192
+ columns: columns,
193
+ selectedColumns: selectedColumns,
194
+ setQuery: setQuery,
195
+ disabledElementCount: 3,
196
+ setPage: setPage
197
+ }))), /*#__PURE__*/React.createElement(Layout, {
198
+ className: style.layout1
199
+ }, /*#__PURE__*/React.createElement(Content, {
200
+ className: style.content
201
+ }, /*#__PURE__*/React.createElement("div", {
202
+ className: style.table_header
203
+ }, /*#__PURE__*/React.createElement("h2", null, "F\u0259xri adlar"), /*#__PURE__*/React.createElement("div", {
204
+ className: style.buttons
205
+ }, /*#__PURE__*/React.createElement(ColSort, {
206
+ columns: columns,
207
+ selectedColumns: selectedColumns,
208
+ handleColumnToggle: handleColumnToggle
209
+ }))), /*#__PURE__*/React.createElement("div", {
210
+ className: "bigTable"
211
+ }, /*#__PURE__*/React.createElement(Table, {
212
+ selectedColumns: selectedColumns,
213
+ innerW: innerW,
214
+ dataSource: data,
215
+ columns: columns,
216
+ disableDrag: true
217
+ })), /*#__PURE__*/React.createElement("div", {
218
+ className: style.pagination
219
+ }, /*#__PURE__*/React.createElement(Pagination, {
220
+ size: size,
221
+ setSize: updateSize,
222
+ total: paginationLength,
223
+ page: page,
224
+ onChange: setPage
225
+ })), /*#__PURE__*/React.createElement(FormModal, {
226
+ ref: ref,
227
+ width: 454,
228
+ title: "Yeni soraqça yaratma",
229
+ titleEdit: "Soraqça redaktə etmə",
230
+ okText: "Yadda saxla",
231
+ cancelText: "Bağla",
232
+ onSubmit: onSubmit,
233
+ onEdit: onEdit,
234
+ className: "absolute",
235
+ centered: false
236
+ }, /*#__PURE__*/React.createElement(Item, {
237
+ rules: [{
238
+ required: true,
239
+ message: ""
240
+ }, {
241
+ min: 3,
242
+ message: "Ən azından 3 simvol olmalıdır"
243
+ }],
244
+ name: "name",
245
+ label: "Ad"
246
+ }, /*#__PURE__*/React.createElement(Input, {
247
+ className: style.modal_input
248
+ }))), /*#__PURE__*/React.createElement(DeleteModal, {
249
+ onCancel: function onCancel() {
250
+ return dispatch(setDeleteModalVisible(false));
251
+ },
252
+ width: 280
253
+ }, /*#__PURE__*/React.createElement(Delete, {
254
+ onDelete: function onDelete() {
255
+ return dispatch(deleteHonorarytitles(id));
256
+ },
257
+ onCancel: function onCancel() {
258
+ return dispatch(setDeleteModalVisible(false));
259
+ },
260
+ value: "Soraqçanı"
261
+ })), /*#__PURE__*/React.createElement(ViewModal, {
262
+ onCancel: closeOnViewModal,
263
+ width: 695
264
+ }, /*#__PURE__*/React.createElement(Success, {
265
+ onClick: closeOnViewModal,
266
+ value: "Soraqça"
267
+ }))))));
268
+ };
269
+ export default QuestionnairesDocumentTypeContent;
@@ -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: "Ad",
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,269 @@
1
+ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
4
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
5
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
6
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
7
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
8
+ import React from "react";
9
+ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
10
+ import Cookies from "js-cookie";
11
+ import style from "../Questionnaires.module.scss";
12
+ import { Form, Input, Layout } from "antd";
13
+ import { PlusIcon } from "../../../assets/icons";
14
+ import FormModal from "../../../components/FormModal";
15
+ import { useDispatch, useSelector } from "react-redux";
16
+ import Delete from "../../../components/Delete/Delete";
17
+ import DeleteModal from "../../../components/DeleteModal/DeleteModal";
18
+ import Success from "../../../components/Success/Success";
19
+ import { setDeleteModalVisible, setViewModalVisible } from "../../../store/slices/global";
20
+ import ViewModal from "../../../components/ViewModal";
21
+ import { getStreetColumns } from "./constant";
22
+ import Pagination from "../../../components/Pagination";
23
+ import ColSort from "../../../components/ColSort";
24
+ import { setPaginationLength } from "../../../helpers/paginationLength";
25
+ import Button from "../../../components/Button";
26
+ import Loading from "../../../components/Loading";
27
+ import Table from "../../../components/Table";
28
+ import Filter from "../../../components/Filter";
29
+ import { addMilitarycategories, deleteMilitarycategories, militaryCategoriesVisibility, editMilitarycategories, getMilitarycategories } from "../../../store/slices/questionnaire";
30
+ var Content = Layout.Content;
31
+ var Item = Form.Item;
32
+ var QuestionnairesDocumentTypeContent = function QuestionnairesDocumentTypeContent() {
33
+ var _useState = useState(null),
34
+ _useState2 = _slicedToArray(_useState, 2),
35
+ innerW = _useState2[0],
36
+ setInnerW = _useState2[1];
37
+ var ref = useRef();
38
+ var dispatch = useDispatch();
39
+ var _useState3 = useState(0),
40
+ _useState4 = _slicedToArray(_useState3, 2),
41
+ id = _useState4[0],
42
+ setId = _useState4[1];
43
+ var _useState5 = useState(1),
44
+ _useState6 = _slicedToArray(_useState5, 2),
45
+ page = _useState6[0],
46
+ setPage = _useState6[1];
47
+ var _useState7 = useState(Cookies.get("pagination-size-questionnaire-document-type") ? JSON.parse(Cookies.get("pagination-size-questionnaire-document-type")) : 20),
48
+ _useState8 = _slicedToArray(_useState7, 2),
49
+ size = _useState8[0],
50
+ setSize = _useState8[1];
51
+ var _useState9 = useState({
52
+ name: ""
53
+ }),
54
+ _useState10 = _slicedToArray(_useState9, 2),
55
+ query = _useState10[0],
56
+ setQuery = _useState10[1];
57
+ var _useState11 = useState(1),
58
+ _useState12 = _slicedToArray(_useState11, 2),
59
+ typeSelect = _useState12[0],
60
+ setTypeSelect = _useState12[1];
61
+ var _useSelector = useSelector(function (state) {
62
+ return state.global;
63
+ }),
64
+ loading = _useSelector.loading,
65
+ militaryCategoriesRender = _useSelector.militaryCategoriesRender;
66
+ var militaryCategories = useSelector(function (state) {
67
+ return state.questionnaire.militaryCategories;
68
+ });
69
+ var paginationLength = setPaginationLength(militaryCategories === null || militaryCategories === void 0 ? void 0 : militaryCategories.count, militaryCategories === null || militaryCategories === void 0 ? void 0 : militaryCategories.size);
70
+ var onSubmit = useCallback(/*#__PURE__*/function () {
71
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(data) {
72
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
73
+ while (1) switch (_context.prev = _context.next) {
74
+ case 0:
75
+ dispatch(addMilitarycategories(_objectSpread(_objectSpread({}, data), {}, {
76
+ category: typeSelect
77
+ })));
78
+ case 1:
79
+ case "end":
80
+ return _context.stop();
81
+ }
82
+ }, _callee);
83
+ }));
84
+ return function (_x) {
85
+ return _ref.apply(this, arguments);
86
+ };
87
+ }(), [dispatch, typeSelect]);
88
+ var onEdit = useCallback(function (id, record) {
89
+ var data = {
90
+ id: id,
91
+ name: record === null || record === void 0 ? void 0 : record.name,
92
+ category: typeSelect
93
+ };
94
+ dispatch(editMilitarycategories(data));
95
+ }, [dispatch, typeSelect]);
96
+ var onStatusChange = useCallback(function (data, checked) {
97
+ var data_ = {
98
+ id: data === null || data === void 0 ? void 0 : data.id,
99
+ checked: checked
100
+ };
101
+ dispatch(militaryCategoriesVisibility(data_));
102
+ }, [dispatch]);
103
+ var closeOnViewModal = useCallback(function () {
104
+ dispatch(setViewModalVisible(false));
105
+ }, [dispatch]);
106
+ var onClickModal = function onClickModal() {
107
+ var _ref$current;
108
+ ref === null || ref === void 0 || (_ref$current = ref.current) === null || _ref$current === void 0 || _ref$current.open();
109
+ };
110
+ var onEditClick = useCallback(function (data) {
111
+ var _ref$current2;
112
+ ref === null || ref === void 0 || (_ref$current2 = ref.current) === null || _ref$current2 === void 0 || _ref$current2.setEdit(data);
113
+ }, []);
114
+ var onDelete = useCallback(function (id) {
115
+ setId(id);
116
+ }, []);
117
+ var handleSearch = function handleSearch(value) {
118
+ setQuery({
119
+ name: value
120
+ });
121
+ setPage(1);
122
+ };
123
+ var handleKeyDown = function handleKeyDown(e) {
124
+ if (e.key === "Enter") {
125
+ handleSearch(e.target.value);
126
+ }
127
+ };
128
+ var handleColumnToggle = function handleColumnToggle(checked, dataIndex) {
129
+ setSelectedColumns(function (prevSelected) {
130
+ if (checked) {
131
+ return [].concat(_toConsumableArray(prevSelected), [dataIndex]);
132
+ } else {
133
+ return prevSelected.filter(function (col) {
134
+ return col !== dataIndex;
135
+ });
136
+ }
137
+ });
138
+ };
139
+ var data = [];
140
+ if (militaryCategories !== null && militaryCategories !== void 0 && militaryCategories.items) {
141
+ var _militaryCategories$i;
142
+ data = militaryCategories === null || militaryCategories === void 0 || (_militaryCategories$i = militaryCategories.items) === null || _militaryCategories$i === void 0 ? void 0 : _militaryCategories$i.map(function (dataObj, i) {
143
+ return {
144
+ num: (militaryCategories === null || militaryCategories === void 0 ? void 0 : militaryCategories.size) * (militaryCategories === null || militaryCategories === void 0 ? void 0 : militaryCategories.page) + i + 1 - (militaryCategories === null || militaryCategories === void 0 ? void 0 : militaryCategories.size),
145
+ id: dataObj === null || dataObj === void 0 ? void 0 : dataObj.id,
146
+ name: dataObj === null || dataObj === void 0 ? void 0 : dataObj.name,
147
+ isActive: dataObj === null || dataObj === void 0 ? void 0 : dataObj.isActive,
148
+ className: "rowClassName1"
149
+ };
150
+ });
151
+ }
152
+ var columns = useMemo(function () {
153
+ return getStreetColumns(onEditClick, onDelete, onStatusChange, dispatch);
154
+ }, [onEditClick, onDelete, onStatusChange, dispatch]);
155
+ var _useState13 = useState(columns.map(function (col) {
156
+ return col.dataIndex;
157
+ })),
158
+ _useState14 = _slicedToArray(_useState13, 2),
159
+ selectedColumns = _useState14[0],
160
+ setSelectedColumns = _useState14[1];
161
+ useEffect(function () {
162
+ if (window.innerWidth >= 1900) {
163
+ setInnerW(210);
164
+ } else {
165
+ setInnerW(155);
166
+ }
167
+ var data = {
168
+ page: page,
169
+ size: size,
170
+ query: query,
171
+ visibility: "nondeleted",
172
+ category: typeSelect
173
+ };
174
+ dispatch(getMilitarycategories(data));
175
+ }, [dispatch, page, militaryCategoriesRender, typeSelect, size, query]);
176
+ var updateSize = function updateSize(newSize) {
177
+ setSize(newSize); // Update state
178
+ Cookies.set("pagination-size-questionnaire-document-type", JSON.stringify(newSize), {
179
+ expires: 7
180
+ }); // Save to cookies
181
+ };
182
+ return /*#__PURE__*/React.createElement(React.Fragment, null, loading ? /*#__PURE__*/React.createElement(Loading, null) : null, /*#__PURE__*/React.createElement(Layout, {
183
+ className: style.layout
184
+ }, /*#__PURE__*/React.createElement(Content, {
185
+ className: style.content
186
+ }, /*#__PURE__*/React.createElement("header", {
187
+ className: style.header
188
+ }, /*#__PURE__*/React.createElement(Button, {
189
+ onClick: onClickModal,
190
+ color: "green"
191
+ }, " ", /*#__PURE__*/React.createElement(PlusIcon, null), " Soraq\xE7a \u0259lav\u0259 et"), /*#__PURE__*/React.createElement(Filter, {
192
+ columns: columns,
193
+ selectedColumns: selectedColumns,
194
+ setQuery: setQuery,
195
+ disabledElementCount: 3,
196
+ setPage: setPage
197
+ }))), /*#__PURE__*/React.createElement(Layout, {
198
+ className: style.layout1
199
+ }, /*#__PURE__*/React.createElement(Content, {
200
+ className: style.content
201
+ }, /*#__PURE__*/React.createElement("div", {
202
+ className: style.table_header
203
+ }, /*#__PURE__*/React.createElement("h2", null, "H\u0259rbi kateqoriyalar"), /*#__PURE__*/React.createElement("div", {
204
+ className: style.buttons
205
+ }, /*#__PURE__*/React.createElement(ColSort, {
206
+ columns: columns,
207
+ selectedColumns: selectedColumns,
208
+ handleColumnToggle: handleColumnToggle
209
+ }))), /*#__PURE__*/React.createElement("div", {
210
+ className: "bigTable"
211
+ }, /*#__PURE__*/React.createElement(Table, {
212
+ selectedColumns: selectedColumns,
213
+ innerW: innerW,
214
+ dataSource: data,
215
+ columns: columns,
216
+ disableDrag: true
217
+ })), /*#__PURE__*/React.createElement("div", {
218
+ className: style.pagination
219
+ }, /*#__PURE__*/React.createElement(Pagination, {
220
+ size: size,
221
+ setSize: updateSize,
222
+ total: paginationLength,
223
+ page: page,
224
+ onChange: setPage
225
+ })), /*#__PURE__*/React.createElement(FormModal, {
226
+ ref: ref,
227
+ width: 454,
228
+ title: "Yeni soraqça yaratma",
229
+ titleEdit: "Soraqça redaktə etmə",
230
+ okText: "Yadda saxla",
231
+ cancelText: "Bağla",
232
+ onSubmit: onSubmit,
233
+ onEdit: onEdit,
234
+ className: "absolute",
235
+ centered: false
236
+ }, /*#__PURE__*/React.createElement(Item, {
237
+ rules: [{
238
+ required: true,
239
+ message: ""
240
+ }, {
241
+ min: 3,
242
+ message: "Ən azından 3 simvol olmalıdır"
243
+ }],
244
+ name: "name",
245
+ label: "Ad"
246
+ }, /*#__PURE__*/React.createElement(Input, {
247
+ className: style.modal_input
248
+ }))), /*#__PURE__*/React.createElement(DeleteModal, {
249
+ onCancel: function onCancel() {
250
+ return dispatch(setDeleteModalVisible(false));
251
+ },
252
+ width: 280
253
+ }, /*#__PURE__*/React.createElement(Delete, {
254
+ onDelete: function onDelete() {
255
+ return dispatch(deleteMilitarycategories(id));
256
+ },
257
+ onCancel: function onCancel() {
258
+ return dispatch(setDeleteModalVisible(false));
259
+ },
260
+ value: "Soraqçanı"
261
+ })), /*#__PURE__*/React.createElement(ViewModal, {
262
+ onCancel: closeOnViewModal,
263
+ width: 695
264
+ }, /*#__PURE__*/React.createElement(Success, {
265
+ onClick: closeOnViewModal,
266
+ value: "Soraqça"
267
+ }))))));
268
+ };
269
+ export default QuestionnairesDocumentTypeContent;
@@ -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: "Ad",
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
+ };