@mundogamernetwork/shared-ui 1.16.26 → 1.16.27

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.
@@ -7,17 +7,36 @@
7
7
  * instead of dead ends.
8
8
  */
9
9
 
10
+ // community-api's /feed/trending wraps the actual pulse/review/video fields
11
+ // in a nested `content` object — content_type/content_id/views are the only
12
+ // fields it puts at the top level (confirmed against the live response).
13
+ // A previous version of this component read title/slug/image/author off the
14
+ // top level directly, which is always undefined: every card silently fell
15
+ // back to the placeholder image and linked to ".../undefined".
10
16
  interface FeedItem {
11
- id: number;
12
- slug: string;
13
- title: string;
14
- url_image_src?: string;
15
- url_image?: string;
16
17
  content_type?: "pulse" | "review" | "video" | string;
17
- author?: { nickname?: string; name?: string };
18
- created_at_diff?: string;
18
+ content: {
19
+ id: number;
20
+ slug: string;
21
+ title: string;
22
+ url_image_src?: string;
23
+ url_image?: string;
24
+ author?: { nickname?: string; name?: string };
25
+ created_at_diff?: string;
26
+ };
19
27
  }
20
28
 
29
+ const CONTENT_TYPE_LABELS: Record<string, string> = {
30
+ pulse: "News",
31
+ review: "Review",
32
+ video: "Video",
33
+ };
34
+
35
+ const contentTypeLabel = (item: FeedItem): string => {
36
+ const type = item.content_type ?? "pulse";
37
+ return CONTENT_TYPE_LABELS[type] ?? type;
38
+ };
39
+
21
40
  const props = defineProps({
22
41
  limit: { type: Number, default: 4 },
23
42
  });
@@ -58,11 +77,11 @@ const articlePath = (item: FeedItem): string => {
58
77
  video: "videos",
59
78
  };
60
79
  const type = typeMap[item.content_type ?? "pulse"] ?? "articles";
61
- return `${communitySiteUrl.value}/${locale}/${type}/${item.slug}`;
80
+ return `${communitySiteUrl.value}/${locale}/${type}/${item.content.slug}`;
62
81
  };
63
82
 
64
83
  const imageUrl = (item: FeedItem): string =>
65
- item.url_image_src || item.url_image || "/imgs/default/no_img_large_dark.png";
84
+ item.content.url_image_src || item.content.url_image || "/imgs/default/no_img_large_dark.png";
66
85
 
67
86
  onMounted(async () => {
68
87
  try {
@@ -108,7 +127,7 @@ onMounted(async () => {
108
127
  <div v-else class="error-news-cta__grid">
109
128
  <a
110
129
  v-for="item in articles"
111
- :key="item.id"
130
+ :key="item.content.id"
112
131
  :href="articlePath(item)"
113
132
  target="_blank"
114
133
  class="error-news-cta__card"
@@ -119,11 +138,11 @@ onMounted(async () => {
119
138
  />
120
139
  <div class="error-news-cta__card-body">
121
140
  <span v-if="item.content_type" class="error-news-cta__card-tag">
122
- {{ item.content_type }}
141
+ {{ contentTypeLabel(item) }}
123
142
  </span>
124
- <p class="error-news-cta__card-title">{{ item.title }}</p>
125
- <span v-if="item.created_at_diff" class="error-news-cta__card-date">
126
- {{ item.created_at_diff }}
143
+ <p class="error-news-cta__card-title">{{ item.content.title }}</p>
144
+ <span v-if="item.content.created_at_diff" class="error-news-cta__card-date">
145
+ {{ item.content.created_at_diff }}
127
146
  </span>
128
147
  </div>
129
148
  </a>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mundogamernetwork/shared-ui",
3
- "version": "1.16.26",
3
+ "version": "1.16.27",
4
4
  "description": "Mundo Gamer Network - Shared UI Layer (Nuxt 3)",
5
5
  "type": "module",
6
6
  "main": "./nuxt.config.ts",
@@ -242,14 +242,6 @@ interface FormData {
242
242
  submitted_at: string
243
243
  }
244
244
 
245
- const contentTypesMap: Record<ContentType, number> = {
246
- article: 1,
247
- video: 2,
248
- stream: 3,
249
- web: 4,
250
- print: 5,
251
- }
252
-
253
245
  const forms = ref<FormData[]>([
254
246
  { content_types: [], material_url: "", description: "", submitted_at: "" },
255
247
  ])
@@ -363,7 +355,12 @@ const submitForm = async () => {
363
355
  await submitMaterial({
364
356
  key_request_id: requestId.value,
365
357
  user_id: unref(currentUserId),
366
- content_types: form.content_types.map((type) => contentTypesMap[type]),
358
+ // Slugs, not guessed ids. article/video/stream/web/print already
359
+ // match content_types.slug (Spatie\Sluggable on the model's own
360
+ // `name`) — the backend resolves them, which is what makes this
361
+ // work regardless of what numeric ids that table happens to hold
362
+ // in a given environment.
363
+ content_types: form.content_types,
367
364
  material_url: form.material_url,
368
365
  description: form.description,
369
366
  submitted_at: new Date(form.submitted_at).toISOString(),