@selfcommunity/react-ui 0.8.0-alpha.9 → 0.8.0-embeds.17
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/lib/cjs/components/BottomNavigation/BottomNavigation.js +11 -2
- package/lib/cjs/components/Composer/Composer.js +10 -2
- package/lib/cjs/components/Composer/Layer/AudienceLayer/AudienceLayer.js +12 -3
- package/lib/cjs/components/CreateEventButton/CreateEventButton.js +5 -1
- package/lib/cjs/components/CreateEventWidget/CreateEventWidget.js +5 -1
- package/lib/cjs/components/Feed/Feed.js +9 -1
- package/lib/cjs/components/MyEventsWidget/MyEventsWidget.js +6 -2
- package/lib/cjs/components/NavigationToolbar/NavigationToolbar.js +12 -3
- package/lib/cjs/components/NavigationToolbarMobile/NavigationToolbarMobile.js +11 -2
- package/lib/cjs/components/Notification/Event/Event.js +4 -0
- package/lib/cjs/components/OnBoardingWidget/OnBoardingWidget.d.ts +5 -0
- package/lib/cjs/components/OnBoardingWidget/OnBoardingWidget.js +18 -6
- package/lib/cjs/components/UserSubscribedGroupsWidget/UserSubscribedGroupsWidget.js +7 -2
- package/lib/cjs/shared/ContributionActionsMenu/index.js +6 -6
- package/lib/cjs/shared/InfiniteScroll/index.js +1 -1
- package/lib/cjs/shared/Media/Link/DisplayComponent.js +2 -2
- package/lib/cjs/utils/formatRelativeTime.js +2 -2
- package/lib/esm/components/BottomNavigation/BottomNavigation.js +11 -2
- package/lib/esm/components/Composer/Composer.js +10 -2
- package/lib/esm/components/Composer/Layer/AudienceLayer/AudienceLayer.js +13 -4
- package/lib/esm/components/CreateEventButton/CreateEventButton.js +5 -1
- package/lib/esm/components/CreateEventWidget/CreateEventWidget.js +5 -1
- package/lib/esm/components/Feed/Feed.js +11 -3
- package/lib/esm/components/MyEventsWidget/MyEventsWidget.js +7 -3
- package/lib/esm/components/NavigationToolbar/NavigationToolbar.js +12 -3
- package/lib/esm/components/NavigationToolbarMobile/NavigationToolbarMobile.js +11 -2
- package/lib/esm/components/Notification/Event/Event.js +4 -0
- package/lib/esm/components/OnBoardingWidget/OnBoardingWidget.d.ts +5 -0
- package/lib/esm/components/OnBoardingWidget/OnBoardingWidget.js +18 -6
- package/lib/esm/components/UserSubscribedGroupsWidget/UserSubscribedGroupsWidget.js +8 -3
- package/lib/esm/shared/ContributionActionsMenu/index.js +6 -6
- package/lib/esm/shared/InfiniteScroll/index.js +1 -1
- package/lib/esm/shared/Media/Link/DisplayComponent.js +2 -2
- package/lib/esm/utils/formatRelativeTime.js +2 -2
- package/lib/umd/react-ui.js +1 -1
- package/package.json +7 -7
|
@@ -78,8 +78,17 @@ export default function NavigationToolbarMobile(inProps) {
|
|
|
78
78
|
// STATE
|
|
79
79
|
const [searchOpen, setSearchOpen] = useState(false);
|
|
80
80
|
// MEMO
|
|
81
|
-
const groupsEnabled = useMemo(() =>
|
|
82
|
-
|
|
81
|
+
const groupsEnabled = useMemo(() => preferences &&
|
|
82
|
+
features &&
|
|
83
|
+
features.includes(SCFeatureName.TAGGING) &&
|
|
84
|
+
features.includes(SCFeatureName.GROUPING) &&
|
|
85
|
+
SCPreferences.CONFIGURATIONS_GROUPS_ENABLED in preferences &&
|
|
86
|
+
preferences[SCPreferences.CONFIGURATIONS_GROUPS_ENABLED].value, [preferences, features]);
|
|
87
|
+
const eventsEnabled = useMemo(() => preferences &&
|
|
88
|
+
features &&
|
|
89
|
+
features.includes(SCFeatureName.TAGGING) &&
|
|
90
|
+
SCPreferences.CONFIGURATIONS_EVENTS_ENABLED in preferences &&
|
|
91
|
+
preferences[SCPreferences.CONFIGURATIONS_EVENTS_ENABLED].value, [preferences, features]);
|
|
83
92
|
const exploreStreamEnabled = preferences[SCPreferences.CONFIGURATIONS_EXPLORE_STREAM_ENABLED].value;
|
|
84
93
|
const postOnlyStaffEnabled = preferences[SCPreferences.CONFIGURATIONS_POST_ONLY_STAFF_ENABLED].value;
|
|
85
94
|
const contentAvailable = preferences[SCPreferences.CONFIGURATIONS_CONTENT_AVAILABILITY].value;
|
|
@@ -51,6 +51,8 @@ export default function EventNotification(props) {
|
|
|
51
51
|
}), { onClick: notificationObject.user.deleted ? () => setOpenAlert(true) : null }, { children: _jsx(UserAvatar, Object.assign({ hide: !notificationObject.user.community_badge, smaller: true }, { children: _jsx(Avatar, { alt: notificationObject.user.username, variant: "circular", src: notificationObject.user.avatar, classes: { root: classes.avatar } }) })) })), primary: _jsxs(Box, { children: [_jsx(Link, Object.assign({}, (!notificationObject.user.deleted && {
|
|
52
52
|
to: scRoutingContext.url(SCRoutes.USER_PROFILE_ROUTE_NAME, notificationObject.user)
|
|
53
53
|
}), { onClick: notificationObject.user.deleted ? () => setOpenAlert(true) : null, className: classes.username }, { children: notificationObject.user.username })), ' ', _jsx(FormattedMessage, { id: `ui.notification.event.${notificationObject.type}`, defaultMessage: `ui.notification.event.${notificationObject.type}`, values: {
|
|
54
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
55
|
+
// @ts-ignore
|
|
54
56
|
icon: (...chunks) => _jsx(Icon, { children: chunks }),
|
|
55
57
|
event: notificationObject.event.name,
|
|
56
58
|
link: (...chunks) => _jsx(Link, Object.assign({ to: scRoutingContext.url(SCRoutes.EVENT_ROUTE_NAME, notificationObject.event) }, { children: chunks }))
|
|
@@ -69,6 +71,8 @@ export default function EventNotification(props) {
|
|
|
69
71
|
}), { onClick: notificationObject.user.deleted ? () => setOpenAlert(true) : null }, { children: _jsx(UserAvatar, Object.assign({ hide: !notificationObject.user.community_badge, smaller: true }, { children: _jsx(Avatar, { className: classes.avatar, alt: notificationObject.user.username, variant: "circular", src: notificationObject.user.avatar }) })) })), primary: _jsxs(_Fragment, { children: [_jsx(Link, Object.assign({}, (!notificationObject.user.deleted && {
|
|
70
72
|
to: scRoutingContext.url(SCRoutes.USER_PROFILE_ROUTE_NAME, notificationObject.user)
|
|
71
73
|
}), { onClick: notificationObject.user.deleted ? () => setOpenAlert(true) : null, className: classes.username }, { children: notificationObject.user.username })), ' ', _jsx(FormattedMessage, { id: `ui.notification.${notificationObject.type}`, defaultMessage: `ui.notification.${notificationObject.type}`, values: {
|
|
74
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
75
|
+
// @ts-ignore
|
|
72
76
|
icon: (...chunks) => _jsx(Icon, { children: chunks }),
|
|
73
77
|
event: notificationObject.event.name,
|
|
74
78
|
link: (...chunks) => _jsx(Link, Object.assign({ to: scRoutingContext.url(SCRoutes.EVENT_ROUTE_NAME, notificationObject.event) }, { children: chunks }))
|
|
@@ -18,6 +18,11 @@ export interface OnBoardingWidgetProps extends VirtualScrollerItemProps {
|
|
|
18
18
|
* @default null
|
|
19
19
|
*/
|
|
20
20
|
onGeneratedContent?: (feedObjs: SCFeedObjectType[]) => void;
|
|
21
|
+
/**
|
|
22
|
+
* Force widget expanded
|
|
23
|
+
* @default false
|
|
24
|
+
*/
|
|
25
|
+
forceExpanded?: boolean;
|
|
21
26
|
}
|
|
22
27
|
declare const OnBoardingWidget: (inProps: OnBoardingWidgetProps) => JSX.Element;
|
|
23
28
|
export default OnBoardingWidget;
|
|
@@ -51,7 +51,7 @@ const OnBoardingWidget = (inProps) => {
|
|
|
51
51
|
props: inProps,
|
|
52
52
|
name: PREFIX
|
|
53
53
|
});
|
|
54
|
-
const { className, GenerateContentsParams = {}, onGeneratedContent = null, onHeightChange } = props, rest = __rest(props, ["className", "GenerateContentsParams", "onGeneratedContent", "onHeightChange"]);
|
|
54
|
+
const { className, GenerateContentsParams = {}, onGeneratedContent = null, onHeightChange, onStateChange, forceExpanded = false } = props, rest = __rest(props, ["className", "GenerateContentsParams", "onGeneratedContent", "onHeightChange", "onStateChange", "forceExpanded"]);
|
|
55
55
|
// STATE
|
|
56
56
|
const [loading, setLoading] = useState(true);
|
|
57
57
|
const [initialized, setInitialized] = useState(false);
|
|
@@ -63,7 +63,7 @@ const OnBoardingWidget = (inProps) => {
|
|
|
63
63
|
const allStepsDone = useMemo(() => {
|
|
64
64
|
return steps === null || steps === void 0 ? void 0 : steps.every((step) => step.status === SCOnBoardingStepStatusType.COMPLETED);
|
|
65
65
|
}, [steps]);
|
|
66
|
-
const [expanded, setExpanded] = useState(!allStepsDone);
|
|
66
|
+
const [expanded, setExpanded] = useState(!allStepsDone || forceExpanded);
|
|
67
67
|
const [_step, setStep] = useState(nextStep);
|
|
68
68
|
const currentContentsStep = steps === null || steps === void 0 ? void 0 : steps.find((s) => s.step === SCOnBoardingStepType.CONTENTS);
|
|
69
69
|
const prevContentsStep = usePreviousValue(currentContentsStep);
|
|
@@ -84,6 +84,15 @@ const OnBoardingWidget = (inProps) => {
|
|
|
84
84
|
const isMobile = useMediaQuery(theme.breakpoints.down('md'));
|
|
85
85
|
const { categories, isLoading } = useSCFetchCategories();
|
|
86
86
|
// HANDLERS
|
|
87
|
+
/**
|
|
88
|
+
* Notify changes to Feed if the Widget is contained
|
|
89
|
+
*/
|
|
90
|
+
const notifyLayoutChanges = useMemo(() => (state) => {
|
|
91
|
+
if (onStateChange && state) {
|
|
92
|
+
onStateChange(state);
|
|
93
|
+
}
|
|
94
|
+
onHeightChange && onHeightChange();
|
|
95
|
+
}, [onStateChange, onHeightChange]);
|
|
87
96
|
const completeStep = (s) => __awaiter(void 0, void 0, void 0, function* () {
|
|
88
97
|
if (s.status !== SCOnBoardingStepStatusType.COMPLETED) {
|
|
89
98
|
yield OnBoardingService.completeAStep(s.id)
|
|
@@ -129,8 +138,9 @@ const OnBoardingWidget = (inProps) => {
|
|
|
129
138
|
setStep(newStep);
|
|
130
139
|
};
|
|
131
140
|
const handleExpand = () => {
|
|
132
|
-
|
|
133
|
-
|
|
141
|
+
const _expanded = !expanded;
|
|
142
|
+
setExpanded(_expanded);
|
|
143
|
+
notifyLayoutChanges({ forceExpanded: _expanded });
|
|
134
144
|
};
|
|
135
145
|
const generateContent = (stepId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
136
146
|
if (!isLoading && !categories.length) {
|
|
@@ -176,11 +186,13 @@ const OnBoardingWidget = (inProps) => {
|
|
|
176
186
|
if (!initialized && nextStep) {
|
|
177
187
|
setStep(nextStep);
|
|
178
188
|
setInitialized(true);
|
|
189
|
+
notifyLayoutChanges({ forceExpanded: expanded });
|
|
179
190
|
}
|
|
180
191
|
}, [initialized, nextStep]);
|
|
181
192
|
useEffect(() => {
|
|
182
|
-
|
|
183
|
-
|
|
193
|
+
const _expanded = !allStepsDone;
|
|
194
|
+
setExpanded(_expanded);
|
|
195
|
+
notifyLayoutChanges({ forceExpanded: _expanded });
|
|
184
196
|
}, [allStepsDone]);
|
|
185
197
|
useEffect(() => {
|
|
186
198
|
if (isAdmin) {
|
|
@@ -6,7 +6,7 @@ import List from '@mui/material/List';
|
|
|
6
6
|
import { Button, CardContent, ListItem, Typography } from '@mui/material';
|
|
7
7
|
import { GroupService } from '@selfcommunity/api-services';
|
|
8
8
|
import { CacheStrategies, isInteger, Logger } from '@selfcommunity/utils';
|
|
9
|
-
import { SCCache, useSCPreferences, useSCUser } from '@selfcommunity/react-core';
|
|
9
|
+
import { SCCache, SCPreferences, useSCPreferences, useSCUser } from '@selfcommunity/react-core';
|
|
10
10
|
import { actionWidgetTypes, dataWidgetReducer, stateWidgetInitializer } from '../../utils/widget';
|
|
11
11
|
import { SCFeatureName, SCGroupPrivacyType, SCGroupSubscriptionStatusType } from '@selfcommunity/types';
|
|
12
12
|
import { SCOPE_SC_UI } from '../../constants/Errors';
|
|
@@ -71,8 +71,13 @@ export default function UserSubscribedGroupsWidget(inProps) {
|
|
|
71
71
|
// CONTEXT
|
|
72
72
|
const scUserContext = useSCUser();
|
|
73
73
|
const isMe = useMemo(() => scUserContext.user && userId === scUserContext.user.id, [scUserContext.user, userId]);
|
|
74
|
-
const { features } = useSCPreferences();
|
|
75
|
-
const groupsEnabled = useMemo(() =>
|
|
74
|
+
const { preferences, features } = useSCPreferences();
|
|
75
|
+
const groupsEnabled = useMemo(() => preferences &&
|
|
76
|
+
features &&
|
|
77
|
+
features.includes(SCFeatureName.TAGGING) &&
|
|
78
|
+
features.includes(SCFeatureName.GROUPING) &&
|
|
79
|
+
SCPreferences.CONFIGURATIONS_GROUPS_ENABLED in preferences &&
|
|
80
|
+
preferences[SCPreferences.CONFIGURATIONS_GROUPS_ENABLED].value, [preferences, features]);
|
|
76
81
|
// STATE
|
|
77
82
|
const [state, dispatch] = useReducer(dataWidgetReducer, {
|
|
78
83
|
isLoadingNext: false,
|
|
@@ -75,7 +75,6 @@ const messages = defineMessages({
|
|
|
75
75
|
}
|
|
76
76
|
});
|
|
77
77
|
export default function ContributionActionsMenu(props) {
|
|
78
|
-
var _a, _b, _c;
|
|
79
78
|
// PROPS
|
|
80
79
|
const { className, feedObjectId, feedObject, feedObjectType = SCContributionType.POST, commentObjectId, commentObject, onFlagContribution, onEditContribution, onHideContribution, onDeleteContribution, onRestoreContribution, onSuspendNotificationContribution, onSuspendNotificationEvent, PopperProps = {} } = props, rest = __rest(props, ["className", "feedObjectId", "feedObject", "feedObjectType", "commentObjectId", "commentObject", "onFlagContribution", "onEditContribution", "onHideContribution", "onDeleteContribution", "onRestoreContribution", "onSuspendNotificationContribution", "onSuspendNotificationEvent", "PopperProps"]);
|
|
81
80
|
// INTL
|
|
@@ -622,9 +621,9 @@ export default function ContributionActionsMenu(props) {
|
|
|
622
621
|
return name;
|
|
623
622
|
}
|
|
624
623
|
/**
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
624
|
+
* action
|
|
625
|
+
* @param sectionId
|
|
626
|
+
*/
|
|
628
627
|
function handleOpenSection(sectionId) {
|
|
629
628
|
if (sectionId) {
|
|
630
629
|
if (sectionId === openSection) {
|
|
@@ -703,7 +702,8 @@ export default function ContributionActionsMenu(props) {
|
|
|
703
702
|
scUserContext.user.id !== contributionObj.author.id &&
|
|
704
703
|
contributionObj &&
|
|
705
704
|
contributionObj.type !== SCContributionType.COMMENT &&
|
|
706
|
-
Boolean(contributionObj.event)
|
|
705
|
+
Boolean(contributionObj.event) &&
|
|
706
|
+
Boolean(contributionObj.event.active));
|
|
707
707
|
}
|
|
708
708
|
/**
|
|
709
709
|
* Renders section general
|
|
@@ -726,7 +726,7 @@ export default function ContributionActionsMenu(props) {
|
|
|
726
726
|
, Object.assign({
|
|
727
727
|
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
728
728
|
// @ts-ignore
|
|
729
|
-
|
|
729
|
+
ref: (ref) => {
|
|
730
730
|
popperRef.current = ref;
|
|
731
731
|
}, "aria-haspopup": "true", onClick: handleOpen, className: classes.button, size: "small" }, { children: contributionObj && (contributionObj.collapsed || contributionObj.deleted) ? (_jsxs("span", Object.assign({ className: classes.visibilityIcons }, { children: [contributionObj.collapsed ? _jsx(Icon, { children: "visibility_off" }) : _jsx(Icon, { children: "delete" }), _jsx(Icon, { children: "expand_more" })] }))) : (_jsx(Icon, { children: "more_vert" })) })), isMobile ? (_jsx(SwipeableDrawer, Object.assign({ open: open, onClose: handleClose, onOpen: handleOpen, anchor: "bottom", disableSwipeToOpen: true }, { children: renderContent() }))) : (_jsx(PopperRoot, Object.assign({ open: open, anchorEl: popperRef.current, role: undefined, transition: true, className: classes.popperRoot }, PopperProps, { placement: "bottom-end" }, { children: ({ TransitionProps, placement }) => (_jsx(Grow, Object.assign({}, TransitionProps, { style: { transformOrigin: placement === 'bottom' ? 'center top' : 'center bottom' } }, { children: _jsx(Paper, Object.assign({ variant: 'outlined', className: classes.paper }, { children: _jsx(ClickAwayListener, Object.assign({ onClickAway: handleClose }, { children: renderContent() })) })) }))) }))), openConfirmDialog && (_jsx(ConfirmDialog, Object.assign({ open: openConfirmDialog }, (currentAction === DELETE_CONTRIBUTION
|
|
732
732
|
? {
|
|
@@ -223,7 +223,7 @@ class InfiniteScroll extends Component {
|
|
|
223
223
|
// because heighted infiniteScroll visualy breaks
|
|
224
224
|
// on drag down as overflow becomes visible
|
|
225
225
|
const outerDivStyle = this.props.pullDownToRefresh && this.props.height ? { overflow: 'auto' } : {};
|
|
226
|
-
return (_jsx("div", Object.assign({ style: outerDivStyle, className: "infinite-scroll-component__outerdiv" }, { children: _jsxs("div", Object.assign({ className: `infinite-scroll-component ${this.props.className || ''}`, ref: (infScroll) => (this._infScroll = infScroll), style: style }, { children: [this.props.header, this.props.pullDownToRefresh && (_jsx("div", Object.assign({ style: { position: 'relative' }, ref: (pullDown) => (this._pullDown = pullDown) }, { children: _jsx("div", Object.assign({ style: {
|
|
226
|
+
return (_jsx("div", Object.assign({ style: outerDivStyle, className: "infinite-scroll-component__outerdiv" }, { children: _jsxs("div", Object.assign({ className: `infinite-scroll-component ${this.props.className || ''}`, ref: (infScroll) => (this._infScroll = infScroll), style: style }, { children: [this.props.header, this.props.pullDownToRefresh && (_jsx("div", Object.assign({ style: { position: 'relative', marginBottom: 16 }, ref: (pullDown) => (this._pullDown = pullDown) }, { children: _jsx("div", Object.assign({ style: {
|
|
227
227
|
position: 'absolute',
|
|
228
228
|
left: 0,
|
|
229
229
|
right: 0,
|
|
@@ -51,7 +51,7 @@ export default (props) => {
|
|
|
51
51
|
return renderHtml(media, key);
|
|
52
52
|
}
|
|
53
53
|
const domain = new URL(media.embed.metadata.url).hostname.replace('www.', '');
|
|
54
|
-
return (_jsxs(Box, Object.assign({ className: classes.displayLink }, { children: [media.embed.metadata.images && media.embed.metadata.images.length > 0 && (_jsx(_Fragment, { children: fullWidth ? (_jsx(Box, { className: classNames(classes.thumbnailFullWidth, classes.image), style: { background: `url(${media.image})`, paddingBottom: `${100 / media.image_width / media.image_height}%` } })) : (_jsx(Box, { className: classNames(classes.thumbnail, classes.image), style: { background: `url(${media.image})` } })) })), _jsxs(Box, Object.assign({ className: classes.snippet }, { children: [_jsx("b", Object.assign({ className: classes.snippetTitle }, { children: media.embed.metadata.title })), _jsx("br", {}), _jsx("p", Object.assign({ className: classes.snippetDescription }, { children: media.embed.metadata.description })), _jsx("a", Object.assign({ href: media.embed.metadata.url, target: '_blank', onClick: () => handleLinkClick(media) }, { children: domain }))] })), _jsx("div", { style: { clear: 'both' } })] })
|
|
54
|
+
return (_jsxs(Box, Object.assign({ className: classes.displayLink }, { children: [media.embed.metadata.images && media.embed.metadata.images.length > 0 && (_jsx(_Fragment, { children: fullWidth ? (_jsx(Box, { className: classNames(classes.thumbnailFullWidth, classes.image), style: { background: `url(${media.image})`, paddingBottom: `${100 / media.image_width / media.image_height}%` } })) : (_jsx(Box, { className: classNames(classes.thumbnail, classes.image), style: { background: `url(${media.image})` } })) })), _jsxs(Box, Object.assign({ className: classes.snippet }, { children: [_jsx("b", Object.assign({ className: classes.snippetTitle }, { children: media.embed.metadata.title })), _jsx("br", {}), _jsx("p", Object.assign({ className: classes.snippetDescription }, { children: media.embed.metadata.description })), _jsx("a", Object.assign({ href: media.embed.metadata.url, target: '_blank', onClick: () => handleLinkClick(media) }, { children: domain }))] })), _jsx("div", { style: { clear: 'both' } })] })));
|
|
55
55
|
};
|
|
56
56
|
/**
|
|
57
57
|
* Render html embed
|
|
@@ -59,7 +59,7 @@ export default (props) => {
|
|
|
59
59
|
* @param key
|
|
60
60
|
*/
|
|
61
61
|
const renderHtml = (media, key) => {
|
|
62
|
-
return (_jsxs(Box, Object.assign({ className: classes.displayHtmlWrap }, { children: [_jsx("div", { dangerouslySetInnerHTML: { __html: media.embed.metadata.html }, className: classes.displayHtml }), _jsx("div", Object.assign({ className: classes.displayHtmlPlaceholder, style: { paddingTop: `${(100 * media.embed.metadata.height) / media.embed.metadata.width}%`, maxHeight: media.embed.metadata.height } }, { children: _jsx(CircularProgress, { size: 20, className: classes.displayHtmlLoading }) }))] })
|
|
62
|
+
return (_jsxs(Box, Object.assign({ className: classes.displayHtmlWrap }, { children: [_jsx("div", { dangerouslySetInnerHTML: { __html: media.embed.metadata.html }, className: classes.displayHtml }), _jsx("div", Object.assign({ className: classes.displayHtmlPlaceholder, style: { paddingTop: `${(100 * media.embed.metadata.height) / media.embed.metadata.width}%`, maxHeight: media.embed.metadata.height } }, { children: _jsx(CircularProgress, { size: 20, className: classes.displayHtmlLoading }) }))] })));
|
|
63
63
|
};
|
|
64
64
|
/**
|
|
65
65
|
* Renders component
|
|
@@ -2,8 +2,8 @@ export const getRelativeTime = (date) => {
|
|
|
2
2
|
const diffInMilliseconds = new Date().getTime() - new Date(date).getTime();
|
|
3
3
|
const seconds = Math.floor(diffInMilliseconds / 1000);
|
|
4
4
|
const minutes = Math.floor(seconds / 60);
|
|
5
|
-
const hours = Math.
|
|
6
|
-
const days = Math.
|
|
5
|
+
const hours = Math.floor(minutes / 60);
|
|
6
|
+
const days = Math.round(hours / 24);
|
|
7
7
|
const weeks = Math.floor(days / 7);
|
|
8
8
|
const months = Math.floor(days / 30);
|
|
9
9
|
const years = Math.floor(months / 12);
|