@3sc/common-component 0.0.2 → 0.0.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.
- package/dist/App.js +3 -3
- package/dist/components/alert/alert-body.js +122 -0
- package/dist/components/alert/details-body.js +126 -0
- package/dist/components/alert/index.js +165 -19
- package/dist/components/alert/style.scss +146 -2
- package/dist/components/alert/table-detail.js +37 -0
- package/dist/components/input-field/index.js +67 -0
- package/dist/components/my-dialog.js +59 -21
- package/dist/components/my-pagination/index.js +50 -0
- package/dist/components/my-pagination/logs.js +24 -0
- package/dist/components/notification-card/card.js +100 -0
- package/dist/components/notification-card/index.js +36 -0
- package/dist/components/select-field/index.js +55 -0
- package/dist/components/sort-icon/index.js +26 -0
- package/dist/config/my-context.js +12 -5
- package/dist/config/theme.js +4 -0
- package/dist/helper/common-fun.js +78 -2
- package/dist/sass/_colors.scss +6 -1
- package/dist/sass/_typography.scss +1 -1
- package/dist/services/notification.js +19 -2
- package/dist/utils/ActionType.js +13 -0
- package/dist/utils/Constant.js +25 -3
- package/dist/utils/ErrorMsg.js +14 -0
- package/dist/utils/LocalStorage.js +6 -1
- package/package.json +60 -60
package/dist/App.js
CHANGED
|
@@ -11,9 +11,9 @@ function App() {
|
|
|
11
11
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
12
12
|
className: "App"
|
|
13
13
|
}, "hello", /*#__PURE__*/_react.default.createElement(_modules.Notification, {
|
|
14
|
-
tenantId: "
|
|
15
|
-
buId: "
|
|
16
|
-
snopId: "
|
|
14
|
+
tenantId: "9a33965c-162a-4089-8cb1-5e631e3cdd8a",
|
|
15
|
+
buId: "d628f9a3-1968-4102-b578-727616b382f3",
|
|
16
|
+
snopId: "13a53238-f493-41a5-9d17-7b95aeed7964"
|
|
17
17
|
}));
|
|
18
18
|
}
|
|
19
19
|
var _default = exports.default = App;
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
require("core-js/modules/es.weak-map.js");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
require("core-js/modules/web.dom-collections.iterator.js");
|
|
9
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _material = require("@mui/material");
|
|
11
|
+
var _ErrorMsg = _interopRequireDefault(require("../../utils/ErrorMsg"));
|
|
12
|
+
var _inputField = _interopRequireDefault(require("../input-field"));
|
|
13
|
+
var _Search = _interopRequireDefault(require("@mui/icons-material/Search"));
|
|
14
|
+
var _Refresh = _interopRequireDefault(require("@mui/icons-material/Refresh"));
|
|
15
|
+
var _selectField = _interopRequireDefault(require("../select-field"));
|
|
16
|
+
var _Constant = require("../../utils/Constant");
|
|
17
|
+
var _card = _interopRequireDefault(require("../notification-card/card"));
|
|
18
|
+
var _commonFun = require("../../helper/common-fun");
|
|
19
|
+
var _myPagination = _interopRequireDefault(require("../my-pagination"));
|
|
20
|
+
var _logs = _interopRequireDefault(require("../my-pagination/logs"));
|
|
21
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
22
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
23
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
24
|
+
const AlertBody = _ref => {
|
|
25
|
+
let {
|
|
26
|
+
loading,
|
|
27
|
+
isEmpty,
|
|
28
|
+
data,
|
|
29
|
+
handleShowDetails: _handleShowDetails,
|
|
30
|
+
handleRead: _handleRead,
|
|
31
|
+
handleRefresh
|
|
32
|
+
} = _ref;
|
|
33
|
+
const [inputValue, setInputValue] = (0, _react.useState)("");
|
|
34
|
+
const [page, setPage] = (0, _react.useState)(1);
|
|
35
|
+
const [rowPerPage, setRowPerPage] = (0, _react.useState)(10);
|
|
36
|
+
const [total, setTotal] = (0, _react.useState)(0);
|
|
37
|
+
const [newData, setNewData] = (0, _react.useState)([]);
|
|
38
|
+
(0, _react.useEffect)(() => {
|
|
39
|
+
setTotal(data.length);
|
|
40
|
+
}, [data]);
|
|
41
|
+
const handleSelectChange = e => {
|
|
42
|
+
const value = e.target.value;
|
|
43
|
+
console.log(value);
|
|
44
|
+
};
|
|
45
|
+
const handleChangePage = page => {
|
|
46
|
+
console.log(page);
|
|
47
|
+
};
|
|
48
|
+
const handleSearch = e => {
|
|
49
|
+
const value = e.target.value;
|
|
50
|
+
setInputValue(value);
|
|
51
|
+
};
|
|
52
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_material.DialogContent, {
|
|
53
|
+
dividers: true,
|
|
54
|
+
sx: {
|
|
55
|
+
pt: "0 !important"
|
|
56
|
+
}
|
|
57
|
+
}, /*#__PURE__*/_react.default.createElement(_material.Box, {
|
|
58
|
+
sx: loading || isEmpty ? {
|
|
59
|
+
display: "flex",
|
|
60
|
+
justifyContent: "center",
|
|
61
|
+
alignItems: "center",
|
|
62
|
+
minHeight: 320
|
|
63
|
+
} : {}
|
|
64
|
+
}, loading ? /*#__PURE__*/_react.default.createElement(_material.CircularProgress, null) : isEmpty ? /*#__PURE__*/_react.default.createElement(_material.Typography, {
|
|
65
|
+
className: "no-record"
|
|
66
|
+
}, _ErrorMsg.default.NRF) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_material.Box, {
|
|
67
|
+
className: "sticky-input-select"
|
|
68
|
+
}, /*#__PURE__*/_react.default.createElement(_material.Box, {
|
|
69
|
+
sx: {
|
|
70
|
+
display: "flex",
|
|
71
|
+
gap: 1
|
|
72
|
+
}
|
|
73
|
+
}, /*#__PURE__*/_react.default.createElement(_inputField.default, {
|
|
74
|
+
value: inputValue,
|
|
75
|
+
onChange: handleSearch,
|
|
76
|
+
label: "Search",
|
|
77
|
+
focused: true,
|
|
78
|
+
adornmentIcon: {
|
|
79
|
+
startAdornment: /*#__PURE__*/_react.default.createElement(_material.InputAdornment, {
|
|
80
|
+
position: "start"
|
|
81
|
+
}, /*#__PURE__*/_react.default.createElement(_Search.default, null))
|
|
82
|
+
}
|
|
83
|
+
}), /*#__PURE__*/_react.default.createElement(_selectField.default, {
|
|
84
|
+
value: rowPerPage,
|
|
85
|
+
option: _Constant.optionRow,
|
|
86
|
+
handleSelectChange: handleSelectChange
|
|
87
|
+
}), /*#__PURE__*/_react.default.createElement(_material.IconButton, {
|
|
88
|
+
color: "primary",
|
|
89
|
+
onClick: handleRefresh
|
|
90
|
+
}, /*#__PURE__*/_react.default.createElement(_Refresh.default, {
|
|
91
|
+
fontSize: "medium"
|
|
92
|
+
}))), /*#__PURE__*/_react.default.createElement(_logs.default, {
|
|
93
|
+
start: page,
|
|
94
|
+
end: rowPerPage,
|
|
95
|
+
total: total
|
|
96
|
+
})), data.map((item, index) => {
|
|
97
|
+
return /*#__PURE__*/_react.default.createElement(_card.default, {
|
|
98
|
+
key: index,
|
|
99
|
+
isCheckBox: true,
|
|
100
|
+
title: item.message,
|
|
101
|
+
subTitle: (0, _commonFun.fullFormatDate)(item.createdAt),
|
|
102
|
+
isRead: item.isRead,
|
|
103
|
+
handleShowDetails: () => _handleShowDetails(item.id),
|
|
104
|
+
handleRead: () => _handleRead(item.id),
|
|
105
|
+
subType: item.sub_type,
|
|
106
|
+
isSubType: true
|
|
107
|
+
});
|
|
108
|
+
})))), !(loading || isEmpty) && /*#__PURE__*/_react.default.createElement(_material.DialogActions, {
|
|
109
|
+
sx: {
|
|
110
|
+
justifyContent: "space-between",
|
|
111
|
+
gap: 1
|
|
112
|
+
},
|
|
113
|
+
className: "action-show-all-dialog"
|
|
114
|
+
}, /*#__PURE__*/_react.default.createElement(_myPagination.default, {
|
|
115
|
+
page: page,
|
|
116
|
+
rowPerPage: rowPerPage,
|
|
117
|
+
total: total,
|
|
118
|
+
handleChangePage: handleChangePage,
|
|
119
|
+
isMarkAllRead: true
|
|
120
|
+
})));
|
|
121
|
+
};
|
|
122
|
+
var _default = exports.default = AlertBody;
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
require("core-js/modules/es.weak-map.js");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
require("core-js/modules/web.dom-collections.iterator.js");
|
|
9
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _material = require("@mui/material");
|
|
11
|
+
var _ErrorMsg = _interopRequireDefault(require("../../utils/ErrorMsg"));
|
|
12
|
+
var _inputField = _interopRequireDefault(require("../input-field"));
|
|
13
|
+
var _Search = _interopRequireDefault(require("@mui/icons-material/Search"));
|
|
14
|
+
var _selectField = _interopRequireDefault(require("../select-field"));
|
|
15
|
+
var _Constant = require("../../utils/Constant");
|
|
16
|
+
var _myPagination = _interopRequireDefault(require("../my-pagination"));
|
|
17
|
+
var _tableDetail = _interopRequireDefault(require("./table-detail"));
|
|
18
|
+
var _commonFun = require("../../helper/common-fun");
|
|
19
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
20
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
21
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
22
|
+
const DetailsBody = _ref => {
|
|
23
|
+
let {
|
|
24
|
+
loading,
|
|
25
|
+
isEmpty,
|
|
26
|
+
data
|
|
27
|
+
} = _ref;
|
|
28
|
+
const [inputValue, setInputValue] = (0, _react.useState)("");
|
|
29
|
+
const [page, setPage] = (0, _react.useState)(1);
|
|
30
|
+
const [rowPerPage, setRowPerPage] = (0, _react.useState)(10);
|
|
31
|
+
const [total, setTotal] = (0, _react.useState)(0);
|
|
32
|
+
const [newData, setNewData] = (0, _react.useState)([]);
|
|
33
|
+
const [sortDir, setSortDir] = (0, _react.useState)(false);
|
|
34
|
+
const [sortKey, setSortKey] = (0, _react.useState)("");
|
|
35
|
+
(0, _react.useEffect)(() => {
|
|
36
|
+
if (inputValue || sortKey) {
|
|
37
|
+
const newData = (0, _commonFun.searchByKeyArr)(data, _Constant.detailsSearchKey, inputValue);
|
|
38
|
+
if (sortKey) {
|
|
39
|
+
const sortedData = (0, _commonFun.sortByKeyArr)(newData, sortKey, sortDir ? "asc" : "desc");
|
|
40
|
+
setNewData((0, _commonFun.dataSlice)(sortedData, page, rowPerPage));
|
|
41
|
+
setTotal(sortedData.length);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
setNewData((0, _commonFun.dataSlice)(newData, page, rowPerPage));
|
|
45
|
+
setTotal(newData.length);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
setNewData((0, _commonFun.dataSlice)(data, page, rowPerPage));
|
|
49
|
+
setTotal(data.length);
|
|
50
|
+
}, [inputValue, data, page, rowPerPage, sortDir, sortKey]);
|
|
51
|
+
const handleSelectChange = e => {
|
|
52
|
+
const value = e.target.value;
|
|
53
|
+
setPage(1);
|
|
54
|
+
setRowPerPage(Number(value));
|
|
55
|
+
};
|
|
56
|
+
const handleChangePage = page => {
|
|
57
|
+
setPage(page);
|
|
58
|
+
};
|
|
59
|
+
const handleSearch = e => {
|
|
60
|
+
const value = e.target.value;
|
|
61
|
+
if (value) setPage(1);
|
|
62
|
+
setInputValue(value);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
// sort function
|
|
66
|
+
const handleSort = key => {
|
|
67
|
+
setSortDir(!sortDir);
|
|
68
|
+
setSortKey(key);
|
|
69
|
+
};
|
|
70
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_material.DialogContent, {
|
|
71
|
+
dividers: true,
|
|
72
|
+
sx: {
|
|
73
|
+
pt: "0 !important"
|
|
74
|
+
}
|
|
75
|
+
}, /*#__PURE__*/_react.default.createElement(_material.Box, {
|
|
76
|
+
sx: loading || isEmpty ? {
|
|
77
|
+
display: "flex",
|
|
78
|
+
justifyContent: "center",
|
|
79
|
+
alignItems: "center",
|
|
80
|
+
minHeight: 320
|
|
81
|
+
} : {}
|
|
82
|
+
}, loading ? /*#__PURE__*/_react.default.createElement(_material.CircularProgress, null) : isEmpty ? /*#__PURE__*/_react.default.createElement(_material.Typography, {
|
|
83
|
+
className: "no-record"
|
|
84
|
+
}, _ErrorMsg.default.NRF) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_material.Box, {
|
|
85
|
+
className: "sticky-input-select"
|
|
86
|
+
}, /*#__PURE__*/_react.default.createElement(_material.Box, {
|
|
87
|
+
sx: {
|
|
88
|
+
display: "flex",
|
|
89
|
+
gap: 1
|
|
90
|
+
}
|
|
91
|
+
}, /*#__PURE__*/_react.default.createElement(_inputField.default, {
|
|
92
|
+
value: inputValue,
|
|
93
|
+
onChange: handleSearch,
|
|
94
|
+
label: "Search",
|
|
95
|
+
focused: true,
|
|
96
|
+
adornmentIcon: {
|
|
97
|
+
startAdornment: /*#__PURE__*/_react.default.createElement(_material.InputAdornment, {
|
|
98
|
+
position: "start"
|
|
99
|
+
}, /*#__PURE__*/_react.default.createElement(_Search.default, null))
|
|
100
|
+
}
|
|
101
|
+
}), /*#__PURE__*/_react.default.createElement(_selectField.default, {
|
|
102
|
+
value: rowPerPage,
|
|
103
|
+
option: _Constant.optionRow,
|
|
104
|
+
handleSelectChange: handleSelectChange
|
|
105
|
+
}))), newData.length === 0 ? /*#__PURE__*/_react.default.createElement(_material.Typography, {
|
|
106
|
+
className: "no-record"
|
|
107
|
+
}, _ErrorMsg.default.NRF) : /*#__PURE__*/_react.default.createElement(_tableDetail.default, {
|
|
108
|
+
data: newData,
|
|
109
|
+
handleSort: handleSort,
|
|
110
|
+
sortDir: sortDir,
|
|
111
|
+
sortKey: sortKey
|
|
112
|
+
})))), !(loading || isEmpty) && /*#__PURE__*/_react.default.createElement(_material.DialogActions, {
|
|
113
|
+
sx: {
|
|
114
|
+
justifyContent: "space-between",
|
|
115
|
+
gap: 1
|
|
116
|
+
},
|
|
117
|
+
className: "action-show-all-dialog"
|
|
118
|
+
}, /*#__PURE__*/_react.default.createElement(_myPagination.default, {
|
|
119
|
+
page: page,
|
|
120
|
+
rowPerPage: rowPerPage,
|
|
121
|
+
total: total,
|
|
122
|
+
handleChangePage: handleChangePage,
|
|
123
|
+
isLogo: true
|
|
124
|
+
})));
|
|
125
|
+
};
|
|
126
|
+
var _default = exports.default = DetailsBody;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
require("core-js/modules/es.symbol.description.js");
|
|
3
4
|
require("core-js/modules/es.weak-map.js");
|
|
4
5
|
Object.defineProperty(exports, "__esModule", {
|
|
5
6
|
value: true
|
|
@@ -15,9 +16,21 @@ require("./style.scss");
|
|
|
15
16
|
var _myContext = require("../../config/my-context");
|
|
16
17
|
var _notification = require("../../services/notification");
|
|
17
18
|
var _StatusCode = _interopRequireDefault(require("../../utils/StatusCode"));
|
|
19
|
+
var _notificationCard = _interopRequireDefault(require("../notification-card"));
|
|
20
|
+
var _commonFun = require("../../helper/common-fun");
|
|
21
|
+
var _ActionType = _interopRequireDefault(require("../../utils/ActionType"));
|
|
22
|
+
var _ErrorMsg = _interopRequireDefault(require("../../utils/ErrorMsg"));
|
|
23
|
+
var _Constant = require("../../utils/Constant");
|
|
24
|
+
var _alertBody = _interopRequireDefault(require("./alert-body"));
|
|
25
|
+
var _detailsBody = _interopRequireDefault(require("./details-body"));
|
|
18
26
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
27
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
20
28
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
29
|
+
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; }
|
|
30
|
+
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; }
|
|
31
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
32
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
|
33
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
21
34
|
const Alert = _ref => {
|
|
22
35
|
let {
|
|
23
36
|
tenantId,
|
|
@@ -31,15 +44,23 @@ const Alert = _ref => {
|
|
|
31
44
|
isMarkAllAsRead
|
|
32
45
|
} = (0, _react.useContext)(_myContext.TasksContext);
|
|
33
46
|
const [open, setOpen] = (0, _react.useState)(false);
|
|
47
|
+
const [showAllAlert, setShowAllAlert] = (0, _react.useState)(false);
|
|
48
|
+
const [showDetails, setShowDetails] = (0, _react.useState)(false);
|
|
49
|
+
const [detailsData, setDetailsData] = (0, _react.useState)({});
|
|
50
|
+
const isEmpty = data.length === 0;
|
|
34
51
|
const fetchNotification = (0, _react.useCallback)(async () => {
|
|
35
52
|
dispatch({
|
|
36
|
-
type:
|
|
53
|
+
type: _ActionType.default.LOADING,
|
|
37
54
|
loading: true
|
|
38
55
|
});
|
|
39
56
|
dispatch({
|
|
40
|
-
type:
|
|
57
|
+
type: _ActionType.default.SUCCESS,
|
|
41
58
|
data: []
|
|
42
59
|
});
|
|
60
|
+
dispatch({
|
|
61
|
+
type: _ActionType.default.MARK_ALL_AS_READ,
|
|
62
|
+
isMarkAllAsRead: 0
|
|
63
|
+
});
|
|
43
64
|
try {
|
|
44
65
|
const res = await (0, _notification.getNotification)({
|
|
45
66
|
tenantId,
|
|
@@ -47,20 +68,25 @@ const Alert = _ref => {
|
|
|
47
68
|
snopId
|
|
48
69
|
});
|
|
49
70
|
if (res.status === _StatusCode.default.OK) {
|
|
50
|
-
var _res$data;
|
|
71
|
+
var _res$data, _res$data2;
|
|
51
72
|
dispatch({
|
|
52
|
-
type:
|
|
73
|
+
type: _ActionType.default.SUCCESS,
|
|
53
74
|
data: ((_res$data = res.data) === null || _res$data === void 0 || (_res$data = _res$data.responseData) === null || _res$data === void 0 ? void 0 : _res$data.response) || []
|
|
54
75
|
});
|
|
76
|
+
const isMarkAll = (0, _commonFun.detectMarkAllAsRead)(((_res$data2 = res.data) === null || _res$data2 === void 0 || (_res$data2 = _res$data2.responseData) === null || _res$data2 === void 0 ? void 0 : _res$data2.response) || []);
|
|
77
|
+
dispatch({
|
|
78
|
+
type: _ActionType.default.MARK_ALL_AS_READ,
|
|
79
|
+
isMarkAllAsRead: isMarkAll
|
|
80
|
+
});
|
|
55
81
|
}
|
|
56
82
|
} catch (err) {
|
|
57
83
|
dispatch({
|
|
58
|
-
type:
|
|
59
|
-
error:
|
|
84
|
+
type: _ActionType.default.ERROR,
|
|
85
|
+
error: _ErrorMsg.default.SWR
|
|
60
86
|
});
|
|
61
87
|
} finally {
|
|
62
88
|
dispatch({
|
|
63
|
-
type:
|
|
89
|
+
type: _ActionType.default.LOADING,
|
|
64
90
|
loading: false
|
|
65
91
|
});
|
|
66
92
|
}
|
|
@@ -68,40 +94,160 @@ const Alert = _ref => {
|
|
|
68
94
|
(0, _react.useEffect)(() => {
|
|
69
95
|
fetchNotification();
|
|
70
96
|
}, [fetchNotification]);
|
|
71
|
-
const handleOpen = () =>
|
|
72
|
-
setOpen(!open);
|
|
73
|
-
};
|
|
97
|
+
const handleOpen = () => setOpen(!open);
|
|
74
98
|
const handleClose = () => setOpen(!open);
|
|
99
|
+
const handleShowAllAlert = () => setShowAllAlert(!showAllAlert);
|
|
100
|
+
const handleHideAllAlert = () => setShowAllAlert(!showAllAlert);
|
|
101
|
+
const handleOpenDetails = () => setShowDetails(!showDetails);
|
|
102
|
+
const handleHideDetails = () => setShowDetails(!showDetails);
|
|
75
103
|
const handleRefresh = () => {
|
|
76
104
|
fetchNotification();
|
|
77
105
|
};
|
|
78
|
-
const handleShowAll = () => {
|
|
79
|
-
|
|
80
|
-
|
|
106
|
+
const handleShowAll = () => {
|
|
107
|
+
handleShowAllAlert();
|
|
108
|
+
};
|
|
109
|
+
const handleShowDetails = id => {
|
|
110
|
+
const filterData = data.find(item => item.id === id);
|
|
111
|
+
setDetailsData(filterData);
|
|
112
|
+
handleOpenDetails();
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
// mark as read function
|
|
116
|
+
const handleRead = async id => {
|
|
117
|
+
if (!id) return;
|
|
118
|
+
dispatch({
|
|
119
|
+
type: _ActionType.default.LOADING,
|
|
120
|
+
loading: true
|
|
121
|
+
});
|
|
122
|
+
try {
|
|
123
|
+
const res = await (0, _notification.putNotification)([id]);
|
|
124
|
+
if (res.status === _StatusCode.default.OK) {
|
|
125
|
+
const newData = data.map(item => {
|
|
126
|
+
if (item.id === id) {
|
|
127
|
+
return _objectSpread(_objectSpread({}, item), {}, {
|
|
128
|
+
isRead: true
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
return item;
|
|
132
|
+
});
|
|
133
|
+
dispatch({
|
|
134
|
+
type: _ActionType.default.SUCCESS,
|
|
135
|
+
data: newData
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
} catch (e) {
|
|
139
|
+
dispatch({
|
|
140
|
+
type: _ActionType.default.ERROR,
|
|
141
|
+
error: _ErrorMsg.default.SWR
|
|
142
|
+
});
|
|
143
|
+
} finally {
|
|
144
|
+
dispatch({
|
|
145
|
+
type: _ActionType.default.LOADING,
|
|
146
|
+
loading: false
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
// mark all as read function
|
|
152
|
+
const handleMarkAllAsRead = async () => {
|
|
153
|
+
const payload = (0, _commonFun.createPayloadMarkAllAsRead)(data);
|
|
154
|
+
dispatch({
|
|
155
|
+
type: _ActionType.default.LOADING,
|
|
156
|
+
loading: true
|
|
157
|
+
});
|
|
158
|
+
try {
|
|
159
|
+
const res = await (0, _notification.putNotification)(payload);
|
|
160
|
+
if (res.status === _StatusCode.default.OK) {
|
|
161
|
+
const newData = data.map(item => {
|
|
162
|
+
return _objectSpread(_objectSpread({}, item), {}, {
|
|
163
|
+
isRead: true
|
|
164
|
+
});
|
|
165
|
+
});
|
|
166
|
+
dispatch({
|
|
167
|
+
type: _ActionType.default.SUCCESS,
|
|
168
|
+
data: newData
|
|
169
|
+
});
|
|
170
|
+
dispatch({
|
|
171
|
+
type: _ActionType.default.MARK_ALL_AS_READ,
|
|
172
|
+
isMarkAllAsRead: false
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
} catch (e) {
|
|
176
|
+
dispatch({
|
|
177
|
+
type: _ActionType.default.ERROR,
|
|
178
|
+
error: _ErrorMsg.default.SWR
|
|
179
|
+
});
|
|
180
|
+
} finally {
|
|
181
|
+
dispatch({
|
|
182
|
+
type: _ActionType.default.LOADING,
|
|
183
|
+
loading: false
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
console.log(_ActionType.default.LOADING, isMarkAllAsRead, loading, data);
|
|
81
188
|
return /*#__PURE__*/_react.default.createElement(_material.Box, null, /*#__PURE__*/_react.default.createElement(_material.Box, {
|
|
82
189
|
sx: {
|
|
83
190
|
display: "flex",
|
|
84
191
|
justifyContent: "center"
|
|
85
192
|
}
|
|
86
193
|
}, /*#__PURE__*/_react.default.createElement(_bell.default, {
|
|
87
|
-
count:
|
|
194
|
+
count: isMarkAllAsRead || 0,
|
|
88
195
|
handleClick: handleOpen
|
|
89
196
|
})), /*#__PURE__*/_react.default.createElement(_myDialog.default, {
|
|
90
197
|
title: "Alerts",
|
|
91
198
|
open: open,
|
|
92
|
-
loading: loading
|
|
93
|
-
isMarkAllAsRead: isMarkAllAsRead
|
|
199
|
+
loading: loading,
|
|
200
|
+
isMarkAllAsRead: isMarkAllAsRead,
|
|
94
201
|
onClose: handleClose,
|
|
95
202
|
onRefresh: handleRefresh,
|
|
96
203
|
handleShowAll: handleShowAll,
|
|
97
|
-
handleMarkAllAsRead: handleMarkAllAsRead
|
|
204
|
+
handleMarkAllAsRead: handleMarkAllAsRead,
|
|
205
|
+
headerIconType: _Constant.HEADER_ICON_TYPE.REFRESH,
|
|
206
|
+
isDialogActionShow: true,
|
|
207
|
+
className: "alert-dialog-main"
|
|
208
|
+
}, /*#__PURE__*/_react.default.createElement(_material.DialogContent, {
|
|
209
|
+
dividers: true
|
|
98
210
|
}, /*#__PURE__*/_react.default.createElement(_material.Box, {
|
|
99
|
-
sx: {
|
|
211
|
+
sx: loading || isEmpty ? {
|
|
100
212
|
display: "flex",
|
|
101
213
|
justifyContent: "center",
|
|
102
214
|
alignItems: "center",
|
|
103
215
|
height: 320
|
|
216
|
+
} : {
|
|
217
|
+
height: 320
|
|
104
218
|
}
|
|
105
|
-
}, loading ? /*#__PURE__*/_react.default.createElement(_material.CircularProgress, null) : /*#__PURE__*/_react.default.createElement(_material.
|
|
219
|
+
}, loading ? /*#__PURE__*/_react.default.createElement(_material.CircularProgress, null) : isEmpty ? /*#__PURE__*/_react.default.createElement(_material.Typography, {
|
|
220
|
+
className: "no-record"
|
|
221
|
+
}, _ErrorMsg.default.NRF) : /*#__PURE__*/_react.default.createElement(_notificationCard.default, {
|
|
222
|
+
data: (0, _commonFun.filterAlertData)(data),
|
|
223
|
+
handleRead: handleRead,
|
|
224
|
+
handleShowDetails: handleShowDetails
|
|
225
|
+
})))), /*#__PURE__*/_react.default.createElement(_myDialog.default, {
|
|
226
|
+
title: "Alerts",
|
|
227
|
+
open: showAllAlert,
|
|
228
|
+
loading: loading,
|
|
229
|
+
onClose: handleHideAllAlert,
|
|
230
|
+
onRefresh: handleRefresh,
|
|
231
|
+
headerIconType: _Constant.HEADER_ICON_TYPE.CLOSE,
|
|
232
|
+
className: "alert-dialog"
|
|
233
|
+
}, /*#__PURE__*/_react.default.createElement(_alertBody.default, {
|
|
234
|
+
loading: loading,
|
|
235
|
+
isEmpty: isEmpty,
|
|
236
|
+
data: data,
|
|
237
|
+
handleRefresh: handleRefresh,
|
|
238
|
+
handleShowDetails: handleShowDetails,
|
|
239
|
+
handleRead: handleRead
|
|
240
|
+
})), /*#__PURE__*/_react.default.createElement(_myDialog.default, {
|
|
241
|
+
title: detailsData === null || detailsData === void 0 ? void 0 : detailsData.message,
|
|
242
|
+
subTitle: detailsData === null || detailsData === void 0 ? void 0 : detailsData.remark,
|
|
243
|
+
open: showDetails,
|
|
244
|
+
onClose: handleHideDetails,
|
|
245
|
+
headerIconType: _Constant.HEADER_ICON_TYPE.CLOSE,
|
|
246
|
+
className: "alert-dialog"
|
|
247
|
+
}, /*#__PURE__*/_react.default.createElement(_detailsBody.default, {
|
|
248
|
+
loading: loading,
|
|
249
|
+
isEmpty: isEmpty,
|
|
250
|
+
data: (detailsData === null || detailsData === void 0 ? void 0 : detailsData.notificationDetails) || []
|
|
251
|
+
})));
|
|
106
252
|
};
|
|
107
253
|
var _default = exports.default = Alert;
|
|
@@ -3,8 +3,16 @@
|
|
|
3
3
|
.title {
|
|
4
4
|
color: $secondary-color;
|
|
5
5
|
font-family: Montserrat, sans-serif;
|
|
6
|
-
font-size: 1.
|
|
6
|
+
font-size: 1.6rem;
|
|
7
7
|
font-weight: 600;
|
|
8
|
+
width: 95%;
|
|
9
|
+
line-height: 1.2;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.sub-title {
|
|
13
|
+
color: $primary-color;
|
|
14
|
+
font-weight: 500;
|
|
15
|
+
margin-top: 0.5rem;
|
|
8
16
|
}
|
|
9
17
|
|
|
10
18
|
.dialog-action {
|
|
@@ -13,10 +21,146 @@
|
|
|
13
21
|
justify-content: space-between;
|
|
14
22
|
|
|
15
23
|
.view-all {
|
|
16
|
-
color:
|
|
24
|
+
color: $secondary-color;
|
|
17
25
|
font-family: Montserrat, sans-serif;
|
|
18
26
|
font-weight: 500;
|
|
19
27
|
text-transform: initial;
|
|
28
|
+
font-size: 1.2rem;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.card {
|
|
33
|
+
&:not(:last-child) {
|
|
34
|
+
border-bottom: 1px solid rgba(0, 0, 0, 0.12);
|
|
35
|
+
padding-bottom: 0.5rem;
|
|
36
|
+
}
|
|
37
|
+
padding: 0.5rem 0;
|
|
38
|
+
|
|
39
|
+
.badge {
|
|
40
|
+
margin-top: 0.6rem;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.title-card {
|
|
44
|
+
color: $secondary-color;
|
|
45
|
+
font-family: Montserrat, sans-serif;
|
|
46
|
+
font-size: 1rem;
|
|
47
|
+
font-weight: 600;
|
|
48
|
+
max-height: 2.625rem;
|
|
49
|
+
overflow: hidden;
|
|
50
|
+
text-overflow: ellipsis;
|
|
51
|
+
line-height: 1.2;
|
|
52
|
+
display: -webkit-box;
|
|
53
|
+
-webkit-line-clamp: 2;
|
|
54
|
+
-webkit-box-orient: vertical;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.sub-title {
|
|
58
|
+
font-size: 1rem;
|
|
59
|
+
color: $light-grey;
|
|
60
|
+
font-family: Montserrat, sans-serif;
|
|
61
|
+
font-weight: 600;
|
|
62
|
+
text-align: right;
|
|
63
|
+
margin: 0.2rem 0;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.read {
|
|
67
|
+
font-weight: 400;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.alert-dialog-main {
|
|
73
|
+
.MuiPaper-root {
|
|
74
|
+
width: 35rem;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.no-record {
|
|
78
|
+
font-family: Montserrat, sans-serif;
|
|
79
|
+
font-size: 1.2rem;
|
|
80
|
+
font-weight: 600;
|
|
81
|
+
text-transform: initial;
|
|
82
|
+
color: $secondary-color;
|
|
83
|
+
text-align: center;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.alert-dialog {
|
|
88
|
+
.MuiPaper-root {
|
|
89
|
+
width: 70rem;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.no-record {
|
|
93
|
+
font-family: Montserrat, sans-serif;
|
|
94
|
+
font-size: 1.2rem;
|
|
95
|
+
font-weight: 600;
|
|
96
|
+
text-transform: initial;
|
|
97
|
+
color: $secondary-color;
|
|
98
|
+
text-align: center;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.sticky-input-select {
|
|
102
|
+
display: flex;
|
|
103
|
+
flex-direction: row;
|
|
104
|
+
align-items: center;
|
|
105
|
+
justify-content: space-between;
|
|
106
|
+
gap: 1;
|
|
107
|
+
position: sticky;
|
|
108
|
+
background: #fff;
|
|
109
|
+
z-index: 1;
|
|
110
|
+
width: 100%;
|
|
111
|
+
top: 0;
|
|
112
|
+
height: 5rem;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.action-show-all-dialog {
|
|
117
|
+
.view-all {
|
|
118
|
+
font-family: Montserrat, sans-serif;
|
|
119
|
+
font-weight: 500;
|
|
120
|
+
text-transform: initial;
|
|
121
|
+
font-size: 1.2rem;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.table {
|
|
126
|
+
width: 100%;
|
|
127
|
+
border-collapse: collapse;
|
|
128
|
+
|
|
129
|
+
tr {
|
|
130
|
+
th {
|
|
131
|
+
span {
|
|
132
|
+
display: flex;
|
|
133
|
+
align-items: center;
|
|
134
|
+
justify-content: space-between;
|
|
135
|
+
gap: 0.5rem;
|
|
136
|
+
cursor: pointer;
|
|
137
|
+
}
|
|
20
138
|
}
|
|
21
139
|
}
|
|
140
|
+
|
|
141
|
+
th,
|
|
142
|
+
td {
|
|
143
|
+
border: 0.125rem solid $secondary-color;
|
|
144
|
+
font-family: Montserrat, sans-serif;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
th {
|
|
148
|
+
word-break: break-word;
|
|
149
|
+
font-weight: 600;
|
|
150
|
+
font-size: 1.3rem;
|
|
151
|
+
line-height: 1.5rem;
|
|
152
|
+
color: $secondary-color;
|
|
153
|
+
background: $table-header;
|
|
154
|
+
padding: 0.6rem 1.3125rem;
|
|
155
|
+
text-align: left;
|
|
156
|
+
vertical-align: middle;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
td {
|
|
160
|
+
word-break: break-word;
|
|
161
|
+
color: $table-td-color;
|
|
162
|
+
font-size: 1.1rem;
|
|
163
|
+
line-height: 1.25rem;
|
|
164
|
+
padding: 0.6rem 1.3125rem;
|
|
165
|
+
}
|
|
22
166
|
}
|