@dev.smartpricing/message-composer-layer 4.0.2-templates.1 → 4.0.2

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 (32) hide show
  1. package/app/api/index.ts +1 -1
  2. package/app/api/organization.ts +5 -0
  3. package/app/components/Common/MessagePreviewSlideover.vue +0 -1
  4. package/app/components/Composer/EmailComposer.vue +1 -31
  5. package/app/components/Composer/MessageLibrary.vue +2 -71
  6. package/app/components/Composer/WhatsappComposer.vue +0 -24
  7. package/app/components/CreateTemplateButton.vue +45 -8
  8. package/app/components/Email/InlinePreview.vue +3 -26
  9. package/app/components/Email/SendTestEmailModal.vue +34 -2
  10. package/app/components/TemplateList/BaseTable.vue +0 -7
  11. package/app/composables/composerContext.ts +5 -0
  12. package/app/pages/{compose → template}/email/create.vue +1 -10
  13. package/app/pages/{compose → template}/whatsapp/create.vue +1 -4
  14. package/app/queries/index.ts +0 -1
  15. package/app/utils/testIds.const.ts +0 -1
  16. package/i18n/locales/de.ts +3 -43
  17. package/i18n/locales/en.ts +3 -53
  18. package/i18n/locales/es.ts +3 -42
  19. package/i18n/locales/fr.ts +3 -42
  20. package/i18n/locales/it.ts +3 -42
  21. package/package.json +2 -2
  22. package/app/api/templates.ts +0 -62
  23. package/app/components/Common/NewMessageModal.vue +0 -274
  24. package/app/components/TemplateList/PromoteModal.vue +0 -69
  25. package/app/pages/templates/email/[id].vue +0 -82
  26. package/app/pages/templates/email/create.vue +0 -74
  27. package/app/pages/templates/index.vue +0 -263
  28. package/app/pages/templates/whatsapp/[id].vue +0 -82
  29. package/app/pages/templates/whatsapp/create.vue +0 -74
  30. package/app/queries/templates.ts +0 -132
  31. /package/app/pages/{compose → template}/email/[id].vue +0 -0
  32. /package/app/pages/{compose → template}/whatsapp/[id].vue +0 -0
@@ -1,132 +0,0 @@
1
- import { useQuery, useMutation, useQueryCache } from '@pinia/colada'
2
- import type { RenderType } from '@dev.smartpricing/message-composer-utils/types'
3
- import type {
4
- TemplateWithMessageSummary,
5
- CreateTemplatePayload,
6
- UpdateTemplatePayload,
7
- PromoteTemplatePayload,
8
- } from '@dev.smartpricing/message-composer-utils/types'
9
- import { templatesApi } from '~/api/templates'
10
-
11
- // QUERIES
12
-
13
- export function useTemplatesQuery(
14
- options?: MaybeRefOrGetter<{
15
- renderType?: RenderType
16
- scope?: 'system' | 'mine' | 'all'
17
- tags?: string[]
18
- tagsMode?: 'and' | 'or'
19
- }>,
20
- ) {
21
- return useQuery({
22
- key: () => ['templates', JSON.stringify(toValue(options))],
23
- query: () => templatesApi.getAll(toValue(options)),
24
- staleTime: 0,
25
- })
26
- }
27
-
28
- export function useTemplateQuery(id: MaybeRefOrGetter<string>) {
29
- return useQuery({
30
- key: () => ['templates', toValue(id)],
31
- query: () => templatesApi.getById(toValue(id)),
32
- staleTime: 2 * 60 * 1000,
33
- })
34
- }
35
-
36
- // MUTATIONS
37
-
38
- export function useCreateTemplateMutation() {
39
- const queryCache = useQueryCache()
40
-
41
- return useMutation({
42
- mutation: (data: CreateTemplatePayload) => templatesApi.create(data),
43
- onSuccess: () => {
44
- queryCache.invalidateQueries({ key: ['templates'] })
45
- },
46
- })
47
- }
48
-
49
- export function useUpdateTemplateMutation() {
50
- const queryCache = useQueryCache()
51
-
52
- return useMutation({
53
- mutation: ({ id, data }: { id: string; data: UpdateTemplatePayload }) =>
54
- templatesApi.update(id, data),
55
- onSuccess: (_, { id }) => {
56
- queryCache.invalidateQueries({ key: ['templates', id] })
57
- queryCache.invalidateQueries({ key: ['templates'] })
58
- },
59
- })
60
- }
61
-
62
- export function useDeleteTemplateMutation() {
63
- const queryCache = useQueryCache()
64
-
65
- return useMutation({
66
- mutation: templatesApi.delete,
67
- onMutate: async (id) => {
68
- queryCache.cancelQueries({ key: ['templates'] })
69
- const previous = queryCache.getQueryData(['templates'])
70
-
71
- queryCache.setQueryData(['templates'], (old: TemplateWithMessageSummary[] | undefined) =>
72
- old?.filter((t) => t.id !== id),
73
- )
74
-
75
- return { previous }
76
- },
77
- onError: (_, __, context) => {
78
- if (context?.previous) {
79
- queryCache.setQueryData(['templates'], context.previous)
80
- }
81
- },
82
- onSuccess: () => {
83
- queryCache.invalidateQueries({ key: ['templates'] })
84
- },
85
- })
86
- }
87
-
88
- export function usePublishTemplateMutation() {
89
- const queryCache = useQueryCache()
90
-
91
- return useMutation({
92
- mutation: templatesApi.publish,
93
- onSuccess: () => {
94
- queryCache.invalidateQueries({ key: ['templates'] })
95
- },
96
- })
97
- }
98
-
99
- export function useUnpublishTemplateMutation() {
100
- const queryCache = useQueryCache()
101
-
102
- return useMutation({
103
- mutation: templatesApi.unpublish,
104
- onSuccess: () => {
105
- queryCache.invalidateQueries({ key: ['templates'] })
106
- },
107
- })
108
- }
109
-
110
- export function usePromoteTemplateMutation() {
111
- const queryCache = useQueryCache()
112
-
113
- return useMutation({
114
- mutation: ({ id, data }: { id: string; data: PromoteTemplatePayload }) =>
115
- templatesApi.promote(id, data),
116
- onSuccess: () => {
117
- queryCache.invalidateQueries({ key: ['templates'] })
118
- },
119
- })
120
- }
121
-
122
- export function useSaveAsTemplateMutation() {
123
- const queryCache = useQueryCache()
124
-
125
- return useMutation({
126
- mutation: ({ messageGroupId, name }: { messageGroupId: string; name?: string }) =>
127
- templatesApi.saveFromMessageGroup(messageGroupId, name),
128
- onSuccess: () => {
129
- queryCache.invalidateQueries({ key: ['templates'] })
130
- },
131
- })
132
- }
File without changes