@dev.smartpricing/message-composer-layer 4.4.1-next.0 → 4.5.1-automation.0

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 (112) hide show
  1. package/README.md +182 -7
  2. package/app/api/automations.ts +74 -0
  3. package/app/api/brands.ts +20 -13
  4. package/app/api/client.ts +3 -6
  5. package/app/api/dynamicValues.ts +2 -1
  6. package/app/api/index.ts +1 -0
  7. package/app/api/media.ts +6 -3
  8. package/app/api/messageGroups.ts +11 -3
  9. package/app/api/meta.ts +62 -4
  10. package/app/api/organization.ts +10 -1
  11. package/app/api/tracking.ts +2 -2
  12. package/app/app.config.ts +10 -0
  13. package/app/components/Automations/ActionCard.vue +174 -0
  14. package/app/components/Automations/ActionEditor.vue +398 -0
  15. package/app/components/Automations/Actions.vue +158 -0
  16. package/app/components/Automations/CloneModal.vue +78 -0
  17. package/app/components/Automations/Conditions.vue +155 -0
  18. package/app/components/Automations/Create.vue +114 -0
  19. package/app/components/Automations/Data.vue +46 -0
  20. package/app/components/Automations/DeleteModal.vue +80 -0
  21. package/app/components/Automations/Edit.vue +145 -0
  22. package/app/components/Automations/Form.vue +282 -0
  23. package/app/components/Automations/List.vue +370 -0
  24. package/app/components/Automations/PageGate.vue +50 -0
  25. package/app/components/Automations/SaveProblems.vue +54 -0
  26. package/app/components/Automations/Unavailable.vue +71 -0
  27. package/app/components/Automations/UnavailableBadge.vue +35 -0
  28. package/app/components/Common/AppContextErrors.vue +2 -2
  29. package/app/components/Common/MessageGroupSelect.vue +43 -3
  30. package/app/components/Common/OrganizationGate.vue +51 -0
  31. package/app/components/Common/OrganizationSelect.vue +27 -0
  32. package/app/components/Common/WhatsappNotConfigured.vue +20 -0
  33. package/app/components/Composer/EmailComposer.vue +9 -1
  34. package/app/components/Composer/MessageLibrary.vue +8 -0
  35. package/app/components/Composer/WabaSelectModal.vue +73 -0
  36. package/app/components/Composer/WhatsappComposer.vue +83 -4
  37. package/app/components/Editor/RichTextEditor.vue +14 -2
  38. package/app/components/Filters/DateInput.vue +57 -0
  39. package/app/components/Filters/Editor.vue +163 -0
  40. package/app/components/Filters/Row.vue +119 -0
  41. package/app/components/Filters/Summary.vue +215 -0
  42. package/app/components/Filters/UnavailableRow.vue +74 -0
  43. package/app/components/Filters/ValueInput.vue +215 -0
  44. package/app/components/Layout/BasePage.vue +2 -0
  45. package/app/components/MessageSendFlow/EmailPreview.vue +3 -0
  46. package/app/components/MessageSendFlow/MessageSendFlow.vue +15 -2
  47. package/app/components/MetaImport/Button.vue +50 -0
  48. package/app/components/MetaImport/Dialog.vue +261 -0
  49. package/app/components/MetaImport/Outcome.vue +136 -0
  50. package/app/components/MetaImport/ProposalList.vue +192 -0
  51. package/app/components/TemplateList/BaseTable.vue +22 -1
  52. package/app/components/Whatsapp/Preview.vue +5 -12
  53. package/app/components/Whatsapp/Translator/Header.vue +4 -19
  54. package/app/composables/apiErrorMessages.ts +1 -0
  55. package/app/composables/automationsContext.ts +42 -0
  56. package/app/composables/composerContext.ts +5 -5
  57. package/app/composables/useAutomationClone.ts +33 -0
  58. package/app/composables/useAutomationEditorTrip.ts +77 -0
  59. package/app/composables/useAutomationSaveProblems.ts +82 -0
  60. package/app/composables/useAutomationUnavailable.ts +98 -0
  61. package/app/composables/useAutomationsGate.ts +68 -0
  62. package/app/composables/useBuiltInOptionLists.ts +44 -0
  63. package/app/composables/useEditorTripBack.ts +15 -0
  64. package/app/composables/useEffectiveOrganization.ts +34 -0
  65. package/app/composables/useMessageGroupWaba.ts +76 -0
  66. package/app/composables/useMessageSendFlow.ts +46 -8
  67. package/app/composables/usePagedMessageGroups.ts +14 -2
  68. package/app/composables/useTemplateOperations.ts +18 -4
  69. package/app/composables/useTracking.ts +14 -5
  70. package/app/composables/useWhatsappConfiguration.ts +32 -0
  71. package/app/layouts/default.vue +4 -1
  72. package/app/middleware/automations-enabled.ts +12 -0
  73. package/app/pages/automations/[id].vue +87 -0
  74. package/app/pages/automations/index.vue +28 -0
  75. package/app/pages/automations/new.vue +53 -0
  76. package/app/pages/brands.vue +1 -0
  77. package/app/pages/images.vue +4 -0
  78. package/app/pages/index.vue +6 -1
  79. package/app/pages/preview/[id].vue +2 -0
  80. package/app/pages/template/email/[id].vue +5 -0
  81. package/app/pages/template/email/create.vue +5 -0
  82. package/app/pages/template/whatsapp/[id].vue +6 -0
  83. package/app/pages/template/whatsapp/create.vue +5 -0
  84. package/app/queries/automations.ts +206 -0
  85. package/app/queries/brands.ts +27 -7
  86. package/app/queries/compilation.ts +15 -2
  87. package/app/queries/dynamicValues.ts +13 -2
  88. package/app/queries/index.ts +1 -0
  89. package/app/queries/media.ts +8 -3
  90. package/app/queries/messageGroups.ts +60 -25
  91. package/app/queries/meta.ts +100 -5
  92. package/app/stores/appContext.ts +9 -45
  93. package/app/stores/editorTrip.ts +67 -0
  94. package/app/stores/effectiveOrganization.ts +128 -0
  95. package/app/stores/emailEditor.ts +5 -1
  96. package/app/stores/metaSubmission.ts +7 -17
  97. package/app/types/app-config.d.ts +3 -0
  98. package/app/types/tracking.ts +33 -0
  99. package/app/utils/automations/form.ts +389 -0
  100. package/app/utils/automations/metadata.ts +71 -0
  101. package/app/utils/automations/unavailable.ts +90 -0
  102. package/app/utils/filters/data/countries.json +998 -0
  103. package/app/utils/filters/data/languages.json +754 -0
  104. package/app/utils/filters/rows.ts +367 -0
  105. package/app/utils/testIds.const.ts +108 -0
  106. package/i18n/locales/de.ts +363 -0
  107. package/i18n/locales/en.ts +345 -0
  108. package/i18n/locales/es.ts +349 -0
  109. package/i18n/locales/fr.ts +357 -0
  110. package/i18n/locales/it.ts +354 -0
  111. package/package.json +4 -4
  112. package/app.config.ts +0 -5
@@ -0,0 +1,174 @@
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>
@@ -0,0 +1,398 @@
1
+ <script setup lang="ts">
2
+ import type {
3
+ AutomationChannel,
4
+ AutomationTrigger,
5
+ } from '@dev.smartpricing/message-composer-utils/types'
6
+ import { useMessageGroupApprovalsQuery } from '~/queries'
7
+ import {
8
+ AUTOMATION_RECURRENCES,
9
+ cloneFormData,
10
+ dateReferenceValue,
11
+ localSendingTime,
12
+ parseDateReferenceValue,
13
+ type AutomationFormAction,
14
+ type AutomationRecurrence,
15
+ } from '../../utils/automations/form'
16
+ import type { AutomationUnavailableKind } from '../../utils/automations/unavailable'
17
+
18
+ /**
19
+ * The slideover that adds or edits one Action: its Channel, its Message Group
20
+ * and its Schedule. It works on a copy, handed back on Save only.
21
+ */
22
+ const props = defineProps<{
23
+ /** The Action to start from; the slideover is open while there is one. */
24
+ action: AutomationFormAction | undefined
25
+ /** Whether `action` is one the form does not hold yet. */
26
+ isNew: boolean
27
+ trigger: AutomationTrigger
28
+ /** The Channels an Action can be on here. */
29
+ channels: AutomationChannel[]
30
+ /** The Channels the Organization cannot use. */
31
+ unusableChannels: AutomationChannel[]
32
+ }>()
33
+
34
+ const emit = defineEmits<{
35
+ save: [action: AutomationFormAction]
36
+ close: []
37
+ /** The user leaves for the Message editor, with the Action as edited so far. */
38
+ editMessage: [request: { action: AutomationFormAction; target: 'create' | 'edit' }]
39
+ }>()
40
+
41
+ const { t } = useI18n()
42
+
43
+ const edited = ref<AutomationFormAction>()
44
+
45
+ watch(
46
+ () => props.action,
47
+ (action) => {
48
+ edited.value = action ? cloneFormData(action) : undefined
49
+ },
50
+ { immediate: true },
51
+ )
52
+
53
+ const open = computed({
54
+ get: () => Boolean(props.action),
55
+ set: (isOpen) => {
56
+ if (!isOpen) emit('close')
57
+ },
58
+ })
59
+
60
+ const { data: approvals } = useMessageGroupApprovalsQuery(() =>
61
+ edited.value ? [edited.value.messageGroupId] : [],
62
+ )
63
+
64
+ const unavailable = useAutomationUnavailable()
65
+
66
+ /** What the Action being edited holds that is no longer available. */
67
+ const unavailableItems = computed(() =>
68
+ edited.value
69
+ ? unavailable.actionItems(edited.value, {
70
+ trigger: props.trigger,
71
+ unusableChannels: props.unusableChannels,
72
+ approvals: approvals.value,
73
+ })
74
+ : [],
75
+ )
76
+
77
+ function unavailableOf(...kinds: AutomationUnavailableKind[]) {
78
+ return unavailableItems.value.find((item) => kinds.includes(item.kind))
79
+ }
80
+
81
+ const unusableChannel = computed(() => unavailableOf('channel'))
82
+ const unlistedDateReference = computed(() => unavailableOf('date_reference'))
83
+ const unapproved = computed(() => unavailableOf('message_group_inactive', 'message_group_active'))
84
+
85
+ /** The Action's own Channel stays in the list when it cannot be picked here, as a disabled option. */
86
+ const channelOptions = computed(() => {
87
+ const options: { value: AutomationChannel; label: string; disabled?: boolean }[] =
88
+ props.channels.map((channel) => ({
89
+ value: channel,
90
+ label: t(`automations.channels.${channel}`),
91
+ }))
92
+
93
+ const own = edited.value?.channel
94
+ if (own && !props.channels.includes(own)) {
95
+ const channel = t(`automations.channels.${own}`)
96
+ options.unshift({
97
+ value: own,
98
+ label: props.unusableChannels.includes(own)
99
+ ? t('automations.unavailable.channel_option', { channel })
100
+ : channel,
101
+ disabled: true,
102
+ })
103
+ }
104
+ return options
105
+ })
106
+
107
+ function setChannel(channel: AutomationChannel) {
108
+ if (!edited.value || channel === edited.value.channel) return
109
+ edited.value.channel = channel
110
+ // A Message Group is of one Channel.
111
+ edited.value.messageGroupId = ''
112
+ edited.value.messageGroupName = ''
113
+ }
114
+
115
+ /** A stored Date Reference the Trigger no longer lists shows as it is, and cannot be picked. */
116
+ const dateReferenceOptions = computed(() => [
117
+ ...(edited.value && unlistedDateReference.value
118
+ ? [
119
+ {
120
+ value: dateReferenceValue(edited.value),
121
+ label: edited.value.dateReference,
122
+ disabled: true,
123
+ },
124
+ ]
125
+ : []),
126
+ ...props.trigger.date_references.flatMap((reference) =>
127
+ reference.directions.map(({ direction, label }) => ({
128
+ value: dateReferenceValue({ direction, dateReference: reference.key }),
129
+ label,
130
+ })),
131
+ ),
132
+ ])
133
+
134
+ function setDateReference(value: string) {
135
+ if (edited.value) Object.assign(edited.value, parseDateReferenceValue(value))
136
+ }
137
+
138
+ // Every hour of the day, by its UTC value and with the user's clock as label.
139
+ const sendingTimeOptions = Array.from({ length: 24 }, (_, hour) => {
140
+ const value = `${String(hour).padStart(2, '0')}:00:00Z`
141
+ return { value, label: localSendingTime(value) }
142
+ })
143
+
144
+ const NO_RECURRENCE = 'none'
145
+
146
+ const recurrenceOptions = computed(() => [
147
+ { value: NO_RECURRENCE, label: t('automations.recurrence.none') },
148
+ ...AUTOMATION_RECURRENCES.map((recurrence) => ({
149
+ value: recurrence,
150
+ label: t(`automations.recurrence.${recurrence}`),
151
+ })),
152
+ ])
153
+
154
+ // A recurrence and a strict delay exclude each other.
155
+ function setRecurrence(value: string) {
156
+ if (!edited.value) return
157
+ edited.value.recurrence = value === NO_RECURRENCE ? undefined : (value as AutomationRecurrence)
158
+ if (edited.value.recurrence) edited.value.strictDelay = false
159
+ }
160
+
161
+ function setStrictDelay(strict: boolean) {
162
+ if (!edited.value) return
163
+ edited.value.strictDelay = strict
164
+ if (strict) edited.value.recurrence = undefined
165
+ }
166
+
167
+ const advancedOpen = ref(false)
168
+
169
+ // Immediate: an Action reopened after an editor trip is there from the start.
170
+ watch(
171
+ open,
172
+ (isOpen) => {
173
+ if (!isOpen || !edited.value) return
174
+ const { recurrence, strictDelay, preventDuplicates } = edited.value
175
+ advancedOpen.value = Boolean(recurrence) || strictDelay || !preventDuplicates
176
+ },
177
+ { immediate: true },
178
+ )
179
+
180
+ function editMessage(target: 'create' | 'edit') {
181
+ if (edited.value) emit('editMessage', { action: edited.value, target })
182
+ }
183
+
184
+ function save() {
185
+ if (!edited.value?.messageGroupId) return
186
+ // An emptied number input holds no number.
187
+ const days = Math.max(0, Math.round(Number(edited.value.days) || 0))
188
+ emit('save', { ...edited.value, days })
189
+ }
190
+ </script>
191
+
192
+ <template>
193
+ <USlideover
194
+ v-model:open="open"
195
+ close-icon="ph:x"
196
+ :close="{ 'data-testid': automationsTestIds.channelSlideoverCloseButton }"
197
+ :title="isNew ? t('automations.channel.addTitle') : t('automations.channel.editTitle')"
198
+ :ui="{ content: 'max-w-4xl', body: 'p-0 sm:p-0', footer: 'justify-end' }"
199
+ :content="dialogTestId(automationsTestIds.channelSlideover)"
200
+ >
201
+ <template #body>
202
+ <div v-if="edited" class="grid grid-cols-2 h-full divide-muted divide-x">
203
+ <div class="space-y-5 py-6">
204
+ <div v-if="unavailableItems.length > 0" class="px-6">
205
+ <AutomationsUnavailable :items="unavailableItems" in-place />
206
+ </div>
207
+
208
+ <UFormField class="px-6" :label="t('automations.channel.channelType')">
209
+ <template v-if="unusableChannel" #hint>
210
+ <AutomationsUnavailableBadge :item="unusableChannel" />
211
+ </template>
212
+ <USelect
213
+ :model-value="edited.channel"
214
+ :items="channelOptions"
215
+ class="w-full"
216
+ :data-testid="automationsTestIds.channelTypeSelect"
217
+ @update:model-value="setChannel"
218
+ />
219
+ </UFormField>
220
+
221
+ <USeparator />
222
+
223
+ <UFormField
224
+ class="px-6"
225
+ :label="t('automations.channel.selectMessage')"
226
+ :description="t('automations.channel.selectMessageHint')"
227
+ >
228
+ <template v-if="unapproved" #hint>
229
+ <AutomationsUnavailableBadge :item="unapproved" />
230
+ </template>
231
+ <!-- Approved only: an Action is Active from the start. -->
232
+ <CommonMessageGroupSelect
233
+ :key="edited.channel"
234
+ v-model="edited.messageGroupId"
235
+ :render-type="edited.channel === 'whatsapp' ? 'whatsapp_v1' : 'email_v1'"
236
+ :placeholder="t('automations.channel.selectMessagePlaceholder')"
237
+ :search-placeholder="t('automations.channel.searchMessagePlaceholder')"
238
+ @select="edited.messageGroupName = $event.name"
239
+ />
240
+
241
+ <!-- Not on a Channel that cannot be used here: its editor would turn the user away. -->
242
+ <p
243
+ v-if="channels.includes(edited.channel)"
244
+ class="paragraph-sm text-muted mt-2 flex items-center gap-1"
245
+ >
246
+ {{ t('automations.channel.cannotFindMessage') }}
247
+ <UButton
248
+ variant="link"
249
+ size="sm"
250
+ color="secondary"
251
+ :label="t('automations.channel.createNew')"
252
+ :data-testid="automationsTestIds.channelCreateNewButton"
253
+ @click="editMessage('create')"
254
+ />
255
+ <UButton
256
+ v-if="edited.messageGroupId"
257
+ variant="link"
258
+ size="sm"
259
+ color="secondary"
260
+ :label="t('common.actions.edit')"
261
+ :data-testid="automationsTestIds.channelEditTemplateButton"
262
+ @click="editMessage('edit')"
263
+ />
264
+ </p>
265
+ </UFormField>
266
+
267
+ <USeparator />
268
+
269
+ <UFormField
270
+ class="px-6"
271
+ :label="t('automations.channel.when')"
272
+ :description="t('automations.channel.whenHint')"
273
+ >
274
+ <template v-if="unlistedDateReference" #hint>
275
+ <AutomationsUnavailableBadge :item="unlistedDateReference" />
276
+ </template>
277
+ <div class="flex items-center gap-2">
278
+ <UFieldGroup>
279
+ <UInputNumber
280
+ v-model="edited.days"
281
+ :min="0"
282
+ :decrement="false"
283
+ :increment="false"
284
+ :data-testid="automationsTestIds.channelDaysInput"
285
+ />
286
+ <UBadge color="neutral" variant="outline" size="sm">
287
+ {{ t('automations.channel.chooseDays') }}
288
+ </UBadge>
289
+ </UFieldGroup>
290
+
291
+ <USelect
292
+ :model-value="dateReferenceValue(edited)"
293
+ :items="dateReferenceOptions"
294
+ class="w-full"
295
+ :data-testid="automationsTestIds.channelDateRefSelect"
296
+ @update:model-value="setDateReference"
297
+ />
298
+ </div>
299
+ </UFormField>
300
+
301
+ <UFormField class="w-1/2 px-6" :label="t('automations.channel.sendingTime')">
302
+ <USelect
303
+ v-model="edited.sendingTimeUTC"
304
+ :items="sendingTimeOptions"
305
+ class="w-full"
306
+ :data-testid="automationsTestIds.channelSendingTimeSelect"
307
+ />
308
+ </UFormField>
309
+
310
+ <USeparator />
311
+
312
+ <UCollapsible
313
+ v-model:open="advancedOpen"
314
+ class="px-6"
315
+ :data-testid="automationsTestIds.channelAdvancedCollapse"
316
+ >
317
+ <UButton
318
+ :label="t('automations.advanced')"
319
+ color="neutral"
320
+ variant="ghost"
321
+ size="sm"
322
+ :trailing-icon="advancedOpen ? 'ph:caret-up-bold' : 'ph:caret-down-bold'"
323
+ block
324
+ :data-testid="automationsTestIds.channelAdvancedCollapseButton"
325
+ />
326
+
327
+ <template #content>
328
+ <div class="space-y-4 pt-4">
329
+ <UFormField :label="t('automations.recurrence.label')">
330
+ <USelect
331
+ :model-value="edited.recurrence ?? NO_RECURRENCE"
332
+ :items="recurrenceOptions"
333
+ class="w-full"
334
+ :disabled="edited.strictDelay"
335
+ :data-testid="automationsTestIds.channelRecurrenceSelect"
336
+ @update:model-value="setRecurrence"
337
+ />
338
+ </UFormField>
339
+
340
+ <USwitch
341
+ :model-value="edited.strictDelay"
342
+ :label="t('automations.strictDelay.label')"
343
+ :description="t('automations.strictDelay.hint')"
344
+ :data-testid="automationsTestIds.channelStrictDelaySwitch"
345
+ @update:model-value="setStrictDelay"
346
+ />
347
+
348
+ <USwitch
349
+ v-model="edited.preventDuplicates"
350
+ :label="t('automations.preventDuplicates.label')"
351
+ :description="t('automations.preventDuplicates.hint')"
352
+ :data-testid="automationsTestIds.channelPreventDuplicatesSwitch"
353
+ />
354
+ </div>
355
+ </template>
356
+ </UCollapsible>
357
+ </div>
358
+
359
+ <div class="flex flex-col h-full p-6">
360
+ <p class="label-lg mb-3">{{ t('automations.channel.preview') }}</p>
361
+
362
+ <div class="flex-1" :data-testid="automationsTestIds.channelPreview">
363
+ <CommonPreviewById
364
+ v-if="edited.messageGroupId"
365
+ :id="edited.messageGroupId"
366
+ class="w-full h-full min-h-[400px]"
367
+ show-subject
368
+ />
369
+ <UEmpty
370
+ v-else
371
+ variant="naked"
372
+ icon="ph:image-square"
373
+ :title="t('automations.channel.no_message.title')"
374
+ :description="t('automations.channel.no_message.description')"
375
+ />
376
+ </div>
377
+ </div>
378
+ </div>
379
+ </template>
380
+
381
+ <template #footer>
382
+ <UButton
383
+ color="neutral"
384
+ variant="outline"
385
+ :label="t('common.actions.cancel')"
386
+ :data-testid="automationsTestIds.channelSlideoverCancel"
387
+ @click="open = false"
388
+ />
389
+ <UButton
390
+ color="primary"
391
+ :label="t('common.actions.save')"
392
+ :disabled="!edited?.messageGroupId"
393
+ :data-testid="automationsTestIds.channelSlideoverSave"
394
+ @click="save"
395
+ />
396
+ </template>
397
+ </USlideover>
398
+ </template>