@mundogamernetwork/shared-ui 1.1.95 → 1.1.96
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/locales/de.json +1 -0
- package/locales/en.json +1 -0
- package/locales/pt-BR.json +1 -0
- package/locales/ro.json +1 -0
- package/package.json +1 -1
- package/pages/key-campaigns/redeem-key.vue +36 -5
- package/services/campaignService.ts +10 -0
package/locales/de.json
CHANGED
|
@@ -181,6 +181,7 @@
|
|
|
181
181
|
"select_option": "Option auswählen",
|
|
182
182
|
"required_data": "Erforderliche Angaben",
|
|
183
183
|
"already_requested": "Sie haben bereits eine Anfrage für diese Kampagne gestellt.",
|
|
184
|
+
"sold_out": "Alle Keys für diese Kampagne wurden bereits eingelöst.",
|
|
184
185
|
"back_to_campaign": "Zur Kampagne zurückkehren",
|
|
185
186
|
"status_pending": "Anfrage ausstehend — bitte warten Sie auf die Genehmigung",
|
|
186
187
|
"status_approved": "Anfrage genehmigt — Sie können jetzt Ihren Schlüssel abrufen",
|
package/locales/en.json
CHANGED
|
@@ -181,6 +181,7 @@
|
|
|
181
181
|
"select_option": "Select an option",
|
|
182
182
|
"required_data": "Required data",
|
|
183
183
|
"already_requested": "You have already submitted a request for this campaign.",
|
|
184
|
+
"sold_out": "All keys for this campaign have already been claimed.",
|
|
184
185
|
"back_to_campaign": "Back to campaign",
|
|
185
186
|
"status_pending": "Request pending — waiting for approval",
|
|
186
187
|
"status_approved": "Request approved — you can now retrieve your key",
|
package/locales/pt-BR.json
CHANGED
|
@@ -181,6 +181,7 @@
|
|
|
181
181
|
"select_option": "Selecione uma opção",
|
|
182
182
|
"required_data": "Dados obrigatórios",
|
|
183
183
|
"already_requested": "Você já enviou uma solicitação para esta campanha.",
|
|
184
|
+
"sold_out": "Todas as chaves desta campanha já foram resgatadas.",
|
|
184
185
|
"back_to_campaign": "Voltar para a campanha",
|
|
185
186
|
"status_pending": "Solicitação pendente — aguardando aprovação",
|
|
186
187
|
"status_approved": "Solicitação aprovada — você pode resgatar sua chave",
|
package/locales/ro.json
CHANGED
|
@@ -181,6 +181,7 @@
|
|
|
181
181
|
"select_option": "Selectează o opțiune",
|
|
182
182
|
"required_data": "Date obligatorii",
|
|
183
183
|
"already_requested": "Ați trimis deja o cerere pentru această campanie.",
|
|
184
|
+
"sold_out": "Toate cheile pentru această campanie au fost deja revendicate.",
|
|
184
185
|
"back_to_campaign": "Înapoi la campanie",
|
|
185
186
|
"status_pending": "Cerere în așteptare — așteptați aprobarea",
|
|
186
187
|
"status_approved": "Cerere aprobată — puteți prelua cheia",
|
package/package.json
CHANGED
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
fetchCampaignBySlug,
|
|
7
7
|
fetchKeyPlatforms,
|
|
8
8
|
fetchKeyRegions,
|
|
9
|
+
fetchAvailableOptions,
|
|
9
10
|
requestKey,
|
|
10
11
|
} from "../../services/campaignService"
|
|
11
12
|
|
|
@@ -52,14 +53,29 @@ onMounted(async () => {
|
|
|
52
53
|
return
|
|
53
54
|
}
|
|
54
55
|
try {
|
|
55
|
-
const [campaignRes, platformsRes, regionsRes] = await Promise.all([
|
|
56
|
+
const [campaignRes, platformsRes, regionsRes, availableRes] = await Promise.all([
|
|
56
57
|
fetchCampaignBySlug(String(keyId)),
|
|
57
58
|
fetchKeyPlatforms(keyId),
|
|
58
59
|
fetchKeyRegions(keyId),
|
|
60
|
+
fetchAvailableOptions(keyId).catch(() => null),
|
|
59
61
|
])
|
|
60
62
|
campaign.value = campaignRes?.data?.data || campaignRes?.data || null
|
|
61
|
-
|
|
62
|
-
|
|
63
|
+
const allPlatforms = platformsRes?.data?.data || platformsRes?.data || []
|
|
64
|
+
const allRegions = regionsRes?.data?.data || regionsRes?.data || []
|
|
65
|
+
|
|
66
|
+
// Only offer platforms/regions that still have an unredeemed key item —
|
|
67
|
+
// fetchKeyPlatforms/fetchKeyRegions return every one the campaign has
|
|
68
|
+
// EVER had items for, including combos that are fully sold out.
|
|
69
|
+
const availableData = availableRes?.data ?? null
|
|
70
|
+
const availablePlatformIds: number[] | null = availableData?.available_platform_ids ?? null
|
|
71
|
+
const availableRegionIds: number[] | null = availableData?.available_region_ids ?? null
|
|
72
|
+
|
|
73
|
+
platforms.value = availablePlatformIds
|
|
74
|
+
? allPlatforms.filter((p: any) => availablePlatformIds.includes(p.id))
|
|
75
|
+
: allPlatforms
|
|
76
|
+
regions.value = availableRegionIds
|
|
77
|
+
? allRegions.filter((r: any) => availableRegionIds.includes(r.id))
|
|
78
|
+
: allRegions
|
|
63
79
|
|
|
64
80
|
// Pre-select if only one option
|
|
65
81
|
if (platforms.value.length === 1) selectedPlatformId.value = platforms.value[0].id
|
|
@@ -71,7 +87,11 @@ onMounted(async () => {
|
|
|
71
87
|
}
|
|
72
88
|
})
|
|
73
89
|
|
|
74
|
-
|
|
90
|
+
// True once options finished loading and either list came back empty — every
|
|
91
|
+
// platform/region combo this campaign ever had is now fully redeemed.
|
|
92
|
+
const soldOut = computed(() => !loading.value && (platforms.value.length === 0 || regions.value.length === 0))
|
|
93
|
+
|
|
94
|
+
const canSubmit = computed(() => !submitting.value && !soldOut.value)
|
|
75
95
|
|
|
76
96
|
// Collapsible "Required data" box — matches tv's original toggle behavior
|
|
77
97
|
const isBoxOpen = ref(true)
|
|
@@ -186,8 +206,19 @@ function goBack() {
|
|
|
186
206
|
<p v-if="campaign?.name" class="campaign-name">{{ campaign.name }}</p>
|
|
187
207
|
</div>
|
|
188
208
|
|
|
209
|
+
<!-- All platform/region combos are fully redeemed -->
|
|
210
|
+
<div v-if="!hasExistingRequest && soldOut" class="existing-request-notice">
|
|
211
|
+
<MGIcon size="1x" icon="version" class="notice-icon" />
|
|
212
|
+
<div class="notice-texts">
|
|
213
|
+
<div class="notice-title">{{ $t("keys.campaigns.sold_out") }}</div>
|
|
214
|
+
</div>
|
|
215
|
+
<button class="btn notice-back" @click="goBack">
|
|
216
|
+
{{ $t("keys.campaigns.back_to_campaign") }}
|
|
217
|
+
</button>
|
|
218
|
+
</div>
|
|
219
|
+
|
|
189
220
|
<!-- Already has a request -->
|
|
190
|
-
<div v-if="hasExistingRequest" class="existing-request-notice">
|
|
221
|
+
<div v-else-if="hasExistingRequest" class="existing-request-notice">
|
|
191
222
|
<MGIcon size="1x" icon="version" class="notice-icon" />
|
|
192
223
|
<div class="notice-texts">
|
|
193
224
|
<div class="notice-title">{{ $t("keys.campaigns.already_requested") }}</div>
|
|
@@ -308,6 +308,16 @@ export const fetchKeyRegions = (keyId: number, params: Record<string, any> = {})
|
|
|
308
308
|
return mainClient.get(`/public/keys/${keyId}/regions`, { params })
|
|
309
309
|
}
|
|
310
310
|
|
|
311
|
+
/**
|
|
312
|
+
* Which platform/region combos still have unredeemed key items. fetchKeyPlatforms/
|
|
313
|
+
* fetchKeyRegions return every platform/region the campaign has EVER had items
|
|
314
|
+
* for (including fully redeemed ones) — this is the live-stock check needed to
|
|
315
|
+
* only offer options that can actually still be requested.
|
|
316
|
+
*/
|
|
317
|
+
export const fetchAvailableOptions = (keyId: number) => {
|
|
318
|
+
return mainClient.get(`/public/keys/${keyId}/available-options`)
|
|
319
|
+
}
|
|
320
|
+
|
|
311
321
|
// ---------------------------------------------------------------------------
|
|
312
322
|
// Auth-required endpoints (authClient — withCredentials)
|
|
313
323
|
// ---------------------------------------------------------------------------
|