@dev.smartpricing/message-composer-layer 4.5.1-next.3 → 4.5.1-next.5

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/app/api/meta.ts CHANGED
@@ -1,4 +1,9 @@
1
1
  import type {
2
+ MetaImportCheck,
3
+ MetaImportConfirmBody,
4
+ MetaImportProposal,
5
+ MetaImportResult,
6
+ MetaImportScope,
2
7
  OrganizationWaba,
3
8
  SubmissionJob,
4
9
  SubmissionJobResponse,
@@ -8,7 +13,38 @@ import { apiClient } from './client'
8
13
 
9
14
  const submitBody = (wabaId?: string): SubmitToWabaBody => (wabaId ? { waba_id: wabaId } : {})
10
15
 
16
+ /** The Organization, Product and WABA of an Import, as a query string. */
17
+ const importQuery = ({ organization_id, product, waba_id }: MetaImportScope) =>
18
+ new URLSearchParams({ organization_id, product, waba_id }).toString()
19
+
11
20
  export const metaApi = {
21
+ /**
22
+ * How many Meta Templates of the WABA an Import would offer (ADR 0020). No
23
+ * error toast: it runs in the background of the list, and a failure only
24
+ * means no Import button.
25
+ */
26
+ checkImport: (scope: MetaImportScope) =>
27
+ apiClient<MetaImportCheck>(`/integrations/meta/import/check?${importQuery(scope)}`, {
28
+ _skipErrorToast: true,
29
+ } as Record<string, unknown>),
30
+
31
+ /**
32
+ * What an Import of the WABA would write, read from Meta now. Writes
33
+ * nothing. No error toast: the import dialog says itself that Meta could
34
+ * not be read (a 502).
35
+ */
36
+ getImportProposal: (scope: MetaImportScope) =>
37
+ apiClient<MetaImportProposal>(`/integrations/meta/import/proposal?${importQuery(scope)}`, {
38
+ _skipErrorToast: true,
39
+ } as Record<string, unknown>),
40
+
41
+ /** Confirms an Import: only Meta Template ids and how they are grouped. */
42
+ confirmImport: (body: MetaImportConfirmBody) =>
43
+ apiClient<MetaImportResult>('/integrations/meta/import', {
44
+ method: 'POST',
45
+ body,
46
+ }),
47
+
12
48
  /**
13
49
  * The WABAs of an Organization, empty when it has none (ADR 0015). No error
14
50
  * toast: a failed lookup leaves the WhatsApp configuration unknown, and the
@@ -19,6 +19,8 @@ const emit = defineEmits<{
19
19
  duplicated: [result: { id: string | number; sourceId: string | number; name: string }]
20
20
  published: [row: MessageGroupWithMessageSummary]
21
21
  unpublished: [row: MessageGroupWithMessageSummary]
22
+ /** Once, when the list has loaded for the first time. */
23
+ loaded: []
22
24
  }>()
23
25
 
24
26
  const { trackEvent } = useTracking()
@@ -36,6 +38,12 @@ const {
36
38
  refetch: execute,
37
39
  } = useMessageGroupList(renderType)
38
40
 
41
+ whenever(
42
+ () => !isFetching.value,
43
+ () => emit('loaded'),
44
+ { immediate: true, once: true },
45
+ )
46
+
39
47
  // Polling
40
48
  const interval = setInterval(() => execute(), 15000)
41
49
  onBeforeUnmount(() => clearInterval(interval))
@@ -0,0 +1,50 @@
1
+ <script setup lang="ts">
2
+ import MetaImportDialog from '~/components/MetaImport/Dialog.vue'
3
+ import { useMetaImportCheckQuery } from '~/queries'
4
+
5
+ /**
6
+ * The Import from Meta button of the Message Group list (ADR 0020). It is
7
+ * there only when a WABA of the Organization holds Meta Templates the
8
+ * composer does not, and says how many. The check behind it runs on its own:
9
+ * the list never waits for it.
10
+ */
11
+ const props = defineProps<{
12
+ /** False until the list has loaded: the check is asked only after it. */
13
+ enabled: boolean
14
+ }>()
15
+
16
+ const emit = defineEmits<{
17
+ /** An Import was confirmed: the list holds new WhatsApp Message Groups. */
18
+ imported: []
19
+ }>()
20
+
21
+ const appContext = useAppContextStore()
22
+ const organization = useEffectiveOrganizationStore()
23
+
24
+ const { data: checks } = useMetaImportCheckQuery({ enabled: () => props.enabled })
25
+
26
+ const count = computed(() => (checks.value ?? []).reduce((sum, check) => sum + check.count, 0))
27
+
28
+ const dialog = useOverlay().create(MetaImportDialog)
29
+
30
+ async function openDialog() {
31
+ const organizationId = organization.organizationId
32
+ const product = appContext.product
33
+ if (!checks.value?.length || !organizationId || !product) return
34
+
35
+ const imported = await dialog.open({ checks: checks.value, organizationId, product }).result
36
+ if (imported) emit('imported')
37
+ }
38
+ </script>
39
+
40
+ <template>
41
+ <UButton
42
+ v-if="count > 0"
43
+ :label="$t('pages.message_library.import_from_meta', { count })"
44
+ icon="ph:download-simple"
45
+ color="neutral"
46
+ variant="outline"
47
+ data-testid="meta-import-button"
48
+ @click="openDialog"
49
+ />
50
+ </template>
@@ -0,0 +1,261 @@
1
+ <script setup lang="ts">
2
+ import type {
3
+ MessageGroupProduct,
4
+ MetaImportProposal,
5
+ MetaImportProposalGroup,
6
+ MetaImportResult,
7
+ MetaImportScope,
8
+ } from '@dev.smartpricing/message-composer-utils/types'
9
+ import { useConfirmMetaImportMutation, useMetaImportProposalQuery } from '~/queries'
10
+ import type { WabaImportCheck } from '~/queries/meta'
11
+
12
+ /**
13
+ * Import from Meta (ADR 0020): the WABA to import from, when the
14
+ * Organization has several; then the proposal, read from Meta; then the
15
+ * outcome. Nothing is written before the user confirms the proposal.
16
+ * Opened through `useOverlay`: closes with whether an Import was confirmed.
17
+ */
18
+ const props = defineProps<{
19
+ /** The Organization's WABAs, each with what the check counted. */
20
+ checks: WabaImportCheck[]
21
+ organizationId: string
22
+ /** The Product the Host supplied: the imported Message Groups belong to it. */
23
+ product: MessageGroupProduct
24
+ }>()
25
+
26
+ const emit = defineEmits<{ close: [imported: boolean] }>()
27
+
28
+ const { metaWabaId } = storeToRefs(useAppContextStore())
29
+
30
+ const severalWabas = props.checks.length > 1
31
+ const step = ref<'waba' | 'proposal' | 'result'>(severalWabas ? 'waba' : 'proposal')
32
+
33
+ // The WABA in the radio group: the Host's when it is one of them, else the
34
+ // first that has something to import.
35
+ const selectedWabaId = ref<string | undefined>(
36
+ (
37
+ props.checks.find(({ waba }) => waba.id === metaWabaId.value) ??
38
+ props.checks.find(({ count }) => count > 0)
39
+ )?.waba.id,
40
+ )
41
+ /** The WABA the proposal is read from: set once the choice is made. */
42
+ const wabaId = ref<string | undefined>(severalWabas ? undefined : props.checks[0]?.waba.id)
43
+
44
+ const wabaItems = computed(() =>
45
+ props.checks.map(({ waba, count }) => ({
46
+ value: waba.id,
47
+ label: waba.name || waba.id,
48
+ numbers: waba.phone_numbers.join(', '),
49
+ count,
50
+ // Not `id`: the radio group gives each item one of its own.
51
+ wabaId: waba.id,
52
+ })),
53
+ )
54
+
55
+ function chooseWaba() {
56
+ wabaId.value = selectedWabaId.value
57
+ step.value = 'proposal'
58
+ }
59
+
60
+ const scope = computed<MetaImportScope | undefined>(() =>
61
+ wabaId.value
62
+ ? { organization_id: props.organizationId, product: props.product, waba_id: wabaId.value }
63
+ : undefined,
64
+ )
65
+
66
+ const { data: proposed, isLoading, error, refetch } = useMetaImportProposalQuery(scope)
67
+
68
+ /** What tells a proposed group from the others: a Meta Template is in one only. */
69
+ const groupKey = (group: MetaImportProposalGroup) => group.templates[0]?.id
70
+
71
+ // The groups of differently named Meta Templates the user split back into
72
+ // the groups their names make. There is no putting them together again.
73
+ const split = ref<Array<string | undefined>>([])
74
+
75
+ function splitGroup(group: MetaImportProposalGroup) {
76
+ split.value = [...split.value, groupKey(group)]
77
+ }
78
+
79
+ /** The proposal as the user left it: what is shown, confirmed and reported on. */
80
+ const proposal = computed<MetaImportProposal | undefined>(() => {
81
+ if (!proposed.value) return undefined
82
+ return {
83
+ ...proposed.value,
84
+ groups: proposed.value.groups.flatMap((group) =>
85
+ group.name_groups && split.value.includes(groupKey(group))
86
+ ? group.name_groups.map((part) => ({ ...part, name_groups: null }))
87
+ : [group],
88
+ ),
89
+ }
90
+ })
91
+
92
+ // Everything that can be imported starts ticked: the user unticks.
93
+ const ticked = ref<string[]>([])
94
+ watch(
95
+ proposed,
96
+ (value) => {
97
+ split.value = []
98
+ ticked.value = (value?.groups ?? []).flatMap((group) =>
99
+ group.templates.filter((template) => template.importable).map((template) => template.id),
100
+ )
101
+ },
102
+ { immediate: true },
103
+ )
104
+
105
+ /** The ticked Meta Templates, grouped as proposed; a group with none ticked is left out. */
106
+ const groupsToImport = computed(() => {
107
+ const tickedIds = new Set(ticked.value)
108
+ return (proposal.value?.groups ?? [])
109
+ .map((group) => ({
110
+ template_ids: group.templates.map(({ id }) => id).filter((id) => tickedIds.has(id)),
111
+ }))
112
+ .filter((group) => group.template_ids.length > 0)
113
+ })
114
+
115
+ const { mutateAsync: confirmImport, isLoading: isImporting } = useConfirmMetaImportMutation()
116
+ const result = shallowRef<MetaImportResult>()
117
+
118
+ async function confirm() {
119
+ if (!scope.value || groupsToImport.value.length === 0) return
120
+ try {
121
+ const answer = await confirmImport({ ...scope.value, groups: groupsToImport.value })
122
+ // A demo session is answered without an outcome: nothing was written.
123
+ result.value = { groups: answer.groups ?? [], refreshed: answer.refreshed ?? [] }
124
+ step.value = 'result'
125
+ } catch {
126
+ // The API client has told the user; the proposal stays to try again.
127
+ }
128
+ }
129
+
130
+ function close() {
131
+ if (isImporting.value) return
132
+ emit('close', !!result.value)
133
+ }
134
+ </script>
135
+
136
+ <template>
137
+ <UModal
138
+ :title="
139
+ step === 'result' ? $t('dialogs.meta_import.result_title') : $t('dialogs.meta_import.title')
140
+ "
141
+ :description="$t('dialogs.meta_import.description')"
142
+ close-icon="ph:x"
143
+ :close="{ onClick: close }"
144
+ :dismissible="false"
145
+ :ui="{ content: 'sm:max-w-3xl' }"
146
+ data-testid="meta-import-dialog"
147
+ >
148
+ <template #body>
149
+ <div v-if="step === 'waba'" class="flex flex-col gap-3">
150
+ <p class="text-sm text-muted">{{ $t('dialogs.meta_import.choose_waba') }}</p>
151
+ <URadioGroup
152
+ v-model="selectedWabaId"
153
+ :items="wabaItems"
154
+ variant="table"
155
+ class="w-full"
156
+ :ui="{ item: 'w-full' }"
157
+ data-testid="meta-import-waba-options"
158
+ >
159
+ <template #description="{ item }">
160
+ <span class="flex flex-col">
161
+ <span>{{ item.numbers || $t('dialogs.select_waba.no_numbers') }}</span>
162
+ <span class="text-xs text-dimmed font-mono">{{ item.wabaId }}</span>
163
+ <span class="text-xs">
164
+ {{ $t('dialogs.meta_import.waba_count', { count: item.count }) }}
165
+ </span>
166
+ </span>
167
+ </template>
168
+ </URadioGroup>
169
+ </div>
170
+
171
+ <MetaImportOutcome
172
+ v-else-if="step === 'result' && result && proposal"
173
+ :result="result"
174
+ :proposal="proposal"
175
+ />
176
+
177
+ <div
178
+ v-else-if="isLoading"
179
+ class="flex items-center justify-center gap-2 py-10 text-sm text-muted"
180
+ data-testid="meta-import-loading"
181
+ >
182
+ <UIcon name="ph:circle-notch" class="size-5 animate-spin" />
183
+ {{ $t('dialogs.meta_import.loading') }}
184
+ </div>
185
+
186
+ <UAlert
187
+ v-else-if="error || !proposal"
188
+ color="error"
189
+ variant="subtle"
190
+ icon="ph:warning-circle"
191
+ :title="$t('dialogs.meta_import.load_failed_title')"
192
+ :description="$t('dialogs.meta_import.load_failed_description')"
193
+ :actions="[
194
+ {
195
+ label: $t('dialogs.meta_import.retry'),
196
+ color: 'neutral',
197
+ variant: 'outline',
198
+ onClick: () => void refetch(),
199
+ },
200
+ ]"
201
+ data-testid="meta-import-load-failed"
202
+ />
203
+
204
+ <MetaImportProposalList
205
+ v-else
206
+ v-model:ticked="ticked"
207
+ :proposal="proposal"
208
+ @split="splitGroup"
209
+ />
210
+ </template>
211
+
212
+ <template #footer>
213
+ <div class="flex items-center gap-2 justify-end w-full">
214
+ <span
215
+ v-if="step === 'proposal' && proposal && !isLoading && !error"
216
+ class="text-sm text-muted mr-auto"
217
+ data-testid="meta-import-selection"
218
+ >
219
+ {{
220
+ $t('dialogs.meta_import.selection', {
221
+ groups: groupsToImport.length,
222
+ templates: ticked.length,
223
+ })
224
+ }}
225
+ </span>
226
+
227
+ <UButton
228
+ v-if="step === 'result'"
229
+ :label="$t('dialogs.meta_import.close')"
230
+ data-testid="meta-import-close"
231
+ @click="close"
232
+ />
233
+ <template v-else>
234
+ <UButton
235
+ variant="outline"
236
+ color="neutral"
237
+ :label="$t('common.actions.cancel')"
238
+ :disabled="isImporting"
239
+ data-testid="meta-import-cancel"
240
+ @click="close"
241
+ />
242
+ <UButton
243
+ v-if="step === 'waba'"
244
+ :label="$t('dialogs.meta_import.continue')"
245
+ :disabled="!selectedWabaId"
246
+ data-testid="meta-import-continue"
247
+ @click="chooseWaba"
248
+ />
249
+ <UButton
250
+ v-else
251
+ :label="$t('dialogs.meta_import.confirm')"
252
+ :loading="isImporting"
253
+ :disabled="isLoading || !!error || groupsToImport.length === 0"
254
+ data-testid="meta-import-confirm"
255
+ @click="confirm"
256
+ />
257
+ </template>
258
+ </div>
259
+ </template>
260
+ </UModal>
261
+ </template>
@@ -0,0 +1,136 @@
1
+ <script setup lang="ts">
2
+ import type {
3
+ MetaImportProposal,
4
+ MetaImportResult,
5
+ } from '@dev.smartpricing/message-composer-utils/types'
6
+ import { useMessageGroupNamesQuery } from '~/queries'
7
+
8
+ /**
9
+ * The outcome of a confirmed Import: how many Message Groups were written,
10
+ * which were not and why, and which were written without one of their
11
+ * languages. Names come from the proposal the user confirmed: the answer
12
+ * carries Meta Template ids only. It also says how many Message Groups
13
+ * imported earlier were brought up to date with Meta, and which were not.
14
+ */
15
+ const props = defineProps<{
16
+ result: MetaImportResult
17
+ proposal: MetaImportProposal
18
+ }>()
19
+
20
+ const proposed = computed(() => {
21
+ const byId = new Map<string, { group: string; template: string }>()
22
+ for (const group of props.proposal.groups) {
23
+ for (const template of group.templates) {
24
+ byId.set(template.id, {
25
+ group: group.name,
26
+ template: `${template.name} · ${template.language_code}`,
27
+ })
28
+ }
29
+ }
30
+ return byId
31
+ })
32
+
33
+ const groupName = (templateIds: string[]) =>
34
+ proposed.value.get(templateIds[0] ?? '')?.group ?? templateIds.join(', ')
35
+
36
+ const importedCount = computed(() => props.result.groups.filter((group) => group.written).length)
37
+
38
+ const failed = computed(() =>
39
+ props.result.groups
40
+ .filter((group) => !group.written)
41
+ .map((group) => ({
42
+ key: group.template_ids.join(','),
43
+ name: groupName(group.template_ids),
44
+ reason: group.reason,
45
+ })),
46
+ )
47
+
48
+ /** Meta Templates left out of a Message Group that was written. */
49
+ const leftOut = computed(() =>
50
+ props.result.groups
51
+ .filter((group) => group.written)
52
+ .flatMap((group) =>
53
+ group.templates
54
+ .filter((template) => !template.written)
55
+ .map((template) => ({
56
+ key: template.id,
57
+ group: groupName(group.template_ids),
58
+ template: proposed.value.get(template.id)?.template ?? template.id,
59
+ reason: template.reason,
60
+ })),
61
+ ),
62
+ )
63
+
64
+ const refreshedCount = computed(
65
+ () => props.result.refreshed.filter((group) => group.refreshed).length,
66
+ )
67
+
68
+ // The answer names a Message Group imported earlier by id alone: its name is
69
+ // looked up, and the id stands in when the lookup fails.
70
+ const { data: names } = useMessageGroupNamesQuery(() =>
71
+ props.result.refreshed.filter((group) => !group.refreshed).map((group) => group.message_group_id),
72
+ )
73
+
74
+ const notRefreshed = computed(() =>
75
+ props.result.refreshed
76
+ .filter((group) => !group.refreshed)
77
+ .map((group) => ({
78
+ key: group.message_group_id,
79
+ name: names.value?.[group.message_group_id] ?? group.message_group_id,
80
+ reason: group.reason,
81
+ })),
82
+ )
83
+ </script>
84
+
85
+ <template>
86
+ <div class="flex flex-col gap-4" data-testid="meta-import-result">
87
+ <UAlert
88
+ :color="importedCount > 0 ? 'success' : 'neutral'"
89
+ variant="subtle"
90
+ icon="ph:check-circle"
91
+ :title="$t('dialogs.meta_import.imported_count', { count: importedCount })"
92
+ data-testid="meta-import-result-imported"
93
+ />
94
+
95
+ <div v-if="failed.length > 0" data-testid="meta-import-result-failed">
96
+ <p class="text-sm font-medium mb-1">{{ $t('dialogs.meta_import.failed_title') }}</p>
97
+ <ul class="flex flex-col gap-1 text-sm">
98
+ <li v-for="group in failed" :key="group.key">
99
+ <span class="font-medium">{{ group.name }}</span>
100
+ <span v-if="group.reason" class="text-error">
101
+ — {{ $t(`dialogs.meta_import.group_failures.${group.reason}`) }}
102
+ </span>
103
+ </li>
104
+ </ul>
105
+ </div>
106
+
107
+ <div v-if="leftOut.length > 0" data-testid="meta-import-result-left-out">
108
+ <p class="text-sm font-medium mb-1">{{ $t('dialogs.meta_import.partial_title') }}</p>
109
+ <ul class="flex flex-col gap-1 text-sm">
110
+ <li v-for="item in leftOut" :key="item.key">
111
+ <span class="font-medium">{{ item.group }}</span>
112
+ <span class="text-xs text-dimmed font-mono"> {{ item.template }}</span>
113
+ <span v-if="item.reason" class="text-error">
114
+ — {{ $t(`dialogs.meta_import.reasons.${item.reason}`) }}
115
+ </span>
116
+ </li>
117
+ </ul>
118
+ </div>
119
+
120
+ <p v-if="refreshedCount > 0" class="text-sm text-muted" data-testid="meta-import-refreshed">
121
+ {{ $t('dialogs.meta_import.refreshed_count', { count: refreshedCount }) }}
122
+ </p>
123
+
124
+ <div v-if="notRefreshed.length > 0" data-testid="meta-import-result-not-refreshed">
125
+ <p class="text-sm font-medium mb-1">{{ $t('dialogs.meta_import.refresh_failed_title') }}</p>
126
+ <ul class="flex flex-col gap-1 text-sm">
127
+ <li v-for="group in notRefreshed" :key="group.key">
128
+ <span class="font-medium">{{ group.name }}</span>
129
+ <span v-if="group.reason" class="text-error">
130
+ — {{ $t(`dialogs.meta_import.refresh_failures.${group.reason}`) }}
131
+ </span>
132
+ </li>
133
+ </ul>
134
+ </div>
135
+ </div>
136
+ </template>
@@ -0,0 +1,192 @@
1
+ <script setup lang="ts">
2
+ import type {
3
+ MessageStatus,
4
+ MetaImportProposal,
5
+ MetaImportProposalGroup,
6
+ MetaImportProposalTemplate,
7
+ } from '@dev.smartpricing/message-composer-utils/types'
8
+ import { getLanguageDisplayName } from '@dev.smartpricing/message-composer-utils/utils'
9
+
10
+ /**
11
+ * The proposal of an Import (ADR 0020): each proposed Message Group with its
12
+ * Meta Templates, a tick box per group and per language. A Meta Template
13
+ * that cannot be imported is shown with its reason and has no box to tick.
14
+ * A group made of differently named Meta Templates can be split back into
15
+ * the groups their names make.
16
+ */
17
+ defineProps<{
18
+ proposal: MetaImportProposal
19
+ }>()
20
+
21
+ const emit = defineEmits<{ split: [group: MetaImportProposalGroup] }>()
22
+
23
+ /** The ids of the ticked Meta Templates. */
24
+ const ticked = defineModel<string[]>('ticked', { required: true })
25
+
26
+ const { locale } = useI18n()
27
+
28
+ const tickedIds = computed(() => new Set(ticked.value))
29
+
30
+ const importableIds = (group: MetaImportProposalGroup) =>
31
+ group.templates.filter((template) => template.importable).map((template) => template.id)
32
+
33
+ function groupState(group: MetaImportProposalGroup): boolean | 'indeterminate' {
34
+ const ids = importableIds(group)
35
+ const count = ids.filter((id) => tickedIds.value.has(id)).length
36
+ if (count === 0) return false
37
+ return count === ids.length ? true : 'indeterminate'
38
+ }
39
+
40
+ function setGroup(group: MetaImportProposalGroup, value: boolean | 'indeterminate') {
41
+ const ids = importableIds(group)
42
+ const others = ticked.value.filter((id) => !ids.includes(id))
43
+ ticked.value = value === true ? [...others, ...ids] : others
44
+ }
45
+
46
+ function setTemplate(template: MetaImportProposalTemplate, value: boolean | 'indeterminate') {
47
+ const others = ticked.value.filter((id) => id !== template.id)
48
+ ticked.value = value === true ? [...others, template.id] : others
49
+ }
50
+
51
+ /** The composer language the Meta Template lands on, or Meta's code when it lands on none. */
52
+ const languageName = (template: MetaImportProposalTemplate) =>
53
+ template.language_id
54
+ ? getLanguageDisplayName(template.language_id, locale.value)
55
+ : template.language_code
56
+
57
+ const STATUS_COLORS = {
58
+ draft: 'neutral',
59
+ approved: 'success',
60
+ rejected: 'error',
61
+ pending: 'warning',
62
+ } as const satisfies Record<MessageStatus, string>
63
+
64
+ /** Meta's own word for a status the composer shows as pending (`PAUSED`, `DISABLED`). */
65
+ const metaStatusNote = (template: MetaImportProposalTemplate) =>
66
+ ['APPROVED', 'PENDING', 'REJECTED'].includes(template.meta_status) ? '' : template.meta_status
67
+ </script>
68
+
69
+ <template>
70
+ <div class="flex flex-col gap-3" data-testid="meta-import-proposal">
71
+ <p class="text-sm text-muted">{{ $t('dialogs.meta_import.intro') }}</p>
72
+
73
+ <UAlert
74
+ v-if="proposal.fallback_used"
75
+ color="warning"
76
+ variant="subtle"
77
+ icon="ph:warning"
78
+ :title="$t('dialogs.meta_import.fallback_title')"
79
+ :description="$t('dialogs.meta_import.fallback_description')"
80
+ data-testid="meta-import-fallback"
81
+ />
82
+
83
+ <p v-if="proposal.groups.length === 0" class="text-sm" data-testid="meta-import-empty">
84
+ {{ $t('dialogs.meta_import.empty') }}
85
+ </p>
86
+
87
+ <section
88
+ v-for="group in proposal.groups"
89
+ :key="group.templates[0]?.id"
90
+ class="rounded-lg border border-default"
91
+ data-testid="meta-import-group"
92
+ >
93
+ <header class="flex items-center gap-3 px-3 py-2 bg-elevated/50 rounded-t-lg">
94
+ <UCheckbox
95
+ :model-value="groupState(group)"
96
+ :disabled="importableIds(group).length === 0"
97
+ :aria-label="group.name"
98
+ data-testid="meta-import-group-checkbox"
99
+ @update:model-value="setGroup(group, $event)"
100
+ />
101
+ <span class="font-medium truncate">{{ group.name }}</span>
102
+ <UBadge
103
+ v-if="group.category"
104
+ :label="$t(`categories.${group.category}`)"
105
+ color="neutral"
106
+ variant="subtle"
107
+ size="sm"
108
+ />
109
+ <template v-if="group.name_groups">
110
+ <span class="text-xs text-muted ml-auto" data-testid="meta-import-group-merged">
111
+ {{ $t('dialogs.meta_import.merged_hint') }}
112
+ </span>
113
+ <UButton
114
+ :label="$t('dialogs.meta_import.split')"
115
+ icon="ph:arrows-split"
116
+ color="neutral"
117
+ variant="outline"
118
+ size="xs"
119
+ class="shrink-0"
120
+ data-testid="meta-import-group-split"
121
+ @click="emit('split', group)"
122
+ />
123
+ </template>
124
+ </header>
125
+
126
+ <ul class="divide-y divide-default">
127
+ <li
128
+ v-for="template in group.templates"
129
+ :key="template.id"
130
+ class="flex items-start gap-3 px-3 py-2"
131
+ data-testid="meta-import-template"
132
+ >
133
+ <UCheckbox
134
+ v-if="template.importable"
135
+ :model-value="tickedIds.has(template.id)"
136
+ :aria-label="`${languageName(template)} ${template.name}`"
137
+ class="mt-0.5"
138
+ data-testid="meta-import-template-checkbox"
139
+ @update:model-value="setTemplate(template, $event)"
140
+ />
141
+ <UIcon v-else name="ph:prohibit" class="size-4 mt-0.5 shrink-0 text-error" />
142
+
143
+ <div class="flex flex-col gap-1 min-w-0 flex-1">
144
+ <div class="flex flex-wrap items-center gap-x-2 gap-y-1">
145
+ <span class="text-sm" :class="{ 'text-muted': !template.importable }">
146
+ {{ languageName(template) }}
147
+ </span>
148
+ <span class="text-xs text-dimmed font-mono break-all">
149
+ {{ template.name }} · {{ template.language_code }}
150
+ </span>
151
+ </div>
152
+
153
+ <p
154
+ v-if="!template.importable"
155
+ class="text-xs text-error"
156
+ data-testid="meta-import-template-reason"
157
+ >
158
+ {{ $t('dialogs.meta_import.not_importable') }}:
159
+ {{ template.reason ? $t(`dialogs.meta_import.reasons.${template.reason}`) : '' }}
160
+ </p>
161
+ <p
162
+ v-for="warning in template.warnings"
163
+ :key="warning"
164
+ class="flex items-start gap-1 text-xs text-warning"
165
+ data-testid="meta-import-template-warning"
166
+ >
167
+ <UIcon name="ph:warning" class="size-3.5 mt-px shrink-0" />
168
+ {{ $t(`dialogs.meta_import.warnings.${warning}`) }}
169
+ </p>
170
+ </div>
171
+
172
+ <UBadge
173
+ leading-icon="ph:circle-fill"
174
+ :label="
175
+ metaStatusNote(template)
176
+ ? `${$t(`status.${template.status}`)} (${metaStatusNote(template)})`
177
+ : $t(`status.${template.status}`)
178
+ "
179
+ :color="STATUS_COLORS[template.status]"
180
+ variant="outline"
181
+ size="sm"
182
+ class="shrink-0"
183
+ />
184
+ </li>
185
+ </ul>
186
+ </section>
187
+
188
+ <p v-if="proposal.held_count > 0" class="text-sm text-muted" data-testid="meta-import-held">
189
+ {{ $t('dialogs.meta_import.held_count', { count: proposal.held_count }) }}
190
+ </p>
191
+ </div>
192
+ </template>
@@ -25,6 +25,9 @@ watch(renderType, (newType) => {
25
25
  trackEvent('change_tab', { messages_kind: newType === 'email_v1' ? 'email' : 'whatsapp' })
26
26
  })
27
27
 
28
+ // The Import from Meta check waits for the list: it must never slow it down.
29
+ const listLoaded = ref(false)
30
+
28
31
  const tabItems = computed(() => {
29
32
  const items = []
30
33
  if (hasWhatsapp.value) {
@@ -55,9 +58,10 @@ const tabItems = computed(() => {
55
58
  >
56
59
  <template #actions>
57
60
  <CommonOrganizationSelect />
61
+ <MetaImportButton :enabled="listLoaded" @imported="renderType = 'whatsapp_v1'" />
58
62
  <CreateTemplateButton />
59
63
  </template>
60
64
 
61
- <ComposerMessageLibrary v-model:render-type="renderType" />
65
+ <ComposerMessageLibrary v-model:render-type="renderType" @loaded="listLoaded = true" />
62
66
  </LayoutBasePage>
63
67
  </template>
@@ -3,7 +3,6 @@ import type { MaybeRefOrGetter } from 'vue'
3
3
  import type {
4
4
  DuplicateMessageGroupBody,
5
5
  MessageGroup,
6
- MessageGroupWithMessageSummary,
7
6
  PostEntity,
8
7
  } from '@dev.smartpricing/message-composer-utils/types'
9
8
  import { messageGroupsApi } from '~/api'
@@ -78,6 +77,32 @@ export function useMessageGroupQuery(
78
77
  })
79
78
  }
80
79
 
80
+ /**
81
+ * The names of the Message Groups of these ids, by id. One that cannot be
82
+ * read is missing from the answer: the caller shows what it has instead.
83
+ */
84
+ export function useMessageGroupNamesQuery(ids: MaybeRefOrGetter<string[]>) {
85
+ return useQuery({
86
+ key: () => ['message-groups', 'names', ...toValue(ids)],
87
+ query: async () => {
88
+ const names: Record<string, string> = {}
89
+ await Promise.all(
90
+ toValue(ids).map((id) =>
91
+ messageGroupsApi
92
+ .getById(id)
93
+ .then((group) => {
94
+ names[id] = group.name
95
+ })
96
+ .catch(() => {}),
97
+ ),
98
+ )
99
+ return names
100
+ },
101
+ staleTime: 0,
102
+ enabled: () => toValue(ids).length > 0,
103
+ })
104
+ }
105
+
81
106
  // MUTATIONS
82
107
  export function useCreateMessageGroupMutation() {
83
108
  const queryCache = useQueryCache()
@@ -141,24 +166,6 @@ export function useDeleteMessageGroupMutation() {
141
166
 
142
167
  return useMutation({
143
168
  mutation: messageGroupsApi.delete,
144
- onMutate: async (id) => {
145
- // Optimistic update
146
- queryCache.cancelQueries({ key: ['message-groups'] })
147
- const previous = queryCache.getQueryData(['message-groups'])
148
-
149
- queryCache.setQueryData(
150
- ['message-groups'],
151
- (old: MessageGroupWithMessageSummary[] | undefined) => old?.filter((g) => g.id !== id),
152
- )
153
-
154
- return { previous }
155
- },
156
- onError: (_, __, context) => {
157
- // Rollback on error
158
- if (context?.previous) {
159
- queryCache.setQueryData(['message-groups'], context.previous)
160
- }
161
- },
162
169
  onSuccess: () => {
163
170
  queryCache.invalidateQueries({ key: ['message-groups'] })
164
171
  },
@@ -1,4 +1,9 @@
1
- import { useQuery } from '@pinia/colada'
1
+ import { useMutation, useQuery, useQueryCache } from '@pinia/colada'
2
+ import type { MaybeRefOrGetter } from 'vue'
3
+ import type {
4
+ MetaImportScope,
5
+ OrganizationWaba,
6
+ } from '@dev.smartpricing/message-composer-utils/types'
2
7
  import { metaApi } from '~/api'
3
8
 
4
9
  /**
@@ -16,3 +21,88 @@ export function useOrganizationWabasQuery() {
16
21
  staleTime: 5 * 60 * 1000,
17
22
  })
18
23
  }
24
+
25
+ /** A WABA with how many of its Meta Templates an Import would offer. */
26
+ export interface WabaImportCheck {
27
+ waba: OrganizationWaba
28
+ count: number
29
+ }
30
+
31
+ /**
32
+ * The check of an Import (ADR 0020), for the Message Group list: each WABA of
33
+ * the list's Organization with how many Meta Templates an Import would offer,
34
+ * under the Host's Product. Not asked for an Organization without a WABA. A
35
+ * WABA whose check fails counts zero, like one Meta cannot read.
36
+ */
37
+ export function useMetaImportCheckQuery(options: { enabled?: MaybeRefOrGetter<boolean> } = {}) {
38
+ const organization = useEffectiveOrganizationStore()
39
+ const appContext = useAppContextStore()
40
+ const { data: wabas } = useOrganizationWabasQuery()
41
+
42
+ return useQuery({
43
+ key: () => [
44
+ 'meta-import-check',
45
+ organization.organizationId,
46
+ appContext.product ?? null,
47
+ (wabas.value ?? []).map((waba) => waba.id).join(','),
48
+ ],
49
+ query: (): Promise<WabaImportCheck[]> => {
50
+ const organization_id = organization.requireOrganizationId()
51
+ const product = appContext.product
52
+ if (!product) throw new Error('[message-composer] No Product: the import check was not sent')
53
+
54
+ return Promise.all(
55
+ (wabas.value ?? []).map(async (waba) => {
56
+ const { count } = await metaApi
57
+ .checkImport({ organization_id, product, waba_id: waba.id })
58
+ .catch(() => ({ count: 0 }))
59
+ return { waba, count }
60
+ }),
61
+ )
62
+ },
63
+ enabled: () =>
64
+ toValue(options.enabled ?? true) &&
65
+ !!appContext.product &&
66
+ !!wabas.value?.length &&
67
+ // The list's Organization, not one an editor page still claims while
68
+ // the list mounts.
69
+ organization.organizationId === organization.resolvedOrganizationId,
70
+ // The backend keeps each WABA's count for ten minutes; this only spares
71
+ // the round trip when the list is left and reopened.
72
+ staleTime: 60 * 1000,
73
+ })
74
+ }
75
+
76
+ /**
77
+ * The proposal of an Import, read from Meta when the dialog asks and never
78
+ * reused: the user ticks against exactly what this answered, so nothing
79
+ * refetches it behind their back.
80
+ */
81
+ export function useMetaImportProposalQuery(scope: MaybeRefOrGetter<MetaImportScope | undefined>) {
82
+ return useQuery({
83
+ key: () => ['meta-import-proposal', JSON.stringify(toValue(scope) ?? null)],
84
+ query: () => {
85
+ const value = toValue(scope)
86
+ if (!value) throw new Error('[message-composer] No WABA chosen: the proposal was not asked')
87
+ return metaApi.getImportProposal(value)
88
+ },
89
+ enabled: () => !!toValue(scope),
90
+ staleTime: 0,
91
+ gcTime: 0,
92
+ refetchOnWindowFocus: false,
93
+ refetchOnReconnect: false,
94
+ })
95
+ }
96
+
97
+ /** Confirms an Import. The list and the check are read again whatever the outcome. */
98
+ export function useConfirmMetaImportMutation() {
99
+ const queryCache = useQueryCache()
100
+
101
+ return useMutation({
102
+ mutation: metaApi.confirmImport,
103
+ onSettled: () => {
104
+ queryCache.invalidateQueries({ key: ['message-groups'] })
105
+ queryCache.invalidateQueries({ key: ['meta-import-check'] })
106
+ },
107
+ })
108
+ }
@@ -119,6 +119,68 @@ export default {
119
119
  title: 'Fehlende Übersetzungen',
120
120
  translate_and_save: 'Automatisch übersetzen und speichern',
121
121
  },
122
+ meta_import: {
123
+ choose_waba: 'Wähle das WhatsApp-Business-Konto, aus dem importiert werden soll.',
124
+ close: 'Schließen',
125
+ confirm: 'Importieren',
126
+ continue: 'Weiter',
127
+ description:
128
+ 'Übernimm die WhatsApp-Vorlagen, die dein WhatsApp-Business-Konto bereits bei Meta hat, in deine Nachrichten.',
129
+ empty: 'Aus diesem WhatsApp-Business-Konto gibt es nichts Neues zu importieren.',
130
+ failed_title: 'Nicht importiert',
131
+ fallback_description:
132
+ 'Vorlagen mit unterschiedlichen Namen wurden nur anhand ihrer Namen zusammengefasst, nicht anhand ihres Textes. Prüfe jede Nachricht vor dem Import.',
133
+ fallback_title: 'Die Übersetzungen konnten nicht geprüft werden',
134
+ group_failures: {
135
+ duplicate_language: 'Zwei ihrer Vorlagen sind in derselben Sprache.',
136
+ nothing_to_import: 'Keine ihrer Vorlagen konnte importiert werden.',
137
+ write_failed: 'Sie konnte nicht gespeichert werden. Versuche es erneut.',
138
+ },
139
+ held_count: 'Ausgelassen, weil bereits unter deinen Nachrichten: {count}',
140
+ imported_count: 'Importierte Nachrichten: {count}',
141
+ intro:
142
+ 'Jedes Feld wird zu einer Nachricht, mit einer Übersetzung pro Sprache. Entferne das Häkchen bei allem, was du nicht importieren möchtest. Nichts wird importiert, bevor du bestätigst.',
143
+ load_failed_description: 'Versuche es in einigen Minuten erneut.',
144
+ load_failed_title: 'Die Vorlagen konnten nicht aus Meta gelesen werden',
145
+ loading: 'Vorlagen werden aus Meta gelesen...',
146
+ merged_hint: 'Als Übersetzungen einer Nachricht zusammengefasst',
147
+ not_importable: 'Kann nicht importiert werden',
148
+ partial_title: 'Ohne einige Sprachen importiert',
149
+ reasons: {
150
+ media_download_failed: 'Das Kopfzeilenbild konnte nicht aus Meta kopiert werden.',
151
+ not_found: 'Sie existiert bei Meta nicht mehr.',
152
+ not_offered: 'Sie ist bei Meta abgelehnt oder bereits unter deinen Nachrichten.',
153
+ positional_variables: 'Sie verwendet nummerierte Variablen, die nicht unterstützt werden.',
154
+ unknown_button: 'Sie hat einen Schaltflächentyp, der nicht unterstützt wird.',
155
+ unknown_component: 'Sie hat eine Komponente, die nicht unterstützt wird.',
156
+ unknown_header: 'Sie hat einen Kopfzeilentyp, der nicht unterstützt wird.',
157
+ unknown_language: 'Ihre Sprache ist hier nicht verfügbar.',
158
+ unsupported_category: 'Ihre Kategorie ist weder Marketing noch Utility.',
159
+ },
160
+ refresh_failed_title: 'Frühere Importe nicht aktualisiert',
161
+ refresh_failures: {
162
+ media_download_failed: 'Das Kopfzeilenbild konnte nicht aus Meta kopiert werden.',
163
+ write_failed: 'Sie konnte nicht gespeichert werden. Versuche es erneut.',
164
+ },
165
+ refreshed_count: 'Frühere Importe mit Meta abgeglichen: {count}',
166
+ result_title: 'Import abgeschlossen',
167
+ retry: 'Erneut versuchen',
168
+ selection: 'Ausgewählte Nachrichten: {groups} · Vorlagen: {templates}',
169
+ split: 'Trennen',
170
+ title: 'Aus Meta importieren',
171
+ waba_count: 'Neue Vorlagen: {count}',
172
+ warnings: {
173
+ buttons_over_limit:
174
+ 'Sie hat mehr Schaltflächen, als hier zu einer Nachricht hinzugefügt werden können.',
175
+ call_permission_request:
176
+ 'Sie hat eine Anruferlaubnis-Anfrage, die hier nicht angezeigt wird.',
177
+ dynamic_url_button: 'Sie hat eine Link-Schaltfläche mit einer Variablen.',
178
+ label_over_limit:
179
+ 'Sie hat eine Schaltflächenbeschriftung, die länger ist als das hier geltende Limit.',
180
+ same_language_split:
181
+ 'Eine andere Vorlage mit diesem Namen deckt diese Sprache bereits ab, daher wird diese zu einer eigenen Nachricht.',
182
+ },
183
+ },
122
184
  publish_message_group: {
123
185
  message: '„{name}“ veröffentlichen, damit es für Kundinnen und Kunden sichtbar ist?',
124
186
  success: '„{name}“ wurde veröffentlicht.',
@@ -825,6 +887,7 @@ export default {
825
887
  status: 'Status',
826
888
  updated_at: 'Aktualisiert am',
827
889
  },
890
+ import_from_meta: 'Aus Meta importieren ({count})',
828
891
  loading: 'Nachrichten werden geladen...',
829
892
  pagination_summary: '{from}–{to} von {total}',
830
893
  product_placeholder: 'Produkt auswählen',
@@ -115,6 +115,65 @@ export default {
115
115
  title: 'Missing translations',
116
116
  translate_and_save: 'Translate automatically and save',
117
117
  },
118
+ meta_import: {
119
+ choose_waba: 'Choose the WhatsApp Business Account to import from.',
120
+ close: 'Close',
121
+ confirm: 'Import',
122
+ continue: 'Continue',
123
+ description:
124
+ 'Bring the WhatsApp templates your WhatsApp Business Account already has at Meta into your messages.',
125
+ empty: 'There is nothing new to import from this WhatsApp Business Account.',
126
+ failed_title: 'Not imported',
127
+ fallback_description:
128
+ 'Templates with different names were put together by their names alone, not by their text. Check each message before you import.',
129
+ fallback_title: 'The translations could not be checked',
130
+ group_failures: {
131
+ duplicate_language: 'Two of its templates are in the same language.',
132
+ nothing_to_import: 'None of its templates could be imported.',
133
+ write_failed: 'It could not be saved. Try again.',
134
+ },
135
+ held_count: 'Left out because they are already among your messages: {count}',
136
+ imported_count: 'Messages imported: {count}',
137
+ intro:
138
+ 'Each box becomes one message, with one translation per language. Untick what you do not want to import. Nothing is imported until you confirm.',
139
+ load_failed_description: 'Try again in a few minutes.',
140
+ load_failed_title: 'The templates could not be read from Meta',
141
+ loading: 'Reading the templates from Meta...',
142
+ merged_hint: 'Put together as translations of one message',
143
+ not_importable: 'Cannot be imported',
144
+ partial_title: 'Imported without some languages',
145
+ reasons: {
146
+ media_download_failed: 'Its header image could not be copied from Meta.',
147
+ not_found: 'It no longer exists at Meta.',
148
+ not_offered: 'It is rejected at Meta or already among your messages.',
149
+ positional_variables: 'It uses numbered variables, which are not supported.',
150
+ unknown_button: 'It has a button type that is not supported.',
151
+ unknown_component: 'It has a component that is not supported.',
152
+ unknown_header: 'It has a header type that is not supported.',
153
+ unknown_language: 'Its language is not available here.',
154
+ unsupported_category: 'Its category is neither marketing nor utility.',
155
+ },
156
+ refresh_failed_title: 'Earlier imports not brought up to date',
157
+ refresh_failures: {
158
+ media_download_failed: 'Its header image could not be copied from Meta.',
159
+ write_failed: 'It could not be saved. Try again.',
160
+ },
161
+ refreshed_count: 'Earlier imports brought up to date with Meta: {count}',
162
+ result_title: 'Import completed',
163
+ retry: 'Try again',
164
+ selection: 'Selected messages: {groups} · templates: {templates}',
165
+ split: 'Split',
166
+ title: 'Import from Meta',
167
+ waba_count: 'New templates: {count}',
168
+ warnings: {
169
+ buttons_over_limit: 'It has more buttons than you can add to a message here.',
170
+ call_permission_request: 'It has a call permission request, which is not shown here.',
171
+ dynamic_url_button: 'It has a link button with a variable.',
172
+ label_over_limit: 'It has a button label longer than the limit used here.',
173
+ same_language_split:
174
+ 'Another template with this name already covers this language, so this one becomes a message of its own.',
175
+ },
176
+ },
118
177
  publish_message_group: {
119
178
  message: 'Publish "{name}" to make it visible to clients?',
120
179
  success: '"{name}" has been published.',
@@ -814,6 +873,7 @@ export default {
814
873
  status: 'Status',
815
874
  updated_at: 'Updated at',
816
875
  },
876
+ import_from_meta: 'Import from Meta ({count})',
817
877
  loading: 'Loading messages...',
818
878
  pagination_summary: '{from}–{to} of {total}',
819
879
  product_placeholder: 'Select product',
@@ -116,6 +116,66 @@ export default {
116
116
  title: 'Faltan traducciones',
117
117
  translate_and_save: 'Traducir automáticamente y guardar',
118
118
  },
119
+ meta_import: {
120
+ choose_waba: 'Elige la cuenta de WhatsApp Business desde la que importar.',
121
+ close: 'Cerrar',
122
+ confirm: 'Importar',
123
+ continue: 'Continuar',
124
+ description:
125
+ 'Trae a tus mensajes las plantillas de WhatsApp que tu cuenta de WhatsApp Business ya tiene en Meta.',
126
+ empty: 'No hay nada nuevo que importar desde esta cuenta de WhatsApp Business.',
127
+ failed_title: 'No importados',
128
+ fallback_description:
129
+ 'Las plantillas con nombres distintos se han agrupado solo por su nombre, no por su texto. Revisa cada mensaje antes de importar.',
130
+ fallback_title: 'No se han podido comprobar las traducciones',
131
+ group_failures: {
132
+ duplicate_language: 'Dos de sus plantillas están en el mismo idioma.',
133
+ nothing_to_import: 'Ninguna de sus plantillas se ha podido importar.',
134
+ write_failed: 'No se ha podido guardar. Inténtalo de nuevo.',
135
+ },
136
+ held_count: 'Excluidas porque ya están entre tus mensajes: {count}',
137
+ imported_count: 'Mensajes importados: {count}',
138
+ intro:
139
+ 'Cada recuadro se convierte en un mensaje, con una traducción por idioma. Desmarca lo que no quieras importar. No se importa nada hasta que confirmes.',
140
+ load_failed_description: 'Inténtalo de nuevo en unos minutos.',
141
+ load_failed_title: 'No se han podido leer las plantillas desde Meta',
142
+ loading: 'Leyendo las plantillas desde Meta...',
143
+ merged_hint: 'Agrupadas como traducciones de un mismo mensaje',
144
+ not_importable: 'No se puede importar',
145
+ partial_title: 'Importados sin algunos idiomas',
146
+ reasons: {
147
+ media_download_failed: 'No se ha podido copiar desde Meta la imagen de su encabezado.',
148
+ not_found: 'Ya no existe en Meta.',
149
+ not_offered: 'Está rechazada en Meta o ya está entre tus mensajes.',
150
+ positional_variables: 'Usa variables numeradas, que no son compatibles.',
151
+ unknown_button: 'Tiene un tipo de botón que no es compatible.',
152
+ unknown_component: 'Tiene un componente que no es compatible.',
153
+ unknown_header: 'Tiene un tipo de encabezado que no es compatible.',
154
+ unknown_language: 'Su idioma no está disponible aquí.',
155
+ unsupported_category: 'Su categoría no es ni marketing ni utility.',
156
+ },
157
+ refresh_failed_title: 'Importaciones anteriores no actualizadas',
158
+ refresh_failures: {
159
+ media_download_failed: 'No se ha podido copiar desde Meta la imagen de su encabezado.',
160
+ write_failed: 'No se ha podido guardar. Inténtalo de nuevo.',
161
+ },
162
+ refreshed_count: 'Importaciones anteriores actualizadas con Meta: {count}',
163
+ result_title: 'Importación completada',
164
+ retry: 'Reintentar',
165
+ selection: 'Mensajes seleccionados: {groups} · plantillas: {templates}',
166
+ split: 'Separar',
167
+ title: 'Importar desde Meta',
168
+ waba_count: 'Plantillas nuevas: {count}',
169
+ warnings: {
170
+ buttons_over_limit: 'Tiene más botones de los que se pueden añadir aquí a un mensaje.',
171
+ call_permission_request:
172
+ 'Tiene una solicitud de permiso de llamada, que aquí no se muestra.',
173
+ dynamic_url_button: 'Tiene un botón de enlace con una variable.',
174
+ label_over_limit: 'Tiene una etiqueta de botón más larga que el límite usado aquí.',
175
+ same_language_split:
176
+ 'Otra plantilla con este nombre ya cubre este idioma, así que esta se convierte en un mensaje aparte.',
177
+ },
178
+ },
119
179
  publish_message_group: {
120
180
  message: '¿Publicar "{name}" para que sea visible para los clientes?',
121
181
  success: '"{name}" se ha publicado.',
@@ -823,6 +883,7 @@ export default {
823
883
  status: 'Estado',
824
884
  updated_at: 'Actualizado el',
825
885
  },
886
+ import_from_meta: 'Importar desde Meta ({count})',
826
887
  loading: 'Cargando mensajes...',
827
888
  pagination_summary: '{from}–{to} de {total}',
828
889
  product_placeholder: 'Seleccionar producto',
@@ -116,6 +116,67 @@ export default {
116
116
  title: 'Traductions manquantes',
117
117
  translate_and_save: 'Traduire automatiquement et enregistrer',
118
118
  },
119
+ meta_import: {
120
+ choose_waba: 'Choisissez le compte WhatsApp Business depuis lequel importer.',
121
+ close: 'Fermer',
122
+ confirm: 'Importer',
123
+ continue: 'Continuer',
124
+ description:
125
+ 'Reprenez dans vos messages les modèles WhatsApp que votre compte WhatsApp Business possède déjà chez Meta.',
126
+ empty: 'Il n’y a rien de nouveau à importer depuis ce compte WhatsApp Business.',
127
+ failed_title: 'Non importés',
128
+ fallback_description:
129
+ "Les modèles aux noms différents ont été regroupés d'après leur nom seulement, pas d'après leur texte. Vérifiez chaque message avant d'importer.",
130
+ fallback_title: "Les traductions n'ont pas pu être vérifiées",
131
+ group_failures: {
132
+ duplicate_language: 'Deux de ses modèles sont dans la même langue.',
133
+ nothing_to_import: 'Aucun de ses modèles n’a pu être importé.',
134
+ write_failed: 'Il n’a pas pu être enregistré. Réessayez.',
135
+ },
136
+ held_count: 'Laissés de côté car déjà parmi vos messages : {count}',
137
+ imported_count: 'Messages importés : {count}',
138
+ intro:
139
+ 'Chaque encadré devient un message, avec une traduction par langue. Décochez ce que vous ne voulez pas importer. Rien n’est importé avant votre confirmation.',
140
+ load_failed_description: 'Réessayez dans quelques minutes.',
141
+ load_failed_title: 'Les modèles n’ont pas pu être lus depuis Meta',
142
+ loading: 'Lecture des modèles depuis Meta...',
143
+ merged_hint: "Regroupés comme traductions d'un même message",
144
+ not_importable: 'Ne peut pas être importé',
145
+ partial_title: 'Importés sans certaines langues',
146
+ reasons: {
147
+ media_download_failed: 'L’image de son en-tête n’a pas pu être copiée depuis Meta.',
148
+ not_found: 'Il n’existe plus chez Meta.',
149
+ not_offered: 'Il est rejeté chez Meta ou déjà parmi vos messages.',
150
+ positional_variables:
151
+ 'Il utilise des variables numérotées, qui ne sont pas prises en charge.',
152
+ unknown_button: 'Il a un type de bouton qui n’est pas pris en charge.',
153
+ unknown_component: 'Il a un composant qui n’est pas pris en charge.',
154
+ unknown_header: 'Il a un type d’en-tête qui n’est pas pris en charge.',
155
+ unknown_language: 'Sa langue n’est pas disponible ici.',
156
+ unsupported_category: 'Sa catégorie n’est ni marketing ni utility.',
157
+ },
158
+ refresh_failed_title: 'Imports précédents non mis à jour',
159
+ refresh_failures: {
160
+ media_download_failed: 'L’image de son en-tête n’a pas pu être copiée depuis Meta.',
161
+ write_failed: 'Il n’a pas pu être enregistré. Réessayez.',
162
+ },
163
+ refreshed_count: 'Imports précédents mis à jour avec Meta : {count}',
164
+ result_title: 'Import terminé',
165
+ retry: 'Réessayer',
166
+ selection: 'Messages sélectionnés : {groups} · modèles : {templates}',
167
+ split: 'Séparer',
168
+ title: 'Importer depuis Meta',
169
+ waba_count: 'Nouveaux modèles : {count}',
170
+ warnings: {
171
+ buttons_over_limit: 'Il a plus de boutons qu’on ne peut en ajouter ici à un message.',
172
+ call_permission_request:
173
+ 'Il a une demande d’autorisation d’appel, qui n’est pas affichée ici.',
174
+ dynamic_url_button: 'Il a un bouton de lien avec une variable.',
175
+ label_over_limit: 'Il a un libellé de bouton plus long que la limite utilisée ici.',
176
+ same_language_split:
177
+ 'Un autre modèle portant ce nom couvre déjà cette langue ; celui-ci devient donc un message à part.',
178
+ },
179
+ },
119
180
  publish_message_group: {
120
181
  message: 'Publier « {name} » pour le rendre visible aux clients ?',
121
182
  success: '« {name} » a été publié.',
@@ -827,6 +888,7 @@ export default {
827
888
  status: 'Statut',
828
889
  updated_at: 'Mis à jour le',
829
890
  },
891
+ import_from_meta: 'Importer depuis Meta ({count})',
830
892
  loading: 'Chargement des messages...',
831
893
  pagination_summary: '{from}–{to} sur {total}',
832
894
  product_placeholder: 'Sélectionner un produit',
@@ -115,6 +115,69 @@ export default {
115
115
  title: 'Traduzioni mancanti',
116
116
  translate_and_save: 'Traduci automaticamente e salva',
117
117
  },
118
+ meta_import: {
119
+ choose_waba: 'Scegli l’account WhatsApp Business da cui importare.',
120
+ close: 'Chiudi',
121
+ confirm: 'Importa',
122
+ continue: 'Continua',
123
+ description:
124
+ 'Porta tra i tuoi messaggi i template WhatsApp che il tuo account WhatsApp Business ha già su Meta.',
125
+ empty: 'Non c’è niente di nuovo da importare da questo account WhatsApp Business.',
126
+ failed_title: 'Non importati',
127
+ fallback_description:
128
+ 'I template con nomi diversi sono stati riuniti solo in base al nome, non al testo. Controlla ogni messaggio prima di importare.',
129
+ fallback_title: 'Non è stato possibile verificare le traduzioni',
130
+ group_failures: {
131
+ duplicate_language: 'Due dei suoi template sono nella stessa lingua.',
132
+ nothing_to_import: 'Nessuno dei suoi template può essere importato.',
133
+ write_failed: 'Non è stato possibile salvarlo. Riprova.',
134
+ },
135
+ held_count: 'Esclusi perché già tra i tuoi messaggi: {count}',
136
+ imported_count: 'Messaggi importati: {count}',
137
+ intro:
138
+ 'Ogni riquadro diventa un messaggio, con una traduzione per lingua. Togli la spunta a ciò che non vuoi importare. Niente viene importato finché non confermi.',
139
+ load_failed_description: 'Riprova tra qualche minuto.',
140
+ load_failed_title: 'Non è stato possibile leggere i template da Meta',
141
+ loading: 'Lettura dei template da Meta...',
142
+ merged_hint: 'Riuniti come traduzioni di un unico messaggio',
143
+ not_importable: 'Non importabile',
144
+ partial_title: 'Importati senza alcune lingue',
145
+ reasons: {
146
+ media_download_failed:
147
+ 'Non è stato possibile copiare da Meta l’immagine dell’intestazione.',
148
+ not_found: 'Non esiste più su Meta.',
149
+ not_offered: 'È rifiutato su Meta oppure è già tra i tuoi messaggi.',
150
+ positional_variables: 'Usa variabili numerate, che non sono supportate.',
151
+ unknown_button: 'Ha un tipo di pulsante non supportato.',
152
+ unknown_component: 'Ha un componente non supportato.',
153
+ unknown_header: 'Ha un tipo di intestazione non supportato.',
154
+ unknown_language: 'La sua lingua non è disponibile qui.',
155
+ unsupported_category: 'La sua categoria non è né marketing né utility.',
156
+ },
157
+ refresh_failed_title: 'Importazioni precedenti non aggiornate',
158
+ refresh_failures: {
159
+ media_download_failed:
160
+ 'Non è stato possibile copiare da Meta l’immagine dell’intestazione.',
161
+ write_failed: 'Non è stato possibile salvarlo. Riprova.',
162
+ },
163
+ refreshed_count: 'Importazioni precedenti aggiornate con Meta: {count}',
164
+ result_title: 'Importazione completata',
165
+ retry: 'Riprova',
166
+ selection: 'Messaggi selezionati: {groups} · template: {templates}',
167
+ split: 'Separa',
168
+ title: 'Importa da Meta',
169
+ waba_count: 'Nuovi template: {count}',
170
+ warnings: {
171
+ buttons_over_limit:
172
+ 'Ha più pulsanti di quanti se ne possano aggiungere qui a un messaggio.',
173
+ call_permission_request:
174
+ 'Ha una richiesta di permesso di chiamata, che qui non viene mostrata.',
175
+ dynamic_url_button: 'Ha un pulsante link con una variabile.',
176
+ label_over_limit: 'Ha un’etichetta di pulsante più lunga del limite usato qui.',
177
+ same_language_split:
178
+ 'Un altro template con questo nome copre già questa lingua, quindi questo diventa un messaggio a sé.',
179
+ },
180
+ },
118
181
  publish_message_group: {
119
182
  message: 'Pubblicare "{name}" per renderlo visibile ai clienti?',
120
183
  success: '"{name}" è stato pubblicato.',
@@ -820,6 +883,7 @@ export default {
820
883
  status: 'Stato',
821
884
  updated_at: 'Aggiornato il',
822
885
  },
886
+ import_from_meta: 'Importa da Meta ({count})',
823
887
  loading: 'Caricamento dei messaggi...',
824
888
  pagination_summary: '{from}–{to} di {total}',
825
889
  product_placeholder: 'Seleziona prodotto',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dev.smartpricing/message-composer-layer",
3
- "version": "4.5.1-next.3",
3
+ "version": "4.5.1-next.5",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./nuxt.config.ts",
@@ -35,7 +35,7 @@
35
35
  "vue-router": "^5.0.7",
36
36
  "vue3-emoji-picker": "^1.1.8",
37
37
  "zod": "^4.4.3",
38
- "@dev.smartpricing/message-composer-utils": "4.5.1-next.3"
38
+ "@dev.smartpricing/message-composer-utils": "4.5.1-next.5"
39
39
  },
40
40
  "devDependencies": {
41
41
  "@dev.smartpricing/platform-layer": "^0.0.23",