UNPKG

infinity-forge

Version:
82 lines 5.03 kB
"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || (function () { var ownKeys = function(o) { ownKeys = Object.getOwnPropertyNames || function (o) { var ar = []; for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; return ar; }; return ownKeys(o); }; return function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); __setModuleDefault(result, mod); return result; }; })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.Notifications = Notifications; var jsx_runtime_1 = require("react/jsx-runtime"); var react_1 = require("react"); var ui_1 = require("../../../../ui/index.js"); var system_1 = require("../../../../system/index.js"); var read_notifications_1 = require("./read-notifications/index.js"); var content_notification_1 = require("./content-notification/index.js"); var S = __importStar(require("./styles.js")); function Notifications() { var _a, _b; var Configurations = (0, system_1.useInfraInjection)().Configurations; var notifications = (0, system_1.useLoadAllNotifications)(); var detailsRef = (0, react_1.useRef)(null); (0, react_1.useEffect)(function () { function handleClickOutside(event) { if (detailsRef.current && !detailsRef.current.contains(event.target)) { detailsRef.current.open = false; } } document.addEventListener('mousedown', handleClickOutside); return function () { document.removeEventListener('mousedown', handleClickOutside); }; }, [detailsRef]); if (!Configurations.notification || !((_a = Configurations.notification) === null || _a === void 0 ? void 0 : _a.enable)) { return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {}); } return ((0, jsx_runtime_1.jsx)(ui_1.Error, { name: 'Notifications', children: (0, jsx_runtime_1.jsx)(S.Notifications, { children: (0, jsx_runtime_1.jsxs)("details", { ref: detailsRef, children: [(0, jsx_runtime_1.jsx)("summary", { children: (0, jsx_runtime_1.jsx)(read_notifications_1.ReadNotifications, { notifications: notifications.data, icon: (_b = Configurations === null || Configurations === void 0 ? void 0 : Configurations.notification) === null || _b === void 0 ? void 0 : _b.icon }) }), (0, jsx_runtime_1.jsx)(S.Content, { children: (0, jsx_runtime_1.jsx)(system_1.Tab, { tabs: [ { key: 'not_read', title: 'Não lido', content: function () { var _a, _b; return ((0, jsx_runtime_1.jsx)(content_notification_1.ContentNotification, { notifications: (_a = notifications === null || notifications === void 0 ? void 0 : notifications.data) === null || _a === void 0 ? void 0 : _a.filter(function (item) { return !item.isRead; }), CustomComponent: (_b = Configurations === null || Configurations === void 0 ? void 0 : Configurations.notification) === null || _b === void 0 ? void 0 : _b.CustomComponent })); }, }, { key: 'read', title: 'Lidos', content: function () { var _a, _b; return ((0, jsx_runtime_1.jsx)(content_notification_1.ContentNotification, { notifications: (_a = notifications === null || notifications === void 0 ? void 0 : notifications.data) === null || _a === void 0 ? void 0 : _a.filter(function (item) { return item.isRead; }), CustomComponent: (_b = Configurations === null || Configurations === void 0 ? void 0 : Configurations.notification) === null || _b === void 0 ? void 0 : _b.CustomComponent })); }, }, ] }) })] }) }) })); } //# sourceMappingURL=index.js.map