@mundogamernetwork/shared-ui 1.17.18 → 1.18.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.
Files changed (56) hide show
  1. package/README.md +23 -0
  2. package/assets/kit/kit-base.css +47 -0
  3. package/assets/whats-new/tokens.css +43 -0
  4. package/components/MediaKit/MgRateCardBundleEditor.vue +2 -7
  5. package/components/MediaKit/MgRateCardEditor.vue +1 -1
  6. package/components/keys/KeyBrowser.vue +4 -9
  7. package/components/keys/KeyCampaignDashboardCard.vue +1 -1
  8. package/components/playtest/PlaytestInviteLanding.vue +17 -6
  9. package/components/ui/MgBanners.vue +13 -0
  10. package/components/ui/MgLoginModal.vue +1 -1
  11. package/components/whats-new/MgWhatsNewDialog.vue +552 -0
  12. package/components/whats-new/MgWhatsNewMedia.vue +242 -0
  13. package/components/whats-new/MgWhatsNewModal.vue +285 -0
  14. package/components/whats-new/MgWhatsNewRichText.vue +90 -0
  15. package/composables/useForceLogout.ts +0 -1
  16. package/composables/useLogout.ts +0 -2
  17. package/composables/useMgCheckout.ts +0 -1
  18. package/error.vue +1 -1
  19. package/locales/de.json +6 -0
  20. package/locales/en.json +6 -0
  21. package/locales/es.json +6 -0
  22. package/locales/pt-BR.json +6 -0
  23. package/locales/ro.json +6 -0
  24. package/nuxt.config.ts +11 -2
  25. package/package.json +5 -11
  26. package/pages/[slug]/index.vue +1 -1
  27. package/pages/about.vue +1 -1
  28. package/pages/blog.vue +1 -1
  29. package/pages/careers.vue +1 -1
  30. package/pages/contact.vue +8 -14
  31. package/pages/faq.vue +1 -1
  32. package/pages/key-campaigns/index.vue +1 -1
  33. package/pages/key-campaigns/redeem-key.vue +5 -11
  34. package/pages/magazine/[slug]/index.vue +1 -1
  35. package/pages/magazine/[slug]/preview.vue +2 -2
  36. package/pages/magazine/index.vue +3 -2
  37. package/pages/partners.vue +1 -1
  38. package/pages/press.vue +1 -1
  39. package/pages/presskit/game/[slug].vue +29 -1
  40. package/pages/roadmap.vue +1 -1
  41. package/pages/status.vue +1 -1
  42. package/pages/team.vue +1 -1
  43. package/pages/whats-new-preview.vue +96 -0
  44. package/services/campaignService.ts +0 -1
  45. package/services/creatorNetworkProgramService.ts +47 -0
  46. package/services/documentService.ts +16 -4
  47. package/services/httpService.ts +2 -2
  48. package/services/institutionalService.ts +1 -1
  49. package/stores/whatsNew.ts +170 -0
  50. package/types/index.ts +0 -3
  51. package/utils/clearSession.ts +0 -1
  52. package/utils/keyRequestError.ts +54 -0
  53. package/utils/whatsNew.ts +300 -0
  54. package/utils/whatsNewMessages.ts +133 -0
  55. package/utils/whatsNewText.ts +10 -0
  56. package/types/echo.d.ts +0 -7
package/README.md CHANGED
@@ -175,6 +175,29 @@ mgSharedUi: {
175
175
 
176
176
  ---
177
177
 
178
+ ### Novidades da Rede (`MgWhatsNewModal`)
179
+
180
+ Modal "What's New" gerenciado pelo admin da rede (contrato: `GET /whats-new/pending` e `POST /whats-new/receipts` da api-main). O `<MgBanners />` já o monta, então os fronts não editam layout. Configure no `nuxt.config.ts` do front:
181
+
182
+ ```ts
183
+ runtimeConfig: { public: { mgSharedUi: { whatsNew: {
184
+ enabled: true, // false desliga neste front
185
+ allowedRoutes: ["/feed", "/dashboard"], // vazio = qualquer rota logada não bloqueada
186
+ blockedRoutes: ["/wallet"], // soma-se às embutidas
187
+ } } } }
188
+ ```
189
+
190
+ Também pode ser usado direto: `<MgWhatsNewModal :suppress="meuModalAberto" :blocked-routes="['/wallet']" />` (props abaixo; `suppress` só existe no uso direto).
191
+
192
+ - O backend decide *o que* mostrar (0 ou 1 comunicado por chamada); o componente decide *quando*: logado, 2,5 s de ociosidade na rota, nenhum outro modal aberto, 1 por sessão e 24 h entre exibições. Sem comunicado na API, nada é renderizado, então o backend é a flag de liberação.
193
+ - Props: `suppress` (o front tem um modal/tour próprio aberto: o comunicado espera na fila; modais com `role=dialog aria-modal` e tours driver.js já são detectados sozinhos), `blocked-routes` (rotas extras onde nunca interrompe, somadas às embutidas: login, cadastro, checkout, pagamento, criar/publicar/upload), `allowed-routes` (lista branca opcional; use em layouts compartilhados com páginas públicas), `logged-in` (sobrescreve a detecção via `useAuthStore().signedIn`), `has-route` (checa se uma rota interna existe; por padrão consulta o router. Atenção: `pages/[slug]` do shared-ui faz qualquer caminho de um segmento "existir").
194
+ - Plataforma: `runtimeConfig.public.mgSharedUi.systemId`; base da API: `networkBaseUrl`; idioma: vue-i18n (`ar-AE` é enviado como `ar`). O cache do comunicado é só em memória; só `device_id` (UUID aleatório) e a hora da última exibição ficam no `localStorage`.
195
+ - Textos fixos (Novidades, Fechar, Ver todas…) vivem em `utils/whatsNewMessages.ts` (en, pt-BR, de, es, ro, ar) e não dependem dos locales do app (vários fronts não mesclam os do shared-ui). Não mova para JSON em `locales/`: o `@nuxtjs/i18n` compila esses arquivos em AST.
196
+ - Cores: só tokens `--mg-wn-*` de `assets/whats-new/tokens.css` (claro padrão, escuro sob `.dark-mode`). Um front pode redefini-los no próprio tema.
197
+ - Texto do comunicado: `**negrito**` e `[texto](url)` (só `https://` ou `/caminho`), renderizados como nós Vue, sem `v-html`.
198
+ - Preview do admin: rota `/whats-new-preview` (noindex). O pai (iframe) envia `postMessage({ type: "mg-whats-new-preview", payload, theme?, lang? })` e recebe `{ type: "mg-whats-new-preview-ready" }`. Para QA: `/whats-new-preview?demo=image|video|embed|text&lang=pt-BR&theme=dark`.
199
+ - Testes: `yarn test` (vitest via npx) cobre markup seguro, rotas bloqueadas, elegibilidade, embeds e idiomas.
200
+
178
201
  ## Sobrescrita (Override)
179
202
 
180
203
  Por ser um Nuxt Layer, qualquer arquivo pode ser sobrescrito no app consumidor. Basta criar o arquivo com o mesmo caminho:
@@ -177,6 +177,53 @@ body:has(.kit-press) {
177
177
  color: var(--kit-text, #f4f6fa);
178
178
  border: 1px solid rgba(255,255,255,0.18);
179
179
  }
180
+ .kit-btn-outline-accent {
181
+ background: transparent;
182
+ color: var(--kit-accent);
183
+ border: 1px solid var(--kit-accent);
184
+ }
185
+
186
+ /* ── Creator Network program (offered while it has a seat to give) ── */
187
+ .kit-program-pill {
188
+ display: inline-flex;
189
+ align-items: center;
190
+ gap: 8px;
191
+ width: fit-content;
192
+ padding: 4px 10px;
193
+ font-size: 0.72rem;
194
+ font-weight: 700;
195
+ letter-spacing: 1.5px;
196
+ text-transform: uppercase;
197
+ text-decoration: none;
198
+ color: var(--kit-accent);
199
+ border: 1px solid var(--kit-accent);
200
+ background: color-mix(in srgb, var(--kit-accent) 12%, transparent);
201
+ }
202
+ .kit-program-pill:hover { background: color-mix(in srgb, var(--kit-accent) 22%, transparent); }
203
+ .kit-program-dot {
204
+ width: 8px;
205
+ height: 8px;
206
+ background: var(--kit-accent);
207
+ animation: kit-program-pulse 2s ease-in-out infinite;
208
+ }
209
+ @keyframes kit-program-pulse { 50% { opacity: 0.35; } }
210
+ @media (prefers-reduced-motion: reduce) { .kit-program-dot { animation: none; } }
211
+ .kit-program-card {
212
+ display: flex;
213
+ align-items: center;
214
+ justify-content: space-between;
215
+ gap: 24px;
216
+ padding: 24px;
217
+ background: var(--kit-surface);
218
+ border: 1px solid var(--kit-line);
219
+ border-left: 3px solid var(--kit-accent);
220
+ }
221
+ .kit-program-card p { margin: 0; max-width: 60ch; line-height: 1.6; color: var(--kit-text); }
222
+ .kit-program-card .kit-btn { flex: none; }
223
+ @media (max-width: 720px) {
224
+ .kit-program-card { flex-direction: column; align-items: stretch; }
225
+ .kit-program-card .kit-btn { text-align: center; }
226
+ }
180
227
 
181
228
  /* ── Content wrapper ────────────────────────────────────────────────*/
182
229
  .kit-wrap {
@@ -0,0 +1,43 @@
1
+ /*
2
+ * Theme tokens of the What's New modal. Colours live ONLY here; the component
3
+ * reads them through var(--mg-wn-*) with no literal fallback. A front can
4
+ * restyle the modal by redefining any of these in its own theme.
5
+ * Light is the default; the dark values apply under @nuxtjs/color-mode's
6
+ * `.dark-mode` class (every front sets colorMode.preference).
7
+ */
8
+ :root,
9
+ .light-mode {
10
+ --mg-wn-overlay: rgba(11, 11, 20, 0.55);
11
+ --mg-wn-surface: #ffffff;
12
+ --mg-wn-surface-2: #f2f3f7;
13
+ --mg-wn-text: #1d2030;
14
+ --mg-wn-text-muted: #4f566b;
15
+ --mg-wn-border: #dcdfe8;
16
+ --mg-wn-accent: #3b38c4;
17
+ --mg-wn-on-accent: #ffffff;
18
+ --mg-wn-success: #146c43;
19
+ --mg-wn-warning: #8a4f00;
20
+ --mg-wn-neutral: #4f566b;
21
+ --mg-wn-media-bg: #1d2030;
22
+ --mg-wn-media-control-bg: rgba(0, 0, 0, 0.66);
23
+ --mg-wn-media-control-fg: #ffffff;
24
+ --mg-wn-shadow: rgba(0, 0, 0, 0.28);
25
+ }
26
+
27
+ .dark-mode {
28
+ --mg-wn-overlay: rgba(0, 0, 0, 0.66);
29
+ --mg-wn-surface: #1c1d2b;
30
+ --mg-wn-surface-2: #262838;
31
+ --mg-wn-text: #eceef8;
32
+ --mg-wn-text-muted: #a9aec6;
33
+ --mg-wn-border: #383b52;
34
+ --mg-wn-accent: #a3a1ff;
35
+ --mg-wn-on-accent: #12121c;
36
+ --mg-wn-success: #5fd199;
37
+ --mg-wn-warning: #f0b45a;
38
+ --mg-wn-neutral: #a9aec6;
39
+ --mg-wn-media-bg: #0c0c14;
40
+ --mg-wn-media-control-bg: rgba(0, 0, 0, 0.72);
41
+ --mg-wn-media-control-fg: #ffffff;
42
+ --mg-wn-shadow: rgba(0, 0, 0, 0.6);
43
+ }
@@ -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 getBundleRateCards(bundle)" :key="item.id" class="bundle-item-tag">
147
+ <span v-for="item in bundle.rate_cards?.data || bundle.rate_cards || []" :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,12 +297,7 @@ onMounted(() => {
297
297
  });
298
298
 
299
299
  function qtyFor(id: number): number {
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 : [];
300
+ return form.value.quantities[id] || 1;
306
301
  }
307
302
  function setQty(id: number, value: number) {
308
303
  form.value.quantities = { ...form.value.quantities, [id]: Math.max(1, value || 1) };
@@ -315,7 +315,7 @@ const saveRateCard = async () => {
315
315
  Object.keys(rateCardErrors).forEach(k => delete rateCardErrors[k]);
316
316
  if (!form.value.content_format_id) rateCardErrors.content_format_id = 'required';
317
317
  if (!form.value.ad_channel_id) rateCardErrors.ad_channel_id = 'required';
318
- if (!form.value.price_min) rateCardErrors.price_min = 'required';
318
+ if (!form.value.price_min && form.value.price_min !== 0) rateCardErrors.price_min = 'required';
319
319
  if (Object.keys(rateCardErrors).length) return;
320
320
 
321
321
  saving.value = true;
@@ -10,6 +10,7 @@ import {
10
10
  type RevealResult,
11
11
  } from '../../services/keyService'
12
12
  import httpService, { mgApiUrl } from '../../services/httpService'
13
+ import { keyRequestErrorMessage } from '../../utils/keyRequestError'
13
14
 
14
15
  const { t } = useI18n()
15
16
 
@@ -140,18 +141,12 @@ async function doRequestKey(pool: KeyCampaign) {
140
141
  }
141
142
  } catch (err: any) {
142
143
  const status = err?.response?.status
143
- const errorCode = err?.response?.data?.error_code
144
+ let specific: ReturnType<typeof keyRequestErrorMessage> = null
144
145
 
145
146
  if (status === 401) {
146
147
  isAuthenticated.value = false
147
- } else if (status === 409) {
148
- requestErrors.value[pool.id] = t('keys.campaigns.error_duplicate')
149
- } else if (status === 403 && errorCode === 'user_key_blocked') {
150
- requestErrors.value[pool.id] = t('keys.campaigns.error_user_blocked')
151
- } else if (status === 403) {
152
- requestErrors.value[pool.id] = t('keys.campaigns.error_not_eligible')
153
- } else if (status === 422 && errorCode === 'pending_limit_reached') {
154
- requestErrors.value[pool.id] = t('keys.campaigns.error_pending_limit')
148
+ } else if ((specific = keyRequestErrorMessage(err))) {
149
+ requestErrors.value[pool.id] = t(specific.key, specific.params ?? {})
155
150
  } else {
156
151
  requestErrors.value[pool.id] =
157
152
  err?.response?.data?.message || t('keys.campaigns.error_request')
@@ -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 : String((card.type as any)?.name ?? "") }}
198
+ {{ typeof card.type === "string" ? card.type : card.type.name }}
199
199
  </span>
200
200
  </div>
201
201
  </div>
@@ -30,6 +30,12 @@ const props = defineProps<{
30
30
  /** Route to the campaign for a visitor who is already signed in. */
31
31
  campaignPath: string;
32
32
  signedIn?: boolean;
33
+ /**
34
+ * Hide the built-in join/open button. A page that records the invitee's
35
+ * answer itself (accept / decline) passes this so there is one decision
36
+ * point instead of a button that never records anything next to the real ones.
37
+ */
38
+ hideCta?: boolean;
33
39
  }>();
34
40
 
35
41
  const { t } = useI18n();
@@ -106,12 +112,14 @@ onMounted(async () => {
106
112
  </div>
107
113
 
108
114
  <!-- Someone already signed in has no reason to see a signup CTA. -->
109
- <NuxtLink v-if="signedIn" :to="campaignPath" class="pil__cta">
110
- {{ t('playtest_invite.cta_open') }}
111
- </NuxtLink>
112
- <a v-else :href="registerUrl" class="pil__cta">
113
- {{ t('playtest_invite.cta_join') }}
114
- </a>
115
+ <template v-if="!hideCta">
116
+ <NuxtLink v-if="signedIn" :to="campaignPath" class="pil__cta">
117
+ {{ t('playtest_invite.cta_open') }}
118
+ </NuxtLink>
119
+ <a v-else :href="registerUrl" class="pil__cta">
120
+ {{ t('playtest_invite.cta_join') }}
121
+ </a>
122
+ </template>
115
123
 
116
124
  <!-- Stated plainly rather than discovered at the end of a signup:
117
125
  taking part needs an account because the reward is paid into a
@@ -133,6 +141,9 @@ onMounted(async () => {
133
141
 
134
142
  <style scoped lang="scss">
135
143
  .pil {
144
+ // Set explicitly: it used to inherit whatever the host page had, which in the dark
145
+ // theme left the body copy dark grey on near-black.
146
+ color: var(--text-primary, #fff);
136
147
  margin: 0 auto;
137
148
  max-width: 640px;
138
149
  padding: 40px 20px 64px;
@@ -12,6 +12,14 @@ onMounted(async () => {
12
12
  });
13
13
 
14
14
  const { isVisible: announcementVisible } = storeToRefs(announcementStore);
15
+
16
+ // "Novidades da Rede" rides along with the banners: every front already mounts
17
+ // <MgBanners /> in its logged-in layouts, so the modal needs no layout edit.
18
+ // Per-front rules live in nuxt.config → runtimeConfig.public.mgSharedUi.whatsNew.
19
+ const whatsNewConfig: any = (useRuntimeConfig().public.mgSharedUi as any)?.whatsNew ?? {};
20
+ const whatsNewEnabled = whatsNewConfig.enabled !== false;
21
+ const whatsNewAllowed: string[] = whatsNewConfig.allowedRoutes ?? [];
22
+ const whatsNewBlocked: string[] = whatsNewConfig.blockedRoutes ?? [];
15
23
  </script>
16
24
 
17
25
  <template>
@@ -20,4 +28,9 @@ const { isVisible: announcementVisible } = storeToRefs(announcementStore);
20
28
  active/visible announcement. -->
21
29
  <MgAnnouncementBanner />
22
30
  <MgPromotionBanner v-if="!announcementVisible" />
31
+ <MgWhatsNewModal
32
+ v-if="whatsNewEnabled"
33
+ :allowed-routes="whatsNewAllowed"
34
+ :blocked-routes="whatsNewBlocked"
35
+ />
23
36
  </template>
@@ -35,7 +35,7 @@ const props = defineProps({
35
35
  });
36
36
 
37
37
  const registerUrl = computed(() =>
38
- buildRegisterUrl(String(accountsBaseUrl), undefined, String(systemId)),
38
+ buildRegisterUrl(accountsBaseUrl, undefined, systemId),
39
39
  );
40
40
 
41
41
  function close() {