@dev.smartpricing/message-composer-layer 1.0.12 → 1.0.13

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.
@@ -9,7 +9,7 @@ const { trackEvent } = useTracking()
9
9
 
10
10
  function createTemplate(type: 'whatsapp' | 'email') {
11
11
  trackEvent('message_create', { message_kind: type })
12
- router.push(`/template/${type}/create`)
12
+ router.push({ name: `${type}-message-create` })
13
13
  }
14
14
 
15
15
  const templateOptions = computed(() => {
@@ -1,43 +1,43 @@
1
1
  <script setup lang="ts">
2
- import type { ButtonProps, TabsItem } from "#ui/types";
2
+ import type { ButtonProps, TabsItem } from '#ui/types'
3
3
 
4
- const props = defineProps<{
5
- title: string
6
- tabs?: TabsItem[]
7
- activeTab?: string | number
8
- back?: ButtonProps
9
- testId?: string
10
- }>();
4
+ const props = defineProps<{
5
+ title: string
6
+ tabs?: TabsItem[]
7
+ activeTab?: string | number
8
+ back?: ButtonProps
9
+ testId?: string
10
+ }>()
11
11
 
12
- const emit = defineEmits<{
13
- tabChange: [value: string | number]
14
- }>();
12
+ const emit = defineEmits<{
13
+ tabChange: [value: string | number]
14
+ }>()
15
15
 
16
- watchEffect(() => {
17
- useHead({ title: props.title });
18
- });
16
+ watchEffect(() => {
17
+ useHead({ title: props.title })
18
+ })
19
19
  </script>
20
20
 
21
21
  <template>
22
- <div class="flex flex-col min-h-0">
23
- <SNavigationBarHeader
24
- :title="title"
25
- :back="back"
26
- :tabs="tabs"
27
- :active-tab="activeTab"
28
- :data-testid="testId"
29
- class="bg-white sticky top-0 z-10"
30
- @tab-change="emit('tabChange', $event)"
31
- >
32
- <template #actions>
33
- <div class="flex items-center gap-1.5">
34
- <slot name="actions" />
35
- </div>
36
- </template>
37
- </SNavigationBarHeader>
22
+ <div class="flex flex-col min-h-0">
23
+ <SNavigationBarHeader
24
+ :title="title"
25
+ :back="back"
26
+ :tabs="tabs"
27
+ :active-tab="activeTab"
28
+ :data-testid="testId"
29
+ class="bg-white sticky top-0 z-10"
30
+ @tab-change="emit('tabChange', $event)"
31
+ >
32
+ <template #actions>
33
+ <div class="flex items-center gap-1.5">
34
+ <slot name="actions" />
35
+ </div>
36
+ </template>
37
+ </SNavigationBarHeader>
38
38
 
39
- <div class="flex flex-col gap-4 sm:gap-6 flex-1 overflow-y-auto sm:p-4 p-4">
40
- <slot />
41
- </div>
42
- </div>
39
+ <div class="flex flex-col gap-4 sm:gap-6 flex-1 overflow-y-auto sm:p-4 p-4">
40
+ <slot />
41
+ </div>
42
+ </div>
43
43
  </template>
@@ -3,7 +3,7 @@ import type { RouteLocationRaw } from 'vue-router'
3
3
  export function useGoBack() {
4
4
  const router = useRouter()
5
5
 
6
- function goBackOrFallback(fallback: RouteLocationRaw = '/') {
6
+ function goBackOrFallback(fallback: RouteLocationRaw = { name: 'message-library' }) {
7
7
  if (router.options.history.state.back) {
8
8
  router.back()
9
9
  } else {
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <SNavigationPage :panel-props="{ ui: { body: 'p-0 sm:p-0 gap-0 sm:gap-0 overflow-hidden' } }">
3
- <slot />
4
- </SNavigationPage>
2
+ <SNavigationPage :panel-props="{ ui: { body: 'p-0 sm:p-0 gap-0 sm:gap-0 overflow-hidden' } }">
3
+ <slot />
4
+ </SNavigationPage>
5
5
  </template>
@@ -1,13 +1,10 @@
1
1
  export default defineNuxtRouteMiddleware((to) => {
2
2
  const { isChannelAllowed } = useChannels()
3
3
 
4
- // Extract channel from route path: /template/(whatsapp|email)/...
5
- const pathMatch = to.path.match(/\/template\/(whatsapp|email)/)
6
- if (!pathMatch) return
7
-
8
- const channel = pathMatch[1] as 'whatsapp' | 'email'
4
+ const channel = to.meta.channel as 'whatsapp' | 'email' | undefined
5
+ if (!channel) return
9
6
 
10
7
  if (!isChannelAllowed(channel)) {
11
- return navigateTo('/', { replace: true })
8
+ return navigateTo({ name: 'message-library' }, { replace: true })
12
9
  }
13
10
  })
@@ -1,4 +1,8 @@
1
1
  <script setup lang="ts">
2
+ definePageMeta({
3
+ name: 'images',
4
+ })
5
+
2
6
  import type { MediaFromDb } from '@dev.smartpricing/message-composer-utils/types'
3
7
  import { useMediaQuery, useUploadToSmartchatMutation, useDeleteMediaMutation } from '~/queries'
4
8
  import { formatDate } from '@dev.smartpricing/message-composer-utils/utils'
@@ -46,10 +50,7 @@ async function handleDelete(item: MediaFromDb) {
46
50
  </script>
47
51
 
48
52
  <template>
49
- <LayoutBasePage
50
- :title="t('pages.images.title')"
51
- :test-id="imagesPageTestIds.navbar"
52
- >
53
+ <LayoutBasePage :title="t('pages.images.title')" :test-id="imagesPageTestIds.navbar">
53
54
  <div v-if="isPending" class="flex justify-center py-12">
54
55
  <UIcon
55
56
  name="i-heroicons-arrow-path"
@@ -143,7 +143,7 @@ const router = useRouter()
143
143
  function navigate(row: MessageGroupWithMessageSummary) {
144
144
  trackEvent('message_edit', getMessageTrackingProps(row))
145
145
  const type = row.messages[0]?.render_type === 'email_v1' ? 'email' : 'whatsapp'
146
- router.push(`/template/${type}/${row.id}`)
146
+ router.push({ name: `${type}-message-edit`, params: { id: row.id } })
147
147
  }
148
148
 
149
149
  const { t } = useI18n()
@@ -6,6 +6,7 @@ import { useI18n } from 'vue-i18n'
6
6
  import { useMessageGroupQuery } from '~/queries/messageGroups'
7
7
 
8
8
  definePageMeta({
9
+ name: 'message-preview',
9
10
  layout: false,
10
11
  })
11
12
 
@@ -2,6 +2,7 @@
2
2
  definePageMeta({
3
3
  name: 'email-message-edit',
4
4
  middleware: ['channel-guard'],
5
+ channel: 'email',
5
6
  })
6
7
 
7
8
  import EmailEditor from '@/components/Email/Editor/Index.vue'
@@ -1,6 +1,8 @@
1
1
  <script setup lang="ts">
2
2
  definePageMeta({
3
+ name: 'email-message-create',
3
4
  middleware: ['channel-guard'],
5
+ channel: 'email',
4
6
  })
5
7
 
6
8
  import EmailEditor from '@/components/Email/Editor/Index.vue'
@@ -2,6 +2,7 @@
2
2
  definePageMeta({
3
3
  name: 'whatsapp-message-edit',
4
4
  middleware: ['channel-guard'],
5
+ channel: 'whatsapp',
5
6
  })
6
7
 
7
8
  import WhatsappEditorSyncWrapper from '@/components/Whatsapp/Editor/SyncWrapper.vue'
@@ -239,7 +240,7 @@ async function saveAsNew() {
239
240
  const result = await createTemplate(templateData, 'draft')
240
241
  if (result) {
241
242
  notifyParent('TEMPLATE_SAVED_AS_NEW', { id: result.id, name: result.name })
242
- navigateTo(`/template/whatsapp/${result.id}`, { replace: true })
243
+ navigateTo({ name: 'whatsapp-message-edit', params: { id: result.id } }, { replace: true })
243
244
  }
244
245
  }
245
246
 
@@ -1,6 +1,8 @@
1
1
  <script setup lang="ts">
2
2
  definePageMeta({
3
+ name: 'whatsapp-message-create',
3
4
  middleware: ['channel-guard'],
5
+ channel: 'whatsapp',
4
6
  })
5
7
 
6
8
  import WhatsappEditorSyncWrapper from '@/components/Whatsapp/Editor/SyncWrapper.vue'
@@ -0,0 +1,7 @@
1
+ declare module 'nuxt/app' {
2
+ interface PageMeta {
3
+ channel?: 'whatsapp' | 'email'
4
+ }
5
+ }
6
+
7
+ export {}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dev.smartpricing/message-composer-layer",
3
- "version": "1.0.12",
3
+ "version": "1.0.13",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./nuxt.config.ts",
@@ -39,7 +39,7 @@
39
39
  "vue-router": "^5.0.6",
40
40
  "vue3-emoji-picker": "^1.1.8",
41
41
  "zod": "^4.4.1",
42
- "@dev.smartpricing/message-composer-utils": "3.1.12"
42
+ "@dev.smartpricing/message-composer-utils": "3.1.13"
43
43
  },
44
44
  "devDependencies": {
45
45
  "@nuxt/eslint": "^1.15.2",