@pnp/spfx-controls-react
Version:
Reusable React controls for SharePoint Framework solutions
30 lines • 1.74 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.CommentItem = void 0;
var tslib_1 = require("tslib");
var React = tslib_1.__importStar(require("react"));
var react_1 = require("react");
var format_1 = tslib_1.__importDefault(require("date-fns/format"));
var parseISO_1 = tslib_1.__importDefault(require("date-fns/parseISO"));
var ActivityItem_1 = require("@fluentui/react/lib/ActivityItem");
var Text_1 = require("@fluentui/react/lib/Text");
var Stack_1 = require("@fluentui/react/lib/Stack");
var CommentText_1 = require("./CommentText");
var lodash_1 = require("lodash");
var PHOTO_URL = "/_layouts/15/userphoto.aspx?size=M&accountname=";
var CommentItem = function (props) {
if ((0, lodash_1.isEmpty)(props.comment))
return null;
var _a = props.comment, author = _a.author, createdDate = _a.createdDate, text = _a.text, mentions = _a.mentions;
var activityDescription = (0, react_1.useMemo)(function () {
var _activity = [];
_activity.push(React.createElement(Text_1.Text, { variant: "smallPlus", styles: { root: { fontWeight: 700 } } }, author.name));
_activity.push(React.createElement(CommentText_1.CommentText, { text: text, mentions: mentions }));
return _activity;
}, [mentions, text]);
return (React.createElement(React.Fragment, null,
React.createElement(Stack_1.Stack, null,
React.createElement(ActivityItem_1.ActivityItem, { activityPersonas: [{ imageUrl: "".concat(PHOTO_URL).concat(author.email) }], activityDescription: activityDescription, timeStamp: (0, format_1.default)((0, parseISO_1.default)(createdDate), "PPpp") }))));
};
exports.CommentItem = CommentItem;
//# sourceMappingURL=CommentItem.js.map