@retailrocketgroup/retailrocket-create.reactivation-vue-email-template-render 5.0.384767 → 6.0.388330-dev

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.
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@retailrocketgroup/retailrocket-create.reactivation-vue-email-template-render",
3
- "version": "5.0.384767",
3
+ "version": "6.0.388330-dev",
4
4
  "private": false
5
5
  }
@@ -5,9 +5,13 @@ import { createApp } from 'vue';
5
5
  import { createVuetify } from 'vuetify';
6
6
  import { ClickOutside } from 'vuetify/directives';
7
7
 
8
- import { CreateEmailTemplateApp } from '@easy-wizzy/core';
8
+ import { TemplatesGallery } from '@easy-wizzy/core';
9
9
  import { createSimpleDataForm, matcherFactory } from '@easy-wizzy/core';
10
- import type { GeneralStringExpressionDataSource } from '@easy-wizzy/retailrocket-common';
10
+ import type {
11
+ GeneralListExpressionDataSource,
12
+ GeneralNumberExpressionDataSource,
13
+ GeneralStringExpressionDataSource
14
+ } from '@easy-wizzy/retailrocket-common';
11
15
  import { expressionEvaluatorFactory } from '@easy-wizzy/core';
12
16
  import { listExpressionEvaluatorFactory } from '@easy-wizzy/core';
13
17
  import { numberExpressionEvaluatorDelegate } from '@easy-wizzy/core';
@@ -15,19 +19,22 @@ import { stringExpressionEvaluatorFactory } from '@easy-wizzy/core';
15
19
  import { dataStructBuilderExpressionEvaluatorFactory } from '@easy-wizzy/core';
16
20
 
17
21
  import type { EmailTemplateType } from '@easy-wizzy/core';
18
- import type { EmailTemplatePreviewTileComponent } from '@easy-wizzy/core';
19
22
  import type { LocaleKey } from '@easy-wizzy/core';
20
23
  import type { StringExpressionEvaluatorDelegate } from '@easy-wizzy/core';
21
24
 
22
- import { createEmailTemplateAppDepsFactory } from '@easy-wizzy/common-app';
23
- import { emailTemplatePreviewTileComponentFactory } from '@easy-wizzy/common-app';
24
- import { emailTemplatePreviewTileDepsFactory } from '@easy-wizzy/common-app';
25
+ import { templatesGalleryDepsFactory } from '@easy-wizzy/common-app';
26
+ import {
27
+ templatePreviewCardDepsFactory
28
+ } from '@easy-wizzy/common-app';
25
29
  import { productImageUrlBuilderExpressionEvaluatorFactory } from '@easy-wizzy/common-app';
26
- import { defaultTemplateLibraryFactory } from '@easy-wizzy/common-app';
27
30
  import { apiMachineFetchFactory } from '@easy-wizzy/common-app';
28
31
  import { variableSelectorDepsFactory } from '@easy-wizzy/common-app';
29
32
 
30
33
  import type { ApiMachineFetchDelegate } from '@easy-wizzy/common-app';
34
+ import type { FavoriteTemplateParam } from '@easy-wizzy/common-app';
35
+ import type {
36
+ ListExpressionDataSourceBffClient
37
+ } from '@easy-wizzy/common-app';
31
38
 
32
39
  import { stringExpressionBuilderPluginFactory, richTextToolbarPluginFactory, VariableSelector } from '@easy-wizzy/retailrocket-common';
33
40
 
@@ -46,6 +53,7 @@ import { reactivationEvaluateNumberExpressionDataSourceFactory } from '@/impleme
46
53
  import { reactivationStringExpressionDataSourceEvaluatorFactory } from '@/implementation/DataSources/StringExpressionDataSource/reactivationEvaluateStringExpressionDataSource';
47
54
 
48
55
  import { createApi as listExpressionDataSourceBffClientFactory } from '@retailrocket/retailrocket.wysiwyg.bff.v2.apiclients.listexpressiondatasource';
56
+ import type { TemplatePreviewCardDeps } from '@easy-wizzy/core';
49
57
 
50
58
  const appTagId = '#app';
51
59
  const appTag = document.querySelector(appTagId);
@@ -60,8 +68,14 @@ const params = {
60
68
  antiForgeryFormTokenValue: appTag!.getAttribute('data-anti-forgery-form-token-value')!,
61
69
  createEmailTemplateSubmitUrl: appTag!.getAttribute('data-create-email-template-submit-url')!,
62
70
  initialEmailTemplateJson: appTag!.getAttribute('data-initial-reactivation-template')!,
63
- reactivationFavoritesTemplates: JSON.parse(appTag!.getAttribute('data-reactivation-favorites-templates')!) as [{ templateId: string, templateJson: string, favoriteTemplateName: string }],
64
- commonFavoritesTemplates: JSON.parse(appTag!.getAttribute('data-common-favorites-templates')!) as [{ templateId: string, templateJson: string, favoriteTemplateName: string }],
71
+ reactivationFavoritesTemplates: JSON
72
+ .parse(
73
+ appTag!.getAttribute('data-reactivation-favorites-templates')!
74
+ ) as FavoriteTemplateParam[],
75
+ commonFavoritesTemplates: JSON
76
+ .parse(
77
+ appTag!.getAttribute('data-common-favorites-templates')!
78
+ ) as FavoriteTemplateParam[],
65
79
  exitLink: appTag!.getAttribute('data-exit-link')!,
66
80
  localeKey: appTag!.getAttribute('data-locale-key') as LocaleKey || 'en'
67
81
  };
@@ -83,7 +97,8 @@ const listExpressionDataSourceBffClient = listExpressionDataSourceBffClientFacto
83
97
  const createTemplate = <
84
98
  TListExpressionDataSource,
85
99
  TNumberExpressionDataSource,
86
- TStringExpressionDataSource>(arg: {
100
+ TStringExpressionDataSource
101
+ >(arg: {
87
102
  template: EmailTemplateType<
88
103
  TListExpressionDataSource,
89
104
  TNumberExpressionDataSource,
@@ -112,18 +127,21 @@ const nextCouponFromBatch: NextCouponFromBatchType = {
112
127
  BatchId: ''
113
128
  };
114
129
 
115
- const createEmailTemplatePreviewTile = (arg: {
116
- template: EmailTemplateType<
117
- ReactivationListExpressionDataSource,
118
- ReactivationNumberExpressionDataSource,
119
- ReactivationStringExpressionDataSource
120
- >;
121
- templateName: string;
122
- }): EmailTemplatePreviewTileComponent => {
130
+ const _templatePreviewCardDepsFactory = (arg: {
131
+ partnerId: string,
132
+ listExpressionDataSourceBffClient: ListExpressionDataSourceBffClient,
133
+ contactCustomData: ContactCustomData,
134
+ nextCouponFromBatch: NextCouponFromBatchType,
135
+ localeKey: LocaleKey
136
+ }): TemplatePreviewCardDeps<
137
+ ReactivationListExpressionDataSource,
138
+ ReactivationNumberExpressionDataSource,
139
+ ReactivationStringExpressionDataSource
140
+ > => {
123
141
 
124
142
  const listExpressionDataSourceEvaluator = reactivationEvaluateListExpressionDataSourceFactory({
125
- partnerId: params.partnerId,
126
- listExpressionDataSourceBffClient: listExpressionDataSourceBffClient,
143
+ partnerId: arg.partnerId,
144
+ listExpressionDataSourceBffClient: arg.listExpressionDataSourceBffClient,
127
145
  customerStockId: undefined
128
146
  });
129
147
 
@@ -150,8 +168,8 @@ const createEmailTemplatePreviewTile = (arg: {
150
168
  partnerId: params.partnerId,
151
169
  numberExpressionEvaluator: numberExpressionEvaluator
152
170
  }),
153
- contactCustomData: contactCustomData,
154
- nextCouponFromBatch: nextCouponFromBatch
171
+ contactCustomData: arg.contactCustomData,
172
+ nextCouponFromBatch: arg.nextCouponFromBatch
155
173
  })
156
174
  });
157
175
 
@@ -164,61 +182,44 @@ const createEmailTemplatePreviewTile = (arg: {
164
182
  })
165
183
  });
166
184
 
167
- const dataStructExpressionEvaluator = dataStructBuilderExpressionEvaluatorFactory({
168
- expressionEvaluator: expressionEvaluator
185
+ const stringExpressionBuilderPlugin = stringExpressionBuilderPluginFactory({
186
+ localeKey: arg.localeKey
169
187
  });
170
188
 
171
- const stringExpressionBuilderPlugin = stringExpressionBuilderPluginFactory({
172
- localeKey: params.localeKey
189
+ const dataStructExpressionEvaluator = dataStructBuilderExpressionEvaluatorFactory({
190
+ expressionEvaluator: expressionEvaluator
173
191
  });
174
192
 
175
- return emailTemplatePreviewTileComponentFactory<
193
+ return templatePreviewCardDepsFactory<
176
194
  ReactivationListExpressionDataSource,
177
195
  ReactivationNumberExpressionDataSource,
178
196
  ReactivationStringExpressionDataSource
179
197
  >({
180
- template: arg.template,
181
- templateName: arg.templateName,
182
- emailTemplatePreviewTileDeps: emailTemplatePreviewTileDepsFactory<
183
- ReactivationListExpressionDataSource,
184
- ReactivationNumberExpressionDataSource,
185
- ReactivationStringExpressionDataSource
186
- >({
187
- localeKey: params.localeKey,
188
- dataSourceFieldNameDelegate: ({ dataSource }) => {
189
- return matcherFactory(dataSource as GeneralStringExpressionDataSource).Match({
190
- StringFromContactCustomData: (customData) => customData.FieldName,
191
- StringFromContactCustomDataWithFallback: (customDataWithFallback) => customDataWithFallback.FallbackValue,
192
- ProductImageUrlBuilderExpression: () => 'ImageResizer',
193
- NextCouponFromBatch: () => 'Coupon'
194
- });
195
- },
196
- richTextToolbarPlugins: [
197
- richTextToolbarPluginFactory({
198
- richTextToolbarPluginComponent: VariableSelector,
199
- deps: variableSelectorDepsFactory({
200
- localeKey: params.localeKey,
201
- stringExpressionBuilderPlugin: stringExpressionBuilderPlugin
202
- })
203
- })
204
- ],
205
- listExpressionEvaluator: listExpressionEvaluator,
206
- numberExpressionEvaluator: numberExpressionEvaluator,
207
- stringExpressionEvaluator: stringExpressionEvaluator,
208
- dataStructExpressionEvaluator: dataStructExpressionEvaluator,
209
- expressionEvaluator: expressionEvaluator,
210
- stringExpressionBuilderPlugin: stringExpressionBuilderPlugin
211
- }),
212
- onFavoriteTemplateSelected: () => {
213
- //eslint-disable-next-line no-console
214
- console.log('onFavoriteTemplateSelected');
215
- // create email template
216
- createTemplate({
217
- template: arg.template
198
+ localeKey: params.localeKey,
199
+ dataSourceFieldNameDelegate: ({ dataSource }) => {
200
+ return matcherFactory(dataSource as GeneralStringExpressionDataSource).Match({
201
+ StringFromContactCustomData: (customData) => customData.FieldName,
202
+ StringFromContactCustomDataWithFallback: (customDataWithFallback) => customDataWithFallback.FallbackValue,
203
+ ProductImageUrlBuilderExpression: () => 'ImageResizer',
204
+ NextCouponFromBatch: () => 'Coupon'
218
205
  });
219
- // redirect
220
206
  },
221
- });
207
+ richTextToolbarPlugins: [
208
+ richTextToolbarPluginFactory({
209
+ richTextToolbarPluginComponent: VariableSelector,
210
+ deps: variableSelectorDepsFactory({
211
+ localeKey: arg.localeKey,
212
+ stringExpressionBuilderPlugin: stringExpressionBuilderPlugin
213
+ })
214
+ })
215
+ ],
216
+ listExpressionEvaluator: listExpressionEvaluator,
217
+ numberExpressionEvaluator: numberExpressionEvaluator,
218
+ stringExpressionEvaluator: stringExpressionEvaluator,
219
+ dataStructExpressionEvaluator: dataStructExpressionEvaluator,
220
+ expressionEvaluator: expressionEvaluator,
221
+ stringExpressionBuilderPlugin: stringExpressionBuilderPlugin
222
+ })
222
223
  };
223
224
 
224
225
  const initialEmailTemplate = params.localeKey === 'ru'
@@ -226,68 +227,56 @@ const initialEmailTemplate = params.localeKey === 'ru'
226
227
  : initialEmailTemplateEn;
227
228
 
228
229
  const app = createApp(
229
- CreateEmailTemplateApp,
230
+ TemplatesGallery,
230
231
  {
231
- onInitialTemplateSelected: () => {
232
- //eslint-disable-next-line no-console
233
- console.log('onInitialTemplateSelected');
232
+ onTemplateSelected: (template: EmailTemplateType<
233
+ ReactivationListExpressionDataSource,
234
+ ReactivationNumberExpressionDataSource,
235
+ ReactivationStringExpressionDataSource
236
+ >) => {
234
237
  createTemplate({
235
- template: params.initialEmailTemplateJson.length
236
- ? JSON.parse(params.initialEmailTemplateJson)
237
- : initialEmailTemplate,
238
+ template: template
238
239
  });
239
240
  },
240
- deps:
241
- createEmailTemplateAppDepsFactory<
242
- ReactivationListExpressionDataSource,
243
- ReactivationNumberExpressionDataSource,
244
- ReactivationStringExpressionDataSource
245
- >({
241
+ commonFavoriteTemplates: params
242
+ .commonFavoritesTemplates
243
+ .map(t => ({
244
+ template: JSON.parse(t.templateJson) as EmailTemplateType<
245
+ GeneralListExpressionDataSource,
246
+ GeneralNumberExpressionDataSource,
247
+ GeneralStringExpressionDataSource
248
+ >,
249
+ templateName: t.favoriteTemplateName
250
+ })),
251
+ customFavoriteTemplates: params
252
+ .reactivationFavoritesTemplates
253
+ .map(t => ({
254
+ template: JSON.parse(t.templateJson) as EmailTemplateType<
255
+ ReactivationListExpressionDataSource,
256
+ ReactivationNumberExpressionDataSource,
257
+ ReactivationStringExpressionDataSource
258
+ >,
259
+ templateName: t.favoriteTemplateName
260
+ })),
261
+ deps: templatesGalleryDepsFactory<
262
+ ReactivationListExpressionDataSource,
263
+ ReactivationNumberExpressionDataSource,
264
+ ReactivationStringExpressionDataSource
265
+ >({
266
+ partnerId: params.partnerId,
267
+ localeKey: params.localeKey,
268
+ templatePreviewCardDeps: _templatePreviewCardDepsFactory({
246
269
  partnerId: params.partnerId,
247
- localeKey: params.localeKey,
248
- emailTemplatePreviews:
249
- {
250
- custom: [
251
- ...params
252
- .commonFavoritesTemplates
253
- .map(o => ({
254
- templateName: o.favoriteTemplateName,
255
- previewTileComponent: createEmailTemplatePreviewTile({
256
- template: JSON.parse(o.templateJson),
257
- templateName: o.favoriteTemplateName
258
- })
259
- })),
260
- ...params
261
- .reactivationFavoritesTemplates
262
- .map(o => ({
263
- templateName: o.favoriteTemplateName,
264
- previewTileComponent: createEmailTemplatePreviewTile({
265
- template: JSON.parse(o.templateJson),
266
- templateName: o.favoriteTemplateName
267
- })
268
- }))
269
- ],
270
- default: [
271
- ...defaultTemplateLibraryFactory(params.localeKey)
272
- .map(o => ({
273
- templateName: o.favoriteTemplateName,
274
- previewTileComponent: createEmailTemplatePreviewTile({
275
- template: o.defaultTemplate as EmailTemplateType<
276
- ReactivationListExpressionDataSource,
277
- ReactivationNumberExpressionDataSource,
278
- ReactivationStringExpressionDataSource
279
- >,
280
- templateName: o.favoriteTemplateName
281
- })
282
- }))
283
- ]
284
- },
285
- initialEmailTemplate: params.initialEmailTemplateJson.length
286
- ? JSON.parse(params.initialEmailTemplateJson)
287
- : initialEmailTemplate,
288
- exitLink: params.exitLink
289
- }
290
- )
270
+ listExpressionDataSourceBffClient: listExpressionDataSourceBffClient,
271
+ contactCustomData: contactCustomData,
272
+ nextCouponFromBatch: nextCouponFromBatch,
273
+ localeKey: params.localeKey
274
+ }),
275
+ initialEmailTemplate: params.initialEmailTemplateJson.length
276
+ ? JSON.parse(params.initialEmailTemplateJson)
277
+ : initialEmailTemplate,
278
+ exitLink: params.exitLink
279
+ })
291
280
  }
292
281
  );
293
282
 
@@ -298,4 +287,4 @@ app.use(createVuetify({
298
287
  }
299
288
  }));
300
289
 
301
- app.mount(appTagId);
290
+ app.mount(appTagId);