UNPKG

@selfcommunity/react-ui

Version:

React UI Components to integrate a Community created with SelfCommunity Platform.

53 lines (52 loc) 5.52 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const jsx_runtime_1 = require("react/jsx-runtime"); const styles_1 = require("@mui/material/styles"); const material_1 = require("@mui/material"); const react_core_1 = require("@selfcommunity/react-core"); const react_intl_1 = require("react-intl"); const DateTimeAgo_1 = tslib_1.__importDefault(require("../../../shared/DateTimeAgo")); const NewChip_1 = tslib_1.__importDefault(require("../../../shared/NewChip/NewChip")); const classnames_1 = tslib_1.__importDefault(require("classnames")); const types_1 = require("../../../types"); const NotificationItem_1 = tslib_1.__importDefault(require("../../../shared/NotificationItem")); const constants_1 = require("../constants"); const messages = (0, react_intl_1.defineMessages)({ incubatorApproved: { id: 'ui.notification.incubatorApproved.approved', defaultMessage: 'ui.notification.incubatorApproved.approved' } }); const classes = { root: `${constants_1.PREFIX}-incubator-approved-root`, categoryIcon: `${constants_1.PREFIX}-category-icon`, categoryApprovedText: `${constants_1.PREFIX}-category-approved-text`, activeAt: `${constants_1.PREFIX}-active-at`, viewIncubatorButton: `${constants_1.PREFIX}-view-incubator-button` }; const Root = (0, styles_1.styled)(NotificationItem_1.default, { name: constants_1.PREFIX, slot: 'IncubatorApprovedRoot' })(() => ({})); function IncubatorApprovedNotification(props) { // PROPS const { notificationObject = null, id = `n_${props.notificationObject['feed_serialization_id']}`, template = types_1.SCNotificationObjectTemplateType.DETAIL, className } = props, rest = tslib_1.__rest(props, ["notificationObject", "id", "template", "className"]); // ROUTING const scRoutingContext = (0, react_core_1.useSCRouting)(); // CONST const isSnippetTemplate = template === types_1.SCNotificationObjectTemplateType.SNIPPET; //INTL const intl = (0, react_intl_1.useIntl)(); /** * Renders root object */ return ((0, jsx_runtime_1.jsx)(Root, Object.assign({ id: id, className: (0, classnames_1.default)(classes.root, className, `${constants_1.PREFIX}-${template}`), template: template, isNew: notificationObject.is_new, disableTypography: true, image: (0, jsx_runtime_1.jsx)(material_1.Avatar, { alt: notificationObject.incubator.approved_category.name, src: notificationObject.incubator.approved_category.image_medium, variant: "square", classes: { root: classes.categoryIcon } }), primary: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: isSnippetTemplate ? ((0, jsx_runtime_1.jsx)(react_core_1.Link, Object.assign({ to: scRoutingContext.url(react_core_1.SCRoutes.CATEGORY_ROUTE_NAME, notificationObject.incubator.approved_category) }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ component: "div", className: classes.categoryApprovedText, color: "inherit" }, { children: intl.formatMessage(messages.incubatorApproved, { name: notificationObject.incubator.name, b: (...chunks) => (0, jsx_runtime_1.jsx)("strong", { children: chunks }) }) })) }))) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [template === types_1.SCNotificationObjectTemplateType.DETAIL && notificationObject.is_new && (0, jsx_runtime_1.jsx)(NewChip_1.default, {}), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ component: "div", className: classes.categoryApprovedText, color: "inherit" }, { children: intl.formatMessage(messages.incubatorApproved, { name: notificationObject.incubator.name, b: (...chunks) => (0, jsx_runtime_1.jsx)("strong", { children: chunks }) }) }))] })) }), secondary: (template === types_1.SCNotificationObjectTemplateType.DETAIL || template === types_1.SCNotificationObjectTemplateType.SNIPPET) && ((0, jsx_runtime_1.jsx)(DateTimeAgo_1.default, { date: notificationObject.active_at, className: classes.activeAt })), footer: template === types_1.SCNotificationObjectTemplateType.DETAIL ? ((0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ component: react_core_1.Link, to: scRoutingContext.url(react_core_1.SCRoutes.CATEGORY_ROUTE_NAME, notificationObject.incubator.approved_category), className: classes.viewIncubatorButton }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: 'ui.notification.incubatorApproved.viewIncubator', defaultMessage: 'ui.notification.incubatorApproved.viewIncubator' }) }))) : template === types_1.SCNotificationObjectTemplateType.TOAST ? ((0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ direction: "row", justifyContent: "space-between", alignItems: "center", spacing: 2 }, { children: [(0, jsx_runtime_1.jsx)(DateTimeAgo_1.default, { date: notificationObject.active_at }), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ color: "primary", component: 'div' }, { children: (0, jsx_runtime_1.jsx)(react_core_1.Link, Object.assign({ to: scRoutingContext.url(react_core_1.SCRoutes.CATEGORY_ROUTE_NAME, notificationObject.incubator) }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.userToastNotifications.incubatorApproved.viewIncubator", defaultMessage: 'ui.userToastNotifications.incubatorApproved.viewIncubator' }) })) }))] }))) : null }, rest))); } exports.default = IncubatorApprovedNotification;