@dev.smartpricing/message-composer-layer 1.0.3 → 1.0.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.
@@ -0,0 +1,59 @@
1
+ <script setup lang="ts">
2
+ import type { EmailMessage, WhatsappMessage } from '@dev.smartpricing/message-composer-utils/types'
3
+ import { useMessageGroupQuery } from '~/queries/messageGroups'
4
+
5
+ defineOptions({ name: 'PreviewById' })
6
+
7
+ const props = withDefaults(
8
+ defineProps<{
9
+ id: string
10
+ showSubject?: boolean
11
+ view?: 'desktop' | 'mobile'
12
+ dynamicData?: Record<string, string>
13
+ brandId?: string
14
+ }>(),
15
+ { showSubject: false, view: 'desktop' },
16
+ )
17
+
18
+ const { locale } = useI18n()
19
+ const { data: messageGroup, isLoading } = useMessageGroupQuery(() => props.id)
20
+
21
+ const selectedMessage = computed(() => {
22
+ if (!messageGroup.value?.messages.length) return undefined
23
+
24
+ const msgByLocale = messageGroup.value.messages.find((m) => m.language_id === locale.value)
25
+ if (msgByLocale) return msgByLocale
26
+
27
+ return messageGroup.value.messages[0]
28
+ })
29
+
30
+ const isWhatsapp = computed(() => selectedMessage.value?.render_type === 'whatsapp_v1')
31
+ const isEmail = computed(() => selectedMessage.value?.render_type === 'email_v1')
32
+ </script>
33
+
34
+ <template>
35
+ <div class="flex-1" :data-testid="previewByIdTestIds.root">
36
+ <div v-if="isLoading" class="space-y-2 p-4" :data-testid="previewByIdTestIds.loading">
37
+ <USkeleton class="h-6 w-1/3" />
38
+ <USkeleton class="h-4" />
39
+ <USkeleton class="h-4 w-5/8" />
40
+ <USkeleton class="h-32" />
41
+ </div>
42
+
43
+ <EmailPreview
44
+ v-else-if="isEmail && selectedMessage"
45
+ :message="selectedMessage as EmailMessage"
46
+ :message-group-id="id"
47
+ :show-subject="showSubject"
48
+ :view="view"
49
+ :dynamic-data="dynamicData"
50
+ :brand-id="brandId"
51
+ />
52
+
53
+ <WhatsappPreview
54
+ v-else-if="isWhatsapp && selectedMessage"
55
+ :message="selectedMessage as WhatsappMessage"
56
+ :dynamic-data="dynamicData"
57
+ />
58
+ </div>
59
+ </template>
@@ -0,0 +1,56 @@
1
+ <script setup lang="ts">
2
+ import type { RenderType } from '@dev.smartpricing/message-composer-utils/types'
3
+ import { useMessageGroupsQuery } from '~/queries/messageGroups'
4
+
5
+ defineOptions({ name: 'TemplateSelect' })
6
+
7
+ const props = withDefaults(
8
+ defineProps<{
9
+ renderType?: RenderType
10
+ placeholder?: string
11
+ searchPlaceholder?: string
12
+ }>(),
13
+ {
14
+ placeholder: 'Select a template',
15
+ searchPlaceholder: 'Search...',
16
+ },
17
+ )
18
+
19
+ const modelValue = defineModel<string>()
20
+
21
+ const emit = defineEmits<{
22
+ select: [item: { id: string; name: string }]
23
+ }>()
24
+
25
+ const { data: messageGroups, isLoading } = useMessageGroupsQuery(() => ({
26
+ renderType: props.renderType,
27
+ }))
28
+
29
+ const items = computed(() => {
30
+ if (!messageGroups.value) return []
31
+ return messageGroups.value.map((group) => ({
32
+ label: group.name,
33
+ value: group.id,
34
+ }))
35
+ })
36
+
37
+ function handleUpdate(value: string) {
38
+ modelValue.value = value
39
+ const group = messageGroups.value?.find((g) => g.id === value)
40
+ emit('select', { id: value, name: group?.name ?? '' })
41
+ }
42
+ </script>
43
+
44
+ <template>
45
+ <USelectMenu
46
+ :model-value="modelValue"
47
+ :items="items"
48
+ value-key="value"
49
+ :loading="isLoading"
50
+ searchable
51
+ :placeholder="placeholder"
52
+ :search-input="{ placeholder: searchPlaceholder }"
53
+ :data-testid="templateSelectTestIds.root"
54
+ @update:model-value="handleUpdate"
55
+ />
56
+ </template>
@@ -726,3 +726,12 @@ export const unsubscribeLinkSettingsTestIds = {
726
726
  textColorInput: 'unsubscribe-link-settings-text-color-input',
727
727
  backgroundColorInput: 'unsubscribe-link-settings-background-color-input',
728
728
  } as const
729
+
730
+ export const previewByIdTestIds = {
731
+ root: 'preview-by-id-root',
732
+ loading: 'preview-by-id-loading',
733
+ } as const
734
+
735
+ export const templateSelectTestIds = {
736
+ root: 'template-select-root',
737
+ } as const
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dev.smartpricing/message-composer-layer",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "files": [
@@ -28,9 +28,9 @@
28
28
  "@tiptap/vue-3": "^3.22.5",
29
29
  "@vueuse/core": "^14.2.1",
30
30
  "@vueuse/nuxt": "^14.2.1",
31
+ "colorthief": "^2.4.0",
31
32
  "jwt-decode": "^4.0.0",
32
33
  "monaco-editor": "^0.55.1",
33
- "colorthief": "^2.4.0",
34
34
  "nuxt": "^4.4.2",
35
35
  "ofetch": "^1.5.1",
36
36
  "typescript": "^6.0.3",
@@ -38,7 +38,7 @@
38
38
  "vue-router": "^5.0.6",
39
39
  "vue3-emoji-picker": "^1.1.8",
40
40
  "zod": "^4.4.1",
41
- "@dev.smartpricing/message-composer-utils": "3.1.2"
41
+ "@dev.smartpricing/message-composer-utils": "3.1.5"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@nuxt/eslint": "^1.15.2",