@mundogamernetwork/shared-ui 1.19.0 → 1.19.1
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/components/MediaKit/MgRateCardBundleEditor.vue +7 -2
- package/components/keys/KeyCampaignDashboardCard.vue +1 -1
- package/components/ui/MgBanners.vue +3 -0
- package/components/ui/MgHeaderAvatarToggle.vue +26 -0
- package/components/ui/MgHeaderComponent.vue +0 -3
- package/components/ui/MgLoginModal.vue +1 -1
- package/components/whats-new/MgWhatsNewHistory.vue +8 -4
- package/error.vue +1 -1
- package/nuxt.config.ts +2 -0
- package/package.json +1 -1
- package/pages/key-campaigns/index.vue +1 -1
- package/pages/key-campaigns/redeem-key.vue +1 -1
- package/pages/magazine/[slug]/preview.vue +1 -1
- package/services/httpService.ts +2 -2
- package/services/institutionalService.ts +1 -1
- package/stores/whatsNew.ts +63 -14
- package/types/index.ts +3 -0
|
@@ -144,7 +144,7 @@
|
|
|
144
144
|
</div>
|
|
145
145
|
<p v-if="bundle.description" class="bundle-desc">{{ bundle.description }}</p>
|
|
146
146
|
<div class="bundle-items">
|
|
147
|
-
<span v-for="item in bundle
|
|
147
|
+
<span v-for="item in getBundleRateCards(bundle)" :key="item.id" class="bundle-item-tag">
|
|
148
148
|
{{ item.content_format?.name || item.label }}<template v-if="item.platform?.name"> · {{ item.platform.name }}</template>
|
|
149
149
|
</span>
|
|
150
150
|
</div>
|
|
@@ -297,7 +297,12 @@ onMounted(() => {
|
|
|
297
297
|
});
|
|
298
298
|
|
|
299
299
|
function qtyFor(id: number): number {
|
|
300
|
-
return form.value.quantities[id] || 1;
|
|
300
|
+
return (form.value.quantities as Record<number, number>)[id] || 1;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
function getBundleRateCards(bundle: any): any[] {
|
|
304
|
+
const cards = bundle?.rate_cards;
|
|
305
|
+
return Array.isArray(cards) ? cards : Array.isArray(cards?.data) ? cards.data : [];
|
|
301
306
|
}
|
|
302
307
|
function setQty(id: number, value: number) {
|
|
303
308
|
form.value.quantities = { ...form.value.quantities, [id]: Math.max(1, value || 1) };
|
|
@@ -195,7 +195,7 @@ const detailRoute = computed(() =>
|
|
|
195
195
|
<svg xmlns="http://www.w3.org/2000/svg" width="12" height="13" viewBox="0 0 16 17" fill="none">
|
|
196
196
|
<path d="M13.3333 4.1112L12.8666 3.64453L11.9333 4.57786L10.9333 3.64453L8.33329 4.1112L2.66663 9.77786L7.19996 14.3112L12.8666 8.64453L13.3333 6.04453L12.4 5.1112L13.3333 4.1112ZM12.6 6.24453L12.2666 8.3112L7.19996 13.3779L3.59996 9.77786L8.66663 4.7112L10.7333 4.3112L11.4666 5.04453L11 5.5112L10.5333 5.04453L9.99996 5.57786L11.4 6.97786L11.8666 6.5112L11.4 6.04453L11.8666 5.57786L12.6 6.24453Z" fill="#D297FF"/>
|
|
197
197
|
</svg>
|
|
198
|
-
{{ typeof card.type === "string" ? card.type : card.type
|
|
198
|
+
{{ typeof card.type === "string" ? card.type : String((card.type as any)?.name ?? "") }}
|
|
199
199
|
</span>
|
|
200
200
|
</div>
|
|
201
201
|
</div>
|
|
@@ -33,4 +33,7 @@ const whatsNewBlocked: string[] = whatsNewConfig.blockedRoutes ?? [];
|
|
|
33
33
|
:allowed-routes="whatsNewAllowed"
|
|
34
34
|
:blocked-routes="whatsNewBlocked"
|
|
35
35
|
/>
|
|
36
|
+
<!-- The "Novidades" history (drawer + reopened announcement) lives here too: the fronts build their own headers out of
|
|
37
|
+
MgHeaderAvatarToggle + MgHeaderUIUser, so the host cannot ride on a layer header. It renders nothing until opened. -->
|
|
38
|
+
<MgWhatsNewHistory v-if="whatsNewEnabled" />
|
|
36
39
|
</template>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { storeToRefs } from "pinia";
|
|
3
|
+
import { formatBadge } from "../../utils/whatsNew";
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* The account-menu toggle icon in the header top bar (not the dropdown
|
|
@@ -26,6 +27,13 @@ const { user, signedIn } = storeToRefs(authStore);
|
|
|
26
27
|
// defensively instead of destructuring: a host whose store doesn't expose
|
|
27
28
|
// it treats the state as already known, skipping the skeleton rather than
|
|
28
29
|
// getting stuck showing it forever.
|
|
30
|
+
// "Novidades" history: the unread number rides on the avatar, wherever the host draws this toggle. Shown only when the
|
|
31
|
+
// drawer host is mounted (MgBanners does it) and the user is signed in; the number comes from the history store.
|
|
32
|
+
const whatsNewStore = useWhatsNewStore();
|
|
33
|
+
const whatsNewBadge = computed(() =>
|
|
34
|
+
signedIn.value && whatsNewStore.hostMounted ? formatBadge(whatsNewStore.unread) : "",
|
|
35
|
+
);
|
|
36
|
+
|
|
29
37
|
const initialized = computed(() => {
|
|
30
38
|
const raw = (authStore as unknown as { initialized?: boolean }).initialized;
|
|
31
39
|
return raw === undefined ? true : raw;
|
|
@@ -49,6 +57,7 @@ const initialized = computed(() => {
|
|
|
49
57
|
alt=""
|
|
50
58
|
@error="(e: Event) => { const t = e.target as HTMLImageElement; if (t) { t.onerror = null; t.src = '/imgs/default-avatar.png' } }"
|
|
51
59
|
/>
|
|
60
|
+
<span v-if="whatsNewBadge" class="mg-wn-avatar-badge" aria-hidden="true">{{ whatsNewBadge }}</span>
|
|
52
61
|
<template #fallback>
|
|
53
62
|
<div
|
|
54
63
|
class="mg-avatar-skeleton"
|
|
@@ -81,6 +90,23 @@ const initialized = computed(() => {
|
|
|
81
90
|
}
|
|
82
91
|
}
|
|
83
92
|
|
|
93
|
+
// Positioned against the host's avatar wrapper (every host's menu item is position:relative).
|
|
94
|
+
.mg-wn-avatar-badge {
|
|
95
|
+
position: absolute;
|
|
96
|
+
top: -4px;
|
|
97
|
+
inset-inline-end: -4px;
|
|
98
|
+
min-width: 16px;
|
|
99
|
+
height: 16px;
|
|
100
|
+
padding: 0 4px;
|
|
101
|
+
font-size: 0.625rem;
|
|
102
|
+
font-weight: 700;
|
|
103
|
+
line-height: 16px;
|
|
104
|
+
text-align: center;
|
|
105
|
+
color: var(--mg-wn-on-accent);
|
|
106
|
+
background: var(--mg-wn-accent);
|
|
107
|
+
pointer-events: none;
|
|
108
|
+
}
|
|
109
|
+
|
|
84
110
|
.mg-avatar-img {
|
|
85
111
|
display: block;
|
|
86
112
|
// Host apps wrap this in a fixed-size clickable link/button and expect
|
|
@@ -144,9 +144,6 @@ onMounted(() => {
|
|
|
144
144
|
/>
|
|
145
145
|
</transition>
|
|
146
146
|
|
|
147
|
-
<!-- Drawer + reopened announcement of the "Novidades" history: outside the dropdown so they outlive it. -->
|
|
148
|
-
<MgWhatsNewHistory v-if="signedIn" />
|
|
149
|
-
|
|
150
147
|
<transition name="fade">
|
|
151
148
|
<MgNotificationsModal
|
|
152
149
|
v-if="showNotifications"
|
|
@@ -38,14 +38,18 @@ const enabled = cfg.enabled !== false && cfg.history !== false && configured;
|
|
|
38
38
|
const uiLocale = computed(() => i18nLocale.value || "en");
|
|
39
39
|
const identity = computed(() => (signedIn.value ? String(user.value?.uuid ?? user.value?.id ?? "user") : null));
|
|
40
40
|
|
|
41
|
+
const hostId = Math.random().toString(36).slice(2, 10);
|
|
42
|
+
// Only the first mounted host renders: a layout switch (or two layouts) must never open two drawers.
|
|
43
|
+
const isOwner = computed(() => store.hosts[0] === hostId);
|
|
44
|
+
|
|
41
45
|
onMounted(() => {
|
|
42
46
|
if (!enabled) return;
|
|
43
|
-
store.
|
|
47
|
+
store.registerHost(hostId);
|
|
44
48
|
if (identity.value) store.fetchUnread(identity.value);
|
|
45
49
|
});
|
|
46
50
|
|
|
47
51
|
onBeforeUnmount(() => {
|
|
48
|
-
store.
|
|
52
|
+
store.unregisterHost(hostId);
|
|
49
53
|
});
|
|
50
54
|
|
|
51
55
|
watch(identity, (id) => {
|
|
@@ -97,7 +101,7 @@ function onVideoPlay() {
|
|
|
97
101
|
<ClientOnly>
|
|
98
102
|
<Teleport to="body">
|
|
99
103
|
<MgWhatsNewDrawer
|
|
100
|
-
v-if="enabled && signedIn && store.drawerOpen"
|
|
104
|
+
v-if="enabled && signedIn && isOwner && store.drawerOpen"
|
|
101
105
|
:locale="uiLocale"
|
|
102
106
|
@close="store.closeDrawer()"
|
|
103
107
|
@open="onOpen"
|
|
@@ -105,7 +109,7 @@ function onVideoPlay() {
|
|
|
105
109
|
@retry="store.fetchHistory(uiLocale, 1)"
|
|
106
110
|
/>
|
|
107
111
|
<MgWhatsNewDialog
|
|
108
|
-
v-if="enabled && signedIn && store.viewing"
|
|
112
|
+
v-if="enabled && signedIn && isOwner && store.viewing"
|
|
109
113
|
:post="store.viewing"
|
|
110
114
|
:locale="uiLocale"
|
|
111
115
|
:resolve-internal="resolveInternal"
|
package/error.vue
CHANGED
|
@@ -12,7 +12,7 @@ interface CustomError {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
const error = useError();
|
|
15
|
-
const statusCodeError = Number((error.value as CustomError)?.statusCode) || 404;
|
|
15
|
+
const statusCodeError = Number((error.value as unknown as CustomError)?.statusCode) || 404;
|
|
16
16
|
|
|
17
17
|
// Do NOT call getUser() on error page — causes infinite loop when API is down or token expired
|
|
18
18
|
|
package/nuxt.config.ts
CHANGED
|
@@ -141,6 +141,8 @@ export default defineNuxtConfig({
|
|
|
141
141
|
agencyBaseUrl: "", // VITE_BASE_URL_AGENCY — used for "create your press kit" CTA link
|
|
142
142
|
accountsBaseUrl: "", // VITE_BASE_ACCOUNTS_URL
|
|
143
143
|
networkBaseUrl: "", // VITE_BASE_URL_NETWORK (institutional APIs)
|
|
144
|
+
communityApiUrl: "", // VITE_BASE_URL_COMMUNITY (community API)
|
|
145
|
+
communitySiteUrl: "", // VITE_BASE_URL_COMMUNITY_FRONT (community frontend)
|
|
144
146
|
// Per-platform pricing/plans page. Left empty, the account menu's
|
|
145
147
|
// "Plans & Pricing" link is hidden — set it per front (e.g.
|
|
146
148
|
// `${localePath}/pricing`) since each front's plans page lives at a
|
package/package.json
CHANGED
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
<FormAppSelect
|
|
70
70
|
id="keyCampaignsPlatformFilter"
|
|
71
71
|
:model="activePlatformFilter ?? ''"
|
|
72
|
-
@update:model="(val) => setPlatformFilter(val ? Number(val) : null)"
|
|
72
|
+
@update:model="(val: string | number) => setPlatformFilter(val ? Number(val) : null)"
|
|
73
73
|
:label="$t('keys.campaigns.all')"
|
|
74
74
|
:options="platformList.map((p) => [p.id, platformAbbr(p.name)])"
|
|
75
75
|
/>
|
|
@@ -88,7 +88,7 @@ onMounted(async () => {
|
|
|
88
88
|
fetchKeyRegions(keyId),
|
|
89
89
|
fetchAvailableOptions(keyId).catch(() => null),
|
|
90
90
|
])
|
|
91
|
-
|
|
91
|
+
campaign.value = (campaignRes as any)?.data?.data || (campaignRes as any)?.data || null
|
|
92
92
|
const allPlatforms = platformsRes?.data?.data || platformsRes?.data || []
|
|
93
93
|
const allRegions = regionsRes?.data?.data || regionsRes?.data || []
|
|
94
94
|
|
package/services/httpService.ts
CHANGED
|
@@ -134,13 +134,13 @@ export function mgApiUrl(endpoint: string, usePrefix = true) {
|
|
|
134
134
|
case "login":
|
|
135
135
|
case "logout":
|
|
136
136
|
case "register":
|
|
137
|
-
return [apiBaseURL, usePrefix ? locale : "", endpoint]
|
|
137
|
+
return ([apiBaseURL, usePrefix ? locale : "", endpoint] as string[])
|
|
138
138
|
.filter((v) => v)
|
|
139
139
|
.map((part) => part.replace(/^\//, ""))
|
|
140
140
|
.map((part) => part.replace(/\/api\/v1$/, ""))
|
|
141
141
|
.join("/");
|
|
142
142
|
default:
|
|
143
|
-
return [apiBaseURL, usePrefix ? locale : "", endpoint]
|
|
143
|
+
return ([apiBaseURL, usePrefix ? locale : "", endpoint] as string[])
|
|
144
144
|
.filter((v) => v)
|
|
145
145
|
.map((part) => part.replace(/^\//, ""))
|
|
146
146
|
.join("/");
|
|
@@ -31,7 +31,7 @@ export const complexSerialize = function (obj: SerializeObject): string {
|
|
|
31
31
|
if (typeof value === "object" && value !== null) {
|
|
32
32
|
appendObject(`${baseKey}[${key}]`, value);
|
|
33
33
|
} else {
|
|
34
|
-
searchParams.append(`${baseKey}[${key}]`, value
|
|
34
|
+
searchParams.append(`${baseKey}[${key}]`, String(value));
|
|
35
35
|
}
|
|
36
36
|
});
|
|
37
37
|
};
|
package/stores/whatsNew.ts
CHANGED
|
@@ -70,6 +70,10 @@ export const useWhatsNewStore = defineStore("whats-new-store", {
|
|
|
70
70
|
drawerOpen: false,
|
|
71
71
|
// <MgWhatsNewHistory /> is mounted: the menu entry only shows when something can open the drawer.
|
|
72
72
|
hostMounted: false,
|
|
73
|
+
// ids of the mounted hosts, first = the one that renders the drawer (a layout switch can briefly mount two)
|
|
74
|
+
hosts: [] as string[],
|
|
75
|
+
// language the list was last loaded in, so a silent refresh can reload it the same way
|
|
76
|
+
historyLocale: "" as string,
|
|
73
77
|
history: [] as WnHistoryItem[],
|
|
74
78
|
historyMeta: null as WnHistoryMeta | null,
|
|
75
79
|
historyStatus: "idle" as "idle" | "loading" | "loadingMore" | "error",
|
|
@@ -169,6 +173,16 @@ export const useWhatsNewStore = defineStore("whats-new-store", {
|
|
|
169
173
|
|
|
170
174
|
// ── history ───────────────────────────────────────────────────────────
|
|
171
175
|
|
|
176
|
+
registerHost(id: string) {
|
|
177
|
+
if (!this.hosts.includes(id)) this.hosts.push(id);
|
|
178
|
+
this.hostMounted = true;
|
|
179
|
+
},
|
|
180
|
+
|
|
181
|
+
unregisterHost(id: string) {
|
|
182
|
+
this.hosts = this.hosts.filter((h) => h !== id);
|
|
183
|
+
this.hostMounted = this.hosts.length > 0;
|
|
184
|
+
},
|
|
185
|
+
|
|
172
186
|
resetHistory() {
|
|
173
187
|
this.unread = 0;
|
|
174
188
|
this.unreadFor = null;
|
|
@@ -205,11 +219,56 @@ export const useWhatsNewStore = defineStore("whats-new-store", {
|
|
|
205
219
|
}
|
|
206
220
|
},
|
|
207
221
|
|
|
208
|
-
/**
|
|
222
|
+
/**
|
|
223
|
+
* A moment after a `view` the server may have retired older announcements too: re-read the badge and, when the
|
|
224
|
+
* list is loaded, the list itself, so no row keeps a "new" mark the badge no longer counts.
|
|
225
|
+
*/
|
|
209
226
|
refreshUnreadSoon() {
|
|
210
227
|
const identity = this.unreadFor;
|
|
211
228
|
if (!identity || typeof window === "undefined") return;
|
|
212
|
-
setTimeout(() =>
|
|
229
|
+
setTimeout(async () => {
|
|
230
|
+
await this.fetchUnread(identity, true);
|
|
231
|
+
await this.refreshHistorySilently();
|
|
232
|
+
}, 2500);
|
|
233
|
+
},
|
|
234
|
+
|
|
235
|
+
/** Reloads the pages already shown without flipping the drawer to its loading state. */
|
|
236
|
+
async refreshHistorySilently() {
|
|
237
|
+
const { networkBaseUrl, platformId } = getConfig();
|
|
238
|
+
if (!networkBaseUrl || !platformId || !this.history.length || !this.historyLocale) return;
|
|
239
|
+
if (this.historyStatus !== "idle") return;
|
|
240
|
+
const pages = Math.max(1, this.historyMeta?.page ?? 1);
|
|
241
|
+
const rows: WnHistoryItem[] = [];
|
|
242
|
+
let meta: WnHistoryMeta | null = null;
|
|
243
|
+
try {
|
|
244
|
+
for (let page = 1; page <= pages; page++) {
|
|
245
|
+
const res: any = await this.requestHistoryPage(this.historyLocale, page);
|
|
246
|
+
rows.push(...(Array.isArray(res?.data) ? res.data : []));
|
|
247
|
+
meta = res?.meta ?? meta;
|
|
248
|
+
}
|
|
249
|
+
} catch {
|
|
250
|
+
return; // keep what is on screen
|
|
251
|
+
}
|
|
252
|
+
if (this.historyStatus !== "idle") return;
|
|
253
|
+
this.history = rows;
|
|
254
|
+
this.historyMeta = meta;
|
|
255
|
+
if (meta) this.unread = Math.max(0, Number(meta.unread_count ?? 0));
|
|
256
|
+
},
|
|
257
|
+
|
|
258
|
+
requestHistoryPage(locale: string, page: number) {
|
|
259
|
+
const { networkBaseUrl, platformId } = getConfig();
|
|
260
|
+
const params = new URLSearchParams({
|
|
261
|
+
platform_id: String(platformId),
|
|
262
|
+
surface: "web",
|
|
263
|
+
lang: toApiLang(locale),
|
|
264
|
+
page: String(page),
|
|
265
|
+
per_page: String(WN_HISTORY_PAGE),
|
|
266
|
+
});
|
|
267
|
+
return $fetch(`${networkBaseUrl}/whats-new?${params.toString()}`, {
|
|
268
|
+
credentials: "include",
|
|
269
|
+
timeout: 10000,
|
|
270
|
+
retry: 0,
|
|
271
|
+
});
|
|
213
272
|
},
|
|
214
273
|
|
|
215
274
|
/** The user has just seen post `id`: update the list row and the badge without waiting for the server. */
|
|
@@ -228,19 +287,9 @@ export const useWhatsNewStore = defineStore("whats-new-store", {
|
|
|
228
287
|
if (!networkBaseUrl || !platformId) return;
|
|
229
288
|
const append = page > 1;
|
|
230
289
|
this.historyStatus = append ? "loadingMore" : "loading";
|
|
290
|
+
this.historyLocale = locale;
|
|
231
291
|
try {
|
|
232
|
-
const
|
|
233
|
-
platform_id: String(platformId),
|
|
234
|
-
surface: "web",
|
|
235
|
-
lang: toApiLang(locale),
|
|
236
|
-
page: String(page),
|
|
237
|
-
per_page: String(WN_HISTORY_PAGE),
|
|
238
|
-
});
|
|
239
|
-
const res: any = await $fetch(`${networkBaseUrl}/whats-new?${params.toString()}`, {
|
|
240
|
-
credentials: "include",
|
|
241
|
-
timeout: 10000,
|
|
242
|
-
retry: 0,
|
|
243
|
-
});
|
|
292
|
+
const res: any = await this.requestHistoryPage(locale, page);
|
|
244
293
|
const rows: WnHistoryItem[] = Array.isArray(res?.data) ? res.data : [];
|
|
245
294
|
if (append) {
|
|
246
295
|
const known = new Set(this.history.map((h) => h.id));
|
package/types/index.ts
CHANGED
|
@@ -114,6 +114,8 @@ export interface MgSharedUiConfig {
|
|
|
114
114
|
systemId: string;
|
|
115
115
|
apiBaseURL: string;
|
|
116
116
|
accountsBaseUrl: string;
|
|
117
|
+
communityApiUrl?: string;
|
|
118
|
+
communitySiteUrl?: string;
|
|
117
119
|
features: {
|
|
118
120
|
chat: boolean;
|
|
119
121
|
notifications: boolean;
|
|
@@ -121,6 +123,7 @@ export interface MgSharedUiConfig {
|
|
|
121
123
|
darkMode: boolean;
|
|
122
124
|
search: boolean;
|
|
123
125
|
statusOnline: boolean;
|
|
126
|
+
gamification?: boolean;
|
|
124
127
|
};
|
|
125
128
|
languages: string[];
|
|
126
129
|
protectedRoutes: string[];
|