@selfcommunity/react-core 0.6.0-alpha.0 → 0.6.0-alpha.10
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/constants/Preferences.d.ts +2 -0
- package/lib/cjs/constants/Preferences.js +6 -2
- package/lib/cjs/hooks/useSCFetchEvent.d.ts +1 -1
- package/lib/cjs/hooks/useSCFetchEvent.js +36 -28
- package/lib/cjs/hooks/useSCSubscribedEventsManager.d.ts +1 -1
- package/lib/cjs/hooks/useSCSubscribedEventsManager.js +36 -47
- package/lib/cjs/utils/validator.js +1 -2
- package/lib/esm/constants/Preferences.d.ts +2 -0
- package/lib/esm/constants/Preferences.js +4 -0
- package/lib/esm/hooks/useSCFetchEvent.d.ts +1 -1
- package/lib/esm/hooks/useSCFetchEvent.js +36 -28
- package/lib/esm/hooks/useSCSubscribedEventsManager.d.ts +1 -1
- package/lib/esm/hooks/useSCSubscribedEventsManager.js +36 -47
- package/lib/esm/utils/validator.js +1 -2
- package/lib/umd/react-core.js +1 -1
- package/package.json +5 -5
|
@@ -134,6 +134,8 @@ export declare const CONFIGURATIONS_EVENTS_ENABLED: string;
|
|
|
134
134
|
export declare const CONFIGURATIONS_EVENTS_ONLY_STAFF_ENABLED: string;
|
|
135
135
|
export declare const CONFIGURATIONS_EVENTS_VISIBILITY_ENABLED: string;
|
|
136
136
|
export declare const CONFIGURATIONS_EVENTS_PRIVATE_ENABLED: string;
|
|
137
|
+
export declare const CONFIGURATIONS_ONBOARDING_ENABLED: string;
|
|
138
|
+
export declare const CONFIGURATIONS_ONBOARDING_HIDDEN: string;
|
|
137
139
|
/**
|
|
138
140
|
* PROVIDERS
|
|
139
141
|
*/
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ADDONS_SHARE_POST_ON_FACEBOOK_ENABLED = exports.ADDONS_POST_GEOLOCATION_ENABLED = exports.ADDONS_REGISTRATION_WIZARD = exports.ADDONS_POLLS_ENABLED = exports.ADDONS_LOYALTY_POINTS_COLLECTION = exports.ADDONS_INCUBATOR_SUBSCRIBERS = exports.ADDONS_INCUBATOR_ENABLED = exports.ADDONS_CLOSED_COMMUNITY = exports.ADDONS_AFFINITY_ENABLED = exports.POINTS_DAILY_VISIT = exports.POINTS_APP_USED = exports.POINTS_SOCIAL_SHARE = exports.POINTS_CONNECTION_OR_FOLLOWER = exports.POINTS_RECEIVE_VOTE = exports.POINTS_MAKE_COMMENT = exports.POINTS_MAKE_POST = exports.POINTS_MAKE_DISCUSSION = exports.LOYALTY_PRIZE_C_IMAGE = exports.LOYALTY_PRIZE_B_IMAGE = exports.LOYALTY_PRIZE_A_IMAGE = exports.STAFF_STAFF_BADGE_LABEL = exports.STAFF_STAFF_BADGE_ICON = exports.IMAGES_ERRORPAGES_IMAGE = exports.IMAGES_ERROR_503 = exports.IMAGES_ERROR_404 = exports.IMAGES_USER_DEFAULT_COVER = exports.IMAGES_APP_ICON = exports.COVERS_VISIBILITY = exports.COVERS_COVER_4_HP_M1920 = exports.COVERS_COVER_3_HP_M1920 = exports.COVERS_COVER_2_HP_M1920 = exports.COVERS_COVER_1_HP_M1920 = exports.COLORS_COLORFONTSECONDARY = exports.COLORS_COLORFONT = exports.COLORS_NAVBARBACK = exports.COLORS_COLORSECONDARY = exports.COLORS_COLORPRIMARY = exports.COLORS_COLORBACK = exports.LOGO_NAVBAR_LOGO_MOBILE = exports.LOGO_NAVBAR_LOGO = exports.STYLE_FONT_FAMILY = exports.TEXT_ERROR_PAGES_SUBTITLE = exports.TEXT_ERROR_PAGES_TITLE = exports.TEXT_APPLICATION_COPYRIGHT = exports.TEXT_APPLICATION_SLOGAN2 = exports.TEXT_APPLICATION_SLOGAN1 = exports.TEXT_APPLICATION_NAME = exports.DEFAULT_GLOBAL_PREFERENCES_OPTION = exports.GLOBAL_PREFERENCES_OPTION = exports.PREFERENCES_OPTION = void 0;
|
|
4
|
-
exports.
|
|
5
|
-
exports.DATA_TYPES = exports.getPreference = exports.getPreferenceName = exports.getPreferenceSection = exports.WEBMASTER_META_DESCRIPTION = exports.WEBMASTER_META_TITLE_HOME_NOT_LOGGED = exports.WEBMASTER_META_ROBOTS = exports.PROVIDERS_WEB_PUSH_ENABLED = exports.PROVIDERS_WEB_PUSH_PUBLIC_KEY = exports.PROVIDERS_GOOGLE_APP_SECRET = exports.PROVIDERS_GOOGLE_APP_KEY = exports.PROVIDERS_GOOGLE_SIGNIN_ENABLED = exports.PROVIDERS_GOOGLE_GEOCODING_API_KEY = exports.PROVIDERS_TWITTER_APP_SECRET = exports.PROVIDERS_TWITTER_APP_KEY = exports.PROVIDERS_TWITTER_SIGNIN_ENABLED = exports.PROVIDERS_LINKEDIN_APP_SECRET = exports.PROVIDERS_LINKEDIN_APP_KEY = exports.PROVIDERS_LINKEDIN_SIGNIN_ENABLED = exports.PROVIDERS_FACEBOOK_APP_SECRET = exports.PROVIDERS_FACEBOOK_APP_KEY = exports.PROVIDERS_FACEBOOK_SIGNIN_ENABLED = exports.PROVIDERS_APP_URL_ON_GOOGLE_PLAY = void 0;
|
|
4
|
+
exports.CONFIGURATIONS_ONBOARDING_ENABLED = exports.CONFIGURATIONS_EVENTS_PRIVATE_ENABLED = exports.CONFIGURATIONS_EVENTS_VISIBILITY_ENABLED = exports.CONFIGURATIONS_EVENTS_ONLY_STAFF_ENABLED = exports.CONFIGURATIONS_EVENTS_ENABLED = exports.CONFIGURATIONS_GROUPS_PRIVATE_ENABLED = exports.CONFIGURATIONS_GROUPS_VISIBILITY_ENABLED = exports.CONFIGURATIONS_GROUPS_ONLY_STAFF_ENABLED = exports.CONFIGURATIONS_GROUPS_ENABLED = exports.CONFIGURATIONS_CUSTOM_NAVBAR_ITEM_IMAGE = exports.CONFIGURATIONS_CUSTOM_NAVBAR_ITEM_URL = exports.CONFIGURATIONS_CUSTOM_NAVBAR_ITEM_TEXT = exports.CONFIGURATIONS_CUSTOM_NAVBAR_ITEM_ENABLED = exports.CONFIGURATIONS_GDPR_SIGNUP_ACCEPT_HTML = exports.CONFIGURATIONS_GDPR_COOKIE_CONSENT_EXTERNAL_HTML = exports.CONFIGURATIONS_TAG_MANAGER_CONTAINER_ID = exports.CONFIGURATIONS_USER_METADATA_DEFINITIONS = exports.CONFIGURATIONS_APP_URL = exports.CONFIGURATIONS_URL_TEMPLATE_INCUBATOR = exports.CONFIGURATIONS_URL_TEMPLATE_USER_PRIVATE_MESSAGES = exports.CONFIGURATIONS_URL_TEMPLATE_NOTIFICATIONS = exports.CONFIGURATIONS_URL_TEMPLATE_USER_PROFILE_SETTINGS = exports.CONFIGURATIONS_URL_TEMPLATE_USER_PROFILE = exports.CONFIGURATIONS_URL_TEMPLATE_CATEGORIES_LIST = exports.CONFIGURATIONS_URL_TEMPLATE_CATEGORY = exports.CONFIGURATIONS_URL_TEMPLATE_COMMENT = exports.CONFIGURATIONS_URL_TEMPLATE_STATUS = exports.CONFIGURATIONS_URL_TEMPLATE_DISCUSSION = exports.CONFIGURATIONS_URL_TEMPLATE_POST = exports.CONFIGURATIONS_URL_TEMPLATE_VERIFY_EMAIL = exports.CONFIGURATIONS_URL_TEMPLATE_PASSWORD_RECOVER = exports.CONFIGURATIONS_URL_TEMPLATE_EMAIL_UNSUBSCRIBE = exports.CONFIGURATIONS_URL_TEMPLATE_EMAIL_SETTINGS = exports.CONFIGURATIONS_STATUS_TYPE_ENABLED = exports.CONFIGURATIONS_DISCUSSION_TYPE_ENABLED = exports.CONFIGURATIONS_POST_TYPE_ENABLED = exports.CONFIGURATIONS_USERS_APPROVAL_ENABLED = exports.CONFIGURATIONS_CONTENT_AVAILABILITY = exports.CONFIGURATIONS_STREAM_QUALITY = exports.CONFIGURATIONS_POST_ONLY_STAFF_ENABLED = exports.CONFIGURATIONS_PEOPLE_SEARCH_ENABLED = exports.CONFIGURATIONS_MANUAL_CATEGORIES_ORDER_ENABLED = exports.CONFIGURATIONS_HOME_STREAM_ORDER_BY = exports.CONFIGURATIONS_EXPLORE_STREAM_ORDER_BY = exports.CONFIGURATIONS_EXPLORE_STREAM_ENABLED = exports.CONFIGURATIONS_FOLLOW_ENABLED = exports.ADVERTISING_CUSTOM_ADV_ONLY_FOR_ANONYMOUS_USERS_ENABLED = exports.ADVERTISING_CUSTOM_ADV_ENABLED = exports.ADDONS_SHARE_POST_ON_LINKEDIN_ENABLED = exports.ADDONS_SHARE_POST_ON_TWITTER_ENABLED = void 0;
|
|
5
|
+
exports.DATA_TYPES = exports.getPreference = exports.getPreferenceName = exports.getPreferenceSection = exports.WEBMASTER_META_DESCRIPTION = exports.WEBMASTER_META_TITLE_HOME_NOT_LOGGED = exports.WEBMASTER_META_ROBOTS = exports.PROVIDERS_WEB_PUSH_ENABLED = exports.PROVIDERS_WEB_PUSH_PUBLIC_KEY = exports.PROVIDERS_GOOGLE_APP_SECRET = exports.PROVIDERS_GOOGLE_APP_KEY = exports.PROVIDERS_GOOGLE_SIGNIN_ENABLED = exports.PROVIDERS_GOOGLE_GEOCODING_API_KEY = exports.PROVIDERS_TWITTER_APP_SECRET = exports.PROVIDERS_TWITTER_APP_KEY = exports.PROVIDERS_TWITTER_SIGNIN_ENABLED = exports.PROVIDERS_LINKEDIN_APP_SECRET = exports.PROVIDERS_LINKEDIN_APP_KEY = exports.PROVIDERS_LINKEDIN_SIGNIN_ENABLED = exports.PROVIDERS_FACEBOOK_APP_SECRET = exports.PROVIDERS_FACEBOOK_APP_KEY = exports.PROVIDERS_FACEBOOK_SIGNIN_ENABLED = exports.PROVIDERS_APP_URL_ON_GOOGLE_PLAY = exports.PROVIDERS_APP_URL_ON_APP_STORE = exports.CONFIGURATIONS_ONBOARDING_HIDDEN = void 0;
|
|
6
6
|
const types_1 = require("@selfcommunity/types");
|
|
7
7
|
/**
|
|
8
8
|
* DEFAULT CONF VALIDATION OPTION
|
|
@@ -140,6 +140,8 @@ exports.CONFIGURATIONS_EVENTS_ENABLED = `${types_1.SCPreferenceSection.CONFIGURA
|
|
|
140
140
|
exports.CONFIGURATIONS_EVENTS_ONLY_STAFF_ENABLED = `${types_1.SCPreferenceSection.CONFIGURATIONS}.${types_1.SCPreferenceName.EVENTS_ONLY_STAFF_ENABLED}`;
|
|
141
141
|
exports.CONFIGURATIONS_EVENTS_VISIBILITY_ENABLED = `${types_1.SCPreferenceSection.CONFIGURATIONS}.${types_1.SCPreferenceName.EVENTS_VISIBILITY_ENABLED}`;
|
|
142
142
|
exports.CONFIGURATIONS_EVENTS_PRIVATE_ENABLED = `${types_1.SCPreferenceSection.CONFIGURATIONS}.${types_1.SCPreferenceName.EVENTS_PRIVATE_ENABLED}`;
|
|
143
|
+
exports.CONFIGURATIONS_ONBOARDING_ENABLED = `${types_1.SCPreferenceSection.CONFIGURATIONS}.${types_1.SCPreferenceName.ONBOARDING_ENABLED}`;
|
|
144
|
+
exports.CONFIGURATIONS_ONBOARDING_HIDDEN = `${types_1.SCPreferenceSection.CONFIGURATIONS}.${types_1.SCPreferenceName.ONBOARDING_HIDDEN}`;
|
|
143
145
|
/**
|
|
144
146
|
* PROVIDERS
|
|
145
147
|
*/
|
|
@@ -287,6 +289,8 @@ exports.DATA_TYPES = {
|
|
|
287
289
|
[exports.CONFIGURATIONS_EVENTS_ONLY_STAFF_ENABLED]: booleanType,
|
|
288
290
|
[exports.CONFIGURATIONS_EVENTS_VISIBILITY_ENABLED]: booleanType,
|
|
289
291
|
[exports.CONFIGURATIONS_EVENTS_PRIVATE_ENABLED]: booleanType,
|
|
292
|
+
[exports.CONFIGURATIONS_ONBOARDING_ENABLED]: booleanType,
|
|
293
|
+
[exports.CONFIGURATIONS_ONBOARDING_HIDDEN]: booleanType,
|
|
290
294
|
[exports.PROVIDERS_APP_URL_ON_APP_STORE]: stringType,
|
|
291
295
|
[exports.PROVIDERS_APP_URL_ON_GOOGLE_PLAY]: stringType,
|
|
292
296
|
[exports.PROVIDERS_FACEBOOK_SIGNIN_ENABLED]: stringType,
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const react_1 = require("react");
|
|
4
|
-
const Errors_1 = require("../constants/Errors");
|
|
5
|
-
const types_1 = require("@selfcommunity/types");
|
|
6
3
|
const api_services_1 = require("@selfcommunity/api-services");
|
|
4
|
+
const types_1 = require("@selfcommunity/types");
|
|
7
5
|
const utils_1 = require("@selfcommunity/utils");
|
|
8
|
-
const
|
|
6
|
+
const react_1 = require("react");
|
|
9
7
|
const use_deep_compare_effect_1 = require("use-deep-compare-effect");
|
|
10
8
|
const SCUserProvider_1 = require("../components/provider/SCUserProvider");
|
|
9
|
+
const Cache_1 = require("../constants/Cache");
|
|
10
|
+
const Errors_1 = require("../constants/Errors");
|
|
11
11
|
/**
|
|
12
12
|
:::info
|
|
13
13
|
This custom hook is used to fetch an event object.
|
|
@@ -28,18 +28,37 @@ function useSCFetchEvent({ id = null, event = null, autoSubscribe = true, cacheS
|
|
|
28
28
|
const __event = authUserId ? event : (0, utils_1.objectWithoutProperties)(event, ['subscription_status']);
|
|
29
29
|
const [scEvent, setScEvent] = (0, react_1.useState)(cacheStrategy !== utils_1.CacheStrategies.NETWORK_ONLY ? utils_1.LRUCache.get(__eventCacheKey, __event) : null);
|
|
30
30
|
const [error, setError] = (0, react_1.useState)(null);
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
31
|
+
/**
|
|
32
|
+
* Memoized setSCEvent (auto-subscription if need it)
|
|
33
|
+
*/
|
|
34
|
+
const setSCEvent = (0, react_1.useMemo)(() => (e) => {
|
|
35
|
+
if (autoSubscribe &&
|
|
36
|
+
authUserId !== null &&
|
|
37
|
+
((e.privacy === types_1.SCEventPrivacyType.PUBLIC && !e.subscription_status) || e.subscription_status === types_1.SCEventSubscriptionStatusType.INVITED)) {
|
|
38
|
+
// Auto subscribe to the event
|
|
39
|
+
api_services_1.EventService.subscribeToEvent(e.id)
|
|
40
|
+
.then(() => {
|
|
41
|
+
const updatedEvent = Object.assign(Object.assign({}, e), { subscription_status: types_1.SCEventSubscriptionStatusType.SUBSCRIBED });
|
|
42
|
+
setScEvent(updatedEvent);
|
|
43
|
+
utils_1.LRUCache.set(__eventCacheKey, updatedEvent);
|
|
44
|
+
})
|
|
45
|
+
.catch(() => {
|
|
46
|
+
setScEvent(e);
|
|
47
|
+
utils_1.LRUCache.set(__eventCacheKey, e);
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
setScEvent(e);
|
|
52
|
+
utils_1.LRUCache.set(__eventCacheKey, e);
|
|
53
|
+
}
|
|
54
|
+
}, [autoSubscribe, authUserId, setScEvent]);
|
|
36
55
|
/**
|
|
37
56
|
* Memoized fetchTag
|
|
38
57
|
*/
|
|
39
|
-
const fetchEvent = (0, react_1.useMemo)(() => () => {
|
|
58
|
+
const fetchEvent = (0, react_1.useMemo)(() => (id) => {
|
|
40
59
|
return api_services_1.http
|
|
41
60
|
.request({
|
|
42
|
-
url: api_services_1.Endpoints.GetEventInfo.url({ id
|
|
61
|
+
url: api_services_1.Endpoints.GetEventInfo.url({ id }),
|
|
43
62
|
method: api_services_1.Endpoints.GetEventInfo.method,
|
|
44
63
|
})
|
|
45
64
|
.then((res) => {
|
|
@@ -48,26 +67,15 @@ function useSCFetchEvent({ id = null, event = null, autoSubscribe = true, cacheS
|
|
|
48
67
|
}
|
|
49
68
|
return Promise.resolve(res.data);
|
|
50
69
|
});
|
|
51
|
-
}, [
|
|
70
|
+
}, []);
|
|
52
71
|
/**
|
|
53
72
|
* If id attempt to get the event by id
|
|
54
73
|
*/
|
|
55
74
|
(0, react_1.useEffect)(() => {
|
|
56
|
-
if (
|
|
57
|
-
fetchEvent()
|
|
58
|
-
.then((
|
|
59
|
-
|
|
60
|
-
authUserId !== null &&
|
|
61
|
-
((event.privacy === types_1.SCEventPrivacyType.PUBLIC && !event.subscription_status) || event.subscription_status === types_1.SCEventSubscriptionStatusType.INVITED)) {
|
|
62
|
-
// Auto subscribe to the event
|
|
63
|
-
api_services_1.EventService.subscribeToEvent(event.id).then(() => {
|
|
64
|
-
const updatedEvent = Object.assign(Object.assign({}, event), { subscription_status: types_1.SCEventSubscriptionStatusType.SUBSCRIBED });
|
|
65
|
-
setSCEvent(updatedEvent);
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
else {
|
|
69
|
-
setSCEvent(event);
|
|
70
|
-
}
|
|
75
|
+
if (id !== null && id !== undefined && !event) {
|
|
76
|
+
fetchEvent(id)
|
|
77
|
+
.then((e) => {
|
|
78
|
+
setSCEvent(e);
|
|
71
79
|
})
|
|
72
80
|
.catch((err) => {
|
|
73
81
|
utils_1.LRUCache.delete(__eventCacheKey);
|
|
@@ -76,7 +84,7 @@ function useSCFetchEvent({ id = null, event = null, autoSubscribe = true, cacheS
|
|
|
76
84
|
utils_1.Logger.error(Errors_1.SCOPE_SC_CORE, err.message);
|
|
77
85
|
});
|
|
78
86
|
}
|
|
79
|
-
}, [
|
|
87
|
+
}, [id, event, authUserId]);
|
|
80
88
|
(0, use_deep_compare_effect_1.useDeepCompareEffectNoCheck)(() => {
|
|
81
89
|
if (event) {
|
|
82
90
|
setSCEvent(event);
|
|
@@ -30,7 +30,7 @@ export default function useSCSubscribedEventsManager(user?: SCUserType): {
|
|
|
30
30
|
isLoading: (v: number | {
|
|
31
31
|
id: number;
|
|
32
32
|
}) => boolean;
|
|
33
|
-
toggleEventAttendance: (event: SCEventType
|
|
33
|
+
toggleEventAttendance: (event: SCEventType) => Promise<any>;
|
|
34
34
|
toggleEventNonattendance: (event: SCEventType) => Promise<any>;
|
|
35
35
|
subscriptionStatus: (event?: SCEventType) => string;
|
|
36
36
|
refresh: () => void;
|
|
@@ -10,9 +10,9 @@ const use_deep_compare_effect_1 = require("use-deep-compare-effect");
|
|
|
10
10
|
const SCPreferencesProvider_1 = require("../components/provider/SCPreferencesProvider");
|
|
11
11
|
const Errors_1 = require("../constants/Errors");
|
|
12
12
|
const Notification_1 = require("../constants/Notification");
|
|
13
|
-
const useSCCachingManager_1 = tslib_1.__importDefault(require("./useSCCachingManager"));
|
|
14
|
-
const event_1 = require("../utils/event");
|
|
15
13
|
const Preferences_1 = require("../constants/Preferences");
|
|
14
|
+
const event_1 = require("../utils/event");
|
|
15
|
+
const useSCCachingManager_1 = tslib_1.__importDefault(require("./useSCCachingManager"));
|
|
16
16
|
/**
|
|
17
17
|
:::info
|
|
18
18
|
This custom hook is used to manage the events followed.
|
|
@@ -115,50 +115,35 @@ function useSCSubscribedEventsManager(user) {
|
|
|
115
115
|
* Memoized toggleEventAttendance Event
|
|
116
116
|
* Toggle action
|
|
117
117
|
*/
|
|
118
|
-
const toggleEventAttendance = (0, react_1.useMemo)(() => (event
|
|
118
|
+
const toggleEventAttendance = (0, react_1.useMemo)(() => (event) => {
|
|
119
119
|
setLoading(event.id);
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
.
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
})
|
|
127
|
-
.then((res) => {
|
|
128
|
-
if (res.status >= 300) {
|
|
129
|
-
return Promise.reject(res);
|
|
130
|
-
}
|
|
131
|
-
updateCache([event.id]);
|
|
132
|
-
setData((prev) => getDataUpdated(prev, event.id, types_1.SCEventSubscriptionStatusType.SUBSCRIBED));
|
|
133
|
-
setUnLoading(event.id);
|
|
134
|
-
return Promise.resolve(res.data);
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
else {
|
|
138
|
-
const requestConfig = !event.subscription_status || event.subscription_status === types_1.SCEventSubscriptionStatusType.INVITED
|
|
120
|
+
const requestConfig = !event.subscription_status || event.subscription_status === types_1.SCEventSubscriptionStatusType.INVITED
|
|
121
|
+
? {
|
|
122
|
+
url: api_services_1.Endpoints.SubscribeToEvent.url({ id: event.id }),
|
|
123
|
+
method: api_services_1.Endpoints.SubscribeToEvent.method,
|
|
124
|
+
}
|
|
125
|
+
: event.subscription_status === types_1.SCEventSubscriptionStatusType.GOING
|
|
139
126
|
? {
|
|
140
|
-
url: api_services_1.Endpoints.
|
|
141
|
-
method: api_services_1.Endpoints.
|
|
127
|
+
url: api_services_1.Endpoints.RemoveGoingToEvent.url({ id: event.id }),
|
|
128
|
+
method: api_services_1.Endpoints.RemoveGoingToEvent.method,
|
|
142
129
|
}
|
|
143
|
-
:
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
});
|
|
161
|
-
}
|
|
130
|
+
: {
|
|
131
|
+
url: api_services_1.Endpoints.GoToEvent.url({ id: event.id }),
|
|
132
|
+
method: api_services_1.Endpoints.GoToEvent.method,
|
|
133
|
+
};
|
|
134
|
+
return api_services_1.http.request(requestConfig).then((res) => {
|
|
135
|
+
if (res.status >= 300) {
|
|
136
|
+
return Promise.reject(res);
|
|
137
|
+
}
|
|
138
|
+
let newStatus = (0, event_1.getEventStatus)(event, true);
|
|
139
|
+
if (event.subscription_status === types_1.SCEventSubscriptionStatusType.NOT_GOING) {
|
|
140
|
+
newStatus = (0, event_1.getEventStatus)(Object.assign({}, event, { subscription_status: types_1.SCEventSubscriptionStatusType.SUBSCRIBED }), true);
|
|
141
|
+
}
|
|
142
|
+
setData((prev) => getDataUpdated(prev, event.id, newStatus));
|
|
143
|
+
updateCache([event.id]);
|
|
144
|
+
setUnLoading(event.id);
|
|
145
|
+
return Promise.resolve(Object.assign({}, event, { subscription_status: newStatus }));
|
|
146
|
+
});
|
|
162
147
|
}, [data, loading, cache]);
|
|
163
148
|
/**
|
|
164
149
|
* Memoized toggleEventNonattendance Event
|
|
@@ -180,10 +165,14 @@ function useSCSubscribedEventsManager(user) {
|
|
|
180
165
|
if (res.status >= 300) {
|
|
181
166
|
return Promise.reject(res);
|
|
182
167
|
}
|
|
168
|
+
let newStatus = (0, event_1.getEventStatus)(event, false);
|
|
169
|
+
if (event.subscription_status === types_1.SCEventSubscriptionStatusType.GOING) {
|
|
170
|
+
newStatus = (0, event_1.getEventStatus)(Object.assign({}, event, { subscription_status: types_1.SCEventSubscriptionStatusType.SUBSCRIBED }), false);
|
|
171
|
+
}
|
|
172
|
+
setData((prev) => getDataUpdated(prev, event.id, newStatus));
|
|
183
173
|
updateCache([event.id]);
|
|
184
|
-
setData((prev) => getDataUpdated(prev, event.id, (0, event_1.getEventStatus)(event, false)));
|
|
185
174
|
setUnLoading(event.id);
|
|
186
|
-
return Promise.resolve(
|
|
175
|
+
return Promise.resolve(Object.assign({}, event, { subscription_status: newStatus }));
|
|
187
176
|
});
|
|
188
177
|
}
|
|
189
178
|
else {
|
|
@@ -197,7 +186,7 @@ function useSCSubscribedEventsManager(user) {
|
|
|
197
186
|
updateCache([event.id]);
|
|
198
187
|
setData((prev) => getDataUpdated(prev, event.id, null));
|
|
199
188
|
setUnLoading(event.id);
|
|
200
|
-
return Promise.resolve(
|
|
189
|
+
return Promise.resolve(Object.assign({}, event, { subscription_status: null }));
|
|
201
190
|
});
|
|
202
191
|
}
|
|
203
192
|
}, [data, loading, cache]);
|
|
@@ -285,7 +274,7 @@ function useSCSubscribedEventsManager(user) {
|
|
|
285
274
|
}
|
|
286
275
|
}
|
|
287
276
|
return null;
|
|
288
|
-
}, [loading, cache, authUserId]);
|
|
277
|
+
}, [loading, cache, authUserId, getSubscriptionStatus, getCurrentEventCacheStatus]);
|
|
289
278
|
/**
|
|
290
279
|
* Empty cache on logout
|
|
291
280
|
*/
|
|
@@ -206,7 +206,7 @@ exports.validateWebSocketDisableToastMessage = validateWebSocketDisableToastMess
|
|
|
206
206
|
const validateWebSocketSecure = (value) => {
|
|
207
207
|
const errors = [];
|
|
208
208
|
const warnings = [];
|
|
209
|
-
if (value) {
|
|
209
|
+
if ((value === null || value === void 0 ? void 0 : value.toString()) !== undefined) {
|
|
210
210
|
if (!(typeof value === 'boolean')) {
|
|
211
211
|
errors.push(errors_1.ValidationError.ERROR_INVALID_NOTIFICATIONS_WEBSOCKET_SECURE);
|
|
212
212
|
}
|
|
@@ -679,7 +679,6 @@ exports.validateOpenAI = validateOpenAI;
|
|
|
679
679
|
* @param v
|
|
680
680
|
*/
|
|
681
681
|
const validateGeocoding = (v) => {
|
|
682
|
-
//console.log(v);
|
|
683
682
|
const errors = [];
|
|
684
683
|
const warnings = [];
|
|
685
684
|
if (v && !(0, utils_1.isObject)(v)) {
|
|
@@ -134,6 +134,8 @@ export declare const CONFIGURATIONS_EVENTS_ENABLED: string;
|
|
|
134
134
|
export declare const CONFIGURATIONS_EVENTS_ONLY_STAFF_ENABLED: string;
|
|
135
135
|
export declare const CONFIGURATIONS_EVENTS_VISIBILITY_ENABLED: string;
|
|
136
136
|
export declare const CONFIGURATIONS_EVENTS_PRIVATE_ENABLED: string;
|
|
137
|
+
export declare const CONFIGURATIONS_ONBOARDING_ENABLED: string;
|
|
138
|
+
export declare const CONFIGURATIONS_ONBOARDING_HIDDEN: string;
|
|
137
139
|
/**
|
|
138
140
|
* PROVIDERS
|
|
139
141
|
*/
|
|
@@ -135,6 +135,8 @@ export const CONFIGURATIONS_EVENTS_ENABLED = `${SCPreferenceSection.CONFIGURATIO
|
|
|
135
135
|
export const CONFIGURATIONS_EVENTS_ONLY_STAFF_ENABLED = `${SCPreferenceSection.CONFIGURATIONS}.${SCPreferenceName.EVENTS_ONLY_STAFF_ENABLED}`;
|
|
136
136
|
export const CONFIGURATIONS_EVENTS_VISIBILITY_ENABLED = `${SCPreferenceSection.CONFIGURATIONS}.${SCPreferenceName.EVENTS_VISIBILITY_ENABLED}`;
|
|
137
137
|
export const CONFIGURATIONS_EVENTS_PRIVATE_ENABLED = `${SCPreferenceSection.CONFIGURATIONS}.${SCPreferenceName.EVENTS_PRIVATE_ENABLED}`;
|
|
138
|
+
export const CONFIGURATIONS_ONBOARDING_ENABLED = `${SCPreferenceSection.CONFIGURATIONS}.${SCPreferenceName.ONBOARDING_ENABLED}`;
|
|
139
|
+
export const CONFIGURATIONS_ONBOARDING_HIDDEN = `${SCPreferenceSection.CONFIGURATIONS}.${SCPreferenceName.ONBOARDING_HIDDEN}`;
|
|
138
140
|
/**
|
|
139
141
|
* PROVIDERS
|
|
140
142
|
*/
|
|
@@ -279,6 +281,8 @@ export const DATA_TYPES = {
|
|
|
279
281
|
[CONFIGURATIONS_EVENTS_ONLY_STAFF_ENABLED]: booleanType,
|
|
280
282
|
[CONFIGURATIONS_EVENTS_VISIBILITY_ENABLED]: booleanType,
|
|
281
283
|
[CONFIGURATIONS_EVENTS_PRIVATE_ENABLED]: booleanType,
|
|
284
|
+
[CONFIGURATIONS_ONBOARDING_ENABLED]: booleanType,
|
|
285
|
+
[CONFIGURATIONS_ONBOARDING_HIDDEN]: booleanType,
|
|
282
286
|
[PROVIDERS_APP_URL_ON_APP_STORE]: stringType,
|
|
283
287
|
[PROVIDERS_APP_URL_ON_GOOGLE_PLAY]: stringType,
|
|
284
288
|
[PROVIDERS_FACEBOOK_SIGNIN_ENABLED]: stringType,
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { useEffect, useMemo, useState } from 'react';
|
|
2
|
-
import { SCOPE_SC_CORE } from '../constants/Errors';
|
|
3
|
-
import { SCEventPrivacyType, SCEventSubscriptionStatusType } from '@selfcommunity/types';
|
|
4
1
|
import { Endpoints, EventService, http } from '@selfcommunity/api-services';
|
|
2
|
+
import { SCEventPrivacyType, SCEventSubscriptionStatusType } from '@selfcommunity/types';
|
|
5
3
|
import { CacheStrategies, Logger, LRUCache, objectWithoutProperties } from '@selfcommunity/utils';
|
|
6
|
-
import {
|
|
4
|
+
import { useEffect, useMemo, useState } from 'react';
|
|
7
5
|
import { useDeepCompareEffectNoCheck } from 'use-deep-compare-effect';
|
|
8
6
|
import { useSCUser } from '../components/provider/SCUserProvider';
|
|
7
|
+
import { getEventObjectCacheKey } from '../constants/Cache';
|
|
8
|
+
import { SCOPE_SC_CORE } from '../constants/Errors';
|
|
9
9
|
/**
|
|
10
10
|
:::info
|
|
11
11
|
This custom hook is used to fetch an event object.
|
|
@@ -26,18 +26,37 @@ export default function useSCFetchEvent({ id = null, event = null, autoSubscribe
|
|
|
26
26
|
const __event = authUserId ? event : objectWithoutProperties(event, ['subscription_status']);
|
|
27
27
|
const [scEvent, setScEvent] = useState(cacheStrategy !== CacheStrategies.NETWORK_ONLY ? LRUCache.get(__eventCacheKey, __event) : null);
|
|
28
28
|
const [error, setError] = useState(null);
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
29
|
+
/**
|
|
30
|
+
* Memoized setSCEvent (auto-subscription if need it)
|
|
31
|
+
*/
|
|
32
|
+
const setSCEvent = useMemo(() => (e) => {
|
|
33
|
+
if (autoSubscribe &&
|
|
34
|
+
authUserId !== null &&
|
|
35
|
+
((e.privacy === SCEventPrivacyType.PUBLIC && !e.subscription_status) || e.subscription_status === SCEventSubscriptionStatusType.INVITED)) {
|
|
36
|
+
// Auto subscribe to the event
|
|
37
|
+
EventService.subscribeToEvent(e.id)
|
|
38
|
+
.then(() => {
|
|
39
|
+
const updatedEvent = Object.assign(Object.assign({}, e), { subscription_status: SCEventSubscriptionStatusType.SUBSCRIBED });
|
|
40
|
+
setScEvent(updatedEvent);
|
|
41
|
+
LRUCache.set(__eventCacheKey, updatedEvent);
|
|
42
|
+
})
|
|
43
|
+
.catch(() => {
|
|
44
|
+
setScEvent(e);
|
|
45
|
+
LRUCache.set(__eventCacheKey, e);
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
setScEvent(e);
|
|
50
|
+
LRUCache.set(__eventCacheKey, e);
|
|
51
|
+
}
|
|
52
|
+
}, [autoSubscribe, authUserId, setScEvent]);
|
|
34
53
|
/**
|
|
35
54
|
* Memoized fetchTag
|
|
36
55
|
*/
|
|
37
|
-
const fetchEvent = useMemo(() => () => {
|
|
56
|
+
const fetchEvent = useMemo(() => (id) => {
|
|
38
57
|
return http
|
|
39
58
|
.request({
|
|
40
|
-
url: Endpoints.GetEventInfo.url({ id
|
|
59
|
+
url: Endpoints.GetEventInfo.url({ id }),
|
|
41
60
|
method: Endpoints.GetEventInfo.method,
|
|
42
61
|
})
|
|
43
62
|
.then((res) => {
|
|
@@ -46,26 +65,15 @@ export default function useSCFetchEvent({ id = null, event = null, autoSubscribe
|
|
|
46
65
|
}
|
|
47
66
|
return Promise.resolve(res.data);
|
|
48
67
|
});
|
|
49
|
-
}, [
|
|
68
|
+
}, []);
|
|
50
69
|
/**
|
|
51
70
|
* If id attempt to get the event by id
|
|
52
71
|
*/
|
|
53
72
|
useEffect(() => {
|
|
54
|
-
if (
|
|
55
|
-
fetchEvent()
|
|
56
|
-
.then((
|
|
57
|
-
|
|
58
|
-
authUserId !== null &&
|
|
59
|
-
((event.privacy === SCEventPrivacyType.PUBLIC && !event.subscription_status) || event.subscription_status === SCEventSubscriptionStatusType.INVITED)) {
|
|
60
|
-
// Auto subscribe to the event
|
|
61
|
-
EventService.subscribeToEvent(event.id).then(() => {
|
|
62
|
-
const updatedEvent = Object.assign(Object.assign({}, event), { subscription_status: SCEventSubscriptionStatusType.SUBSCRIBED });
|
|
63
|
-
setSCEvent(updatedEvent);
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
else {
|
|
67
|
-
setSCEvent(event);
|
|
68
|
-
}
|
|
73
|
+
if (id !== null && id !== undefined && !event) {
|
|
74
|
+
fetchEvent(id)
|
|
75
|
+
.then((e) => {
|
|
76
|
+
setSCEvent(e);
|
|
69
77
|
})
|
|
70
78
|
.catch((err) => {
|
|
71
79
|
LRUCache.delete(__eventCacheKey);
|
|
@@ -74,7 +82,7 @@ export default function useSCFetchEvent({ id = null, event = null, autoSubscribe
|
|
|
74
82
|
Logger.error(SCOPE_SC_CORE, err.message);
|
|
75
83
|
});
|
|
76
84
|
}
|
|
77
|
-
}, [
|
|
85
|
+
}, [id, event, authUserId]);
|
|
78
86
|
useDeepCompareEffectNoCheck(() => {
|
|
79
87
|
if (event) {
|
|
80
88
|
setSCEvent(event);
|
|
@@ -30,7 +30,7 @@ export default function useSCSubscribedEventsManager(user?: SCUserType): {
|
|
|
30
30
|
isLoading: (v: number | {
|
|
31
31
|
id: number;
|
|
32
32
|
}) => boolean;
|
|
33
|
-
toggleEventAttendance: (event: SCEventType
|
|
33
|
+
toggleEventAttendance: (event: SCEventType) => Promise<any>;
|
|
34
34
|
toggleEventNonattendance: (event: SCEventType) => Promise<any>;
|
|
35
35
|
subscriptionStatus: (event?: SCEventType) => string;
|
|
36
36
|
refresh: () => void;
|
|
@@ -7,9 +7,9 @@ import { useDeepCompareEffectNoCheck } from 'use-deep-compare-effect';
|
|
|
7
7
|
import { useSCPreferences } from '../components/provider/SCPreferencesProvider';
|
|
8
8
|
import { SCOPE_SC_CORE } from '../constants/Errors';
|
|
9
9
|
import { SCNotificationMapping } from '../constants/Notification';
|
|
10
|
-
import useSCCachingManager from './useSCCachingManager';
|
|
11
|
-
import { getEventStatus } from '../utils/event';
|
|
12
10
|
import { CONFIGURATIONS_EVENTS_ENABLED } from '../constants/Preferences';
|
|
11
|
+
import { getEventStatus } from '../utils/event';
|
|
12
|
+
import useSCCachingManager from './useSCCachingManager';
|
|
13
13
|
/**
|
|
14
14
|
:::info
|
|
15
15
|
This custom hook is used to manage the events followed.
|
|
@@ -112,50 +112,35 @@ export default function useSCSubscribedEventsManager(user) {
|
|
|
112
112
|
* Memoized toggleEventAttendance Event
|
|
113
113
|
* Toggle action
|
|
114
114
|
*/
|
|
115
|
-
const toggleEventAttendance = useMemo(() => (event
|
|
115
|
+
const toggleEventAttendance = useMemo(() => (event) => {
|
|
116
116
|
setLoading(event.id);
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
.
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
})
|
|
124
|
-
.then((res) => {
|
|
125
|
-
if (res.status >= 300) {
|
|
126
|
-
return Promise.reject(res);
|
|
127
|
-
}
|
|
128
|
-
updateCache([event.id]);
|
|
129
|
-
setData((prev) => getDataUpdated(prev, event.id, SCEventSubscriptionStatusType.SUBSCRIBED));
|
|
130
|
-
setUnLoading(event.id);
|
|
131
|
-
return Promise.resolve(res.data);
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
else {
|
|
135
|
-
const requestConfig = !event.subscription_status || event.subscription_status === SCEventSubscriptionStatusType.INVITED
|
|
117
|
+
const requestConfig = !event.subscription_status || event.subscription_status === SCEventSubscriptionStatusType.INVITED
|
|
118
|
+
? {
|
|
119
|
+
url: Endpoints.SubscribeToEvent.url({ id: event.id }),
|
|
120
|
+
method: Endpoints.SubscribeToEvent.method,
|
|
121
|
+
}
|
|
122
|
+
: event.subscription_status === SCEventSubscriptionStatusType.GOING
|
|
136
123
|
? {
|
|
137
|
-
url: Endpoints.
|
|
138
|
-
method: Endpoints.
|
|
124
|
+
url: Endpoints.RemoveGoingToEvent.url({ id: event.id }),
|
|
125
|
+
method: Endpoints.RemoveGoingToEvent.method,
|
|
139
126
|
}
|
|
140
|
-
:
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
});
|
|
158
|
-
}
|
|
127
|
+
: {
|
|
128
|
+
url: Endpoints.GoToEvent.url({ id: event.id }),
|
|
129
|
+
method: Endpoints.GoToEvent.method,
|
|
130
|
+
};
|
|
131
|
+
return http.request(requestConfig).then((res) => {
|
|
132
|
+
if (res.status >= 300) {
|
|
133
|
+
return Promise.reject(res);
|
|
134
|
+
}
|
|
135
|
+
let newStatus = getEventStatus(event, true);
|
|
136
|
+
if (event.subscription_status === SCEventSubscriptionStatusType.NOT_GOING) {
|
|
137
|
+
newStatus = getEventStatus(Object.assign({}, event, { subscription_status: SCEventSubscriptionStatusType.SUBSCRIBED }), true);
|
|
138
|
+
}
|
|
139
|
+
setData((prev) => getDataUpdated(prev, event.id, newStatus));
|
|
140
|
+
updateCache([event.id]);
|
|
141
|
+
setUnLoading(event.id);
|
|
142
|
+
return Promise.resolve(Object.assign({}, event, { subscription_status: newStatus }));
|
|
143
|
+
});
|
|
159
144
|
}, [data, loading, cache]);
|
|
160
145
|
/**
|
|
161
146
|
* Memoized toggleEventNonattendance Event
|
|
@@ -177,10 +162,14 @@ export default function useSCSubscribedEventsManager(user) {
|
|
|
177
162
|
if (res.status >= 300) {
|
|
178
163
|
return Promise.reject(res);
|
|
179
164
|
}
|
|
165
|
+
let newStatus = getEventStatus(event, false);
|
|
166
|
+
if (event.subscription_status === SCEventSubscriptionStatusType.GOING) {
|
|
167
|
+
newStatus = getEventStatus(Object.assign({}, event, { subscription_status: SCEventSubscriptionStatusType.SUBSCRIBED }), false);
|
|
168
|
+
}
|
|
169
|
+
setData((prev) => getDataUpdated(prev, event.id, newStatus));
|
|
180
170
|
updateCache([event.id]);
|
|
181
|
-
setData((prev) => getDataUpdated(prev, event.id, getEventStatus(event, false)));
|
|
182
171
|
setUnLoading(event.id);
|
|
183
|
-
return Promise.resolve(
|
|
172
|
+
return Promise.resolve(Object.assign({}, event, { subscription_status: newStatus }));
|
|
184
173
|
});
|
|
185
174
|
}
|
|
186
175
|
else {
|
|
@@ -194,7 +183,7 @@ export default function useSCSubscribedEventsManager(user) {
|
|
|
194
183
|
updateCache([event.id]);
|
|
195
184
|
setData((prev) => getDataUpdated(prev, event.id, null));
|
|
196
185
|
setUnLoading(event.id);
|
|
197
|
-
return Promise.resolve(
|
|
186
|
+
return Promise.resolve(Object.assign({}, event, { subscription_status: null }));
|
|
198
187
|
});
|
|
199
188
|
}
|
|
200
189
|
}, [data, loading, cache]);
|
|
@@ -282,7 +271,7 @@ export default function useSCSubscribedEventsManager(user) {
|
|
|
282
271
|
}
|
|
283
272
|
}
|
|
284
273
|
return null;
|
|
285
|
-
}, [loading, cache, authUserId]);
|
|
274
|
+
}, [loading, cache, authUserId, getSubscriptionStatus, getCurrentEventCacheStatus]);
|
|
286
275
|
/**
|
|
287
276
|
* Empty cache on logout
|
|
288
277
|
*/
|
|
@@ -193,7 +193,7 @@ export const validateWebSocketDisableToastMessage = (value) => {
|
|
|
193
193
|
export const validateWebSocketSecure = (value) => {
|
|
194
194
|
const errors = [];
|
|
195
195
|
const warnings = [];
|
|
196
|
-
if (value) {
|
|
196
|
+
if ((value === null || value === void 0 ? void 0 : value.toString()) !== undefined) {
|
|
197
197
|
if (!(typeof value === 'boolean')) {
|
|
198
198
|
errors.push(ValidationError.ERROR_INVALID_NOTIFICATIONS_WEBSOCKET_SECURE);
|
|
199
199
|
}
|
|
@@ -644,7 +644,6 @@ export const validateOpenAI = (v) => {
|
|
|
644
644
|
* @param v
|
|
645
645
|
*/
|
|
646
646
|
export const validateGeocoding = (v) => {
|
|
647
|
-
//console.log(v);
|
|
648
647
|
const errors = [];
|
|
649
648
|
const warnings = [];
|
|
650
649
|
if (v && !isObject(v)) {
|