@dev.smartpricing/message-composer-layer 4.5.1-next.4 → 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.
Files changed (81) hide show
  1. package/README.md +4 -133
  2. package/app/api/index.ts +0 -1
  3. package/app/api/messageGroups.ts +1 -5
  4. package/app/api/meta.ts +36 -0
  5. package/app/components/Common/MessageGroupSelect.vue +1 -30
  6. package/app/components/Composer/EmailComposer.vue +1 -5
  7. package/app/components/Composer/MessageLibrary.vue +8 -0
  8. package/app/components/Composer/WabaSelectModal.vue +1 -3
  9. package/app/components/Composer/WhatsappComposer.vue +1 -5
  10. package/app/components/Layout/BasePage.vue +0 -2
  11. package/app/components/MetaImport/Button.vue +50 -0
  12. package/app/components/MetaImport/Dialog.vue +261 -0
  13. package/app/components/MetaImport/Outcome.vue +136 -0
  14. package/app/components/MetaImport/ProposalList.vue +192 -0
  15. package/app/components/TemplateList/BaseTable.vue +22 -1
  16. package/app/composables/apiErrorMessages.ts +0 -1
  17. package/app/composables/composerContext.ts +3 -3
  18. package/app/composables/useMessageGroupWaba.ts +10 -7
  19. package/app/composables/useTemplateOperations.ts +3 -8
  20. package/app/pages/index.vue +5 -1
  21. package/app/pages/template/email/[id].vue +0 -5
  22. package/app/pages/template/email/create.vue +0 -5
  23. package/app/pages/template/whatsapp/[id].vue +0 -5
  24. package/app/pages/template/whatsapp/create.vue +0 -5
  25. package/app/queries/index.ts +0 -1
  26. package/app/queries/messageGroups.ts +29 -20
  27. package/app/queries/meta.ts +91 -1
  28. package/app/stores/appContext.ts +1 -1
  29. package/app/types/app-config.d.ts +0 -3
  30. package/app/types/tracking.ts +0 -33
  31. package/app/utils/testIds.const.ts +1 -107
  32. package/app.config.ts +5 -0
  33. package/i18n/locales/de.ts +64 -269
  34. package/i18n/locales/en.ts +61 -255
  35. package/i18n/locales/es.ts +62 -258
  36. package/i18n/locales/fr.ts +63 -264
  37. package/i18n/locales/it.ts +65 -260
  38. package/package.json +4 -4
  39. package/app/api/automations.ts +0 -74
  40. package/app/app.config.ts +0 -10
  41. package/app/components/Automations/ActionCard.vue +0 -174
  42. package/app/components/Automations/ActionEditor.vue +0 -398
  43. package/app/components/Automations/Actions.vue +0 -148
  44. package/app/components/Automations/CloneModal.vue +0 -78
  45. package/app/components/Automations/Conditions.vue +0 -155
  46. package/app/components/Automations/Create.vue +0 -114
  47. package/app/components/Automations/Data.vue +0 -46
  48. package/app/components/Automations/DeleteModal.vue +0 -80
  49. package/app/components/Automations/Edit.vue +0 -145
  50. package/app/components/Automations/Form.vue +0 -282
  51. package/app/components/Automations/List.vue +0 -370
  52. package/app/components/Automations/PageGate.vue +0 -50
  53. package/app/components/Automations/SaveProblems.vue +0 -54
  54. package/app/components/Automations/Unavailable.vue +0 -71
  55. package/app/components/Automations/UnavailableBadge.vue +0 -35
  56. package/app/components/Filters/DateInput.vue +0 -57
  57. package/app/components/Filters/Editor.vue +0 -163
  58. package/app/components/Filters/Row.vue +0 -119
  59. package/app/components/Filters/Summary.vue +0 -215
  60. package/app/components/Filters/UnavailableRow.vue +0 -74
  61. package/app/components/Filters/ValueInput.vue +0 -215
  62. package/app/composables/automationsContext.ts +0 -42
  63. package/app/composables/useAutomationClone.ts +0 -33
  64. package/app/composables/useAutomationEditorTrip.ts +0 -77
  65. package/app/composables/useAutomationSaveProblems.ts +0 -82
  66. package/app/composables/useAutomationUnavailable.ts +0 -98
  67. package/app/composables/useAutomationsGate.ts +0 -68
  68. package/app/composables/useBuiltInOptionLists.ts +0 -44
  69. package/app/composables/useEditorTripBack.ts +0 -15
  70. package/app/middleware/automations-enabled.ts +0 -12
  71. package/app/pages/automations/[id].vue +0 -87
  72. package/app/pages/automations/index.vue +0 -28
  73. package/app/pages/automations/new.vue +0 -53
  74. package/app/queries/automations.ts +0 -206
  75. package/app/stores/editorTrip.ts +0 -67
  76. package/app/utils/automations/form.ts +0 -389
  77. package/app/utils/automations/metadata.ts +0 -71
  78. package/app/utils/automations/unavailable.ts +0 -90
  79. package/app/utils/filters/data/countries.json +0 -998
  80. package/app/utils/filters/data/languages.json +0 -754
  81. package/app/utils/filters/rows.ts +0 -367
@@ -1,218 +1,4 @@
1
1
  export default {
2
- automations: {
3
- action: {
4
- at: 'Alle',
5
- itIsSent: 'Viene inviato',
6
- },
7
- actions: {
8
- addChannel: 'Aggiungi messaggio',
9
- },
10
- advanced: 'Avanzate',
11
- audienceAll: 'Tutti i contatti',
12
- audienceSpecific: 'Specifico',
13
- channel: {
14
- addTitle: 'Nuovo messaggio',
15
- cannotFindMessage: 'Hai bisogno di un altro messaggio?',
16
- category: 'Messaggi',
17
- channelType: 'Tipo di messaggio',
18
- chooseDays: 'giorni',
19
- createNew: 'Crea nuovo',
20
- editTitle: 'Modifica messaggio',
21
- no_message: {
22
- description: "Seleziona un messaggio o creane uno nuovo per vederne l'anteprima qui",
23
- title: 'Nessuna anteprima',
24
- },
25
- preview: 'Anteprima',
26
- searchMessagePlaceholder: 'Cerca un messaggio',
27
- selectMessage: 'Messaggio',
28
- selectMessageHint:
29
- 'I messaggi con stato «Bozza» non sono visibili nell’elenco e non possono essere selezionati.',
30
- selectMessagePlaceholder: 'Seleziona un messaggio',
31
- sendingTime: 'Ora di invio',
32
- when: 'Programma invio',
33
- whenHint:
34
- "Questa programmazione non è legata all'azione di check-out nel tuo Sistema di Gestione delle Proprietà (PMS).",
35
- },
36
- channels: {
37
- email: 'Email',
38
- whatsapp: 'WhatsApp',
39
- },
40
- clone: {
41
- namePlaceholder: 'Nome automazione',
42
- title: 'Duplica automazione',
43
- },
44
- delete: {
45
- confirm:
46
- 'Vuoi eliminare questa automazione? Una volta eliminata, non potrà essere recuperata.',
47
- messages: 'Elimina anche i suoi messaggi',
48
- title: 'Elimina automazione',
49
- warning:
50
- 'Un messaggio può essere usato da altre automazioni: eliminandolo lo togli anche da quelle.',
51
- },
52
- editTitle: 'Modifica automazione',
53
- form: {
54
- actions: {
55
- deleteConfirm: 'Elimina messaggio',
56
- deleteConfirmDescription:
57
- 'Sei sicuro di voler eliminare il messaggio? Potrai aggiungerlo di nuovo in qualsiasi momento.',
58
- empty: 'Nessun messaggio è stato ancora aggiunto. Clicca il pulsante per crearne uno.',
59
- emptyHint: 'Scegli come comunicare con il tuo pubblico aggiungendo i messaggi giusti.',
60
- },
61
- addFilters: 'Aggiungi filtri',
62
- changeTrigger: {
63
- confirm: 'Cambia',
64
- message: 'Cambiare il trigger reimposterà i tuoi messaggi e pubblico.',
65
- title: 'Cambiare trigger?',
66
- },
67
- create: 'Crea',
68
- create_specific_audience: 'Crea un pubblico specifico',
69
- create_specific_audience_hint: 'Usa i filtri per inviare il messaggio a un pubblico mirato.',
70
- data: {
71
- requiredBadge: 'Dati obbligatori',
72
- title: 'Dati',
73
- },
74
- error_banner: 'Completa tutti i campi obbligatori',
75
- includeIf: 'Includi i contatti se...',
76
- messages: 'Messaggi',
77
- name: 'Nome',
78
- namePlaceholder: 'Promuovi Marketplace',
79
- required: 'Obbligatorio',
80
- sendToHint: 'Usa i filtri per inviare il messaggio a un pubblico mirato.',
81
- sendTo_all: 'Tutti i contatti',
82
- sendTotitle: 'Pubblico',
83
- title: 'Dettagli',
84
- trigger: 'Trigger',
85
- },
86
- gate: {
87
- catalog_failed_description:
88
- 'Si è verificato un errore durante il caricamento di ciò che serve a questa pagina. Riprova.',
89
- catalog_failed_title: 'Impossibile caricare le automazioni',
90
- load_failed_description:
91
- 'Si è verificato un errore durante il caricamento di questa automazione. Riprova.',
92
- load_failed_title: 'Impossibile caricare l’automazione',
93
- no_catalog_description:
94
- 'In questo prodotto non c’è ancora nulla con cui creare un’automazione. Contatta il supporto se ti aspettavi di trovarle.',
95
- no_catalog_title: 'Le automazioni non sono disponibili qui',
96
- no_context_description:
97
- 'Questa pagina non ha ricevuto ciò che le serve per funzionare. Ricarica la pagina; se succede di nuovo, contatta il supporto.',
98
- no_context_title: 'Impossibile mostrare le automazioni',
99
- no_organization_description:
100
- 'Le automazioni appartengono a un’organizzazione e nessuna è selezionata.',
101
- no_organization_title: 'Nessuna organizzazione su cui lavorare',
102
- not_found_description:
103
- 'Potrebbe essere stata eliminata, oppure appartiene a un’altra organizzazione o a un altro prodotto.',
104
- not_found_title: 'Automazione non trovata',
105
- },
106
- immediately: 'Immediatamente {moment}',
107
- list: {
108
- active: 'Attivo',
109
- allChannels: 'Tutti i messaggi',
110
- allStatuses: 'Tutti gli stati',
111
- allTriggers: 'Tutti i trigger',
112
- empty: 'Nessuna automazione trovata',
113
- headers: {
114
- audience: 'Pubblico',
115
- channels: 'Messaggi',
116
- createdAt: 'Creato il',
117
- name: 'Nome',
118
- status: 'Stato',
119
- trigger: 'Trigger',
120
- },
121
- inactive: 'Inattivo',
122
- search: 'Cerca per nome',
123
- },
124
- nDays: '{count} giorni {moment}',
125
- new: 'Nuova automazione',
126
- newTitle: 'Crea automazione',
127
- oneDay: '1 giorno {moment}',
128
- preventDuplicates: {
129
- hint: 'Non inviare se questo messaggio è già stato inviato o programmato per lo stesso destinatario alla stessa ora',
130
- label: 'Previeni messaggi duplicati',
131
- },
132
- problems: {
133
- action_channel_not_in_catalog:
134
- '"{name}": questo tipo di messaggio non può essere usato con questo trigger.',
135
- action_date_reference_not_in_catalog:
136
- '"{name}": il momento in cui questo messaggio è programmato non è più disponibile. Scegline un altro.',
137
- action_invalid:
138
- '"{name}": questo messaggio è attivo ma non è approvato in tutte le lingue. Disattivalo, o scegli un messaggio approvato, per salvare.',
139
- action_not_found: '"{name}": questo messaggio non esiste più. Scegline un altro.',
140
- action_other_organization:
141
- '"{name}": questo messaggio appartiene a un’altra organizzazione. Scegline un altro.',
142
- condition_field_not_in_catalog:
143
- 'Un filtro è su "{field}", che non è più disponibile. Rimuovilo per salvare.',
144
- condition_operator_not_allowed:
145
- 'Il filtro su "{field}" usa un confronto che non può essere usato. Modificalo o rimuovilo per salvare.',
146
- show: 'Mostra',
147
- title: 'Questa automazione non può ancora essere salvata',
148
- trigger_not_in_catalog: 'Il trigger non è più disponibile. Scegline un altro.',
149
- unknown: 'Qualcosa in questa automazione non può essere salvato. Controlla e riprova.',
150
- },
151
- recurrence: {
152
- daily: 'Giornaliera',
153
- label: 'Ricorrenza',
154
- monthly: 'Mensile',
155
- none: 'Nessuna',
156
- yearly: 'Annuale',
157
- },
158
- strictDelay: {
159
- hint: 'Salta i messaggi se l’orario programmato è già passato',
160
- label: 'Ritardo rigido',
161
- },
162
- system: {
163
- alert:
164
- 'Questa è un’automazione di sistema. Puoi solo attivare o disattivare i suoi messaggi e compilare i dati richiesti. Duplicala per creare una copia completamente modificabile.',
165
- badge: 'Automazione di sistema',
166
- tooltip: 'Si possono modificare solo l’attivazione dei messaggi e i dati richiesti',
167
- },
168
- title: 'Automazioni',
169
- toast: {
170
- cloned: 'Automazione duplicata con successo',
171
- created: 'Automazione creata con successo',
172
- deleted: 'Automazione eliminata con successo',
173
- deleted_messages: 'Messaggi eliminati insieme: {names}',
174
- engine_rejected: 'L’Automation Engine ha rifiutato la richiesta',
175
- kept_messages: 'Messaggi che non è stato possibile eliminare e sono stati mantenuti: {names}',
176
- partly_saved: 'L’automazione è stata salvata solo in parte',
177
- partly_saved_description: 'Le tue modifiche sono ancora qui. Salva di nuovo per completarla.',
178
- updated: 'Automazione aggiornata con successo',
179
- },
180
- trip: {
181
- back: "Torna all'automazione",
182
- kept: 'Le modifiche non salvate sono state mantenute',
183
- },
184
- unavailable: {
185
- badges: {
186
- not_approved: 'Non approvato',
187
- not_set_up: 'Non configurato',
188
- unavailable: 'Non disponibile',
189
- },
190
- channel:
191
- '{channel} non è configurato per questa organizzazione. Questo messaggio viene mantenuto, ma non viene inviato.',
192
- channel_option: '{channel} (non configurato)',
193
- condition_not_editable:
194
- 'Questo filtro non può essere modificato qui. Resta valido: tienilo o rimuovilo.',
195
- condition_unknown_field: 'Questo filtro non è più disponibile. Rimuovilo per salvare.',
196
- date_reference:
197
- 'La data su cui è programmato questo messaggio non è più disponibile. Scegline un’altra per salvare.',
198
- kept: 'Mantenuti così come sono',
199
- message_group_active:
200
- 'Questo messaggio è attivo ma non è approvato in tutte le lingue. Disattivalo, o scegli un messaggio approvato, per salvare.',
201
- message_group_inactive:
202
- 'Questo messaggio non è ancora approvato in tutte le lingue. Potrà essere attivato quando lo sarà.',
203
- option:
204
- 'Un’opzione selezionata non è più disponibile. Resta valida e viene mantenuta finché non la rimuovi.',
205
- title_blocked: 'Questa automazione non può ancora essere salvata',
206
- title_kept: 'Alcune parti di questa automazione non sono disponibili',
207
- to_fix: 'Da correggere prima di salvare',
208
- trigger:
209
- 'Questo trigger non è più disponibile. Scegline un altro per salvare; i messaggi e il pubblico verranno reimpostati.',
210
- where: {
211
- filter: 'Filtro "{field}"',
212
- message: 'Messaggio "{name}"',
213
- },
214
- },
215
- },
216
2
  categories: {
217
3
  marketing: 'Marketing',
218
4
  utility: 'Utilità',
@@ -329,6 +115,69 @@ export default {
329
115
  title: 'Traduzioni mancanti',
330
116
  translate_and_save: 'Traduci automaticamente e salva',
331
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
+ },
332
181
  publish_message_group: {
333
182
  message: 'Pubblicare "{name}" per renderlo visibile ai clienti?',
334
183
  success: '"{name}" è stato pubblicato.',
@@ -851,52 +700,6 @@ export default {
851
700
  no_preview: 'Nessuna anteprima disponibile',
852
701
  subject: 'Oggetto',
853
702
  },
854
- filters: {
855
- actions: {
856
- add_filter: 'Aggiungi filtro',
857
- open_calendar: 'Apri il calendario',
858
- remove_filter: 'Rimuovi filtro',
859
- remove_option: 'Rimuovi opzione',
860
- },
861
- and: 'e',
862
- applied: '{count} filtri applicati',
863
- field_placeholder: 'Scegli un campo',
864
- operators: {
865
- contains: 'Contiene',
866
- does_not_contain: 'Non contiene',
867
- in: 'In',
868
- is: 'È',
869
- is_at_least: 'È almeno',
870
- is_at_most: 'È al massimo',
871
- is_between: 'È tra',
872
- is_empty: 'È vuoto',
873
- is_less: 'È minore di',
874
- is_more: 'È maggiore di',
875
- is_not: 'Non è',
876
- is_not_between: 'Non è tra',
877
- is_not_empty: 'Non è vuoto',
878
- is_set: 'È impostato',
879
- not_in: 'Non in',
880
- },
881
- selected: '{count} selezionati',
882
- types: {
883
- date: 'Data',
884
- multiselect: 'Scelta multipla',
885
- number: 'Numero',
886
- price: 'Prezzo',
887
- select: 'Scelta singola',
888
- text: 'Testo',
889
- },
890
- unavailable: {
891
- badge: 'Non disponibile',
892
- not_editable:
893
- 'Questo filtro non può essere modificato qui. Resta valido: tienilo o rimuovilo.',
894
- option: 'Opzione non disponibile',
895
- option_description:
896
- "Un'opzione selezionata non è più disponibile. Resta valida e viene mantenuta finché non la rimuovi.",
897
- unknown_field: 'Questo filtro non è più disponibile.',
898
- },
899
- },
900
703
  language: {
901
704
  de: 'Tedesco',
902
705
  en: 'Inglese',
@@ -1080,6 +883,8 @@ export default {
1080
883
  status: 'Stato',
1081
884
  updated_at: 'Aggiornato il',
1082
885
  },
886
+ import_from_meta: 'Importa da Meta ({count})',
887
+ loading: 'Caricamento dei messaggi...',
1083
888
  pagination_summary: '{from}–{to} di {total}',
1084
889
  product_placeholder: 'Seleziona prodotto',
1085
890
  render_type_placeholder: 'Seleziona tipo di rendering',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dev.smartpricing/message-composer-layer",
3
- "version": "4.5.1-next.4",
3
+ "version": "4.5.1-next.5",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./nuxt.config.ts",
@@ -8,11 +8,11 @@
8
8
  "app",
9
9
  "i18n",
10
10
  "shared",
11
- "nuxt.config.ts"
11
+ "nuxt.config.ts",
12
+ "app.config.ts"
12
13
  ],
13
14
  "dependencies": {
14
15
  "@formkit/drag-and-drop": "^0.5.3",
15
- "@internationalized/date": "^3.12.4",
16
16
  "@pinia/colada": "^1.3.0",
17
17
  "@tiptap/extension-character-count": "^3.23.4",
18
18
  "@tiptap/extension-emoji": "^3.23.4",
@@ -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.4"
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",
@@ -1,74 +0,0 @@
1
- import type {
2
- Automation,
3
- AutomationCatalogLanguage,
4
- AutomationCatalogResponse,
5
- AutomationDeleteResult,
6
- CloneAutomationBody,
7
- CreateAutomationBody,
8
- MessageGroupProduct,
9
- UpdateAutomationBody,
10
- } from '@dev.smartpricing/message-composer-utils/types'
11
- import { apiClient } from './client'
12
-
13
- /** Every request names its Organization and its Product (ADR 0014, ADR 0019). */
14
- export const automationsApi = {
15
- getAll: (options: { organization_id: string; product: MessageGroupProduct }) =>
16
- apiClient<Automation[]>(`/automations?${new URLSearchParams(options)}`),
17
-
18
- getCatalog: (options: {
19
- organization_id: string
20
- product: MessageGroupProduct
21
- language: AutomationCatalogLanguage
22
- }) => apiClient<AutomationCatalogResponse>(`/automation-catalog?${new URLSearchParams(options)}`),
23
-
24
- /** No error toast: the page says in place why it has no Automation to show. */
25
- getById: (id: string, options: { product: MessageGroupProduct }) =>
26
- apiClient<Automation>(
27
- `/automations/${encodeURIComponent(id)}?${new URLSearchParams(options)}`,
28
- {
29
- _skipErrorToast: true,
30
- } as Record<string, unknown>,
31
- ),
32
-
33
- /** No error toast: a refused save is shown in the form, by its caller. */
34
- create: (body: CreateAutomationBody) =>
35
- apiClient<Automation>('/automations', {
36
- method: 'POST',
37
- body,
38
- _skipErrorToast: true,
39
- } as Record<string, unknown>),
40
-
41
- /** No error toast, as on a create: its caller tells a refused save from a half-saved one. */
42
- update: (id: string, body: UpdateAutomationBody) =>
43
- apiClient<Automation>(`/automations/${encodeURIComponent(id)}`, {
44
- method: 'PUT',
45
- body,
46
- _skipErrorToast: true,
47
- } as Record<string, unknown>),
48
-
49
- /**
50
- * The copy of an Automation, made by the backend from what is stored: with
51
- * its own Message Groups and every Action inactive (ADR 0016).
52
- */
53
- clone: (id: string, body: CloneAutomationBody) =>
54
- apiClient<Automation>(`/automations/${encodeURIComponent(id)}/clone`, {
55
- method: 'POST',
56
- body,
57
- }),
58
-
59
- /**
60
- * Deletes the Automation and the Message Groups named, each a repeated
61
- * `message_group_ids`. With none the answer is empty; with some it says
62
- * which were deleted and which were kept (ADR 0016).
63
- */
64
- delete: (id: string, options: { product: MessageGroupProduct; message_group_ids: string[] }) => {
65
- const query = new URLSearchParams({ product: options.product })
66
- for (const messageGroupId of options.message_group_ids) {
67
- query.append('message_group_ids', messageGroupId)
68
- }
69
- return apiClient<AutomationDeleteResult | undefined>(
70
- `/automations/${encodeURIComponent(id)}?${query}`,
71
- { method: 'DELETE' },
72
- )
73
- },
74
- }
package/app/app.config.ts DELETED
@@ -1,10 +0,0 @@
1
- import type { AppConfigInput } from 'nuxt/schema'
2
-
3
- // Not through `defineAppConfig`: its input type asks every app config for
4
- // Nuxt UI's `ui`, which only the design system's own config sets.
5
- export default {
6
- composer: {
7
- tracking: false,
8
- automations: false,
9
- },
10
- } satisfies Pick<AppConfigInput, 'composer'>
@@ -1,174 +0,0 @@
1
- <script setup lang="ts">
2
- import type {
3
- AutomationChannel,
4
- AutomationTrigger,
5
- } from '@dev.smartpricing/message-composer-utils/types'
6
- import {
7
- dateReferenceLabel,
8
- localSendingTime,
9
- type AutomationFormAction,
10
- } from '../../utils/automations/form'
11
- import type {
12
- AutomationUnavailableItem,
13
- AutomationUnavailableKind,
14
- } from '../../utils/automations/unavailable'
15
-
16
- /** One Action of the form: what it sends and when, its Active switch and its buttons. */
17
- const props = defineProps<{
18
- action: AutomationFormAction
19
- trigger: AutomationTrigger
20
- /** What the Action holds that is no longer available: each is a badge here. */
21
- unavailable: AutomationUnavailableItem[]
22
- /** A refused save pointed at this Action. */
23
- invalid?: boolean
24
- /** The Action is not edited or removed here: its Active switch still works. */
25
- readOnly?: boolean
26
- }>()
27
-
28
- const emit = defineEmits<{
29
- edit: []
30
- remove: []
31
- toggle: [active: boolean]
32
- }>()
33
-
34
- const { t } = useI18n()
35
-
36
- const CHANNEL_ICONS: Record<AutomationChannel, string> = {
37
- email: 'ph:envelope-simple-bold',
38
- whatsapp: 'ph:whatsapp-logo-bold',
39
- }
40
-
41
- const schedule = computed(() => {
42
- // `moment` is the name the ported copy gives the Date Reference.
43
- const moment = dateReferenceLabel(props.action, props.trigger)
44
- const { days } = props.action
45
- if (days === 0) return t('automations.immediately', { moment })
46
- if (days === 1) return t('automations.oneDay', { moment })
47
- return t('automations.nDays', { count: days, moment })
48
- })
49
-
50
- function unavailableOf(...kinds: AutomationUnavailableKind[]) {
51
- return props.unavailable.find((item) => kinds.includes(item.kind))
52
- }
53
-
54
- const unusableChannel = computed(() => unavailableOf('channel'))
55
- const unlistedDateReference = computed(() => unavailableOf('date_reference'))
56
- const unapproved = computed(() => unavailableOf('message_group_inactive', 'message_group_active'))
57
-
58
- /**
59
- * Why the Action cannot be turned on: its Channel cannot be used, or its
60
- * Message Group is not approved. An Active one on an unapproved Message Group
61
- * keeps a switch that works, so the user can turn it off.
62
- */
63
- const cannotBeActive = computed(
64
- () => unusableChannel.value ?? unavailableOf('message_group_inactive'),
65
- )
66
- </script>
67
-
68
- <template>
69
- <UCard :class="{ 'ring-error': invalid }">
70
- <div class="flex items-start gap-4">
71
- <UAvatar :icon="CHANNEL_ICONS[action.channel]" size="xl" class="shrink-0" />
72
-
73
- <div class="flex-1 min-w-0">
74
- <div class="flex items-center gap-2">
75
- <p class="label-md truncate">
76
- {{ action.messageGroupName || t(`automations.channels.${action.channel}`) }}
77
- </p>
78
- <AutomationsUnavailableBadge v-if="unapproved" :item="unapproved" />
79
- <AutomationsUnavailableBadge v-if="unusableChannel" :item="unusableChannel" />
80
- </div>
81
- <p class="mt-2 paragraph-sm text-muted">
82
- {{ t('automations.action.itIsSent') }}
83
- <span class="font-semibold text-default">{{ schedule }}</span>
84
- <AutomationsUnavailableBadge
85
- v-if="unlistedDateReference"
86
- :item="unlistedDateReference"
87
- class="ml-2"
88
- />
89
- <span class="mx-2">&bull;</span>
90
- {{ t('automations.action.at') }}
91
- <span class="font-semibold text-default">
92
- {{ localSendingTime(action.sendingTimeUTC) }}
93
- </span>
94
- <template v-if="action.recurrence">
95
- <span class="mx-2">&bull;</span>
96
- <span class="font-semibold text-default">
97
- {{ t(`automations.recurrence.${action.recurrence}`) }}
98
- </span>
99
- </template>
100
- <template v-if="action.strictDelay">
101
- <span class="mx-2">&bull;</span>
102
- <UBadge :label="t('automations.strictDelay.label')" color="neutral" size="sm" />
103
- </template>
104
- <template v-if="action.preventDuplicates">
105
- <span class="mx-2">&bull;</span>
106
- <UBadge :label="t('automations.preventDuplicates.label')" color="neutral" size="sm" />
107
- </template>
108
- </p>
109
- </div>
110
- </div>
111
-
112
- <template #footer>
113
- <div class="flex items-center gap-1">
114
- <!-- An Action on a Channel that cannot be used is kept as stored, and shown as not Active. -->
115
- <UTooltip :text="cannotBeActive?.text" :disabled="!cannotBeActive">
116
- <!-- A disabled switch takes no hover: the tooltip is on what wraps it. -->
117
- <span class="inline-flex">
118
- <USwitch
119
- :model-value="action.status === 'active' && !unusableChannel"
120
- :disabled="Boolean(cannotBeActive)"
121
- size="sm"
122
- color="secondary"
123
- :label="t('automations.list.active')"
124
- :data-testid="automationsTestIds.actionEnabledSwitch"
125
- @update:model-value="emit('toggle', $event)"
126
- />
127
- </span>
128
- </UTooltip>
129
-
130
- <div class="ml-auto flex items-center gap-1">
131
- <UButton
132
- v-if="!readOnly"
133
- color="error"
134
- variant="ghost"
135
- size="sm"
136
- :label="t('common.actions.delete')"
137
- :data-testid="automationsTestIds.actionDeleteButton"
138
- @click="emit('remove')"
139
- />
140
- <USlideover
141
- close-icon="ph:x"
142
- :close="{ 'data-testid': automationsTestIds.previewSlideoverCloseButton }"
143
- :title="t('common.preview')"
144
- :content="dialogTestId(automationsTestIds.previewSlideover)"
145
- :ui="{ content: 'max-w-2xl', body: 'p-0 sm:p-0' }"
146
- >
147
- <UButton
148
- color="primary"
149
- variant="outline"
150
- size="sm"
151
- :label="t('common.preview')"
152
- :data-testid="automationsTestIds.actionPreviewButton"
153
- />
154
-
155
- <template #body>
156
- <CommonPreviewById
157
- :id="action.messageGroupId"
158
- class="w-full h-full min-h-[400px]"
159
- show-subject
160
- />
161
- </template>
162
- </USlideover>
163
- <UButton
164
- v-if="!readOnly"
165
- size="sm"
166
- :label="t('common.actions.edit')"
167
- :data-testid="automationsTestIds.actionEditButton"
168
- @click="emit('edit')"
169
- />
170
- </div>
171
- </div>
172
- </template>
173
- </UCard>
174
- </template>