@selfcommunity/react-core 0.6.0-alpha.1 → 0.6.0-alpha.11

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.
@@ -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.PROVIDERS_APP_URL_ON_APP_STORE = 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 = 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 Cache_1 = require("../constants/Cache");
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.
@@ -19,7 +19,6 @@ const SCUserProvider_1 = require("../components/provider/SCUserProvider");
19
19
  * @param object.cacheStrategy
20
20
  */
21
21
  function useSCFetchEvent({ id = null, event = null, autoSubscribe = true, cacheStrategy = utils_1.CacheStrategies.CACHE_FIRST, }) {
22
- console.log('Params: ', event, id);
23
22
  const __eventId = event ? event.id : id;
24
23
  // CONTEXT
25
24
  const scUserContext = (0, SCUserProvider_1.useSCUser)();
@@ -37,26 +36,29 @@ function useSCFetchEvent({ id = null, event = null, autoSubscribe = true, cacheS
37
36
  authUserId !== null &&
38
37
  ((e.privacy === types_1.SCEventPrivacyType.PUBLIC && !e.subscription_status) || e.subscription_status === types_1.SCEventSubscriptionStatusType.INVITED)) {
39
38
  // Auto subscribe to the event
40
- api_services_1.EventService.subscribeToEvent(e.id).then(() => {
39
+ api_services_1.EventService.subscribeToEvent(e.id)
40
+ .then(() => {
41
41
  const updatedEvent = Object.assign(Object.assign({}, e), { subscription_status: types_1.SCEventSubscriptionStatusType.SUBSCRIBED });
42
- console.log('Update event', updatedEvent.id);
43
42
  setScEvent(updatedEvent);
44
43
  utils_1.LRUCache.set(__eventCacheKey, updatedEvent);
44
+ })
45
+ .catch(() => {
46
+ setScEvent(e);
47
+ utils_1.LRUCache.set(__eventCacheKey, e);
45
48
  });
46
49
  }
47
50
  else {
48
- const updatedEvent = authUserId ? e : (0, utils_1.objectWithoutProperties)(e, ['subscription_status']);
49
- setScEvent(updatedEvent);
50
- utils_1.LRUCache.set(__eventCacheKey, updatedEvent);
51
+ setScEvent(e);
52
+ utils_1.LRUCache.set(__eventCacheKey, e);
51
53
  }
52
54
  }, [autoSubscribe, authUserId, setScEvent]);
53
55
  /**
54
56
  * Memoized fetchTag
55
57
  */
56
- const fetchEvent = (0, react_1.useMemo)(() => () => {
58
+ const fetchEvent = (0, react_1.useMemo)(() => (id) => {
57
59
  return api_services_1.http
58
60
  .request({
59
- url: api_services_1.Endpoints.GetEventInfo.url({ id: __eventId }),
61
+ url: api_services_1.Endpoints.GetEventInfo.url({ id }),
60
62
  method: api_services_1.Endpoints.GetEventInfo.method,
61
63
  })
62
64
  .then((res) => {
@@ -65,13 +67,13 @@ function useSCFetchEvent({ id = null, event = null, autoSubscribe = true, cacheS
65
67
  }
66
68
  return Promise.resolve(res.data);
67
69
  });
68
- }, [__eventId]);
70
+ }, []);
69
71
  /**
70
72
  * If id attempt to get the event by id
71
73
  */
72
74
  (0, react_1.useEffect)(() => {
73
- if ((__eventId === null || __eventId === void 0 ? void 0 : __eventId.toString()) !== undefined && !event) {
74
- fetchEvent()
75
+ if (id !== null && id !== undefined && !event) {
76
+ fetchEvent(id)
75
77
  .then((e) => {
76
78
  setSCEvent(e);
77
79
  })
@@ -82,7 +84,7 @@ function useSCFetchEvent({ id = null, event = null, autoSubscribe = true, cacheS
82
84
  utils_1.Logger.error(Errors_1.SCOPE_SC_CORE, err.message);
83
85
  });
84
86
  }
85
- }, [__eventId, event]);
87
+ }, [id, event, authUserId]);
86
88
  (0, use_deep_compare_effect_1.useDeepCompareEffectNoCheck)(() => {
87
89
  if (event) {
88
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, userId?: number) => Promise<any>;
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, userId) => {
118
+ const toggleEventAttendance = (0, react_1.useMemo)(() => (event) => {
119
119
  setLoading(event.id);
120
- if (userId) {
121
- return api_services_1.http
122
- .request({
123
- url: api_services_1.Endpoints.InviteOrAcceptEventRequest.url({ id: event.id }),
124
- method: api_services_1.Endpoints.InviteOrAcceptEventRequest.method,
125
- data: { users: [userId] },
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.SubscribeToEvent.url({ id: event.id }),
141
- method: api_services_1.Endpoints.SubscribeToEvent.method,
127
+ url: api_services_1.Endpoints.RemoveGoingToEvent.url({ id: event.id }),
128
+ method: api_services_1.Endpoints.RemoveGoingToEvent.method,
142
129
  }
143
- : event.subscription_status === types_1.SCEventSubscriptionStatusType.GOING
144
- ? {
145
- url: api_services_1.Endpoints.RemoveGoingToEvent.url({ id: event.id }),
146
- method: api_services_1.Endpoints.RemoveGoingToEvent.method,
147
- }
148
- : {
149
- url: api_services_1.Endpoints.GoToEvent.url({ id: event.id }),
150
- method: api_services_1.Endpoints.GoToEvent.method,
151
- };
152
- return api_services_1.http.request(requestConfig).then((res) => {
153
- if (res.status >= 300) {
154
- return Promise.reject(res);
155
- }
156
- updateCache([event.id]);
157
- setData((prev) => getDataUpdated(prev, event.id, (0, event_1.getEventStatus)(event, true)));
158
- setUnLoading(event.id);
159
- return Promise.resolve(res.data);
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(res.data);
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(res.data);
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 { getEventObjectCacheKey } from '../constants/Cache';
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.
@@ -17,7 +17,6 @@ import { useSCUser } from '../components/provider/SCUserProvider';
17
17
  * @param object.cacheStrategy
18
18
  */
19
19
  export default function useSCFetchEvent({ id = null, event = null, autoSubscribe = true, cacheStrategy = CacheStrategies.CACHE_FIRST, }) {
20
- console.log('Params: ', event, id);
21
20
  const __eventId = event ? event.id : id;
22
21
  // CONTEXT
23
22
  const scUserContext = useSCUser();
@@ -35,26 +34,29 @@ export default function useSCFetchEvent({ id = null, event = null, autoSubscribe
35
34
  authUserId !== null &&
36
35
  ((e.privacy === SCEventPrivacyType.PUBLIC && !e.subscription_status) || e.subscription_status === SCEventSubscriptionStatusType.INVITED)) {
37
36
  // Auto subscribe to the event
38
- EventService.subscribeToEvent(e.id).then(() => {
37
+ EventService.subscribeToEvent(e.id)
38
+ .then(() => {
39
39
  const updatedEvent = Object.assign(Object.assign({}, e), { subscription_status: SCEventSubscriptionStatusType.SUBSCRIBED });
40
- console.log('Update event', updatedEvent.id);
41
40
  setScEvent(updatedEvent);
42
41
  LRUCache.set(__eventCacheKey, updatedEvent);
42
+ })
43
+ .catch(() => {
44
+ setScEvent(e);
45
+ LRUCache.set(__eventCacheKey, e);
43
46
  });
44
47
  }
45
48
  else {
46
- const updatedEvent = authUserId ? e : objectWithoutProperties(e, ['subscription_status']);
47
- setScEvent(updatedEvent);
48
- LRUCache.set(__eventCacheKey, updatedEvent);
49
+ setScEvent(e);
50
+ LRUCache.set(__eventCacheKey, e);
49
51
  }
50
52
  }, [autoSubscribe, authUserId, setScEvent]);
51
53
  /**
52
54
  * Memoized fetchTag
53
55
  */
54
- const fetchEvent = useMemo(() => () => {
56
+ const fetchEvent = useMemo(() => (id) => {
55
57
  return http
56
58
  .request({
57
- url: Endpoints.GetEventInfo.url({ id: __eventId }),
59
+ url: Endpoints.GetEventInfo.url({ id }),
58
60
  method: Endpoints.GetEventInfo.method,
59
61
  })
60
62
  .then((res) => {
@@ -63,13 +65,13 @@ export default function useSCFetchEvent({ id = null, event = null, autoSubscribe
63
65
  }
64
66
  return Promise.resolve(res.data);
65
67
  });
66
- }, [__eventId]);
68
+ }, []);
67
69
  /**
68
70
  * If id attempt to get the event by id
69
71
  */
70
72
  useEffect(() => {
71
- if ((__eventId === null || __eventId === void 0 ? void 0 : __eventId.toString()) !== undefined && !event) {
72
- fetchEvent()
73
+ if (id !== null && id !== undefined && !event) {
74
+ fetchEvent(id)
73
75
  .then((e) => {
74
76
  setSCEvent(e);
75
77
  })
@@ -80,7 +82,7 @@ export default function useSCFetchEvent({ id = null, event = null, autoSubscribe
80
82
  Logger.error(SCOPE_SC_CORE, err.message);
81
83
  });
82
84
  }
83
- }, [__eventId, event]);
85
+ }, [id, event, authUserId]);
84
86
  useDeepCompareEffectNoCheck(() => {
85
87
  if (event) {
86
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, userId?: number) => Promise<any>;
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, userId) => {
115
+ const toggleEventAttendance = useMemo(() => (event) => {
116
116
  setLoading(event.id);
117
- if (userId) {
118
- return http
119
- .request({
120
- url: Endpoints.InviteOrAcceptEventRequest.url({ id: event.id }),
121
- method: Endpoints.InviteOrAcceptEventRequest.method,
122
- data: { users: [userId] },
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.SubscribeToEvent.url({ id: event.id }),
138
- method: Endpoints.SubscribeToEvent.method,
124
+ url: Endpoints.RemoveGoingToEvent.url({ id: event.id }),
125
+ method: Endpoints.RemoveGoingToEvent.method,
139
126
  }
140
- : event.subscription_status === SCEventSubscriptionStatusType.GOING
141
- ? {
142
- url: Endpoints.RemoveGoingToEvent.url({ id: event.id }),
143
- method: Endpoints.RemoveGoingToEvent.method,
144
- }
145
- : {
146
- url: Endpoints.GoToEvent.url({ id: event.id }),
147
- method: Endpoints.GoToEvent.method,
148
- };
149
- return http.request(requestConfig).then((res) => {
150
- if (res.status >= 300) {
151
- return Promise.reject(res);
152
- }
153
- updateCache([event.id]);
154
- setData((prev) => getDataUpdated(prev, event.id, getEventStatus(event, true)));
155
- setUnLoading(event.id);
156
- return Promise.resolve(res.data);
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(res.data);
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(res.data);
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)) {