@selfcommunity/react-templates 0.5.0-alpha.41 → 0.5.0-alpha.43
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/CategoryFeed/CategoryFeed.js +14 -7
- package/lib/cjs/components/ExploreFeed/ExploreFeed.js +14 -2
- package/lib/cjs/components/MainFeed/MainFeed.js +13 -1
- package/lib/esm/components/CategoryFeed/CategoryFeed.js +17 -10
- package/lib/esm/components/ExploreFeed/ExploreFeed.js +16 -4
- package/lib/esm/components/MainFeed/MainFeed.js +15 -3
- package/lib/umd/react-templates.js +1 -1
- package/package.json +5 -5
|
@@ -74,17 +74,24 @@ function CategoryFeed(inProps) {
|
|
|
74
74
|
// CONTEXT
|
|
75
75
|
const scRoutingContext = (0, react_core_1.useSCRouting)();
|
|
76
76
|
const scUserContext = (0, react_core_1.useSCUser)();
|
|
77
|
-
const { preferences, features } = (0, react_core_1.useSCPreferences)();
|
|
78
77
|
const { enqueueSnackbar } = (0, notistack_1.useSnackbar)();
|
|
79
78
|
// REF
|
|
80
79
|
const feedRef = (0, react_1.useRef)();
|
|
81
80
|
// Hooks
|
|
82
81
|
const { scCategory } = (0, react_core_1.useSCFetchCategory)({ id: categoryId, category });
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
82
|
+
const isAdvertisingCustomAdvEnabled = (0, react_core_1.useSCPreferenceEnabled)(react_core_1.SCPreferences.ADVERTISING_CUSTOM_ADV_ENABLED);
|
|
83
|
+
const isAdvertisingCustomAdvOnlyForAnonUsersEnabled = (0, react_core_1.useSCPreferenceEnabled)(react_core_1.SCPreferences.ADVERTISING_CUSTOM_ADV_ONLY_FOR_ANONYMOUS_USERS_ENABLED);
|
|
84
|
+
const isPaymentsEnabled = (0, react_core_1.useSCPreferencesAndFeaturesEnabled)([react_core_1.SCPreferences.CONFIGURATIONS_PAYMENTS_ENABLED], [types_1.SCFeatureName.PAYMENTS]);
|
|
85
|
+
/**
|
|
86
|
+
* Render advertising above the feed
|
|
87
|
+
*/
|
|
88
|
+
function renderAdvertising() {
|
|
89
|
+
if (isAdvertisingCustomAdvEnabled &&
|
|
90
|
+
((isAdvertisingCustomAdvOnlyForAnonUsersEnabled && scUserContext.user === null) || !isAdvertisingCustomAdvOnlyForAnonUsersEnabled)) {
|
|
91
|
+
return (0, jsx_runtime_1.jsx)(react_ui_1.CustomAdv, { position: types_1.SCCustomAdvPosition.POSITION_ABOVE_FEED, categoriesId: [scCategory.id] });
|
|
92
|
+
}
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
88
95
|
// HANDLERS
|
|
89
96
|
const handleComposerSuccess = (feedObject) => {
|
|
90
97
|
// Not insert if the category does not match
|
|
@@ -126,7 +133,7 @@ function CategoryFeed(inProps) {
|
|
|
126
133
|
markRead: scUser ? !item.seen : null
|
|
127
134
|
}), itemIdGenerator: (item) => item[item.type].id, ItemProps: FeedObjectProps, ItemSkeleton: react_ui_1.FeedObjectSkeleton, ItemSkeletonProps: {
|
|
128
135
|
template: react_ui_1.SCFeedObjectTemplateType.PREVIEW
|
|
129
|
-
}, FeedSidebarProps: FeedSidebarProps, HeaderComponent: (0, jsx_runtime_1.
|
|
136
|
+
}, FeedSidebarProps: FeedSidebarProps, HeaderComponent: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [((scCategory.content_only_staff && react_core_1.UserUtils.isStaff(scUserContext.user)) || !scCategory.content_only_staff) && ((0, jsx_runtime_1.jsx)(react_ui_1.InlineComposerWidget, { onSuccess: handleComposerSuccess, defaultValue: { categories: [scCategory] }, feedType: types_1.SCFeedTypologyType.CATEGORY })), renderAdvertising()] }), CustomAdvProps: { categoriesId: [scCategory.id] }, enabledCustomAdvPositions: [
|
|
130
137
|
types_1.SCCustomAdvPosition.POSITION_FEED_SIDEBAR,
|
|
131
138
|
types_1.SCCustomAdvPosition.POSITION_FEED,
|
|
132
139
|
types_1.SCCustomAdvPosition.POSITION_BELOW_TOPBAR
|
|
@@ -84,10 +84,22 @@ function ExploreFeed(inProps) {
|
|
|
84
84
|
});
|
|
85
85
|
const { id = 'explore_feed', className, widgets = WIDGETS, FeedObjectProps = {}, FeedSidebarProps = null, FeedProps = {} } = props;
|
|
86
86
|
// CONTEXT
|
|
87
|
-
const { enqueueSnackbar } = (0, notistack_1.useSnackbar)();
|
|
88
87
|
const scUserContext = (0, react_1.useContext)(react_core_1.SCUserContext);
|
|
88
|
+
const isAdvertisingCustomAdvEnabled = (0, react_core_1.useSCPreferenceEnabled)(react_core_1.SCPreferences.ADVERTISING_CUSTOM_ADV_ENABLED);
|
|
89
|
+
const isAdvertisingCustomAdvOnlyForAnonUsersEnabled = (0, react_core_1.useSCPreferenceEnabled)(react_core_1.SCPreferences.ADVERTISING_CUSTOM_ADV_ONLY_FOR_ANONYMOUS_USERS_ENABLED);
|
|
90
|
+
const { enqueueSnackbar } = (0, notistack_1.useSnackbar)();
|
|
89
91
|
// REF
|
|
90
92
|
const feedRef = (0, react_1.useRef)();
|
|
93
|
+
/**
|
|
94
|
+
* Render advertising above the feed
|
|
95
|
+
*/
|
|
96
|
+
function renderAdvertising() {
|
|
97
|
+
if (isAdvertisingCustomAdvEnabled &&
|
|
98
|
+
((isAdvertisingCustomAdvOnlyForAnonUsersEnabled && scUserContext.user === null) || !isAdvertisingCustomAdvOnlyForAnonUsersEnabled)) {
|
|
99
|
+
return (0, jsx_runtime_1.jsx)(react_ui_1.CustomAdv, { position: types_1.SCCustomAdvPosition.POSITION_ABOVE_FEED });
|
|
100
|
+
}
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
91
103
|
// HANDLERS
|
|
92
104
|
const handleComposerSuccess = (feedObject) => {
|
|
93
105
|
const messageId = feedObject.scheduled_at ? 'ui.composer.scheduled.success' : 'ui.inlineComposerWidget.success';
|
|
@@ -131,7 +143,7 @@ function ExploreFeed(inProps) {
|
|
|
131
143
|
markRead: scUser ? !item.seen : null
|
|
132
144
|
}), itemIdGenerator: (item) => item[item.type].id, ItemProps: FeedObjectProps, ItemSkeleton: react_ui_1.FeedObjectSkeleton, ItemSkeletonProps: {
|
|
133
145
|
template: react_ui_1.SCFeedObjectTemplateType.PREVIEW
|
|
134
|
-
}, HeaderComponent: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(react_ui_1.InlineComposerWidget, { onSuccess: handleComposerSuccess }), react_core_1.UserUtils.isAdmin(scUserContext.user) && (0, jsx_runtime_1.jsx)(react_ui_1.OnBoardingWidget, { onGeneratedContent: handleAddGenerationContent })] }), FeedSidebarProps: FeedSidebarProps, enabledCustomAdvPositions: [
|
|
146
|
+
}, HeaderComponent: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(react_ui_1.InlineComposerWidget, { onSuccess: handleComposerSuccess }), react_core_1.UserUtils.isAdmin(scUserContext.user) && (0, jsx_runtime_1.jsx)(react_ui_1.OnBoardingWidget, { onGeneratedContent: handleAddGenerationContent }), renderAdvertising()] }), FeedSidebarProps: FeedSidebarProps, enabledCustomAdvPositions: [
|
|
135
147
|
types_1.SCCustomAdvPosition.POSITION_FEED_SIDEBAR,
|
|
136
148
|
types_1.SCCustomAdvPosition.POSITION_FEED,
|
|
137
149
|
types_1.SCCustomAdvPosition.POSITION_BELOW_TOPBAR
|
|
@@ -85,9 +85,21 @@ function MainFeed(inProps) {
|
|
|
85
85
|
const { id = 'main_feed', className, widgets = WIDGETS, FeedObjectProps = {}, FeedSidebarProps = null, FeedProps = {} } = props;
|
|
86
86
|
//CONTEXT
|
|
87
87
|
const scUserContext = (0, react_1.useContext)(react_core_1.SCUserContext);
|
|
88
|
+
const isAdvertisingCustomAdvEnabled = (0, react_core_1.useSCPreferenceEnabled)(react_core_1.SCPreferences.ADVERTISING_CUSTOM_ADV_ENABLED);
|
|
89
|
+
const isAdvertisingCustomAdvOnlyForAnonUsersEnabled = (0, react_core_1.useSCPreferenceEnabled)(react_core_1.SCPreferences.ADVERTISING_CUSTOM_ADV_ONLY_FOR_ANONYMOUS_USERS_ENABLED);
|
|
88
90
|
const { enqueueSnackbar } = (0, notistack_1.useSnackbar)();
|
|
89
91
|
// REF
|
|
90
92
|
const feedRef = (0, react_1.useRef)();
|
|
93
|
+
/**
|
|
94
|
+
* Render advertising above the feed
|
|
95
|
+
*/
|
|
96
|
+
function renderAdvertising() {
|
|
97
|
+
if (isAdvertisingCustomAdvEnabled &&
|
|
98
|
+
((isAdvertisingCustomAdvOnlyForAnonUsersEnabled && scUserContext.user === null) || !isAdvertisingCustomAdvOnlyForAnonUsersEnabled)) {
|
|
99
|
+
return (0, jsx_runtime_1.jsx)(react_ui_1.CustomAdv, { position: types_1.SCCustomAdvPosition.POSITION_ABOVE_FEED });
|
|
100
|
+
}
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
91
103
|
// Ckeck user is authenticated
|
|
92
104
|
if (!scUserContext.user) {
|
|
93
105
|
return null;
|
|
@@ -131,7 +143,7 @@ function MainFeed(inProps) {
|
|
|
131
143
|
markRead: scUser ? !item.seen : null
|
|
132
144
|
}), itemIdGenerator: (item) => item[item.type].id, ItemProps: FeedObjectProps, ItemSkeleton: react_ui_1.FeedObjectSkeleton, ItemSkeletonProps: {
|
|
133
145
|
template: react_ui_1.SCFeedObjectTemplateType.PREVIEW
|
|
134
|
-
}, FeedSidebarProps: FeedSidebarProps, HeaderComponent: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(react_ui_1.InlineComposerWidget, { onSuccess: handleComposerSuccess }), react_core_1.UserUtils.isAdmin(scUserContext.user) && (0, jsx_runtime_1.jsx)(react_ui_1.OnBoardingWidget, { onGeneratedContent: handleAddGenerationContent })] }), requireAuthentication: true, disablePaginationLinks: true, enabledCustomAdvPositions: [
|
|
146
|
+
}, FeedSidebarProps: FeedSidebarProps, HeaderComponent: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(react_ui_1.InlineComposerWidget, { onSuccess: handleComposerSuccess }), react_core_1.UserUtils.isAdmin(scUserContext.user) && (0, jsx_runtime_1.jsx)(react_ui_1.OnBoardingWidget, { onGeneratedContent: handleAddGenerationContent }), renderAdvertising()] }), requireAuthentication: true, disablePaginationLinks: true, enabledCustomAdvPositions: [
|
|
135
147
|
types_1.SCCustomAdvPosition.POSITION_FEED_SIDEBAR,
|
|
136
148
|
types_1.SCCustomAdvPosition.POSITION_FEED,
|
|
137
149
|
types_1.SCCustomAdvPosition.POSITION_BELOW_TOPBAR
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useMemo, useRef } from 'react';
|
|
3
3
|
import { styled } from '@mui/material';
|
|
4
|
-
import { CategoryTrendingFeedWidget, CategoryTrendingUsersWidget, ContributionUtils, Feed, FeedObject, FeedObjectSkeleton, HiddenPurchasableContent, InlineComposerWidget, SCFeedObjectTemplateType } from '@selfcommunity/react-ui';
|
|
4
|
+
import { CategoryTrendingFeedWidget, CategoryTrendingUsersWidget, ContributionUtils, Feed, FeedObject, FeedObjectSkeleton, HiddenPurchasableContent, InlineComposerWidget, SCFeedObjectTemplateType, CustomAdv } from '@selfcommunity/react-ui';
|
|
5
5
|
import { Endpoints } from '@selfcommunity/api-services';
|
|
6
|
-
import { Link, SCPreferences, SCRoutes, UserUtils, useSCFetchCategory,
|
|
6
|
+
import { Link, SCPreferences, SCRoutes, UserUtils, useSCFetchCategory, useSCPreferenceEnabled, useSCPreferencesAndFeaturesEnabled, useSCRouting, useSCUser } from '@selfcommunity/react-core';
|
|
7
7
|
import { SCCustomAdvPosition, SCFeatureName, SCFeedTypologyType } from '@selfcommunity/types';
|
|
8
8
|
import { CategoryFeedSkeleton } from './index';
|
|
9
9
|
import { useThemeProps } from '@mui/system';
|
|
@@ -71,17 +71,24 @@ export default function CategoryFeed(inProps) {
|
|
|
71
71
|
// CONTEXT
|
|
72
72
|
const scRoutingContext = useSCRouting();
|
|
73
73
|
const scUserContext = useSCUser();
|
|
74
|
-
const { preferences, features } = useSCPreferences();
|
|
75
74
|
const { enqueueSnackbar } = useSnackbar();
|
|
76
75
|
// REF
|
|
77
76
|
const feedRef = useRef();
|
|
78
77
|
// Hooks
|
|
79
78
|
const { scCategory } = useSCFetchCategory({ id: categoryId, category });
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
79
|
+
const isAdvertisingCustomAdvEnabled = useSCPreferenceEnabled(SCPreferences.ADVERTISING_CUSTOM_ADV_ENABLED);
|
|
80
|
+
const isAdvertisingCustomAdvOnlyForAnonUsersEnabled = useSCPreferenceEnabled(SCPreferences.ADVERTISING_CUSTOM_ADV_ONLY_FOR_ANONYMOUS_USERS_ENABLED);
|
|
81
|
+
const isPaymentsEnabled = useSCPreferencesAndFeaturesEnabled([SCPreferences.CONFIGURATIONS_PAYMENTS_ENABLED], [SCFeatureName.PAYMENTS]);
|
|
82
|
+
/**
|
|
83
|
+
* Render advertising above the feed
|
|
84
|
+
*/
|
|
85
|
+
function renderAdvertising() {
|
|
86
|
+
if (isAdvertisingCustomAdvEnabled &&
|
|
87
|
+
((isAdvertisingCustomAdvOnlyForAnonUsersEnabled && scUserContext.user === null) || !isAdvertisingCustomAdvOnlyForAnonUsersEnabled)) {
|
|
88
|
+
return _jsx(CustomAdv, { position: SCCustomAdvPosition.POSITION_ABOVE_FEED, categoriesId: [scCategory.id] });
|
|
89
|
+
}
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
85
92
|
// HANDLERS
|
|
86
93
|
const handleComposerSuccess = (feedObject) => {
|
|
87
94
|
// Not insert if the category does not match
|
|
@@ -123,7 +130,7 @@ export default function CategoryFeed(inProps) {
|
|
|
123
130
|
markRead: scUser ? !item.seen : null
|
|
124
131
|
}), itemIdGenerator: (item) => item[item.type].id, ItemProps: FeedObjectProps, ItemSkeleton: FeedObjectSkeleton, ItemSkeletonProps: {
|
|
125
132
|
template: SCFeedObjectTemplateType.PREVIEW
|
|
126
|
-
}, FeedSidebarProps: FeedSidebarProps, HeaderComponent:
|
|
133
|
+
}, FeedSidebarProps: FeedSidebarProps, HeaderComponent: _jsxs(_Fragment, { children: [((scCategory.content_only_staff && UserUtils.isStaff(scUserContext.user)) || !scCategory.content_only_staff) && (_jsx(InlineComposerWidget, { onSuccess: handleComposerSuccess, defaultValue: { categories: [scCategory] }, feedType: SCFeedTypologyType.CATEGORY })), renderAdvertising()] }), CustomAdvProps: { categoriesId: [scCategory.id] }, enabledCustomAdvPositions: [
|
|
127
134
|
SCCustomAdvPosition.POSITION_FEED_SIDEBAR,
|
|
128
135
|
SCCustomAdvPosition.POSITION_FEED,
|
|
129
136
|
SCCustomAdvPosition.POSITION_BELOW_TOPBAR
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useContext, useMemo, useRef } from 'react';
|
|
3
3
|
import { styled } from '@mui/material';
|
|
4
|
-
import { CategoriesPopularWidget, Feed, FeedObject, FeedObjectSkeleton, SCFeedObjectTemplateType, InlineComposerWidget, LoyaltyProgramWidget, UserSuggestionWidget, PlatformWidget, OnBoardingWidget } from '@selfcommunity/react-ui';
|
|
4
|
+
import { CategoriesPopularWidget, Feed, FeedObject, FeedObjectSkeleton, SCFeedObjectTemplateType, InlineComposerWidget, LoyaltyProgramWidget, UserSuggestionWidget, PlatformWidget, OnBoardingWidget, CustomAdv } from '@selfcommunity/react-ui';
|
|
5
5
|
import { Endpoints } from '@selfcommunity/api-services';
|
|
6
6
|
import { useThemeProps } from '@mui/system';
|
|
7
7
|
import classNames from 'classnames';
|
|
@@ -9,7 +9,7 @@ import { SCCustomAdvPosition } from '@selfcommunity/types';
|
|
|
9
9
|
import { FormattedMessage } from 'react-intl';
|
|
10
10
|
import { useSnackbar } from 'notistack';
|
|
11
11
|
import { PREFIX } from './constants';
|
|
12
|
-
import { SCUserContext, UserUtils } from '@selfcommunity/react-core';
|
|
12
|
+
import { SCPreferences, SCUserContext, UserUtils, useSCPreferenceEnabled } from '@selfcommunity/react-core';
|
|
13
13
|
const classes = {
|
|
14
14
|
root: `${PREFIX}-root`
|
|
15
15
|
};
|
|
@@ -81,10 +81,22 @@ export default function ExploreFeed(inProps) {
|
|
|
81
81
|
});
|
|
82
82
|
const { id = 'explore_feed', className, widgets = WIDGETS, FeedObjectProps = {}, FeedSidebarProps = null, FeedProps = {} } = props;
|
|
83
83
|
// CONTEXT
|
|
84
|
-
const { enqueueSnackbar } = useSnackbar();
|
|
85
84
|
const scUserContext = useContext(SCUserContext);
|
|
85
|
+
const isAdvertisingCustomAdvEnabled = useSCPreferenceEnabled(SCPreferences.ADVERTISING_CUSTOM_ADV_ENABLED);
|
|
86
|
+
const isAdvertisingCustomAdvOnlyForAnonUsersEnabled = useSCPreferenceEnabled(SCPreferences.ADVERTISING_CUSTOM_ADV_ONLY_FOR_ANONYMOUS_USERS_ENABLED);
|
|
87
|
+
const { enqueueSnackbar } = useSnackbar();
|
|
86
88
|
// REF
|
|
87
89
|
const feedRef = useRef();
|
|
90
|
+
/**
|
|
91
|
+
* Render advertising above the feed
|
|
92
|
+
*/
|
|
93
|
+
function renderAdvertising() {
|
|
94
|
+
if (isAdvertisingCustomAdvEnabled &&
|
|
95
|
+
((isAdvertisingCustomAdvOnlyForAnonUsersEnabled && scUserContext.user === null) || !isAdvertisingCustomAdvOnlyForAnonUsersEnabled)) {
|
|
96
|
+
return _jsx(CustomAdv, { position: SCCustomAdvPosition.POSITION_ABOVE_FEED });
|
|
97
|
+
}
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
88
100
|
// HANDLERS
|
|
89
101
|
const handleComposerSuccess = (feedObject) => {
|
|
90
102
|
const messageId = feedObject.scheduled_at ? 'ui.composer.scheduled.success' : 'ui.inlineComposerWidget.success';
|
|
@@ -128,7 +140,7 @@ export default function ExploreFeed(inProps) {
|
|
|
128
140
|
markRead: scUser ? !item.seen : null
|
|
129
141
|
}), itemIdGenerator: (item) => item[item.type].id, ItemProps: FeedObjectProps, ItemSkeleton: FeedObjectSkeleton, ItemSkeletonProps: {
|
|
130
142
|
template: SCFeedObjectTemplateType.PREVIEW
|
|
131
|
-
}, HeaderComponent: _jsxs(_Fragment, { children: [_jsx(InlineComposerWidget, { onSuccess: handleComposerSuccess }), UserUtils.isAdmin(scUserContext.user) && _jsx(OnBoardingWidget, { onGeneratedContent: handleAddGenerationContent })] }), FeedSidebarProps: FeedSidebarProps, enabledCustomAdvPositions: [
|
|
143
|
+
}, HeaderComponent: _jsxs(_Fragment, { children: [_jsx(InlineComposerWidget, { onSuccess: handleComposerSuccess }), UserUtils.isAdmin(scUserContext.user) && _jsx(OnBoardingWidget, { onGeneratedContent: handleAddGenerationContent }), renderAdvertising()] }), FeedSidebarProps: FeedSidebarProps, enabledCustomAdvPositions: [
|
|
132
144
|
SCCustomAdvPosition.POSITION_FEED_SIDEBAR,
|
|
133
145
|
SCCustomAdvPosition.POSITION_FEED,
|
|
134
146
|
SCCustomAdvPosition.POSITION_BELOW_TOPBAR
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useContext, useRef } from 'react';
|
|
3
3
|
import { styled } from '@mui/material';
|
|
4
|
-
import { CategoriesSuggestionWidget, Feed, FeedObject, FeedObjectSkeleton, SCFeedObjectTemplateType, InlineComposerWidget, LoyaltyProgramWidget, UserSuggestionWidget, PlatformWidget, OnBoardingWidget } from '@selfcommunity/react-ui';
|
|
4
|
+
import { CategoriesSuggestionWidget, Feed, FeedObject, FeedObjectSkeleton, SCFeedObjectTemplateType, InlineComposerWidget, LoyaltyProgramWidget, UserSuggestionWidget, PlatformWidget, OnBoardingWidget, CustomAdv } from '@selfcommunity/react-ui';
|
|
5
5
|
import { Endpoints } from '@selfcommunity/api-services';
|
|
6
|
-
import { SCUserContext, UserUtils } from '@selfcommunity/react-core';
|
|
6
|
+
import { SCPreferences, SCUserContext, UserUtils, useSCPreferenceEnabled } from '@selfcommunity/react-core';
|
|
7
7
|
import { useThemeProps } from '@mui/system';
|
|
8
8
|
import classNames from 'classnames';
|
|
9
9
|
import { SCCustomAdvPosition } from '@selfcommunity/types';
|
|
@@ -82,9 +82,21 @@ export default function MainFeed(inProps) {
|
|
|
82
82
|
const { id = 'main_feed', className, widgets = WIDGETS, FeedObjectProps = {}, FeedSidebarProps = null, FeedProps = {} } = props;
|
|
83
83
|
//CONTEXT
|
|
84
84
|
const scUserContext = useContext(SCUserContext);
|
|
85
|
+
const isAdvertisingCustomAdvEnabled = useSCPreferenceEnabled(SCPreferences.ADVERTISING_CUSTOM_ADV_ENABLED);
|
|
86
|
+
const isAdvertisingCustomAdvOnlyForAnonUsersEnabled = useSCPreferenceEnabled(SCPreferences.ADVERTISING_CUSTOM_ADV_ONLY_FOR_ANONYMOUS_USERS_ENABLED);
|
|
85
87
|
const { enqueueSnackbar } = useSnackbar();
|
|
86
88
|
// REF
|
|
87
89
|
const feedRef = useRef();
|
|
90
|
+
/**
|
|
91
|
+
* Render advertising above the feed
|
|
92
|
+
*/
|
|
93
|
+
function renderAdvertising() {
|
|
94
|
+
if (isAdvertisingCustomAdvEnabled &&
|
|
95
|
+
((isAdvertisingCustomAdvOnlyForAnonUsersEnabled && scUserContext.user === null) || !isAdvertisingCustomAdvOnlyForAnonUsersEnabled)) {
|
|
96
|
+
return _jsx(CustomAdv, { position: SCCustomAdvPosition.POSITION_ABOVE_FEED });
|
|
97
|
+
}
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
88
100
|
// Ckeck user is authenticated
|
|
89
101
|
if (!scUserContext.user) {
|
|
90
102
|
return null;
|
|
@@ -128,7 +140,7 @@ export default function MainFeed(inProps) {
|
|
|
128
140
|
markRead: scUser ? !item.seen : null
|
|
129
141
|
}), itemIdGenerator: (item) => item[item.type].id, ItemProps: FeedObjectProps, ItemSkeleton: FeedObjectSkeleton, ItemSkeletonProps: {
|
|
130
142
|
template: SCFeedObjectTemplateType.PREVIEW
|
|
131
|
-
}, FeedSidebarProps: FeedSidebarProps, HeaderComponent: _jsxs(_Fragment, { children: [_jsx(InlineComposerWidget, { onSuccess: handleComposerSuccess }), UserUtils.isAdmin(scUserContext.user) && _jsx(OnBoardingWidget, { onGeneratedContent: handleAddGenerationContent })] }), requireAuthentication: true, disablePaginationLinks: true, enabledCustomAdvPositions: [
|
|
143
|
+
}, FeedSidebarProps: FeedSidebarProps, HeaderComponent: _jsxs(_Fragment, { children: [_jsx(InlineComposerWidget, { onSuccess: handleComposerSuccess }), UserUtils.isAdmin(scUserContext.user) && _jsx(OnBoardingWidget, { onGeneratedContent: handleAddGenerationContent }), renderAdvertising()] }), requireAuthentication: true, disablePaginationLinks: true, enabledCustomAdvPositions: [
|
|
132
144
|
SCCustomAdvPosition.POSITION_FEED_SIDEBAR,
|
|
133
145
|
SCCustomAdvPosition.POSITION_FEED,
|
|
134
146
|
SCCustomAdvPosition.POSITION_BELOW_TOPBAR
|