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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,404 @@
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, Layout, Select as AntdSelect } 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 { addEmployeeConfigurations,
30
+ // addEmployeeConfigurations,
31
+ deleteEmployeeConfigurations, editEmployeeConfigurations, employeeConfigurationsVisibility, getEmployeeConfigurations, getPositionsAll } from "../../../store/slices/questionnaire";
32
+ import { getTransportEmployeesAll } from "../../../store/slices/employees";
33
+ import Select from "../../../components/Select";
34
+ var Option = AntdSelect.Option;
35
+ var Content = Layout.Content;
36
+ var Item = Form.Item;
37
+ var QuestionnairesEmployeeConfigurations = function QuestionnairesEmployeeConfigurations() {
38
+ var _useState = useState(null),
39
+ _useState2 = _slicedToArray(_useState, 2),
40
+ innerW = _useState2[0],
41
+ setInnerW = _useState2[1];
42
+ var ref = useRef();
43
+ var dispatch = useDispatch();
44
+ var _useState3 = useState(0),
45
+ _useState4 = _slicedToArray(_useState3, 2),
46
+ id = _useState4[0],
47
+ setId = _useState4[1];
48
+ var _useState5 = useState(1),
49
+ _useState6 = _slicedToArray(_useState5, 2),
50
+ page = _useState6[0],
51
+ setPage = _useState6[1];
52
+ var _useState7 = useState(Cookies.get("pagination-size-questionnaire-document-type") ? JSON.parse(Cookies.get("pagination-size-questionnaire-document-type")) : 20),
53
+ _useState8 = _slicedToArray(_useState7, 2),
54
+ size = _useState8[0],
55
+ setSize = _useState8[1];
56
+ var _useState9 = useState({
57
+ name: ""
58
+ }),
59
+ _useState10 = _slicedToArray(_useState9, 2),
60
+ query = _useState10[0],
61
+ setQuery = _useState10[1];
62
+ var _useState11 = useState(1),
63
+ _useState12 = _slicedToArray(_useState11, 2),
64
+ typeSelect = _useState12[0],
65
+ setTypeSelect = _useState12[1];
66
+ var _useSelector = useSelector(function (state) {
67
+ return state.global;
68
+ }),
69
+ loading = _useSelector.loading,
70
+ employeeConfigurationsRender = _useSelector.employeeConfigurationsRender;
71
+ var employeeConfigurations = useSelector(function (state) {
72
+ return state.questionnaire.employeeConfigurations;
73
+ });
74
+ var transportEmployeesAll = useSelector(function (state) {
75
+ return state.employees.transportEmployeesAll;
76
+ });
77
+ var positionsAll = useSelector(function (state) {
78
+ return state.questionnaire.positionsAll;
79
+ });
80
+ var paginationLength = setPaginationLength(employeeConfigurations === null || employeeConfigurations === void 0 ? void 0 : employeeConfigurations.count, employeeConfigurations === null || employeeConfigurations === void 0 ? void 0 : employeeConfigurations.size);
81
+ var onSubmit = useCallback(/*#__PURE__*/function () {
82
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(data_) {
83
+ var _data_$EmployeeIds, _data_$Positions, _data_$PersonInCharge, _data_$OperatingManag;
84
+ var data;
85
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
86
+ while (1) switch (_context.prev = _context.next) {
87
+ case 0:
88
+ data = _objectSpread(_objectSpread({}, data_), {}, {
89
+ EmployeeIds: ((_data_$EmployeeIds = data_.EmployeeIds) !== null && _data_$EmployeeIds !== void 0 ? _data_$EmployeeIds : []).join(","),
90
+ Positions: ((_data_$Positions = data_.Positions) !== null && _data_$Positions !== void 0 ? _data_$Positions : []).join(","),
91
+ PersonInChargeForFuelIds: ((_data_$PersonInCharge = data_.PersonInChargeForFuelIds) !== null && _data_$PersonInCharge !== void 0 ? _data_$PersonInCharge : []).join(","),
92
+ GeneralStructures: "21,26,202,255",
93
+ OperatingManagerIds: ((_data_$OperatingManag = data_.OperatingManagerIds) !== null && _data_$OperatingManag !== void 0 ? _data_$OperatingManag : []).join(",")
94
+ });
95
+ console.log(data);
96
+ dispatch(addEmployeeConfigurations(data));
97
+ case 3:
98
+ case "end":
99
+ return _context.stop();
100
+ }
101
+ }, _callee);
102
+ }));
103
+ return function (_x) {
104
+ return _ref.apply(this, arguments);
105
+ };
106
+ }(), [dispatch, typeSelect]);
107
+ var onEdit = useCallback(function (id, record) {
108
+ var data = {
109
+ id: id,
110
+ name: record === null || record === void 0 ? void 0 : record.name,
111
+ category: typeSelect
112
+ };
113
+ dispatch(editEmployeeConfigurations(data));
114
+ }, [dispatch, typeSelect]);
115
+ var onStatusChange = useCallback(function (data, checked) {
116
+ var data_ = {
117
+ id: data === null || data === void 0 ? void 0 : data.id,
118
+ checked: checked
119
+ };
120
+ dispatch(employeeConfigurationsVisibility(data_));
121
+ }, [dispatch]);
122
+ var closeOnViewModal = useCallback(function () {
123
+ dispatch(setViewModalVisible(false));
124
+ }, [dispatch]);
125
+ var onClickModal = function onClickModal() {
126
+ var _ref$current;
127
+ ref === null || ref === void 0 || (_ref$current = ref.current) === null || _ref$current === void 0 || _ref$current.open();
128
+ };
129
+ var onEditClick = useCallback(function (data) {
130
+ var _ref$current2;
131
+ ref === null || ref === void 0 || (_ref$current2 = ref.current) === null || _ref$current2 === void 0 || _ref$current2.setEdit(data);
132
+ }, []);
133
+ var onDelete = useCallback(function (id) {
134
+ setId(id);
135
+ }, []);
136
+ var handleSearch = function handleSearch(value) {
137
+ setQuery({
138
+ name: value
139
+ });
140
+ setPage(1);
141
+ };
142
+ var handleKeyDown = function handleKeyDown(e) {
143
+ if (e.key === "Enter") {
144
+ handleSearch(e.target.value);
145
+ }
146
+ };
147
+ var handleColumnToggle = function handleColumnToggle(checked, dataIndex) {
148
+ setSelectedColumns(function (prevSelected) {
149
+ if (checked) {
150
+ return [].concat(_toConsumableArray(prevSelected), [dataIndex]);
151
+ } else {
152
+ return prevSelected.filter(function (col) {
153
+ return col !== dataIndex;
154
+ });
155
+ }
156
+ });
157
+ };
158
+ var data = [];
159
+ if (employeeConfigurations !== null && employeeConfigurations !== void 0 && employeeConfigurations.items) {
160
+ var _employeeConfiguratio;
161
+ data = employeeConfigurations === null || employeeConfigurations === void 0 || (_employeeConfiguratio = employeeConfigurations.items) === null || _employeeConfiguratio === void 0 ? void 0 : _employeeConfiguratio.map(function (dataObj, i) {
162
+ var formatNames = function formatNames(ids) {
163
+ if (!Array.isArray(ids)) {
164
+ if (typeof ids === "string") {
165
+ ids = ids.split(",").map(function (id) {
166
+ return parseInt(id.trim(), 10);
167
+ });
168
+ } else {
169
+ return "";
170
+ }
171
+ }
172
+ return ids.map(function (id) {
173
+ var person = transportEmployeesAll === null || transportEmployeesAll === void 0 ? void 0 : transportEmployeesAll.find(function (p) {
174
+ return p.id === id;
175
+ });
176
+ return person ? "".concat(person.name, " ").concat(person.surname, " ").concat(person.patronymic) : "";
177
+ }).filter(Boolean).join(", ");
178
+ };
179
+ var formatPositionNames = function formatPositionNames(ids) {
180
+ if (!Array.isArray(ids)) {
181
+ if (typeof ids === "string") {
182
+ ids = ids.split(",").map(function (id) {
183
+ return parseInt(id.trim(), 10);
184
+ });
185
+ } else {
186
+ return "";
187
+ }
188
+ }
189
+ return ids.map(function (id) {
190
+ var pos = positionsAll.find(function (p) {
191
+ return p.id === id;
192
+ });
193
+ return pos ? pos.name : "";
194
+ }).filter(Boolean).join(", ");
195
+ };
196
+ return {
197
+ num: (employeeConfigurations === null || employeeConfigurations === void 0 ? void 0 : employeeConfigurations.size) * (employeeConfigurations === null || employeeConfigurations === void 0 ? void 0 : employeeConfigurations.page) + i + 1 - (employeeConfigurations === null || employeeConfigurations === void 0 ? void 0 : employeeConfigurations.size),
198
+ id: dataObj === null || dataObj === void 0 ? void 0 : dataObj.id,
199
+ EmployeeIds: formatNames(dataObj === null || dataObj === void 0 ? void 0 : dataObj.employeeIds),
200
+ GeneralStructures: dataObj === null || dataObj === void 0 ? void 0 : dataObj.generalStructures,
201
+ OperatingManagerIds: formatNames(dataObj === null || dataObj === void 0 ? void 0 : dataObj.operatingManagerIds),
202
+ PersonInChargeForFuelIds: formatNames(dataObj === null || dataObj === void 0 ? void 0 : dataObj.personInChargeForFuelIds),
203
+ Positions: formatPositionNames(dataObj === null || dataObj === void 0 ? void 0 : dataObj.positions),
204
+ isActive: dataObj === null || dataObj === void 0 ? void 0 : dataObj.isActive,
205
+ className: "rowClassName1"
206
+ };
207
+ });
208
+ }
209
+ var columns = useMemo(function () {
210
+ return getStreetColumns(onEditClick, onDelete, onStatusChange, transportEmployeesAll, dispatch);
211
+ }, [onEditClick, onDelete, onStatusChange, dispatch]);
212
+ var _useState13 = useState(columns.map(function (col) {
213
+ return col.dataIndex;
214
+ })),
215
+ _useState14 = _slicedToArray(_useState13, 2),
216
+ selectedColumns = _useState14[0],
217
+ setSelectedColumns = _useState14[1];
218
+ useEffect(function () {
219
+ if (window.innerWidth >= 1900) {
220
+ setInnerW(210);
221
+ } else {
222
+ setInnerW(155);
223
+ }
224
+ var data = {
225
+ page: page,
226
+ size: size,
227
+ query: query,
228
+ visibility: "nondeleted",
229
+ category: typeSelect
230
+ };
231
+ dispatch(getEmployeeConfigurations(data));
232
+ }, [dispatch, page, employeeConfigurationsRender, typeSelect, size, query]);
233
+ useEffect(function () {
234
+ dispatch(getTransportEmployeesAll());
235
+ dispatch(getPositionsAll({
236
+ visibility: "nondeleted"
237
+ }));
238
+ }, [dispatch]);
239
+ var updateSize = function updateSize(newSize) {
240
+ setSize(newSize); // Update state
241
+ Cookies.set("pagination-size-questionnaire-document-type", JSON.stringify(newSize), {
242
+ expires: 7
243
+ }); // Save to cookies
244
+ };
245
+ // const processDataRecursively = (items) => {
246
+ // return items?.map((item) => ({
247
+ // title: item.name,
248
+ // key: item.id,
249
+ // value: item.id,
250
+ // children: item.children ? processDataRecursively(item.children) : [],
251
+ // }));
252
+ // };
253
+ // const uniqueData = useMemo(() => {
254
+ // return allGeneralStructures?.reduce((acc, current) => {
255
+ // const x = acc.find((item) => item.id === current.id);
256
+ // if (!x) {
257
+ // acc.push(current);
258
+ // }
259
+ // return acc;
260
+ // }, []);
261
+ // }, [allGeneralStructures]);
262
+ // const generalStructureOption = processDataRecursively(uniqueData);
263
+
264
+ return /*#__PURE__*/React.createElement(React.Fragment, null, loading ? /*#__PURE__*/React.createElement(Loading, null) : null, /*#__PURE__*/React.createElement(Layout, {
265
+ className: style.layout
266
+ }, /*#__PURE__*/React.createElement(Content, {
267
+ className: style.content
268
+ }, /*#__PURE__*/React.createElement("header", {
269
+ className: style.header
270
+ }, /*#__PURE__*/React.createElement(Button, {
271
+ onClick: onClickModal,
272
+ color: "green"
273
+ }, " ", /*#__PURE__*/React.createElement(PlusIcon, null), " Soraq\xE7a \u0259lav\u0259 et"), /*#__PURE__*/React.createElement(Filter, {
274
+ columns: columns,
275
+ selectedColumns: selectedColumns,
276
+ setQuery: setQuery,
277
+ disabledElementCount: 3,
278
+ setPage: setPage
279
+ }))), /*#__PURE__*/React.createElement(Layout, {
280
+ className: style.layout1
281
+ }, /*#__PURE__*/React.createElement(Content, {
282
+ className: style.content
283
+ }, /*#__PURE__*/React.createElement("div", {
284
+ className: style.table_header
285
+ }, /*#__PURE__*/React.createElement("h2", null, "Heyy\u0259t t\u0259nziml\u0259m\u0259l\u0259ri"), /*#__PURE__*/React.createElement("div", {
286
+ className: style.buttons
287
+ }, /*#__PURE__*/React.createElement(ColSort, {
288
+ columns: columns,
289
+ selectedColumns: selectedColumns,
290
+ handleColumnToggle: handleColumnToggle
291
+ }))), /*#__PURE__*/React.createElement("div", {
292
+ className: "bigTable"
293
+ }, /*#__PURE__*/React.createElement(Table, {
294
+ selectedColumns: selectedColumns,
295
+ innerW: innerW,
296
+ dataSource: data,
297
+ columns: columns,
298
+ disableDrag: true
299
+ })), /*#__PURE__*/React.createElement("div", {
300
+ className: style.pagination
301
+ }, /*#__PURE__*/React.createElement(Pagination, {
302
+ size: size,
303
+ setSize: updateSize,
304
+ total: paginationLength,
305
+ page: page,
306
+ onChange: setPage
307
+ })), /*#__PURE__*/React.createElement(FormModal, {
308
+ ref: ref,
309
+ width: 454,
310
+ title: "Yeni soraqça yaratma",
311
+ titleEdit: "Soraqça redaktə etmə",
312
+ okText: "Yadda saxla",
313
+ cancelText: "Bağla",
314
+ onSubmit: onSubmit,
315
+ onEdit: onEdit,
316
+ className: "absolute",
317
+ centered: false
318
+ }, /*#__PURE__*/React.createElement(Item, {
319
+ rules: [{
320
+ required: true,
321
+ message: ""
322
+ }],
323
+ name: "EmployeeIds",
324
+ label: "Heyyət üzvü"
325
+ }, /*#__PURE__*/React.createElement(Select, {
326
+ mode: "multiple"
327
+ }, transportEmployeesAll === null || transportEmployeesAll === void 0 ? void 0 : transportEmployeesAll.map(function (item) {
328
+ return /*#__PURE__*/React.createElement(Option, {
329
+ key: item.id,
330
+ value: item.id
331
+ }, "".concat(item.name, " ").concat(item.surname, " ").concat(item.patronymic, ", ").concat(item.generalStructureName, ", ").concat(item.positionName));
332
+ }))), /*#__PURE__*/React.createElement(Item, {
333
+ rules: [{
334
+ required: false,
335
+ message: ""
336
+ }],
337
+ name: "GeneralStructures",
338
+ label: "Struktur vahidi"
339
+ }, /*#__PURE__*/React.createElement(Select, {
340
+ mode: "multiple"
341
+ })), /*#__PURE__*/React.createElement(Item, {
342
+ rules: [{
343
+ required: false,
344
+ message: ""
345
+ }],
346
+ name: "Positions",
347
+ label: "Vəzifələr"
348
+ }, /*#__PURE__*/React.createElement(Select, {
349
+ mode: "multiple"
350
+ }, positionsAll === null || positionsAll === void 0 ? void 0 : positionsAll.map(function (item) {
351
+ return /*#__PURE__*/React.createElement(Option, {
352
+ key: item.id,
353
+ value: item.id
354
+ }, "".concat(item.name));
355
+ }))), /*#__PURE__*/React.createElement(Item, {
356
+ rules: [{
357
+ required: true,
358
+ message: ""
359
+ }],
360
+ name: "PersonInChargeForFuelIds",
361
+ label: "Məsul şəxs"
362
+ }, /*#__PURE__*/React.createElement(Select, {
363
+ mode: "multiple"
364
+ }, transportEmployeesAll === null || transportEmployeesAll === void 0 ? void 0 : transportEmployeesAll.map(function (item) {
365
+ return /*#__PURE__*/React.createElement(Option, {
366
+ key: item.id,
367
+ value: item.id
368
+ }, "".concat(item.name, " ").concat(item.surname, " ").concat(item.patronymic, ", ").concat(item.generalStructureName, ", ").concat(item.positionName));
369
+ }))), /*#__PURE__*/React.createElement(Item, {
370
+ rules: [{
371
+ required: true,
372
+ message: ""
373
+ }],
374
+ name: "OperatingManagerIds",
375
+ label: "İstismar şöbəsinin rəisi"
376
+ }, /*#__PURE__*/React.createElement(Select, {
377
+ mode: "multiple"
378
+ }, transportEmployeesAll === null || transportEmployeesAll === void 0 ? void 0 : transportEmployeesAll.map(function (item) {
379
+ return /*#__PURE__*/React.createElement(Option, {
380
+ key: item.id,
381
+ value: item.id
382
+ }, "".concat(item.name, " ").concat(item.surname, " ").concat(item.patronymic, ", ").concat(item.generalStructureName, ", ").concat(item.positionName));
383
+ })))), /*#__PURE__*/React.createElement(DeleteModal, {
384
+ onCancel: function onCancel() {
385
+ return dispatch(setDeleteModalVisible(false));
386
+ },
387
+ width: 280
388
+ }, /*#__PURE__*/React.createElement(Delete, {
389
+ onDelete: function onDelete() {
390
+ return dispatch(deleteEmployeeConfigurations(id));
391
+ },
392
+ onCancel: function onCancel() {
393
+ return dispatch(setDeleteModalVisible(false));
394
+ },
395
+ value: "Soraqçanı"
396
+ })), /*#__PURE__*/React.createElement(ViewModal, {
397
+ onCancel: closeOnViewModal,
398
+ width: 695
399
+ }, /*#__PURE__*/React.createElement(Success, {
400
+ onClick: closeOnViewModal,
401
+ value: "Soraqça"
402
+ }))))));
403
+ };
404
+ export default QuestionnairesEmployeeConfigurations;
@@ -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
+ };