@articles-media/articles-dev-box 1.0.31 → 1.0.32
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/README.md +11 -3
- package/dist/Ad-BsG4C_lR.js +668 -0
- package/dist/Ad.js +2 -2
- package/dist/AdConfirmExitModal-heFPJNdX.js +55 -0
- package/dist/AdDetailsModal-D2-4lh9e.js +107 -0
- package/dist/ArticlesAd.js +15 -10
- package/dist/Button-DvEZjsVV.js +32 -0
- package/dist/CreditsModal.js +51 -35
- package/dist/DarkModeHandler.js +21 -13
- package/dist/FriendsList.js +49 -47
- package/dist/GameMenu-BD1HSDJ-.js +84 -0
- package/dist/GameMenu.js +2 -0
- package/dist/GameScoreboard-DVoXXDnM.js +174 -0
- package/dist/GameScoreboard.js +2 -2
- package/dist/GlobalBody.js +58 -23
- package/dist/GlobalHead.js +5 -5
- package/dist/Link-CguWJy6y.js +16 -0
- package/dist/ReturnToLauncherButton.js +26 -22
- package/dist/SessionButton.js +62 -38
- package/dist/SettingsModal-yU_TsVYh.js +430 -0
- package/dist/SettingsModal.js +2 -2
- package/dist/SignInButton.js +21 -17
- package/dist/SocketServerUrlHandler.js +14 -10
- package/dist/StatusModal-BXRbJQ10.js +84 -0
- package/dist/ToontownModeHandler.js +13 -10
- package/dist/ViewUserModal-Dgo1C4sR.js +1798 -0
- package/dist/ViewUserModal.js +2 -2
- package/dist/articles-dev-box.css +498 -2
- package/dist/classnames-No-mjhw1.js +66 -0
- package/dist/index.js +23 -22
- package/dist/numberWithCommas-B0B9bjWC.js +2198 -0
- package/dist/typicalZustandStoreExcludes.js +4 -3
- package/dist/typicalZustandStoreStateSlice.js +53 -49
- package/dist/useAuthSiteStatus-ZK1GbPBV.js +34 -0
- package/dist/useFullscreen.js +38 -18
- package/dist/useUserDetails.js +17 -16
- package/dist/useUserFriends.js +23 -21
- package/dist/useUserToken.js +12 -11
- package/package.json +2 -1
- package/dist/Ad-CFuDgQYL.js +0 -504
- package/dist/AdConfirmExitModal-skW9lp88.js +0 -55
- package/dist/AdDetailsModal-CdTR2Y9l.js +0 -107
- package/dist/Button-sSB4xpOw.js +0 -31
- package/dist/GameScoreboard-9GYlLx72.js +0 -165
- package/dist/Link-8nSDV4sI.js +0 -16
- package/dist/SettingsModal-CiLvMoLW.js +0 -303
- package/dist/StatusModal-PG3i9NKf.js +0 -75
- package/dist/ViewUserModal-C5gjfuJ5.js +0 -1549
- package/dist/classnames-DCsil9eG.js +0 -39
- package/dist/numberWithCommas-DSRplpBy.js +0 -1170
- package/dist/useAuthSiteStatus-Cj9IjMj7.js +0 -29
package/README.md
CHANGED
|
@@ -45,6 +45,8 @@ npm run dev
|
|
|
45
45
|
- Scoreboard for registered games that links with a user's Articles Media account.
|
|
46
46
|
- Ad
|
|
47
47
|
- Articles Ad component that connects with user data.
|
|
48
|
+
- GameMenu
|
|
49
|
+
- All in one component that handles the sidebar and menu-bar inside a game page.
|
|
48
50
|
- GlobalHead
|
|
49
51
|
- Not used at this time, allows for just <head> related tags to be added to site without other logic.
|
|
50
52
|
- GlobalBody
|
|
@@ -72,10 +74,16 @@ npm run dev
|
|
|
72
74
|
- typicalZustandStoreStateSlice
|
|
73
75
|
- Slice of zustand states that every game normally uses
|
|
74
76
|
|
|
77
|
+
# Usage Examples
|
|
78
|
+
For newly developed components I sometimes find myself trying to remember what repos used it. Here is a short list of recent components developed and what project is using it. Doing this until AMPM can search by imports or enough projects adopted the component.
|
|
79
|
+
|
|
80
|
+
- typicalZustandStoreExcludes - Catching Game and School Run
|
|
81
|
+
- SessionButton - Catching Game and School Run
|
|
82
|
+
- GameMenu - School Run
|
|
83
|
+
|
|
75
84
|
# Roadmap
|
|
76
|
-
⏹️ Remove Bootstrap reliance
|
|
85
|
+
⏹️ Remove Bootstrap reliance?
|
|
77
86
|
⏹️ Figure out why this package does not work outside webpack, on Turbopack for example it fails. Bootstrap SASS related I think.
|
|
78
87
|
|
|
79
88
|
# TODO
|
|
80
|
-
-
|
|
81
|
-
- Verify I am exporting components the most efficient way.
|
|
89
|
+
- TODO
|
|
@@ -0,0 +1,668 @@
|
|
|
1
|
+
import { n as __toESM, t as require_classnames } from "./classnames-No-mjhw1.js";
|
|
2
|
+
import { t as ArticlesButton } from "./Button-DvEZjsVV.js";
|
|
3
|
+
import { t as Link } from "./Link-CguWJy6y.js";
|
|
4
|
+
import { n as ArticlesDate, o as toDate, r as minutesToMilliseconds, s as millisecondsInMinute, t as numberWithCommas } from "./numberWithCommas-B0B9bjWC.js";
|
|
5
|
+
import * as React from "react";
|
|
6
|
+
import { lazy, memo, useEffect, useState } from "react";
|
|
7
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
import useSWR from "swr";
|
|
9
|
+
//#region node_modules/date-fns/_lib/getRoundingMethod.js
|
|
10
|
+
function getRoundingMethod(method) {
|
|
11
|
+
return (number) => {
|
|
12
|
+
const result = (method ? Math[method] : Math.trunc)(number);
|
|
13
|
+
return result === 0 ? 0 : result;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
//#endregion
|
|
17
|
+
//#region node_modules/date-fns/differenceInMilliseconds.js
|
|
18
|
+
/**
|
|
19
|
+
* @name differenceInMilliseconds
|
|
20
|
+
* @category Millisecond Helpers
|
|
21
|
+
* @summary Get the number of milliseconds between the given dates.
|
|
22
|
+
*
|
|
23
|
+
* @description
|
|
24
|
+
* Get the number of milliseconds between the given dates.
|
|
25
|
+
*
|
|
26
|
+
* @param laterDate - The later date
|
|
27
|
+
* @param earlierDate - The earlier date
|
|
28
|
+
*
|
|
29
|
+
* @returns The number of milliseconds
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* // How many milliseconds are between
|
|
33
|
+
* // 2 July 2014 12:30:20.600 and 2 July 2014 12:30:21.700?
|
|
34
|
+
* const result = differenceInMilliseconds(
|
|
35
|
+
* new Date(2014, 6, 2, 12, 30, 21, 700),
|
|
36
|
+
* new Date(2014, 6, 2, 12, 30, 20, 600)
|
|
37
|
+
* )
|
|
38
|
+
* //=> 1100
|
|
39
|
+
*/
|
|
40
|
+
function differenceInMilliseconds(laterDate, earlierDate) {
|
|
41
|
+
return +toDate(laterDate) - +toDate(earlierDate);
|
|
42
|
+
}
|
|
43
|
+
//#endregion
|
|
44
|
+
//#region node_modules/date-fns/differenceInMinutes.js
|
|
45
|
+
/**
|
|
46
|
+
* The {@link differenceInMinutes} function options.
|
|
47
|
+
*/
|
|
48
|
+
/**
|
|
49
|
+
* @name differenceInMinutes
|
|
50
|
+
* @category Minute Helpers
|
|
51
|
+
* @summary Get the number of minutes between the given dates.
|
|
52
|
+
*
|
|
53
|
+
* @description
|
|
54
|
+
* Get the signed number of full (rounded towards 0) minutes between the given dates.
|
|
55
|
+
*
|
|
56
|
+
* @param dateLeft - The later date
|
|
57
|
+
* @param dateRight - The earlier date
|
|
58
|
+
* @param options - An object with options.
|
|
59
|
+
*
|
|
60
|
+
* @returns The number of minutes
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* // How many minutes are between 2 July 2014 12:07:59 and 2 July 2014 12:20:00?
|
|
64
|
+
* const result = differenceInMinutes(
|
|
65
|
+
* new Date(2014, 6, 2, 12, 20, 0),
|
|
66
|
+
* new Date(2014, 6, 2, 12, 7, 59)
|
|
67
|
+
* )
|
|
68
|
+
* //=> 12
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* // How many minutes are between 10:01:59 and 10:00:00
|
|
72
|
+
* const result = differenceInMinutes(
|
|
73
|
+
* new Date(2000, 0, 1, 10, 0, 0),
|
|
74
|
+
* new Date(2000, 0, 1, 10, 1, 59)
|
|
75
|
+
* )
|
|
76
|
+
* //=> -1
|
|
77
|
+
*/
|
|
78
|
+
function differenceInMinutes(dateLeft, dateRight, options) {
|
|
79
|
+
const diff = differenceInMilliseconds(dateLeft, dateRight) / millisecondsInMinute;
|
|
80
|
+
return getRoundingMethod(options?.roundingMethod)(diff);
|
|
81
|
+
}
|
|
82
|
+
var observerMap = /* @__PURE__ */ new Map();
|
|
83
|
+
var RootIds = /* @__PURE__ */ new WeakMap();
|
|
84
|
+
var rootId = 0;
|
|
85
|
+
var unsupportedValue;
|
|
86
|
+
function getRootId(root) {
|
|
87
|
+
if (!root) return "0";
|
|
88
|
+
if (RootIds.has(root)) return RootIds.get(root);
|
|
89
|
+
rootId += 1;
|
|
90
|
+
RootIds.set(root, rootId.toString());
|
|
91
|
+
return RootIds.get(root);
|
|
92
|
+
}
|
|
93
|
+
function optionsToId(options) {
|
|
94
|
+
return Object.keys(options).sort().filter((key) => options[key] !== void 0).map((key) => {
|
|
95
|
+
return `${key}_${key === "root" ? getRootId(options.root) : options[key]}`;
|
|
96
|
+
}).toString();
|
|
97
|
+
}
|
|
98
|
+
function createObserver(options) {
|
|
99
|
+
const id = optionsToId(options);
|
|
100
|
+
let instance = observerMap.get(id);
|
|
101
|
+
if (!instance) {
|
|
102
|
+
const elements = /* @__PURE__ */ new Map();
|
|
103
|
+
let thresholds;
|
|
104
|
+
const observer = new IntersectionObserver((entries) => {
|
|
105
|
+
entries.forEach((entry) => {
|
|
106
|
+
var _a2;
|
|
107
|
+
const inView = entry.isIntersecting && thresholds.some((threshold) => entry.intersectionRatio >= threshold);
|
|
108
|
+
if (options.trackVisibility && typeof entry.isVisible === "undefined") entry.isVisible = inView;
|
|
109
|
+
(_a2 = elements.get(entry.target)) == null || _a2.forEach((callback) => {
|
|
110
|
+
callback(inView, entry);
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
}, options);
|
|
114
|
+
thresholds = observer.thresholds || (Array.isArray(options.threshold) ? options.threshold : [options.threshold || 0]);
|
|
115
|
+
instance = {
|
|
116
|
+
id,
|
|
117
|
+
observer,
|
|
118
|
+
elements
|
|
119
|
+
};
|
|
120
|
+
observerMap.set(id, instance);
|
|
121
|
+
}
|
|
122
|
+
return instance;
|
|
123
|
+
}
|
|
124
|
+
function observe(element, callback, options = {}, fallbackInView = unsupportedValue) {
|
|
125
|
+
if (typeof window.IntersectionObserver === "undefined" && fallbackInView !== void 0) {
|
|
126
|
+
const bounds = element.getBoundingClientRect();
|
|
127
|
+
callback(fallbackInView, {
|
|
128
|
+
isIntersecting: fallbackInView,
|
|
129
|
+
target: element,
|
|
130
|
+
intersectionRatio: typeof options.threshold === "number" ? options.threshold : 0,
|
|
131
|
+
time: 0,
|
|
132
|
+
boundingClientRect: bounds,
|
|
133
|
+
intersectionRect: bounds,
|
|
134
|
+
rootBounds: bounds
|
|
135
|
+
});
|
|
136
|
+
return () => {};
|
|
137
|
+
}
|
|
138
|
+
const { id, observer, elements } = createObserver(options);
|
|
139
|
+
const callbacks = elements.get(element) || [];
|
|
140
|
+
if (!elements.has(element)) elements.set(element, callbacks);
|
|
141
|
+
callbacks.push(callback);
|
|
142
|
+
observer.observe(element);
|
|
143
|
+
return function unobserve() {
|
|
144
|
+
callbacks.splice(callbacks.indexOf(callback), 1);
|
|
145
|
+
if (callbacks.length === 0) {
|
|
146
|
+
elements.delete(element);
|
|
147
|
+
observer.unobserve(element);
|
|
148
|
+
}
|
|
149
|
+
if (elements.size === 0) {
|
|
150
|
+
observer.disconnect();
|
|
151
|
+
observerMap.delete(id);
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
React.Component;
|
|
156
|
+
function useInView({ threshold, delay, trackVisibility, rootMargin, root, triggerOnce, skip, initialInView, fallbackInView, onChange } = {}) {
|
|
157
|
+
var _a2;
|
|
158
|
+
const [ref, setRef] = React.useState(null);
|
|
159
|
+
const callback = React.useRef(onChange);
|
|
160
|
+
const lastInViewRef = React.useRef(initialInView);
|
|
161
|
+
const [state, setState] = React.useState({
|
|
162
|
+
inView: !!initialInView,
|
|
163
|
+
entry: void 0
|
|
164
|
+
});
|
|
165
|
+
callback.current = onChange;
|
|
166
|
+
React.useEffect(() => {
|
|
167
|
+
if (lastInViewRef.current === void 0) lastInViewRef.current = initialInView;
|
|
168
|
+
if (skip || !ref) return;
|
|
169
|
+
let unobserve;
|
|
170
|
+
unobserve = observe(ref, (inView, entry) => {
|
|
171
|
+
const previousInView = lastInViewRef.current;
|
|
172
|
+
lastInViewRef.current = inView;
|
|
173
|
+
if (previousInView === void 0 && !inView) return;
|
|
174
|
+
setState({
|
|
175
|
+
inView,
|
|
176
|
+
entry
|
|
177
|
+
});
|
|
178
|
+
if (callback.current) callback.current(inView, entry);
|
|
179
|
+
if (entry.isIntersecting && triggerOnce && unobserve) {
|
|
180
|
+
unobserve();
|
|
181
|
+
unobserve = void 0;
|
|
182
|
+
}
|
|
183
|
+
}, {
|
|
184
|
+
root,
|
|
185
|
+
rootMargin,
|
|
186
|
+
threshold,
|
|
187
|
+
trackVisibility,
|
|
188
|
+
delay
|
|
189
|
+
}, fallbackInView);
|
|
190
|
+
return () => {
|
|
191
|
+
if (unobserve) unobserve();
|
|
192
|
+
};
|
|
193
|
+
}, [
|
|
194
|
+
Array.isArray(threshold) ? threshold.toString() : threshold,
|
|
195
|
+
ref,
|
|
196
|
+
root,
|
|
197
|
+
rootMargin,
|
|
198
|
+
triggerOnce,
|
|
199
|
+
skip,
|
|
200
|
+
trackVisibility,
|
|
201
|
+
fallbackInView,
|
|
202
|
+
delay
|
|
203
|
+
]);
|
|
204
|
+
const entryTarget = (_a2 = state.entry) == null ? void 0 : _a2.target;
|
|
205
|
+
const previousEntryTarget = React.useRef(void 0);
|
|
206
|
+
if (!ref && entryTarget && !triggerOnce && !skip && previousEntryTarget.current !== entryTarget) {
|
|
207
|
+
previousEntryTarget.current = entryTarget;
|
|
208
|
+
setState({
|
|
209
|
+
inView: !!initialInView,
|
|
210
|
+
entry: void 0
|
|
211
|
+
});
|
|
212
|
+
lastInViewRef.current = initialInView;
|
|
213
|
+
}
|
|
214
|
+
const result = [
|
|
215
|
+
setRef,
|
|
216
|
+
state.inView,
|
|
217
|
+
state.entry
|
|
218
|
+
];
|
|
219
|
+
result.ref = result[0];
|
|
220
|
+
result.inView = result[1];
|
|
221
|
+
result.entry = result[2];
|
|
222
|
+
return result;
|
|
223
|
+
}
|
|
224
|
+
var _a;
|
|
225
|
+
((_a = React.useInsertionEffect) != null ? _a : React.useLayoutEffect) != null || React.useEffect;
|
|
226
|
+
//#endregion
|
|
227
|
+
//#region src/hooks/Ads/useAd.js
|
|
228
|
+
var fetcher$1 = async (data) => {
|
|
229
|
+
if (process.env.NODE_ENV === "development") try {
|
|
230
|
+
const params = new URLSearchParams({
|
|
231
|
+
ad_id: data.ad_id,
|
|
232
|
+
user_ad_token: data.user_ad_token
|
|
233
|
+
}).toString();
|
|
234
|
+
return (await (await fetch(`http://localhost:3001/api/ads/${data.ad_id}?${params}`)).json()).result;
|
|
235
|
+
} catch (err) {}
|
|
236
|
+
const params = new URLSearchParams({ ad_id: data.ad_id }).toString();
|
|
237
|
+
return fetch(`${data.url}?${params}`).then((res) => res.json()).then((json) => json.result);
|
|
238
|
+
};
|
|
239
|
+
var options$1 = {
|
|
240
|
+
dedupingInterval: 1e3 * 60 * 60,
|
|
241
|
+
errorRetryInterval: 1e3 * 60 * 5
|
|
242
|
+
};
|
|
243
|
+
var useAd = (ad_id, user_ad_token) => {
|
|
244
|
+
const { data, error, isLoading, mutate } = useSWR(ad_id ? {
|
|
245
|
+
url: `https://articles.media/api/ads/${ad_id}`,
|
|
246
|
+
ad_id,
|
|
247
|
+
user_ad_token
|
|
248
|
+
} : null, fetcher$1, options$1);
|
|
249
|
+
return {
|
|
250
|
+
data,
|
|
251
|
+
error,
|
|
252
|
+
isLoading,
|
|
253
|
+
mutate
|
|
254
|
+
};
|
|
255
|
+
};
|
|
256
|
+
//#endregion
|
|
257
|
+
//#region src/hooks/Ads/useAds.js
|
|
258
|
+
var fetcher = async (data) => {
|
|
259
|
+
if (process.env.NODE_ENV === "development") try {
|
|
260
|
+
return await (await fetch("http://localhost:3001/api/ads")).json();
|
|
261
|
+
} catch (err) {}
|
|
262
|
+
return fetch(data.url).then((res) => res.json());
|
|
263
|
+
};
|
|
264
|
+
var minutes = 60;
|
|
265
|
+
var options = {
|
|
266
|
+
dedupingInterval: minutesToMilliseconds(minutes),
|
|
267
|
+
focusThrottleInterval: minutesToMilliseconds(minutes),
|
|
268
|
+
errorRetryInterval: 1e3 * 60 * 5
|
|
269
|
+
};
|
|
270
|
+
var useAds = (params) => {
|
|
271
|
+
const { data, error, isLoading, mutate } = useSWR(params?.loading || params?.disabled ? null : { url: `https://articles.media/api/ads` }, fetcher, options);
|
|
272
|
+
return {
|
|
273
|
+
data,
|
|
274
|
+
error,
|
|
275
|
+
isLoading,
|
|
276
|
+
mutate
|
|
277
|
+
};
|
|
278
|
+
};
|
|
279
|
+
//#endregion
|
|
280
|
+
//#region src/components/Ads/Ad.jsx
|
|
281
|
+
var import_classnames = /* @__PURE__ */ __toESM(require_classnames(), 1);
|
|
282
|
+
var AdDetailsModal = lazy(() => import("./AdDetailsModal-D2-4lh9e.js"));
|
|
283
|
+
var AdConfirmExitModal = lazy(() => import("./AdConfirmExitModal-heFPJNdX.js"));
|
|
284
|
+
function generateRandomInteger(min, max) {
|
|
285
|
+
return Math.floor(Math.random() * (max - min + 1)) + min;
|
|
286
|
+
}
|
|
287
|
+
function Ad(props) {
|
|
288
|
+
let { previewMode, darkMode, user_ad_token, userDetails, userDetailsLoading, prepend, append } = props;
|
|
289
|
+
const userReduxState = false;
|
|
290
|
+
const viewedAds = [];
|
|
291
|
+
const [adId, setAdId] = useState(null);
|
|
292
|
+
const { data: ads, isLoading: adsIsLoading, mutate: adsMutate } = useAds({
|
|
293
|
+
loading: userDetailsLoading,
|
|
294
|
+
disabled: userDetails?.articles_membership?.status == "Active"
|
|
295
|
+
});
|
|
296
|
+
const { data: ad, isLoading: adIsLoading } = useAd(adId, user_ad_token);
|
|
297
|
+
let previewData = props.previewData || {};
|
|
298
|
+
const [randomAdId, setRandomAdId] = useState(null);
|
|
299
|
+
const [promoId, setPromoId] = useState(null);
|
|
300
|
+
const [promo, setPromo] = useState(null);
|
|
301
|
+
const [promoIndex, setPromoIndex] = useState(0);
|
|
302
|
+
const [modalShow, setModalShow] = useState(false);
|
|
303
|
+
const [adDetailsExpanded, setAdDetailsExpanded] = useState(false);
|
|
304
|
+
const [confirmAdExitModal, setConfirmAdExitModal] = useState(false);
|
|
305
|
+
const [selectedDate, handleDateChange] = useState(/* @__PURE__ */ new Date());
|
|
306
|
+
const [loggedEvents, setLoggedEvents] = useState([]);
|
|
307
|
+
useEffect(() => {
|
|
308
|
+
if (!ads) return;
|
|
309
|
+
if (ads?.length > 0 && !adId) {
|
|
310
|
+
console.log("Ad Mounted or reduxAds changed");
|
|
311
|
+
setAdId(props.ad_id || ads[generateRandomInteger(0, ads?.length - 1)]?._id);
|
|
312
|
+
}
|
|
313
|
+
}, [ads]);
|
|
314
|
+
useEffect(() => {}, [ad]);
|
|
315
|
+
useEffect(() => {
|
|
316
|
+
if (ad?.populated_promos && promoIndex >= 0) setPromo(ad?.populated_promos[promoIndex]);
|
|
317
|
+
}, [promoIndex, ad]);
|
|
318
|
+
function adDetailsExpandedToggle() {
|
|
319
|
+
setAdDetailsExpanded(!adDetailsExpanded);
|
|
320
|
+
}
|
|
321
|
+
const { ref, inView, entry } = useInView({
|
|
322
|
+
threshold: 0,
|
|
323
|
+
triggerOnce: true
|
|
324
|
+
});
|
|
325
|
+
function logEvent(event) {
|
|
326
|
+
if (previewMode) console.log("Preventing this event from being logged as this ad is being shown in preview mode.");
|
|
327
|
+
if (loggedEvents.find((obj) => obj == event)) {
|
|
328
|
+
console.log("Already logged this event");
|
|
329
|
+
return;
|
|
330
|
+
}
|
|
331
|
+
const params = new URLSearchParams({
|
|
332
|
+
ad_id: ad?._id,
|
|
333
|
+
event
|
|
334
|
+
}).toString();
|
|
335
|
+
fetch(`/api/ads/event?${params}`).then(function(response) {
|
|
336
|
+
return response.json();
|
|
337
|
+
}).then(function(data) {
|
|
338
|
+
setLoggedEvents([...loggedEvents, event]);
|
|
339
|
+
console.log(data);
|
|
340
|
+
}).catch(function(error) {
|
|
341
|
+
console.log(error);
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
useEffect(() => {
|
|
345
|
+
if (!previewMode) {
|
|
346
|
+
console.log("inView", inView);
|
|
347
|
+
if (inView && adId) {
|
|
348
|
+
let unexpiredRecentViews = [{
|
|
349
|
+
ad_id: adId,
|
|
350
|
+
date: (/* @__PURE__ */ new Date()).toString()
|
|
351
|
+
}, ...viewedAds.filter((obj) => {
|
|
352
|
+
console.log(differenceInMinutes(/* @__PURE__ */ new Date(), new Date(obj.date)));
|
|
353
|
+
if (differenceInMinutes(/* @__PURE__ */ new Date(), new Date(obj.date)) > 5) {
|
|
354
|
+
console.log("adsViewed - Remove Old Ad View Object");
|
|
355
|
+
return;
|
|
356
|
+
} else {
|
|
357
|
+
console.log("adsViewed - Keep Ad View Object");
|
|
358
|
+
return obj;
|
|
359
|
+
}
|
|
360
|
+
})];
|
|
361
|
+
console.log("unexpiredRecentViews", unexpiredRecentViews);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
}, [inView, adId]);
|
|
365
|
+
const [adsAvoided, setAdsAvoided] = useState(null);
|
|
366
|
+
const [adsAvoidedLoading, setAdsAvoidedLoading] = useState(false);
|
|
367
|
+
function logAdAvoided() {
|
|
368
|
+
setAdsAvoidedLoading(true);
|
|
369
|
+
console.log("logAdAvoided called", user_ad_token);
|
|
370
|
+
const url = process.env.NODE_ENV === "development" ? "http://localhost:3001/api/user/advertising/avoided" : `https://articles.media/api/user/advertising/avoided`;
|
|
371
|
+
const params = new URLSearchParams({ user_id: userDetails?._id }).toString();
|
|
372
|
+
fetch(`${url}?${params}`, { headers: { "x-articles-api-key": user_ad_token } }).then(function(response) {
|
|
373
|
+
return response.json();
|
|
374
|
+
}).then(function(data) {
|
|
375
|
+
setAdsAvoidedLoading(false);
|
|
376
|
+
setAdsAvoided(data.avoided_count);
|
|
377
|
+
console.log(data);
|
|
378
|
+
}).catch(function(error) {
|
|
379
|
+
console.log(error);
|
|
380
|
+
setAdsAvoidedLoading(false);
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
useEffect(() => {
|
|
384
|
+
if (!previewMode) {
|
|
385
|
+
console.log("inView", inView);
|
|
386
|
+
if (userDetails?.articles_membership?.status == "Active" && inView) logAdAvoided("Ad Avoided");
|
|
387
|
+
}
|
|
388
|
+
}, [inView, userDetails]);
|
|
389
|
+
if (userDetailsLoading) return null;
|
|
390
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
391
|
+
ref,
|
|
392
|
+
className: (0, import_classnames.default)("ad-wrap", { "active-member": userDetails?.articles_membership?.status == "Active" }),
|
|
393
|
+
style: {
|
|
394
|
+
"--articles-ad-background-color": previewData.background_color || ad?.background_color,
|
|
395
|
+
"--articles-ad-font-color": previewData.font_color || ad?.font_color,
|
|
396
|
+
"--articles-ad-border-color": previewData.border_color || ad?.border_color
|
|
397
|
+
},
|
|
398
|
+
children: [
|
|
399
|
+
adDetailsExpanded && /* @__PURE__ */ jsx(AdDetailsModal, {
|
|
400
|
+
setModalShow: setAdDetailsExpanded,
|
|
401
|
+
ad,
|
|
402
|
+
previewData
|
|
403
|
+
}),
|
|
404
|
+
confirmAdExitModal && /* @__PURE__ */ jsx(AdConfirmExitModal, {
|
|
405
|
+
setModalShow: setConfirmAdExitModal,
|
|
406
|
+
ad,
|
|
407
|
+
previewData
|
|
408
|
+
}),
|
|
409
|
+
prepend && /* @__PURE__ */ jsx("div", {
|
|
410
|
+
className: "prepend-container",
|
|
411
|
+
children: prepend
|
|
412
|
+
}),
|
|
413
|
+
/* @__PURE__ */ jsxs("div", {
|
|
414
|
+
className: "ad",
|
|
415
|
+
children: [userDetails?.articles_membership?.status !== "Active" && /* @__PURE__ */ jsxs("div", {
|
|
416
|
+
className: "main-panel",
|
|
417
|
+
children: [
|
|
418
|
+
/* @__PURE__ */ jsx("div", {
|
|
419
|
+
className: "ad-warning flex-header",
|
|
420
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
421
|
+
className: "",
|
|
422
|
+
children: [ad?.city && "Local", " Advertisement"]
|
|
423
|
+
})
|
|
424
|
+
}),
|
|
425
|
+
/* @__PURE__ */ jsxs("div", {
|
|
426
|
+
className: "content-wrap",
|
|
427
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
428
|
+
className: "photo-banner",
|
|
429
|
+
children: [
|
|
430
|
+
/* @__PURE__ */ jsx("div", {
|
|
431
|
+
className: "logo",
|
|
432
|
+
children: (previewData.logo?.location || ad?.logo?.location) && /* @__PURE__ */ jsx("img", {
|
|
433
|
+
src: previewData?.logo?.key ? `${process.env.NEXT_PUBLIC_CDN}${previewData?.logo?.key}` : `${process.env.NEXT_PUBLIC_CDN}${ad?.logo?.key}`,
|
|
434
|
+
alt: ""
|
|
435
|
+
})
|
|
436
|
+
}),
|
|
437
|
+
/* @__PURE__ */ jsx("div", {
|
|
438
|
+
className: "icon d-none",
|
|
439
|
+
children: /* @__PURE__ */ jsx("i", { className: "fas fa-mug-hot" })
|
|
440
|
+
}),
|
|
441
|
+
/* @__PURE__ */ jsx("img", {
|
|
442
|
+
className: "photo",
|
|
443
|
+
src: previewData?.background?.key ? `${process.env.NEXT_PUBLIC_CDN}${previewData.background?.key}` : `${process.env.NEXT_PUBLIC_CDN}${ad?.background?.key}`,
|
|
444
|
+
alt: ""
|
|
445
|
+
})
|
|
446
|
+
]
|
|
447
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
448
|
+
className: "details-wrap",
|
|
449
|
+
children: [
|
|
450
|
+
/* @__PURE__ */ jsxs("div", {
|
|
451
|
+
className: "detail-title",
|
|
452
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
453
|
+
className: "detail",
|
|
454
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
455
|
+
className: "h4",
|
|
456
|
+
children: previewData?.business || ad?.business
|
|
457
|
+
})
|
|
458
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
459
|
+
className: "flex flex-column d-none",
|
|
460
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
461
|
+
className: "detail",
|
|
462
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
463
|
+
className: "icon",
|
|
464
|
+
children: /* @__PURE__ */ jsx("i", { className: "fas fa-search-location" })
|
|
465
|
+
}), /* @__PURE__ */ jsxs("span", { children: [
|
|
466
|
+
ad?.city,
|
|
467
|
+
", ",
|
|
468
|
+
ad?.state
|
|
469
|
+
] })]
|
|
470
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
471
|
+
className: "detail",
|
|
472
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
473
|
+
className: "icon",
|
|
474
|
+
children: /* @__PURE__ */ jsx("i", { className: "fas fa-clock me-2" })
|
|
475
|
+
}), /* @__PURE__ */ jsx("span", { children: "6:30AM–8PM" })]
|
|
476
|
+
})]
|
|
477
|
+
})]
|
|
478
|
+
}),
|
|
479
|
+
ad?.city && /* @__PURE__ */ jsx("div", { className: "details mb-3 d-none" }),
|
|
480
|
+
/* @__PURE__ */ jsx("div", {
|
|
481
|
+
className: "short-description",
|
|
482
|
+
children: previewData?.description || ad?.description
|
|
483
|
+
})
|
|
484
|
+
]
|
|
485
|
+
})]
|
|
486
|
+
}),
|
|
487
|
+
userReduxState?.roles?.isDev && ad?.populated_promos?.length > 0 && /* @__PURE__ */ jsxs("div", { children: [promo && /* @__PURE__ */ jsx("div", {
|
|
488
|
+
className: "promos-wrap",
|
|
489
|
+
children: promo && /* @__PURE__ */ jsxs("div", {
|
|
490
|
+
className: "promo-wrap d-flex justify-content-between align-items-center mx-2 p-1 px-2 border border-2 border-light mb-0",
|
|
491
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
492
|
+
className: "",
|
|
493
|
+
children: [/* @__PURE__ */ jsx("div", { children: promo.title }), /* @__PURE__ */ jsx("div", {
|
|
494
|
+
className: "small",
|
|
495
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
496
|
+
className: "small",
|
|
497
|
+
children: promo.details
|
|
498
|
+
})
|
|
499
|
+
})]
|
|
500
|
+
}), /* @__PURE__ */ jsx(ArticlesButton, {
|
|
501
|
+
className: "px-3",
|
|
502
|
+
small: true,
|
|
503
|
+
onClick: () => {
|
|
504
|
+
console.log("Load Save Modal");
|
|
505
|
+
setModalShow(true);
|
|
506
|
+
},
|
|
507
|
+
children: "Save"
|
|
508
|
+
})]
|
|
509
|
+
}, promo._id)
|
|
510
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
511
|
+
className: "d-flex justify-content-between",
|
|
512
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
513
|
+
className: "px-2",
|
|
514
|
+
children: [ad?.populated_promos?.length, " Promos Active"]
|
|
515
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
516
|
+
className: "controls",
|
|
517
|
+
children: [
|
|
518
|
+
/* @__PURE__ */ jsx("i", {
|
|
519
|
+
className: "fad fa-arrow-circle-left",
|
|
520
|
+
type: "button",
|
|
521
|
+
onClick: () => {
|
|
522
|
+
if (promoIndex == 0) setPromoIndex(ad?.populated_promos?.length - 1);
|
|
523
|
+
else setPromoIndex((prev) => prev - 1);
|
|
524
|
+
}
|
|
525
|
+
}),
|
|
526
|
+
ad?.populated_promos?.map((obj, obj_i) => /* @__PURE__ */ jsx("i", { className: `fa-square ${obj_i == promoIndex ? "fad" : "fas"}` }, obj._id)),
|
|
527
|
+
/* @__PURE__ */ jsx("i", {
|
|
528
|
+
className: "fad fa-arrow-circle-right",
|
|
529
|
+
type: "button",
|
|
530
|
+
onClick: () => {
|
|
531
|
+
if (promoIndex == ad?.populated_promos?.length - 1) setPromoIndex(0);
|
|
532
|
+
else setPromoIndex((prev) => prev + 1);
|
|
533
|
+
}
|
|
534
|
+
})
|
|
535
|
+
]
|
|
536
|
+
})]
|
|
537
|
+
})] }),
|
|
538
|
+
/* @__PURE__ */ jsx("hr", {
|
|
539
|
+
style: { borderColor: "white" },
|
|
540
|
+
className: "mt-auto mb-0"
|
|
541
|
+
}),
|
|
542
|
+
/* @__PURE__ */ jsxs("div", {
|
|
543
|
+
className: "action-wrap d-flex justify-content-lg-between px-3 py-2",
|
|
544
|
+
children: [
|
|
545
|
+
/* @__PURE__ */ jsx("div", {
|
|
546
|
+
onClick: () => {
|
|
547
|
+
adDetailsExpandedToggle();
|
|
548
|
+
logEvent("Details");
|
|
549
|
+
},
|
|
550
|
+
className: "action flex-grow-1 flex-shrink-0",
|
|
551
|
+
children: "Details"
|
|
552
|
+
}),
|
|
553
|
+
/* @__PURE__ */ jsx("span", { className: "px-4" }),
|
|
554
|
+
/* @__PURE__ */ jsx("a", {
|
|
555
|
+
className: "action flex-grow-1 flex-shrink-0",
|
|
556
|
+
href: ad?.website,
|
|
557
|
+
target: "_blank",
|
|
558
|
+
rel: "noreferrer",
|
|
559
|
+
onClick: (e) => {
|
|
560
|
+
e.preventDefault();
|
|
561
|
+
setConfirmAdExitModal(true);
|
|
562
|
+
logEvent("Confirm Exit Modal Opened");
|
|
563
|
+
},
|
|
564
|
+
children: /* @__PURE__ */ jsx("div", { children: "Website" })
|
|
565
|
+
})
|
|
566
|
+
]
|
|
567
|
+
})
|
|
568
|
+
]
|
|
569
|
+
}), userDetails?.articles_membership?.status == "Active" && /* @__PURE__ */ jsx("div", {
|
|
570
|
+
className: "main-panel",
|
|
571
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
572
|
+
className: "content-wrap",
|
|
573
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
574
|
+
className: "photo-banner",
|
|
575
|
+
children: [
|
|
576
|
+
/* @__PURE__ */ jsx("div", { className: "logo" }),
|
|
577
|
+
/* @__PURE__ */ jsxs("div", {
|
|
578
|
+
className: "splash",
|
|
579
|
+
children: [/* @__PURE__ */ jsx("i", { className: "fas fa-broadcast-tower" }), /* @__PURE__ */ jsxs("div", {
|
|
580
|
+
className: "text",
|
|
581
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
582
|
+
className: "count",
|
|
583
|
+
children: adsAvoidedLoading ? /* @__PURE__ */ jsx("i", { className: "fas fa-spinner fa-spin me-0" }) : adsAvoided ? numberWithCommas(adsAvoided) : 0
|
|
584
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
585
|
+
className: "label",
|
|
586
|
+
children: "ads avoided."
|
|
587
|
+
})]
|
|
588
|
+
})]
|
|
589
|
+
}),
|
|
590
|
+
/* @__PURE__ */ jsxs("div", {
|
|
591
|
+
className: "member-since",
|
|
592
|
+
children: ["Member since: ", /* @__PURE__ */ jsx(ArticlesDate, {
|
|
593
|
+
format: "PP",
|
|
594
|
+
date: userDetails?.articles_membership?.membership_started
|
|
595
|
+
})]
|
|
596
|
+
})
|
|
597
|
+
]
|
|
598
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
599
|
+
className: "details-wrap",
|
|
600
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
601
|
+
className: "detail-title",
|
|
602
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
603
|
+
className: "detail",
|
|
604
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
605
|
+
className: "h4",
|
|
606
|
+
children: "Thanks for the support!"
|
|
607
|
+
})
|
|
608
|
+
})
|
|
609
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
610
|
+
className: "short-description",
|
|
611
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
612
|
+
className: "mb-2",
|
|
613
|
+
children: "Without support from users like you, we wouldn't be here."
|
|
614
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
615
|
+
className: "links-list",
|
|
616
|
+
children: [
|
|
617
|
+
/* @__PURE__ */ jsxs(Link, {
|
|
618
|
+
newPage: true,
|
|
619
|
+
className: "link-item",
|
|
620
|
+
href: "https://articles.media/messages",
|
|
621
|
+
children: [/* @__PURE__ */ jsx("i", { className: "fas fa-comments-alt" }), "0 unread messages."]
|
|
622
|
+
}),
|
|
623
|
+
/* @__PURE__ */ jsxs(Link, {
|
|
624
|
+
newPage: true,
|
|
625
|
+
className: "link-item",
|
|
626
|
+
href: "https://articles.media/settings/notifications",
|
|
627
|
+
onClick: () => {
|
|
628
|
+
logAdAvoided();
|
|
629
|
+
},
|
|
630
|
+
children: [/* @__PURE__ */ jsx("i", { className: "fas fa-bell" }), "0 notifications."]
|
|
631
|
+
}),
|
|
632
|
+
/* @__PURE__ */ jsxs(Link, {
|
|
633
|
+
newPage: true,
|
|
634
|
+
className: "link-item",
|
|
635
|
+
href: "https://articles.media/settings/account",
|
|
636
|
+
children: [/* @__PURE__ */ jsx("i", { className: "fas fa-cog" }), "Manage account settings."]
|
|
637
|
+
})
|
|
638
|
+
]
|
|
639
|
+
})]
|
|
640
|
+
})]
|
|
641
|
+
})]
|
|
642
|
+
})
|
|
643
|
+
})]
|
|
644
|
+
}),
|
|
645
|
+
append && /* @__PURE__ */ jsx("div", {
|
|
646
|
+
className: "append-container",
|
|
647
|
+
children: append
|
|
648
|
+
}),
|
|
649
|
+
!previewMode && /* @__PURE__ */ jsx("div", {
|
|
650
|
+
className: "advertise-with-us p-1",
|
|
651
|
+
style: {
|
|
652
|
+
backgroundColor: previewData.background_color || ad?.background_color,
|
|
653
|
+
color: previewData.font_color || ad?.font_color,
|
|
654
|
+
borderColor: previewData.border_color || ad?.border_color
|
|
655
|
+
},
|
|
656
|
+
children: /* @__PURE__ */ jsxs(Link, {
|
|
657
|
+
className: "small d-block w-100 text-center",
|
|
658
|
+
href: "https://articles.media/advertising",
|
|
659
|
+
newPage: true,
|
|
660
|
+
children: [/* @__PURE__ */ jsx("i", { className: "fas fa-share me-1" }), "Advertise with Articles Media!"]
|
|
661
|
+
})
|
|
662
|
+
})
|
|
663
|
+
]
|
|
664
|
+
});
|
|
665
|
+
}
|
|
666
|
+
var Ad_default = memo(Ad);
|
|
667
|
+
//#endregion
|
|
668
|
+
export { Ad_default as t };
|
package/dist/Ad.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as
|
|
2
|
-
export {
|
|
1
|
+
import { t as Ad_default } from "./Ad-BsG4C_lR.js";
|
|
2
|
+
export { Ad_default as default };
|