@dev.smartpricing/message-composer-layer 1.0.2 → 1.0.4
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
|
+
"version": "1.0.4",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -10,12 +10,24 @@
|
|
|
10
10
|
"nuxt.config.ts",
|
|
11
11
|
"app.config.ts"
|
|
12
12
|
],
|
|
13
|
+
"scripts": {
|
|
14
|
+
"build": "nuxt build",
|
|
15
|
+
"dev": "nuxt dev",
|
|
16
|
+
"lint": "eslint app/ --fix",
|
|
17
|
+
"format": "prettier --write app/",
|
|
18
|
+
"postinstall": "nuxt prepare",
|
|
19
|
+
"test:e2e": "playwright test",
|
|
20
|
+
"test:e2e:debug": "playwright test --debug",
|
|
21
|
+
"test:e2e:ui": "playwright test --ui",
|
|
22
|
+
"cleanup": "nuxt cleanup && rm -rf node_modules pnpm-lock.yaml"
|
|
23
|
+
},
|
|
13
24
|
"dependencies": {
|
|
14
25
|
"@formkit/drag-and-drop": "^0.5.3",
|
|
15
26
|
"@nuxtjs/i18n": "^10.3.0",
|
|
16
27
|
"@pinia/colada": "^1.2.1",
|
|
17
28
|
"@pinia/colada-nuxt": "^1.0.0",
|
|
18
29
|
"@pinia/nuxt": "^0.11.3",
|
|
30
|
+
"@dev.smartpricing/message-composer-utils": "workspace:*",
|
|
19
31
|
"@tiptap/extension-character-count": "^3.22.5",
|
|
20
32
|
"@tiptap/extension-emoji": "^3.22.5",
|
|
21
33
|
"@tiptap/extension-link": "^3.22.5",
|
|
@@ -28,17 +40,16 @@
|
|
|
28
40
|
"@tiptap/vue-3": "^3.22.5",
|
|
29
41
|
"@vueuse/core": "^14.2.1",
|
|
30
42
|
"@vueuse/nuxt": "^14.2.1",
|
|
43
|
+
"colorthief": "^2.4.0",
|
|
31
44
|
"jwt-decode": "^4.0.0",
|
|
32
45
|
"monaco-editor": "^0.55.1",
|
|
33
|
-
"colorthief": "^2.4.0",
|
|
34
46
|
"nuxt": "^4.4.2",
|
|
35
47
|
"ofetch": "^1.5.1",
|
|
36
48
|
"typescript": "^6.0.3",
|
|
37
49
|
"vue": "^3.5.33",
|
|
38
50
|
"vue-router": "^5.0.6",
|
|
39
51
|
"vue3-emoji-picker": "^1.1.8",
|
|
40
|
-
"zod": "^4.4.1"
|
|
41
|
-
"@dev.smartpricing/message-composer-utils": "3.1.2-layer.0"
|
|
52
|
+
"zod": "^4.4.1"
|
|
42
53
|
},
|
|
43
54
|
"devDependencies": {
|
|
44
55
|
"@nuxt/eslint": "^1.15.2",
|
|
@@ -49,16 +60,5 @@
|
|
|
49
60
|
},
|
|
50
61
|
"peerDependencies": {
|
|
51
62
|
"nuxt-ui-layer": ">=1.3.0"
|
|
52
|
-
},
|
|
53
|
-
"scripts": {
|
|
54
|
-
"build": "nuxt build",
|
|
55
|
-
"dev": "nuxt dev",
|
|
56
|
-
"lint": "eslint app/ --fix",
|
|
57
|
-
"format": "prettier --write app/",
|
|
58
|
-
"postinstall": "nuxt prepare",
|
|
59
|
-
"test:e2e": "playwright test",
|
|
60
|
-
"test:e2e:debug": "playwright test --debug",
|
|
61
|
-
"test:e2e:ui": "playwright test --ui",
|
|
62
|
-
"cleanup": "nuxt cleanup && rm -rf node_modules pnpm-lock.yaml"
|
|
63
63
|
}
|
|
64
|
-
}
|
|
64
|
+
}
|