@mundogamernetwork/shared-ui 1.19.9 → 1.19.11
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/keys/KeyBrowser.vue +60 -2
- package/components/keys/MaterialLanguageSelect.vue +272 -0
- package/components/ui/MgCampaignBannerCarousel.vue +10 -3
- package/locales/de.json +18 -1
- package/locales/en.json +18 -1
- package/locales/es.json +18 -1
- package/locales/pt-BR.json +18 -1
- package/locales/ro.json +18 -1
- package/package.json +1 -1
- package/pages/key-campaigns/[slug].vue +27 -0
- package/pages/key-campaigns/index.vue +35 -0
- package/pages/key-campaigns/key-materials.vue +34 -8
- package/pages/key-campaigns/redeem-key.vue +50 -1
- package/services/campaignService.ts +27 -0
- package/services/keyService.ts +7 -0
- package/utils/keyRequestError.ts +15 -0
- package/utils/materialLanguage.ts +92 -0
- package/utils/refusalDetails.ts +14 -0
- package/utils/requestSource.ts +50 -0
|
@@ -44,7 +44,7 @@ const requestErrors = ref<Record<number, string>>({})
|
|
|
44
44
|
const activeTab = ref<'available' | 'mine'>('available')
|
|
45
45
|
const isAuthenticated = ref(true) // assume true; set false on 401
|
|
46
46
|
|
|
47
|
-
const requestForms = ref<Record<number, { platform_ids: number[]; description: string }>>({})
|
|
47
|
+
const requestForms = ref<Record<number, { platform_ids: number[]; description: string; requirements_ack?: boolean }>>({})
|
|
48
48
|
const revealingId = ref<number | null>(null)
|
|
49
49
|
const revealResult = ref<RevealResult | null>(null)
|
|
50
50
|
// revealingId resets to null in the reveal() finally block, before the modal
|
|
@@ -132,6 +132,7 @@ async function doRequestKey(pool: KeyCampaign) {
|
|
|
132
132
|
description: form.description || undefined,
|
|
133
133
|
}
|
|
134
134
|
if (props.accessToken) body.access_token = props.accessToken
|
|
135
|
+
if (pool.requirements?.declares_requirements) body.requirements_acknowledged = true
|
|
135
136
|
await apiRequestKey(pool.id, body)
|
|
136
137
|
pool.already_requested = true
|
|
137
138
|
await loadMyRequests()
|
|
@@ -156,6 +157,10 @@ async function doRequestKey(pool: KeyCampaign) {
|
|
|
156
157
|
}
|
|
157
158
|
}
|
|
158
159
|
|
|
160
|
+
function requirementsPending(pool: KeyCampaign) {
|
|
161
|
+
return !!pool.requirements?.declares_requirements && !requestForms.value[pool.id]?.requirements_ack
|
|
162
|
+
}
|
|
163
|
+
|
|
159
164
|
function handleRequestKey(pool: KeyCampaign) {
|
|
160
165
|
if (!isAuthenticated.value) {
|
|
161
166
|
redirectToLogin()
|
|
@@ -334,6 +339,29 @@ function statusColor(slug: string): string {
|
|
|
334
339
|
/>
|
|
335
340
|
</div>
|
|
336
341
|
|
|
342
|
+
<div
|
|
343
|
+
v-if="!pool.already_requested && pool.available_count > 0 && pool.requirements?.declares_requirements"
|
|
344
|
+
class="kb__requirements"
|
|
345
|
+
>
|
|
346
|
+
<strong class="kb__label">{{ $t('keys.campaigns.requirements_title') }}</strong>
|
|
347
|
+
<p class="kb__requirements-text">
|
|
348
|
+
{{
|
|
349
|
+
pool.requirements.accepts_all_content
|
|
350
|
+
? $t('keys.campaigns.requirements_all_types')
|
|
351
|
+
: $t('keys.campaigns.requirements_accepted_types', {
|
|
352
|
+
types: pool.requirements.accepted_content_types.map((c) => c.name).join(', '),
|
|
353
|
+
})
|
|
354
|
+
}}
|
|
355
|
+
</p>
|
|
356
|
+
<p v-if="pool.requirements.requirements_note" class="kb__requirements-text kb__requirements-note">
|
|
357
|
+
{{ pool.requirements.requirements_note }}
|
|
358
|
+
</p>
|
|
359
|
+
<label class="kb__requirements-ack">
|
|
360
|
+
<input type="checkbox" v-model="requestForms[pool.id].requirements_ack" />
|
|
361
|
+
{{ $t('keys.campaigns.requirements_ack_label') }}
|
|
362
|
+
</label>
|
|
363
|
+
</div>
|
|
364
|
+
|
|
337
365
|
<div class="kb__pool-footer">
|
|
338
366
|
<span v-if="pool.already_requested" class="kb__requested-label">
|
|
339
367
|
✓ {{ $t('keys.browser.already_requested') }}
|
|
@@ -341,7 +369,7 @@ function statusColor(slug: string): string {
|
|
|
341
369
|
<button
|
|
342
370
|
v-else
|
|
343
371
|
class="kb__request-btn"
|
|
344
|
-
:disabled="pool.available_count === 0 || requesting === pool.id"
|
|
372
|
+
:disabled="pool.available_count === 0 || requesting === pool.id || requirementsPending(pool)"
|
|
345
373
|
@click="handleRequestKey(pool)"
|
|
346
374
|
>
|
|
347
375
|
{{ requesting === pool.id ? $t('common.sending') : $t('keys.browser.request_btn') }}
|
|
@@ -541,6 +569,36 @@ function statusColor(slug: string): string {
|
|
|
541
569
|
|
|
542
570
|
&__description-field { display: flex; flex-direction: column; gap: 4px; }
|
|
543
571
|
|
|
572
|
+
&__requirements {
|
|
573
|
+
display: flex;
|
|
574
|
+
flex-direction: column;
|
|
575
|
+
gap: 6px;
|
|
576
|
+
padding: 10px 12px;
|
|
577
|
+
background: var(--bg-app-badge);
|
|
578
|
+
border: 1px solid var(--border-color);
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
&__requirements-text {
|
|
582
|
+
margin: 0;
|
|
583
|
+
font-size: 0.8rem;
|
|
584
|
+
line-height: 1.45;
|
|
585
|
+
color: var(--secondary-info-fg);
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
&__requirements-note { white-space: pre-line; }
|
|
589
|
+
|
|
590
|
+
&__requirements-ack {
|
|
591
|
+
display: flex;
|
|
592
|
+
align-items: flex-start;
|
|
593
|
+
gap: 8px;
|
|
594
|
+
font-size: 0.8rem;
|
|
595
|
+
line-height: 1.4;
|
|
596
|
+
cursor: pointer;
|
|
597
|
+
color: var(--secondary-info-fg);
|
|
598
|
+
|
|
599
|
+
input { flex-shrink: 0; margin-top: 2px; }
|
|
600
|
+
}
|
|
601
|
+
|
|
544
602
|
&__textarea {
|
|
545
603
|
background: var(--surface, #0a0a0a);
|
|
546
604
|
border: 1px solid var(--border-color, #2a2a2a);
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="material-language" ref="rootEl">
|
|
3
|
+
<div class="combo" :class="{ open, 'has-error': !!error }">
|
|
4
|
+
<input
|
|
5
|
+
:id="inputId"
|
|
6
|
+
ref="inputEl"
|
|
7
|
+
class="form-control combo-input"
|
|
8
|
+
type="text"
|
|
9
|
+
role="combobox"
|
|
10
|
+
autocomplete="off"
|
|
11
|
+
aria-autocomplete="list"
|
|
12
|
+
:aria-expanded="open"
|
|
13
|
+
:aria-controls="listId"
|
|
14
|
+
:aria-activedescendant="activeOption ? `${listId}-${activeOption.id}` : undefined"
|
|
15
|
+
:aria-invalid="!!error"
|
|
16
|
+
:aria-required="true"
|
|
17
|
+
:placeholder="$t('keys.materials.language_placeholder')"
|
|
18
|
+
:value="open ? query : selectedName"
|
|
19
|
+
@focus="openList"
|
|
20
|
+
@click="openList"
|
|
21
|
+
@input="onInput"
|
|
22
|
+
@keydown="onKeydown"
|
|
23
|
+
/>
|
|
24
|
+
<button
|
|
25
|
+
type="button"
|
|
26
|
+
class="combo-toggle"
|
|
27
|
+
tabindex="-1"
|
|
28
|
+
:aria-label="$t('keys.materials.language')"
|
|
29
|
+
@mousedown.prevent
|
|
30
|
+
@click="toggleList"
|
|
31
|
+
>
|
|
32
|
+
<MGIcon icon="chevron-down" :class="{ rotate: open }" />
|
|
33
|
+
</button>
|
|
34
|
+
|
|
35
|
+
<ul v-if="open" :id="listId" class="combo-list" role="listbox">
|
|
36
|
+
<li v-if="loading" class="combo-empty">{{ $t("keys.materials.language_loading") }}</li>
|
|
37
|
+
<li v-else-if="loadFailed" class="combo-empty">
|
|
38
|
+
{{ $t("keys.materials.language_load_error") }}
|
|
39
|
+
<button type="button" class="combo-retry" @mousedown.prevent @click="load">{{ $t("keys.materials.language_retry") }}</button>
|
|
40
|
+
</li>
|
|
41
|
+
<li v-else-if="!filtered.length" class="combo-empty">{{ $t("keys.materials.language_no_results") }}</li>
|
|
42
|
+
<li
|
|
43
|
+
v-for="(opt, i) in filtered"
|
|
44
|
+
v-else
|
|
45
|
+
:id="`${listId}-${opt.id}`"
|
|
46
|
+
:key="opt.id"
|
|
47
|
+
role="option"
|
|
48
|
+
class="combo-option"
|
|
49
|
+
:class="{ active: i === activeIndex, selected: opt.id === modelValue }"
|
|
50
|
+
:aria-selected="opt.id === modelValue"
|
|
51
|
+
@mousedown.prevent="choose(opt)"
|
|
52
|
+
@mousemove="activeIndex = i"
|
|
53
|
+
>
|
|
54
|
+
{{ opt.name }}
|
|
55
|
+
</li>
|
|
56
|
+
</ul>
|
|
57
|
+
</div>
|
|
58
|
+
<div v-if="error" class="error-message" role="alert">{{ error }}</div>
|
|
59
|
+
</div>
|
|
60
|
+
</template>
|
|
61
|
+
|
|
62
|
+
<script setup lang="ts">
|
|
63
|
+
import { ref, computed, watch, onMounted, onBeforeUnmount, nextTick } from "vue"
|
|
64
|
+
import { useI18n } from "#imports"
|
|
65
|
+
import { fetchMaterialLanguages } from "../../services/campaignService"
|
|
66
|
+
import { buildLanguageOptions, filterLanguageOptions, type MaterialLanguageOption } from "../../utils/materialLanguage"
|
|
67
|
+
|
|
68
|
+
const props = defineProps<{ modelValue: number | null; error?: string | null }>()
|
|
69
|
+
const emit = defineEmits<{ (e: "update:modelValue", value: number | null): void }>()
|
|
70
|
+
|
|
71
|
+
const { locale } = useI18n()
|
|
72
|
+
const uid = Math.random().toString(36).slice(2, 8)
|
|
73
|
+
const inputId = `material-language-${uid}`
|
|
74
|
+
const listId = `material-language-list-${uid}`
|
|
75
|
+
|
|
76
|
+
const rootEl = ref<HTMLElement | null>(null)
|
|
77
|
+
const inputEl = ref<HTMLInputElement | null>(null)
|
|
78
|
+
const options = ref<MaterialLanguageOption[]>([])
|
|
79
|
+
const loading = ref(false)
|
|
80
|
+
const loadFailed = ref(false)
|
|
81
|
+
const open = ref(false)
|
|
82
|
+
const query = ref("")
|
|
83
|
+
const activeIndex = ref(0)
|
|
84
|
+
|
|
85
|
+
const filtered = computed(() => filterLanguageOptions(options.value, query.value))
|
|
86
|
+
const activeOption = computed(() => (open.value ? filtered.value[activeIndex.value] : undefined))
|
|
87
|
+
const selectedName = computed(() => options.value.find((o) => o.id === props.modelValue)?.name ?? "")
|
|
88
|
+
|
|
89
|
+
async function load() {
|
|
90
|
+
loading.value = true
|
|
91
|
+
loadFailed.value = false
|
|
92
|
+
try {
|
|
93
|
+
options.value = buildLanguageOptions(await fetchMaterialLanguages(), locale.value)
|
|
94
|
+
} catch {
|
|
95
|
+
loadFailed.value = true
|
|
96
|
+
} finally {
|
|
97
|
+
loading.value = false
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function scrollActiveIntoView() {
|
|
102
|
+
nextTick(() => {
|
|
103
|
+
const el = rootEl.value?.querySelector<HTMLElement>(".combo-option.active")
|
|
104
|
+
el?.scrollIntoView?.({ block: "nearest" })
|
|
105
|
+
})
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function openList() {
|
|
109
|
+
if (open.value) return
|
|
110
|
+
open.value = true
|
|
111
|
+
query.value = ""
|
|
112
|
+
const idx = filtered.value.findIndex((o) => o.id === props.modelValue)
|
|
113
|
+
activeIndex.value = idx >= 0 ? idx : 0
|
|
114
|
+
scrollActiveIntoView()
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function closeList() {
|
|
118
|
+
open.value = false
|
|
119
|
+
query.value = ""
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function toggleList() {
|
|
123
|
+
if (open.value) closeList()
|
|
124
|
+
else {
|
|
125
|
+
inputEl.value?.focus()
|
|
126
|
+
openList()
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function onInput(e: Event) {
|
|
131
|
+
query.value = (e.target as HTMLInputElement).value
|
|
132
|
+
open.value = true
|
|
133
|
+
activeIndex.value = 0
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function choose(opt: MaterialLanguageOption) {
|
|
137
|
+
emit("update:modelValue", opt.id)
|
|
138
|
+
closeList()
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function onKeydown(e: KeyboardEvent) {
|
|
142
|
+
if (e.key === "ArrowDown") {
|
|
143
|
+
e.preventDefault()
|
|
144
|
+
if (!open.value) return openList()
|
|
145
|
+
activeIndex.value = Math.min(activeIndex.value + 1, Math.max(filtered.value.length - 1, 0))
|
|
146
|
+
scrollActiveIntoView()
|
|
147
|
+
} else if (e.key === "ArrowUp") {
|
|
148
|
+
e.preventDefault()
|
|
149
|
+
if (!open.value) return openList()
|
|
150
|
+
activeIndex.value = Math.max(activeIndex.value - 1, 0)
|
|
151
|
+
scrollActiveIntoView()
|
|
152
|
+
} else if (e.key === "Enter") {
|
|
153
|
+
if (open.value && activeOption.value) {
|
|
154
|
+
e.preventDefault()
|
|
155
|
+
choose(activeOption.value)
|
|
156
|
+
}
|
|
157
|
+
} else if (e.key === "Escape") {
|
|
158
|
+
if (open.value) {
|
|
159
|
+
e.preventDefault()
|
|
160
|
+
closeList()
|
|
161
|
+
}
|
|
162
|
+
} else if (e.key === "Tab") {
|
|
163
|
+
closeList()
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function onOutside(e: MouseEvent) {
|
|
168
|
+
if (open.value && rootEl.value && !rootEl.value.contains(e.target as Node)) closeList()
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
watch(locale, () => {
|
|
172
|
+
if (options.value.length) load()
|
|
173
|
+
})
|
|
174
|
+
|
|
175
|
+
onMounted(() => {
|
|
176
|
+
document.addEventListener("mousedown", onOutside)
|
|
177
|
+
load()
|
|
178
|
+
})
|
|
179
|
+
onBeforeUnmount(() => document.removeEventListener("mousedown", onOutside))
|
|
180
|
+
</script>
|
|
181
|
+
|
|
182
|
+
<style scoped lang="scss">
|
|
183
|
+
.material-language {
|
|
184
|
+
width: 100%;
|
|
185
|
+
position: relative;
|
|
186
|
+
|
|
187
|
+
.combo {
|
|
188
|
+
position: relative;
|
|
189
|
+
display: flex;
|
|
190
|
+
align-items: center;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// Same look as the page's other fields: the page's scoped `.form-control` rule does not reach inside this child component,
|
|
194
|
+
// so without this the input fell back to the browser's white default on the dark layout.
|
|
195
|
+
.combo-input {
|
|
196
|
+
width: 100%;
|
|
197
|
+
height: 48px;
|
|
198
|
+
padding: 12px 40px 12px 12px;
|
|
199
|
+
border-radius: 0;
|
|
200
|
+
background-color: transparent;
|
|
201
|
+
border: 1px solid var(--bg-app-badge);
|
|
202
|
+
font-size: 16px;
|
|
203
|
+
color: var(--secondary-info-fg);
|
|
204
|
+
|
|
205
|
+
&::placeholder { color: var(--inactive); }
|
|
206
|
+
&:focus { border: 1px solid var(--section-title-marker-fg); box-shadow: none; outline: 0; }
|
|
207
|
+
}
|
|
208
|
+
.has-error .combo-input { border: 1px solid var(--danger) !important; }
|
|
209
|
+
|
|
210
|
+
.combo-toggle {
|
|
211
|
+
position: absolute;
|
|
212
|
+
right: 8px;
|
|
213
|
+
top: 50%;
|
|
214
|
+
transform: translateY(-50%);
|
|
215
|
+
background: none;
|
|
216
|
+
border: 0;
|
|
217
|
+
color: var(--inactive);
|
|
218
|
+
cursor: pointer;
|
|
219
|
+
display: flex;
|
|
220
|
+
align-items: center;
|
|
221
|
+
padding: 4px;
|
|
222
|
+
|
|
223
|
+
.rotate { transform: rotate(180deg); }
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
.combo-list {
|
|
227
|
+
position: absolute;
|
|
228
|
+
z-index: 20;
|
|
229
|
+
top: calc(100% + 4px);
|
|
230
|
+
left: 0;
|
|
231
|
+
right: 0;
|
|
232
|
+
max-height: 260px;
|
|
233
|
+
overflow-y: auto;
|
|
234
|
+
margin: 0;
|
|
235
|
+
padding: 4px 0;
|
|
236
|
+
list-style: none;
|
|
237
|
+
background: var(--body-bg-dash);
|
|
238
|
+
border: 1px solid var(--bg-app-badge);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
.combo-option {
|
|
242
|
+
padding: 8px 12px;
|
|
243
|
+
cursor: pointer;
|
|
244
|
+
font-size: 14px;
|
|
245
|
+
color: var(--secondary-info-fg);
|
|
246
|
+
|
|
247
|
+
&.active { background: var(--bg-app-badge); color: var(--card-cover-title); }
|
|
248
|
+
&.selected { font-weight: 700; color: var(--card-cover-title); }
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
.combo-empty {
|
|
252
|
+
padding: 10px 12px;
|
|
253
|
+
font-size: 13px;
|
|
254
|
+
color: var(--inactive);
|
|
255
|
+
display: flex;
|
|
256
|
+
gap: 8px;
|
|
257
|
+
align-items: center;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
.combo-retry {
|
|
261
|
+
background: none;
|
|
262
|
+
border: 0;
|
|
263
|
+
padding: 0;
|
|
264
|
+
cursor: pointer;
|
|
265
|
+
text-decoration: underline;
|
|
266
|
+
color: var(--section-title-marker-fg);
|
|
267
|
+
font-size: 13px;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
.error-message { color: var(--danger); font-size: 0.8rem; margin-top: 5px; }
|
|
271
|
+
}
|
|
272
|
+
</style>
|
|
@@ -106,13 +106,20 @@ onUnmounted(() => {
|
|
|
106
106
|
cursor: pointer;
|
|
107
107
|
display: block;
|
|
108
108
|
width: 100%;
|
|
109
|
+
max-width: 1280px;
|
|
110
|
+
margin-inline: auto;
|
|
111
|
+
aspect-ratio: 64 / 9;
|
|
112
|
+
max-height: 180px;
|
|
113
|
+
overflow: hidden;
|
|
109
114
|
}
|
|
110
115
|
|
|
111
116
|
.mg-campaign-banner-img {
|
|
112
117
|
display: block;
|
|
113
118
|
width: 100%;
|
|
114
|
-
height:
|
|
119
|
+
height: 100%;
|
|
120
|
+
max-height: 180px;
|
|
115
121
|
object-fit: cover;
|
|
122
|
+
object-position: center;
|
|
116
123
|
}
|
|
117
124
|
|
|
118
125
|
.mg-campaign-banner-indicators {
|
|
@@ -129,12 +136,12 @@ onUnmounted(() => {
|
|
|
129
136
|
height: 8px;
|
|
130
137
|
padding: 0;
|
|
131
138
|
border: 0;
|
|
132
|
-
background:
|
|
139
|
+
background: var(--inactive);
|
|
133
140
|
cursor: pointer;
|
|
134
141
|
transition: background 0.2s;
|
|
135
142
|
|
|
136
143
|
&.active {
|
|
137
|
-
background:
|
|
144
|
+
background: var(--active);
|
|
138
145
|
}
|
|
139
146
|
}
|
|
140
147
|
}
|
package/locales/de.json
CHANGED
|
@@ -367,6 +367,8 @@
|
|
|
367
367
|
"extra_codes": "Diese Anfrage wurde für {count} Keys genehmigt — hier sind alle.",
|
|
368
368
|
"redeem_on_platform": "Löse diesen Schlüssel auf der entsprechenden Plattform ein.",
|
|
369
369
|
"revealing": "Enthülle...",
|
|
370
|
+
"refusal_title": "Grund der Ablehnung",
|
|
371
|
+
"refusal_note_label": "Hinweis vom Studio",
|
|
370
372
|
"status": {
|
|
371
373
|
"pending": "Ausstehend",
|
|
372
374
|
"under_review": "In Prüfung",
|
|
@@ -386,6 +388,14 @@
|
|
|
386
388
|
"error_user_blocked": "Ihr Zugang zu Key-Anfragen wurde vorübergehend gesperrt, da Material-Einreichungen überfällig sind. Bitte reichen Sie Ihre ausstehenden Materialien ein.",
|
|
387
389
|
"error_not_eligible": "Diese Kampagne ist für Ihren aktuellen Plan nicht verfügbar.",
|
|
388
390
|
"error_pending_limit": "Sie haben das gleichzeitige Anfragenlimit Ihres Plans erreicht. Bitte erfüllen Sie Ihre ausstehenden Verpflichtungen, bevor Sie einen neuen Key anfordern.",
|
|
391
|
+
"error_daily_limit": "Sie haben das tägliche Anfragenlimit Ihres Plans erreicht. Bitte versuchen Sie es morgen erneut.",
|
|
392
|
+
"error_requirements_ack": "Bestätige bitte, dass du verstehst, was diese Kampagne erwartet, bevor du einen Key anforderst.",
|
|
393
|
+
"error_content_type_not_accepted": "Dein Inhalt entspricht nicht dem, was diese Kampagne akzeptiert. Prüfe die zulässigen Inhaltstypen und versuche es erneut.",
|
|
394
|
+
"requirements_title": "Das erwartet diese Kampagne",
|
|
395
|
+
"requirements_accepted_types": "Akzeptierte Inhalte: {types}",
|
|
396
|
+
"requirements_all_types": "Jeder Inhaltstyp wird akzeptiert",
|
|
397
|
+
"requirements_ack_label": "Ich verstehe, was für meinen Inhalt in dieser Kampagne erwartet wird.",
|
|
398
|
+
"requirements_ack_required": "Bestätige, dass du verstehst, was erwartet wird, bevor du den Key anforderst.",
|
|
389
399
|
"error_not_open_yet": "Diese Kampagne ist noch nicht geöffnet.",
|
|
390
400
|
"error_closed": "Diese Kampagne ist beendet.",
|
|
391
401
|
"error_country": "Diese Kampagne ist in deinem Land nicht verfügbar.",
|
|
@@ -463,7 +473,14 @@
|
|
|
463
473
|
"finish": "Submit",
|
|
464
474
|
"submitted_title": "Material submitted!",
|
|
465
475
|
"success_message": "Your material was sent for review. Thank you!",
|
|
466
|
-
"success_close": "Close"
|
|
476
|
+
"success_close": "Close",
|
|
477
|
+
"language": "Sprache des Materials",
|
|
478
|
+
"language_placeholder": "Sprache suchen...",
|
|
479
|
+
"language_loading": "Sprachen werden geladen...",
|
|
480
|
+
"language_load_error": "Die Sprachen konnten nicht geladen werden.",
|
|
481
|
+
"language_retry": "Erneut versuchen",
|
|
482
|
+
"language_no_results": "Keine Sprache gefunden",
|
|
483
|
+
"language_hint": "Gib an, in welcher Sprache dein Inhalt ist. Das hilft dem Team nur beim Finden und Filtern der Einreichungen."
|
|
467
484
|
}
|
|
468
485
|
},
|
|
469
486
|
"common": {
|
package/locales/en.json
CHANGED
|
@@ -367,6 +367,8 @@
|
|
|
367
367
|
"extra_codes": "This request was approved for {count} keys — here are all of them.",
|
|
368
368
|
"redeem_on_platform": "Redeem this key on the platform where you received it.",
|
|
369
369
|
"revealing": "Revealing...",
|
|
370
|
+
"refusal_title": "Why it was refused",
|
|
371
|
+
"refusal_note_label": "Note from the studio",
|
|
370
372
|
"status": {
|
|
371
373
|
"pending": "Pending",
|
|
372
374
|
"under_review": "Under review",
|
|
@@ -386,6 +388,14 @@
|
|
|
386
388
|
"error_user_blocked": "Your key request access has been temporarily blocked due to overdue material submissions. Please submit your pending materials to restore access.",
|
|
387
389
|
"error_not_eligible": "This campaign is not available for your current plan.",
|
|
388
390
|
"error_pending_limit": "You have reached the simultaneous request limit for your plan. Please fulfill your pending obligations before requesting a new key.",
|
|
391
|
+
"error_daily_limit": "You have reached the daily limit of key requests for your plan. Please try again tomorrow.",
|
|
392
|
+
"error_requirements_ack": "Please confirm you understand what this campaign expects before requesting a key.",
|
|
393
|
+
"error_content_type_not_accepted": "Your content does not match what this campaign accepts. Check the accepted content types and try again.",
|
|
394
|
+
"requirements_title": "What this campaign expects",
|
|
395
|
+
"requirements_accepted_types": "Accepted content: {types}",
|
|
396
|
+
"requirements_all_types": "Any content type is accepted",
|
|
397
|
+
"requirements_ack_label": "I understand what is expected from my content for this campaign.",
|
|
398
|
+
"requirements_ack_required": "Confirm you understand what is expected before requesting the key.",
|
|
389
399
|
"error_not_open_yet": "This campaign has not opened yet.",
|
|
390
400
|
"error_closed": "This campaign is closed.",
|
|
391
401
|
"error_country": "This campaign is not available in your country.",
|
|
@@ -463,7 +473,14 @@
|
|
|
463
473
|
"finish": "Submit",
|
|
464
474
|
"submitted_title": "Material submitted!",
|
|
465
475
|
"success_message": "Your material was sent for review. Thank you!",
|
|
466
|
-
"success_close": "Close"
|
|
476
|
+
"success_close": "Close",
|
|
477
|
+
"language": "Language of the material",
|
|
478
|
+
"language_placeholder": "Search language...",
|
|
479
|
+
"language_loading": "Loading languages...",
|
|
480
|
+
"language_load_error": "Could not load the languages.",
|
|
481
|
+
"language_retry": "Try again",
|
|
482
|
+
"language_no_results": "No language found",
|
|
483
|
+
"language_hint": "Tell us which language your content is in. It only helps the team find and filter deliveries."
|
|
467
484
|
}
|
|
468
485
|
},
|
|
469
486
|
"common": {
|
package/locales/es.json
CHANGED
|
@@ -367,6 +367,8 @@
|
|
|
367
367
|
"extra_codes": "Esta solicitud fue aprobada para {count} claves: aquí están todas.",
|
|
368
368
|
"redeem_on_platform": "Canjea esta clave en la plataforma donde la recibiste.",
|
|
369
369
|
"revealing": "Revelando...",
|
|
370
|
+
"refusal_title": "Motivo del rechazo",
|
|
371
|
+
"refusal_note_label": "Nota del estudio",
|
|
370
372
|
"status": {
|
|
371
373
|
"pending": "Pendiente",
|
|
372
374
|
"under_review": "En revisión",
|
|
@@ -386,6 +388,14 @@
|
|
|
386
388
|
"error_user_blocked": "Tu acceso a solicitudes de claves ha sido bloqueado temporalmente por envíos de material pendientes. Envía tus materiales para restaurar el acceso.",
|
|
387
389
|
"error_not_eligible": "Esta campaña no está disponible para tu plan actual.",
|
|
388
390
|
"error_pending_limit": "Has alcanzado el límite de solicitudes simultáneas de tu plan. Cumple con tus obligaciones pendientes antes de solicitar una nueva clave.",
|
|
391
|
+
"error_daily_limit": "Has alcanzado el límite diario de solicitudes de clave de tu plan. Inténtalo de nuevo mañana.",
|
|
392
|
+
"error_requirements_ack": "Confirma que entiendes lo que espera esta campaña antes de solicitar una clave.",
|
|
393
|
+
"error_content_type_not_accepted": "Tu contenido no coincide con lo que acepta esta campaña. Revisa los tipos de contenido aceptados e inténtalo de nuevo.",
|
|
394
|
+
"requirements_title": "Lo que espera esta campaña",
|
|
395
|
+
"requirements_accepted_types": "Contenido aceptado: {types}",
|
|
396
|
+
"requirements_all_types": "Se acepta cualquier tipo de contenido",
|
|
397
|
+
"requirements_ack_label": "Entiendo lo que se espera de mi contenido en esta campaña.",
|
|
398
|
+
"requirements_ack_required": "Confirma que entiendes lo que se espera antes de solicitar la clave.",
|
|
389
399
|
"error_not_open_yet": "Esta campaña aún no se ha abierto.",
|
|
390
400
|
"error_closed": "Esta campaña está cerrada.",
|
|
391
401
|
"error_country": "Esta campaña no está disponible en tu país.",
|
|
@@ -463,7 +473,14 @@
|
|
|
463
473
|
"finish": "Finalizar",
|
|
464
474
|
"submitted_title": "Material Enviado",
|
|
465
475
|
"success_message": "Tu material ha sido enviado exitosamente para revisión.",
|
|
466
|
-
"success_close": "Cerrar"
|
|
476
|
+
"success_close": "Cerrar",
|
|
477
|
+
"language": "Idioma del material",
|
|
478
|
+
"language_placeholder": "Buscar idioma...",
|
|
479
|
+
"language_loading": "Cargando idiomas...",
|
|
480
|
+
"language_load_error": "No se pudieron cargar los idiomas.",
|
|
481
|
+
"language_retry": "Reintentar",
|
|
482
|
+
"language_no_results": "No se encontró ningún idioma",
|
|
483
|
+
"language_hint": "Indica en qué idioma está tu contenido. Solo ayuda al equipo a encontrar y filtrar las entregas."
|
|
467
484
|
}
|
|
468
485
|
},
|
|
469
486
|
"common": {
|
package/locales/pt-BR.json
CHANGED
|
@@ -367,6 +367,8 @@
|
|
|
367
367
|
"extra_codes": "Esta solicitação foi aprovada para {count} chaves — aqui estão todas.",
|
|
368
368
|
"redeem_on_platform": "Resgate esta chave na plataforma correspondente.",
|
|
369
369
|
"revealing": "Revelando...",
|
|
370
|
+
"refusal_title": "Motivo da recusa",
|
|
371
|
+
"refusal_note_label": "Observação do estúdio",
|
|
370
372
|
"status": {
|
|
371
373
|
"pending": "Pendente",
|
|
372
374
|
"under_review": "Em análise",
|
|
@@ -386,6 +388,14 @@
|
|
|
386
388
|
"error_user_blocked": "Seu acesso a pedidos de chave está temporariamente bloqueado por materiais não entregues. Envie seus materiais pendentes para restaurar o acesso.",
|
|
387
389
|
"error_not_eligible": "Esta campanha não está disponível para o seu plano atual.",
|
|
388
390
|
"error_pending_limit": "Você atingiu o limite de pedidos simultâneos do seu plano. Entregue o material pendente antes de solicitar uma nova chave.",
|
|
391
|
+
"error_daily_limit": "Você atingiu o limite diário de pedidos de chave do seu plano. Tente novamente amanhã.",
|
|
392
|
+
"error_requirements_ack": "Confirme que você entende o que esta campanha espera antes de solicitar uma chave.",
|
|
393
|
+
"error_content_type_not_accepted": "Seu conteúdo não corresponde ao que esta campanha aceita. Confira os tipos de conteúdo aceitos e tente novamente.",
|
|
394
|
+
"requirements_title": "O que esta campanha espera",
|
|
395
|
+
"requirements_accepted_types": "Conteúdo aceito: {types}",
|
|
396
|
+
"requirements_all_types": "Qualquer tipo de conteúdo é aceito",
|
|
397
|
+
"requirements_ack_label": "Entendo o que é esperado do meu conteúdo nesta campanha.",
|
|
398
|
+
"requirements_ack_required": "Confirme que você entende o que é esperado antes de solicitar a chave.",
|
|
389
399
|
"error_not_open_yet": "Esta campanha ainda não foi aberta.",
|
|
390
400
|
"error_closed": "Esta campanha está encerrada.",
|
|
391
401
|
"error_country": "Esta campanha não está disponível no seu país.",
|
|
@@ -463,7 +473,14 @@
|
|
|
463
473
|
"finish": "Submit",
|
|
464
474
|
"submitted_title": "Material submitted!",
|
|
465
475
|
"success_message": "Your material was sent for review. Thank you!",
|
|
466
|
-
"success_close": "Close"
|
|
476
|
+
"success_close": "Close",
|
|
477
|
+
"language": "Idioma do material",
|
|
478
|
+
"language_placeholder": "Buscar idioma...",
|
|
479
|
+
"language_loading": "Carregando idiomas...",
|
|
480
|
+
"language_load_error": "Não foi possível carregar os idiomas.",
|
|
481
|
+
"language_retry": "Tentar de novo",
|
|
482
|
+
"language_no_results": "Nenhum idioma encontrado",
|
|
483
|
+
"language_hint": "Informe em qual idioma está o seu conteúdo. Isso só ajuda a equipe a encontrar e filtrar as entregas."
|
|
467
484
|
}
|
|
468
485
|
},
|
|
469
486
|
"common": {
|
package/locales/ro.json
CHANGED
|
@@ -367,6 +367,8 @@
|
|
|
367
367
|
"extra_codes": "Această solicitare a fost aprobată pentru {count} chei — iată-le pe toate.",
|
|
368
368
|
"redeem_on_platform": "Activează această cheie pe platforma corespunzătoare.",
|
|
369
369
|
"revealing": "Se dezvăluie...",
|
|
370
|
+
"refusal_title": "Motivul refuzului",
|
|
371
|
+
"refusal_note_label": "Notă de la studio",
|
|
370
372
|
"status": {
|
|
371
373
|
"pending": "În așteptare",
|
|
372
374
|
"under_review": "În revizuire",
|
|
@@ -386,6 +388,14 @@
|
|
|
386
388
|
"error_user_blocked": "Accesul dvs. la solicitările de chei a fost blocat temporar din cauza transmisiilor de materiale restante. Trimiteți materialele dvs. pentru a restabili accesul.",
|
|
387
389
|
"error_not_eligible": "Această campanie nu este disponibilă pentru planul dvs. actual.",
|
|
388
390
|
"error_pending_limit": "Ați atins limita de cereri simultane a planului dvs. Îndepliniți-vă obligațiile restante înainte de a solicita o nouă cheie.",
|
|
391
|
+
"error_daily_limit": "Ați atins limita zilnică de cereri de chei a planului dvs. Încercați din nou mâine.",
|
|
392
|
+
"error_requirements_ack": "Confirmă că înțelegi ce așteaptă această campanie înainte de a solicita o cheie.",
|
|
393
|
+
"error_content_type_not_accepted": "Conținutul tău nu corespunde cu ce acceptă această campanie. Verifică tipurile de conținut acceptate și încearcă din nou.",
|
|
394
|
+
"requirements_title": "Ce așteaptă această campanie",
|
|
395
|
+
"requirements_accepted_types": "Conținut acceptat: {types}",
|
|
396
|
+
"requirements_all_types": "Orice tip de conținut este acceptat",
|
|
397
|
+
"requirements_ack_label": "Înțeleg ce se așteaptă de la conținutul meu în această campanie.",
|
|
398
|
+
"requirements_ack_required": "Confirmă că înțelegi ce se așteaptă înainte de a solicita cheia.",
|
|
389
399
|
"error_not_open_yet": "Această campanie nu s-a deschis încă.",
|
|
390
400
|
"error_closed": "Această campanie este închisă.",
|
|
391
401
|
"error_country": "Această campanie nu este disponibilă în țara ta.",
|
|
@@ -463,7 +473,14 @@
|
|
|
463
473
|
"finish": "Submit",
|
|
464
474
|
"submitted_title": "Material submitted!",
|
|
465
475
|
"success_message": "Your material was sent for review. Thank you!",
|
|
466
|
-
"success_close": "Close"
|
|
476
|
+
"success_close": "Close",
|
|
477
|
+
"language": "Limba materialului",
|
|
478
|
+
"language_placeholder": "Caută limba...",
|
|
479
|
+
"language_loading": "Se încarcă limbile...",
|
|
480
|
+
"language_load_error": "Limbile nu au putut fi încărcate.",
|
|
481
|
+
"language_retry": "Încearcă din nou",
|
|
482
|
+
"language_no_results": "Nicio limbă găsită",
|
|
483
|
+
"language_hint": "Spune-ne în ce limbă este conținutul tău. Ajută doar echipa să găsească și să filtreze livrările."
|
|
467
484
|
}
|
|
468
485
|
},
|
|
469
486
|
"common": {
|
package/package.json
CHANGED
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
import { fetchDetailGame, fetchDetailGameImage } from "../../services/gamesService"
|
|
16
16
|
import { formatEmbargoDateTime } from "../../utils/embargo"
|
|
17
17
|
import { useLoginStore } from "../../stores/login"
|
|
18
|
+
import { captureRequestSource } from "../../utils/requestSource"
|
|
18
19
|
|
|
19
20
|
// Injected by each front — provide in app.vue / a plugin
|
|
20
21
|
const mgPlatform = inject<string>("mgPlatform", "MGTV")
|
|
@@ -680,6 +681,8 @@ async function loadMyRequest() {
|
|
|
680
681
|
}
|
|
681
682
|
|
|
682
683
|
onMounted(async () => {
|
|
684
|
+
// ?ref=embed (utm_* are ignored here) tags the later key request for this campaign only.
|
|
685
|
+
captureRequestSource(campaign.value?.slug || slug, route.query)
|
|
683
686
|
updateCountdown()
|
|
684
687
|
await loadMyRequest()
|
|
685
688
|
})
|
|
@@ -1031,6 +1034,25 @@ watch(
|
|
|
1031
1034
|
</div>
|
|
1032
1035
|
</div>
|
|
1033
1036
|
|
|
1037
|
+
<div v-if="campaign?.requirements?.declares_requirements" class="requirements content-requirements">
|
|
1038
|
+
{{ $t("keys.campaigns.requirements_title") }}
|
|
1039
|
+
<div class="tags">
|
|
1040
|
+
<div class="tag active">
|
|
1041
|
+
<MGIcon icon="check" />
|
|
1042
|
+
{{
|
|
1043
|
+
campaign.requirements.accepts_all_content
|
|
1044
|
+
? $t("keys.campaigns.requirements_all_types")
|
|
1045
|
+
: $t("keys.campaigns.requirements_accepted_types", {
|
|
1046
|
+
types: campaign.requirements.accepted_content_types.map((t: any) => t.name).join(", "),
|
|
1047
|
+
})
|
|
1048
|
+
}}
|
|
1049
|
+
</div>
|
|
1050
|
+
</div>
|
|
1051
|
+
<div class="tags" v-if="campaign.requirements.requirements_note">
|
|
1052
|
+
<div class="tag-bg requirements-note">{{ campaign.requirements.requirements_note }}</div>
|
|
1053
|
+
</div>
|
|
1054
|
+
</div>
|
|
1055
|
+
|
|
1034
1056
|
<div class="actions">
|
|
1035
1057
|
{{ $t("keys.campaigns.campaign.actions") }}
|
|
1036
1058
|
<template v-if="keyActions && keyActions.length > 0">
|
|
@@ -1648,6 +1670,11 @@ watch(
|
|
|
1648
1670
|
i { color: var(--key-accent-ink, #13161C); }
|
|
1649
1671
|
}
|
|
1650
1672
|
}
|
|
1673
|
+
.tag-bg.requirements-note {
|
|
1674
|
+
height: auto;
|
|
1675
|
+
min-height: 32px;
|
|
1676
|
+
white-space: pre-line;
|
|
1677
|
+
}
|
|
1651
1678
|
.tag-bg {
|
|
1652
1679
|
background-color: var(--button-secondary-default-bg);
|
|
1653
1680
|
display: flex;
|
|
@@ -411,6 +411,15 @@
|
|
|
411
411
|
<div v-if="card.key.game?.name && card.key.name !== card.key.game.name" class="request-card__campaign">
|
|
412
412
|
{{ card.key.name }}
|
|
413
413
|
</div>
|
|
414
|
+
<div v-if="card.refusal" class="request-card__refusal">
|
|
415
|
+
<div v-if="card.refusal.reason" class="request-card__refusal-title">{{ $t("keys.campaigns.refusal_title") }}</div>
|
|
416
|
+
<div v-if="card.refusal.reason" class="request-card__refusal-reason">{{ card.refusal.reason }}</div>
|
|
417
|
+
<div v-if="card.refusal.description" class="request-card__refusal-desc">{{ card.refusal.description }}</div>
|
|
418
|
+
<div v-if="card.refusal.note" class="request-card__refusal-note">
|
|
419
|
+
<span class="request-card__refusal-label">{{ $t("keys.campaigns.refusal_note_label") }}</span>
|
|
420
|
+
{{ card.refusal.note }}
|
|
421
|
+
</div>
|
|
422
|
+
</div>
|
|
414
423
|
<div class="request-card__footer">
|
|
415
424
|
<span v-if="card.key.type?.name" class="request-card__type">{{ card.key.type.name }}</span>
|
|
416
425
|
<MGIcon icon="chevron-right" />
|
|
@@ -437,6 +446,7 @@ import { useNuxtApp, navigateTo } from "#app"
|
|
|
437
446
|
import { useCampaignsStore } from "../../stores/campaigns"
|
|
438
447
|
import { fetchMyRequests, fetchRedeemedUsers, downloadContentCalendar } from "../../services/campaignService"
|
|
439
448
|
import { useLoginStore } from "../../stores/login"
|
|
449
|
+
import { refusalDetails } from "../../utils/refusalDetails"
|
|
440
450
|
|
|
441
451
|
// Injected by each consuming front — provide these in app.vue / a plugin
|
|
442
452
|
const mgPlatform = inject<string>("mgPlatform", "MGTV")
|
|
@@ -784,6 +794,7 @@ async function loadMyRequests() {
|
|
|
784
794
|
statusSlug: item.status_request.slug,
|
|
785
795
|
status: statusI18nMap[item.status_request.slug] ?? item.status_request.name,
|
|
786
796
|
color: item.status_request.color,
|
|
797
|
+
refusal: item.status_request.slug === "refused" ? refusalDetails(item) : null,
|
|
787
798
|
key: {
|
|
788
799
|
...item.key,
|
|
789
800
|
cover_src: item.key.cover_src,
|
|
@@ -1071,6 +1082,30 @@ onUnmounted(() => {
|
|
|
1071
1082
|
white-space: nowrap;
|
|
1072
1083
|
}
|
|
1073
1084
|
|
|
1085
|
+
&__refusal {
|
|
1086
|
+
display: flex;
|
|
1087
|
+
flex-direction: column;
|
|
1088
|
+
gap: 4px;
|
|
1089
|
+
padding: 8px 10px;
|
|
1090
|
+
border-left: 3px solid var(--danger);
|
|
1091
|
+
border-radius: 6px;
|
|
1092
|
+
background: var(--key-surface-alt, var(--secondary-info-bg));
|
|
1093
|
+
font-size: 12px;
|
|
1094
|
+
color: var(--secondary-info-fg);
|
|
1095
|
+
white-space: normal;
|
|
1096
|
+
}
|
|
1097
|
+
|
|
1098
|
+
&__refusal-title,
|
|
1099
|
+
&__refusal-label {
|
|
1100
|
+
font-size: 10px;
|
|
1101
|
+
font-weight: 700;
|
|
1102
|
+
text-transform: uppercase;
|
|
1103
|
+
letter-spacing: 0.4px;
|
|
1104
|
+
color: var(--danger);
|
|
1105
|
+
}
|
|
1106
|
+
|
|
1107
|
+
&__refusal-reason { font-weight: 600; color: var(--primary-info-fg, inherit); }
|
|
1108
|
+
|
|
1074
1109
|
&__footer {
|
|
1075
1110
|
display: flex;
|
|
1076
1111
|
align-items: center;
|
|
@@ -119,6 +119,16 @@
|
|
|
119
119
|
</div>
|
|
120
120
|
</div>
|
|
121
121
|
|
|
122
|
+
<div class="form-row">
|
|
123
|
+
<div class="col1">
|
|
124
|
+
<h5>{{ $t("keys.materials.language") }}</h5>
|
|
125
|
+
</div>
|
|
126
|
+
<div class="col2">
|
|
127
|
+
<MaterialLanguageSelect v-model="form.language_id" :error="languageError" />
|
|
128
|
+
<div class="language-hint">{{ $t("keys.materials.language_hint") }}</div>
|
|
129
|
+
</div>
|
|
130
|
+
</div>
|
|
131
|
+
|
|
122
132
|
<div class="form-row">
|
|
123
133
|
<div class="col1">
|
|
124
134
|
<h5>{{ $t("keys.materials.date") }}</h5>
|
|
@@ -140,7 +150,8 @@
|
|
|
140
150
|
<div
|
|
141
151
|
v-else
|
|
142
152
|
class="btn button-submit"
|
|
143
|
-
:class="{ disabled: submitting }"
|
|
153
|
+
:class="{ disabled: submitting || !canSubmit }"
|
|
154
|
+
:aria-disabled="submitting || !canSubmit"
|
|
144
155
|
@click="submitForm"
|
|
145
156
|
>
|
|
146
157
|
<span v-if="submitting">{{ $t("keys.materials.sending") }}</span>
|
|
@@ -199,6 +210,8 @@
|
|
|
199
210
|
import { ref, computed, inject, onMounted, unref } from "vue"
|
|
200
211
|
import { useRoute, useRouter } from "vue-router"
|
|
201
212
|
import { useI18n } from "#imports"
|
|
213
|
+
import MaterialLanguageSelect from "../../components/keys/MaterialLanguageSelect.vue"
|
|
214
|
+
import { languageFieldError, hasLanguage } from "../../utils/materialLanguage"
|
|
202
215
|
import {
|
|
203
216
|
submitMaterial,
|
|
204
217
|
fetchMaterialsByRequest,
|
|
@@ -240,10 +253,11 @@ interface FormData {
|
|
|
240
253
|
material_url: string
|
|
241
254
|
description: string
|
|
242
255
|
submitted_at: string
|
|
256
|
+
language_id: number | null
|
|
243
257
|
}
|
|
244
258
|
|
|
245
259
|
const forms = ref<FormData[]>([
|
|
246
|
-
{ content_types: [], material_url: "", description: "", submitted_at: "" },
|
|
260
|
+
{ content_types: [], material_url: "", description: "", submitted_at: "", language_id: null },
|
|
247
261
|
])
|
|
248
262
|
const activeForm = ref(0)
|
|
249
263
|
const isContentOpened = ref<Record<number, boolean>>({ 1: true })
|
|
@@ -255,6 +269,10 @@ const formError = ref<string | null>(null)
|
|
|
255
269
|
// UI looking logged in) — show a re-login CTA instead of a generic failure.
|
|
256
270
|
const sessionExpired = ref(false)
|
|
257
271
|
const showSuccessModal = ref(false)
|
|
272
|
+
const languageError = ref<string | null>(null)
|
|
273
|
+
// The deliver button stays off until every form has a language: it is required
|
|
274
|
+
// (it informs and filters the studio, it is never a reason to refuse).
|
|
275
|
+
const canSubmit = computed(() => forms.value.every((f) => hasLanguage(f.language_id)))
|
|
258
276
|
|
|
259
277
|
// Submission deadline — counts down from the request's approval date, using
|
|
260
278
|
// the campaign's configured window (defaults to 30 days server-side).
|
|
@@ -324,9 +342,10 @@ function isValidUrl(urlString: string): boolean {
|
|
|
324
342
|
}
|
|
325
343
|
|
|
326
344
|
const submitForm = async () => {
|
|
327
|
-
if (submitting.value) return
|
|
345
|
+
if (submitting.value || !canSubmit.value) return
|
|
328
346
|
submitting.value = true
|
|
329
347
|
urlError.value = null
|
|
348
|
+
languageError.value = null
|
|
330
349
|
formError.value = null
|
|
331
350
|
sessionExpired.value = false
|
|
332
351
|
|
|
@@ -337,7 +356,7 @@ const submitForm = async () => {
|
|
|
337
356
|
})
|
|
338
357
|
|
|
339
358
|
const hasEmptyFields = forms.value.some(
|
|
340
|
-
(form) => form.content_types.length === 0 || !form.material_url || !form.submitted_at,
|
|
359
|
+
(form) => form.content_types.length === 0 || !form.material_url || !form.submitted_at || !hasLanguage(form.language_id),
|
|
341
360
|
)
|
|
342
361
|
|
|
343
362
|
if (hasEmptyFields) {
|
|
@@ -364,6 +383,7 @@ const submitForm = async () => {
|
|
|
364
383
|
content_types: form.content_types,
|
|
365
384
|
material_url: form.material_url,
|
|
366
385
|
description: form.description,
|
|
386
|
+
language_id: form.language_id,
|
|
367
387
|
submitted_at: new Date(form.submitted_at).toISOString(),
|
|
368
388
|
})
|
|
369
389
|
} catch (submitError: any) {
|
|
@@ -373,6 +393,11 @@ const submitForm = async () => {
|
|
|
373
393
|
// without catching this specific code here it fell through to
|
|
374
394
|
// the generic "something went wrong" below, leaving the person
|
|
375
395
|
// no wiser that it's the SAME link they already sent.
|
|
396
|
+
const langErr = languageFieldError(submitError)
|
|
397
|
+
if (langErr) {
|
|
398
|
+
languageError.value = langErr
|
|
399
|
+
return
|
|
400
|
+
}
|
|
376
401
|
if (submitError?.response?.data?.error === "DUPLICATE_MATERIAL_URL") {
|
|
377
402
|
formError.value = t("keys.materials.duplicate_url_error")
|
|
378
403
|
return
|
|
@@ -387,7 +412,7 @@ const submitForm = async () => {
|
|
|
387
412
|
submittedMaterials.value = res?.data?.data ?? []
|
|
388
413
|
} catch { /* silent */ }
|
|
389
414
|
|
|
390
|
-
forms.value = [{ content_types: [], material_url: "", description: "", submitted_at: "" }]
|
|
415
|
+
forms.value = [{ content_types: [], material_url: "", description: "", submitted_at: "", language_id: null }]
|
|
391
416
|
activeForm.value = 0
|
|
392
417
|
showSuccessModal.value = true
|
|
393
418
|
} catch (error) {
|
|
@@ -416,15 +441,15 @@ onMounted(async () => {
|
|
|
416
441
|
|
|
417
442
|
<style scoped lang="scss">
|
|
418
443
|
.form-error {
|
|
419
|
-
color:
|
|
444
|
+
color: var(--danger);
|
|
420
445
|
font-size: 12px;
|
|
421
446
|
padding: 8px 0;
|
|
422
447
|
width: 100%;
|
|
423
448
|
text-align: right;
|
|
424
449
|
}
|
|
425
450
|
|
|
426
|
-
.error-border { border: 1px solid
|
|
427
|
-
.error-message { color:
|
|
451
|
+
.error-border { border: 1px solid var(--danger) !important; }
|
|
452
|
+
.error-message { color: var(--danger); font-size: 0.8rem; margin-top: 5px; }
|
|
428
453
|
|
|
429
454
|
.success-modal-overlay {
|
|
430
455
|
position: fixed;
|
|
@@ -645,6 +670,7 @@ onMounted(async () => {
|
|
|
645
670
|
&:focus { border: 1px solid var(--section-title-marker-fg); box-shadow: none; outline: 0; }
|
|
646
671
|
}
|
|
647
672
|
|
|
673
|
+
.language-hint { font-size: 12px; color: var(--inactive); margin-top: 6px; }
|
|
648
674
|
.textarea { height: 134px; &::placeholder { color: var(--inactive); } }
|
|
649
675
|
|
|
650
676
|
.types {
|
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
import { formatEmbargoDateTime } from "../../utils/embargo"
|
|
16
16
|
import { keyRequestErrorMessage } from "../../utils/keyRequestError"
|
|
17
17
|
import { useLoginStore } from "../../stores/login"
|
|
18
|
+
import { requestSourceFor } from "../../utils/requestSource"
|
|
18
19
|
|
|
19
20
|
const route = useRoute()
|
|
20
21
|
const { $i18n } = useNuxtApp()
|
|
@@ -56,6 +57,15 @@ const notifyKeyCampaigns = ref(true)
|
|
|
56
57
|
// embargo lifts BEFORE asking for the key, not only at reveal.
|
|
57
58
|
const embargoAckChecked = ref(false)
|
|
58
59
|
|
|
60
|
+
// Campaigns that state what they expect (accepted content types / a note): the
|
|
61
|
+
// creator confirms it before asking for the key.
|
|
62
|
+
const requirements = computed(() => campaign.value?.requirements ?? null)
|
|
63
|
+
const requiresAck = computed(() => !!requirements.value?.declares_requirements)
|
|
64
|
+
const requirementsAckChecked = ref(false)
|
|
65
|
+
const acceptedTypesLabel = computed(() =>
|
|
66
|
+
(requirements.value?.accepted_content_types ?? []).map((t: any) => t.name).join(", "),
|
|
67
|
+
)
|
|
68
|
+
|
|
59
69
|
const maxKeysForUser = computed(() => campaign.value?.max_keys_for_user ?? 1)
|
|
60
70
|
|
|
61
71
|
// Where the success screen sends the user back to. Falls back to the id the
|
|
@@ -162,7 +172,13 @@ const missingOptions = computed(
|
|
|
162
172
|
// Drives both the client-side guard and whether region_ids goes on the wire.
|
|
163
173
|
const regionRequired = computed(() => regions.value.length > 0)
|
|
164
174
|
|
|
165
|
-
const canSubmit = computed(
|
|
175
|
+
const canSubmit = computed(
|
|
176
|
+
() =>
|
|
177
|
+
!submitting.value
|
|
178
|
+
&& !soldOut.value
|
|
179
|
+
&& !missingOptions.value
|
|
180
|
+
&& (!requiresAck.value || requirementsAckChecked.value),
|
|
181
|
+
)
|
|
166
182
|
|
|
167
183
|
// Collapsible "Required data" box — matches tv's original toggle behavior
|
|
168
184
|
const isBoxOpen = ref(true)
|
|
@@ -212,6 +228,10 @@ async function submit() {
|
|
|
212
228
|
requestError.value = $i18n.t("keys.campaigns.embargo_ack_required")
|
|
213
229
|
return
|
|
214
230
|
}
|
|
231
|
+
if (requiresAck.value && !requirementsAckChecked.value) {
|
|
232
|
+
requestError.value = $i18n.t("keys.campaigns.requirements_ack_required")
|
|
233
|
+
return
|
|
234
|
+
}
|
|
215
235
|
submitting.value = true
|
|
216
236
|
try {
|
|
217
237
|
const response = await requestKey({
|
|
@@ -223,6 +243,9 @@ async function submit() {
|
|
|
223
243
|
// Recorded on the request so the acknowledgment is provable, not just
|
|
224
244
|
// a checkbox the browser forgot about.
|
|
225
245
|
acknowledge_embargo: hasEmbargo.value && embargoAckChecked.value,
|
|
246
|
+
...(requiresAck.value ? { requirements_acknowledged: true } : {}),
|
|
247
|
+
// Only when the creator came from this campaign's embed.
|
|
248
|
+
...(requestSourceFor(campaign.value?.slug) ? { source: "embed" } : {}),
|
|
226
249
|
})
|
|
227
250
|
const created = response?.data?.data ?? response?.data ?? {}
|
|
228
251
|
|
|
@@ -432,6 +455,30 @@ onUnmounted(() => {
|
|
|
432
455
|
</label>
|
|
433
456
|
</div>
|
|
434
457
|
|
|
458
|
+
<!-- Requirements: what the campaign expects, acknowledged before requesting. -->
|
|
459
|
+
<div v-if="requiresAck" class="embargo-box requirements-box">
|
|
460
|
+
<div class="embargo-box-head">
|
|
461
|
+
<MGIcon size="1x" icon="check" class="notice-icon" />
|
|
462
|
+
<div class="notice-texts">
|
|
463
|
+
<div class="notice-title">{{ $t("keys.campaigns.requirements_title") }}</div>
|
|
464
|
+
<div class="notice-status">
|
|
465
|
+
{{
|
|
466
|
+
requirements.accepts_all_content
|
|
467
|
+
? $t("keys.campaigns.requirements_all_types")
|
|
468
|
+
: $t("keys.campaigns.requirements_accepted_types", { types: acceptedTypesLabel })
|
|
469
|
+
}}
|
|
470
|
+
</div>
|
|
471
|
+
<div v-if="requirements.requirements_note" class="notice-status requirements-note">
|
|
472
|
+
{{ requirements.requirements_note }}
|
|
473
|
+
</div>
|
|
474
|
+
</div>
|
|
475
|
+
</div>
|
|
476
|
+
<label class="checkbox-label embargo-ack">
|
|
477
|
+
<input type="checkbox" v-model="requirementsAckChecked" />
|
|
478
|
+
{{ $t("keys.campaigns.requirements_ack_label") }}
|
|
479
|
+
</label>
|
|
480
|
+
</div>
|
|
481
|
+
|
|
435
482
|
<div v-if="sessionExpired" class="session-expired">
|
|
436
483
|
<MGIcon size="1x" icon="version" class="notice-icon" />
|
|
437
484
|
<div class="notice-texts">
|
|
@@ -552,6 +599,8 @@ onUnmounted(() => {
|
|
|
552
599
|
svg.rotate { transform: rotate(180deg); }
|
|
553
600
|
}
|
|
554
601
|
|
|
602
|
+
.requirements-note { white-space: pre-line; }
|
|
603
|
+
|
|
555
604
|
.embargo-box {
|
|
556
605
|
display: flex;
|
|
557
606
|
flex-direction: column;
|
|
@@ -420,6 +420,9 @@ export const fetchCampaignBySlug = async (slug: string) => {
|
|
|
420
420
|
game_videos: (k.game?.videos || []) as Array<{ external_id: string; name?: string }>,
|
|
421
421
|
press_kit_link: k.press_kit_link ?? null,
|
|
422
422
|
review_guideline: k.review_guideline ?? null,
|
|
423
|
+
// What the studio expects from creators (accepted content types + note).
|
|
424
|
+
// null on older payloads: nothing to show, nothing to acknowledge.
|
|
425
|
+
requirements: k.requirements ?? null,
|
|
423
426
|
// The instant plus a zone the server has already resolved. Replaces the
|
|
424
427
|
// raw embargo_date/embargo_timezone pair, which nothing read once the
|
|
425
428
|
// formatter moved onto this block — the campaign write forms use those
|
|
@@ -593,6 +596,30 @@ export const submitMaterial = (data: Record<string, any>) => {
|
|
|
593
596
|
return authClient.post("/public/key-materials", data)
|
|
594
597
|
}
|
|
595
598
|
|
|
599
|
+
let _languagesCache: Promise<any[]> | null = null
|
|
600
|
+
|
|
601
|
+
/**
|
|
602
|
+
* Every ACTIVE language (public api-main lookup, no status_public filter).
|
|
603
|
+
* Loaded once per page session and kept in memory; a failure is not cached.
|
|
604
|
+
*/
|
|
605
|
+
export const fetchMaterialLanguages = (): Promise<any[]> => {
|
|
606
|
+
if (!_languagesCache) {
|
|
607
|
+
// `/languages` is an api-main lookup. The shared key routes live on each app's OWN API (mainClient), which does not serve it,
|
|
608
|
+
// so go to the network (api-main) host every frontend already configures; it is public, no session needed.
|
|
609
|
+
const networkBase = withApiV1(import.meta.env.VITE_BASE_URL_NETWORK || "")
|
|
610
|
+
const request = networkBase
|
|
611
|
+
? axios.get(`${networkBase}/languages?filter[status]=true&per_page=all&lang=${resolveLang()}`)
|
|
612
|
+
: mainClient.get("/languages?filter[status]=true&per_page=all")
|
|
613
|
+
_languagesCache = request
|
|
614
|
+
.then((res: any) => res?.data?.data ?? res?.data ?? [])
|
|
615
|
+
.catch((e: any) => {
|
|
616
|
+
_languagesCache = null
|
|
617
|
+
throw e
|
|
618
|
+
})
|
|
619
|
+
}
|
|
620
|
+
return _languagesCache
|
|
621
|
+
}
|
|
622
|
+
|
|
596
623
|
/**
|
|
597
624
|
* Fetch all materials submitted for a key request.
|
|
598
625
|
*/
|
package/services/keyService.ts
CHANGED
|
@@ -9,6 +9,13 @@ export type KeyCampaign = {
|
|
|
9
9
|
already_requested: boolean
|
|
10
10
|
game: { id: number; name: string } | null
|
|
11
11
|
cover: string | null
|
|
12
|
+
// What the studio expects from creators; absent on older payloads.
|
|
13
|
+
requirements?: {
|
|
14
|
+
accepts_all_content: boolean
|
|
15
|
+
accepted_content_types: Array<{ id: number; slug: string; name: string }>
|
|
16
|
+
requirements_note: string | null
|
|
17
|
+
declares_requirements: boolean
|
|
18
|
+
} | null
|
|
12
19
|
}
|
|
13
20
|
|
|
14
21
|
export type KeyRequest = {
|
package/utils/keyRequestError.ts
CHANGED
|
@@ -29,6 +29,21 @@ export function keyRequestErrorMessage(err: any): KeyRequestErrorMessage | null
|
|
|
29
29
|
return { key: "keys.campaigns.error_pending_limit" }
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
+
// The plan's cap of requests per day: say so, and when to come back, instead of the server's untranslated sentence.
|
|
33
|
+
if (status === 422 && errorCode === "daily_limit_reached") {
|
|
34
|
+
return { key: "keys.campaigns.error_daily_limit" }
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// The campaign states what it expects and the creator did not acknowledge it.
|
|
38
|
+
if (status === 422 && errorCode === "requirements_ack_required") {
|
|
39
|
+
return { key: "keys.campaigns.error_requirements_ack" }
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// A material of a content type the campaign does not accept.
|
|
43
|
+
if (status === 422 && errorCode === "content_type_not_accepted") {
|
|
44
|
+
return { key: "keys.campaigns.error_content_type_not_accepted" }
|
|
45
|
+
}
|
|
46
|
+
|
|
32
47
|
if (status !== 403) return null
|
|
33
48
|
|
|
34
49
|
if (errorCode === "user_key_blocked") return { key: "keys.campaigns.error_user_blocked" }
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure helpers for the "language of the delivered material" picker.
|
|
3
|
+
*
|
|
4
|
+
* The list comes from the public api-main lookup
|
|
5
|
+
* GET /languages?filter[status]=true&per_page=all (rows: id, name, name_abrev,
|
|
6
|
+
* flag_url, status, status_public). Everything here is side-effect free so the
|
|
7
|
+
* component stays thin and this stays unit-testable.
|
|
8
|
+
*/
|
|
9
|
+
export interface MaterialLanguage {
|
|
10
|
+
id: number
|
|
11
|
+
name: string
|
|
12
|
+
name_abrev?: string | null
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface MaterialLanguageOption {
|
|
16
|
+
id: number
|
|
17
|
+
/** What the picker shows: the name in the UI language (localized_name) when the API sent one, else the plain name. */
|
|
18
|
+
name: string
|
|
19
|
+
/** The language's own/English name from the API, kept so a search for either spelling finds it ("alemão" or "Deutsch"). */
|
|
20
|
+
nativeName: string
|
|
21
|
+
code: string
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** Lower-case, strip accents/diacritics and collapse spaces: "Español " -> "espanol". */
|
|
25
|
+
export function normalizeSearch(value: unknown): string {
|
|
26
|
+
return String(value ?? "")
|
|
27
|
+
.normalize("NFD")
|
|
28
|
+
.replace(/[̀-ͯ]/g, "")
|
|
29
|
+
.toLowerCase()
|
|
30
|
+
.replace(/\s+/g, " ")
|
|
31
|
+
.trim()
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** Accepts the raw response body ({data: [...]} or [...]) and returns a clean, name-sorted option list. */
|
|
35
|
+
export function buildLanguageOptions(raw: unknown, locale = "en"): MaterialLanguageOption[] {
|
|
36
|
+
const rows: any[] = Array.isArray(raw) ? raw : Array.isArray((raw as any)?.data) ? (raw as any).data : []
|
|
37
|
+
const seen = new Set<number>()
|
|
38
|
+
const options: MaterialLanguageOption[] = []
|
|
39
|
+
for (const row of rows) {
|
|
40
|
+
const id = Number(row?.id)
|
|
41
|
+
const raw = typeof row?.name === "string" ? row.name.trim() : ""
|
|
42
|
+
const localized = typeof row?.localized_name === "string" ? row.localized_name.trim() : ""
|
|
43
|
+
const name = localized || raw
|
|
44
|
+
if (!Number.isFinite(id) || id <= 0 || !name || seen.has(id)) continue
|
|
45
|
+
if (row?.status === false) continue
|
|
46
|
+
seen.add(id)
|
|
47
|
+
options.push({ id, name, nativeName: raw, code: String(row?.name_abrev ?? "").trim() })
|
|
48
|
+
}
|
|
49
|
+
let collator: Intl.Collator
|
|
50
|
+
try {
|
|
51
|
+
collator = new Intl.Collator(locale, { sensitivity: "base" })
|
|
52
|
+
} catch {
|
|
53
|
+
collator = new Intl.Collator("en", { sensitivity: "base" })
|
|
54
|
+
}
|
|
55
|
+
return options.sort((a, b) => collator.compare(a.name, b.name) || a.id - b.id)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Accent-insensitive filter. Names starting with the query come first, then
|
|
60
|
+
* names containing it, then matches on the abbreviation. An empty query keeps
|
|
61
|
+
* the whole (already sorted) list.
|
|
62
|
+
*/
|
|
63
|
+
export function filterLanguageOptions(options: MaterialLanguageOption[], query: string): MaterialLanguageOption[] {
|
|
64
|
+
const q = normalizeSearch(query)
|
|
65
|
+
if (!q) return options
|
|
66
|
+
const starts: MaterialLanguageOption[] = []
|
|
67
|
+
const contains: MaterialLanguageOption[] = []
|
|
68
|
+
const byCode: MaterialLanguageOption[] = []
|
|
69
|
+
for (const opt of options) {
|
|
70
|
+
const name = normalizeSearch(opt.name)
|
|
71
|
+
const native = normalizeSearch(opt.nativeName)
|
|
72
|
+
if (name.startsWith(q) || native.startsWith(q)) starts.push(opt)
|
|
73
|
+
else if (name.includes(q) || native.includes(q)) contains.push(opt)
|
|
74
|
+
else if (opt.code && normalizeSearch(opt.code) === q) byCode.push(opt)
|
|
75
|
+
}
|
|
76
|
+
return [...starts, ...contains, ...byCode]
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** The 422 field error the server sends for language_id (Laravel shape), or null. */
|
|
80
|
+
export function languageFieldError(err: any): string | null {
|
|
81
|
+
if (err?.response?.status !== 422) return null
|
|
82
|
+
const data = err.response.data ?? {}
|
|
83
|
+
const msgs = data.errors?.language_id ?? data.data?.errors?.language_id
|
|
84
|
+
if (Array.isArray(msgs) && msgs.length) return String(msgs[0])
|
|
85
|
+
if (typeof msgs === "string" && msgs) return msgs
|
|
86
|
+
return null
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** Whether a delivery can be sent: all-or-nothing on the language being chosen. */
|
|
90
|
+
export function hasLanguage(languageId: number | null | undefined): languageId is number {
|
|
91
|
+
return typeof languageId === "number" && Number.isFinite(languageId) && languageId > 0
|
|
92
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type RefusalReason = { id?: number; slug?: string; name?: string | null; description?: string | null } | null | undefined
|
|
2
|
+
|
|
3
|
+
export type RefusalDetails = { reason: string; description: string; note: string }
|
|
4
|
+
|
|
5
|
+
const clean = (v: unknown): string => (typeof v === "string" ? v.trim() : "")
|
|
6
|
+
|
|
7
|
+
/** What a creator should see for a refused request; null when there is nothing to show (older refusals). */
|
|
8
|
+
export function refusalDetails(item: { refusal_reason?: RefusalReason; admin_notes?: string | null }): RefusalDetails | null {
|
|
9
|
+
const reason = clean(item?.refusal_reason?.name)
|
|
10
|
+
const description = reason ? clean(item?.refusal_reason?.description) : ""
|
|
11
|
+
const note = clean(item?.admin_notes)
|
|
12
|
+
if (!reason && !note) return null
|
|
13
|
+
return { reason, description, note }
|
|
14
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// Remembers that a creator arrived from an embedded campaign (?ref=embed) so
|
|
2
|
+
// the key request made later (possibly after login/signup) is tagged
|
|
3
|
+
// source: 'embed'. Scoped per campaign slug: visiting one embed never tags
|
|
4
|
+
// requests for other campaigns. Every storage access is guarded.
|
|
5
|
+
|
|
6
|
+
const STORAGE_KEY = "mg-key-source"
|
|
7
|
+
const EMBED = "embed"
|
|
8
|
+
|
|
9
|
+
type Query = Record<string, unknown> | null | undefined
|
|
10
|
+
type Store = Pick<Storage, "getItem" | "setItem">
|
|
11
|
+
|
|
12
|
+
const defaultStore = (): Store | null => {
|
|
13
|
+
try {
|
|
14
|
+
return typeof sessionStorage !== "undefined" ? sessionStorage : null
|
|
15
|
+
} catch {
|
|
16
|
+
return null
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const read = (store: Store | null): string[] => {
|
|
21
|
+
try {
|
|
22
|
+
const parsed = JSON.parse(store?.getItem(STORAGE_KEY) ?? "[]")
|
|
23
|
+
return Array.isArray(parsed) ? parsed.filter((s) => typeof s === "string") : []
|
|
24
|
+
} catch {
|
|
25
|
+
return []
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const isEmbedRef = (query: Query): boolean => {
|
|
30
|
+
const ref = query?.ref
|
|
31
|
+
const value = Array.isArray(ref) ? ref[0] : ref
|
|
32
|
+
return value === EMBED
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** Call on arrival at a campaign page; stores the slug when ref=embed. */
|
|
36
|
+
export function captureRequestSource(slug: string, query: Query, store: Store | null = defaultStore()): void {
|
|
37
|
+
if (!slug || !isEmbedRef(query) || !store) return
|
|
38
|
+
try {
|
|
39
|
+
const slugs = read(store)
|
|
40
|
+
if (!slugs.includes(slug)) store.setItem(STORAGE_KEY, JSON.stringify([...slugs, slug]))
|
|
41
|
+
} catch {
|
|
42
|
+
// storage unavailable: the request simply goes untagged
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** 'embed' only if captured for this campaign, otherwise undefined. */
|
|
47
|
+
export function requestSourceFor(slug: string | null | undefined, store: Store | null = defaultStore()): "embed" | undefined {
|
|
48
|
+
if (!slug) return undefined
|
|
49
|
+
return read(store).includes(slug) ? EMBED : undefined
|
|
50
|
+
}
|