@capillarytech/creatives-library 8.0.136-alpha.0 → 8.0.136-alpha.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.
package/index.js CHANGED
@@ -138,8 +138,10 @@ const FTPContainer = {FTP, FTPReducer, FTPSagas};
138
138
  export {default as TagList} from './v2Containers/TagList/index';
139
139
  export {default as TagListSaga} from './v2Containers/TagList/sagas';
140
140
  export {default as TagListReducer} from './v2Containers/TagList/reducer';
141
- export {default as TemplatePreview} from './components/TemplatePreview';
142
- export {default as EmailPreview} from './components/EmailPreview';
141
+
142
+ export {default as TemplatePreview} from './v2Components/TemplatePreview';
143
+ export {default as EmailPreview} from './v2Components/EmailPreview';
144
+
143
145
  export {default as EmailPreviewV2} from './v2Components/EmailPreviewV2';
144
146
  export {default as CallTaskPreview} from './v2Components/CallTaskPreview';
145
147
  export {default as EmailMobilePreview} from './v2Components/EmailMobilePreview';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@capillarytech/creatives-library",
3
3
  "author": "meharaj",
4
- "version": "8.0.136-alpha.0",
4
+ "version": "8.0.136-alpha.2",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
package/routes.js CHANGED
@@ -1,212 +1,146 @@
1
1
  import withReactRouterV3Compatibility from './hoc/withReactRouterV3Compatibility';
2
- import Dashboard from './containers/Dashboard';
3
- import SmsCreate from './containers/Sms/Create';
4
- import SmsEdit from './containers/Sms/Edit';
5
- import Templates from './containers/Templates';
6
- import Gallary from './containers/Assets/Gallery';
7
- import WeChatMapTemplate from './containers/WeChat/MapTemplates';
8
- import WeChatRichmediaCreate from './containers/WeChat/RichmediaTemplates/Create';
9
- import WeChatRichmediaEdit from './containers/WeChat/RichmediaTemplates/Edit';
10
- import Email from './containers/Email';
11
- import Ebill from './containers/Ebill';
12
- import MobilePushCreate from './containers/MobilePush/Create';
13
- import MobilePushEdit from './containers/MobilePush/Edit';
14
- import LineCreate from './containers/Line/Create';
2
+
15
3
  import SomethingWentWrong from '@capillarytech/cap-ui-library/CapSomethingWentWrong';
16
- import NotFoundPage from './containers/NotFoundPage';
4
+ import NotFoundPage from './v2Containers/NotFoundPage';
17
5
  import TemplatesV2 from './v2Containers/TemplatesV2';
18
- import { updateCharCount } from './utils/smsCharCountV2';
19
6
 
20
- const routes = [
21
- {
22
- exact: true,
23
- path: '/',
24
- component: withReactRouterV3Compatibility(Dashboard),
25
- },
26
- //sms routes v1
27
- {
28
- exact: true,
29
- path: '/sms/create',
30
- name: 'create',
31
- component: withReactRouterV3Compatibility(SmsCreate),
32
- },
33
- {
34
- exact: true,
35
- path: '/sms/view',
36
- name: 'view',
37
- component: withReactRouterV3Compatibility(SmsCreate),
38
- },
39
- {
40
- exact: true,
41
- path: '/sms/edit/:id',
42
- name: 'edit',
43
- component: withReactRouterV3Compatibility(SmsEdit),
44
- },
45
- {
46
- exact: true,
47
- path: '/sms',
48
- name: 'sms',
49
- component: withReactRouterV3Compatibility(Templates),
50
- },
51
- //wechat routes v1
52
- {
53
- exact: true,
54
- path: '/wechat',
55
- name: 'wechat',
56
- component: withReactRouterV3Compatibility(Templates),
57
- },
58
- {
59
- exact: true,
60
- path: '/wechat/create',
61
- name: 'create weChat',
62
- component: withReactRouterV3Compatibility(WeChatMapTemplate),
63
- },
64
- {
65
- exact: true,
66
- path: '/wechat/edit/:id',
67
- name: 'edit weChat',
68
- component: withReactRouterV3Compatibility(WeChatMapTemplate),
69
- },
70
- {
71
- exact: true,
72
- path: '/wechat/richmedia/create',
73
- name: 'wechat_richmedia_create',
74
- component: withReactRouterV3Compatibility(WeChatRichmediaCreate),
75
- },
76
- {
77
- exact: true,
78
- path: '/wechat/richmedia/edit/:id',
79
- name: 'wechat_richmedia_edit',
80
- component: withReactRouterV3Compatibility(WeChatRichmediaEdit),
81
- },
82
- //email routes v1
83
- {
84
- exact: true,
85
- path: '/email',
86
- name: 'email',
87
- component: withReactRouterV3Compatibility(Templates),
88
- },
89
- {
90
- exact: true,
91
- path: '/email/create',
92
- name: 'EmailCreate',
93
- component: withReactRouterV3Compatibility(Email),
94
- },
95
- {
96
- exact: true,
97
- path: '/email/view',
98
- name: 'EmailView',
99
- component: withReactRouterV3Compatibility(Email),
100
- },
101
- {
102
- exact: true,
103
- path: '/email/edit/:id',
104
- name: 'EmailEdit',
105
- component: withReactRouterV3Compatibility(Email),
106
- },
107
- //ebill routes v1
108
- {
109
- exact: true,
110
- path: '/ebill',
111
- name: 'Ebill',
112
- component: withReactRouterV3Compatibility(Templates),
113
- },
114
- {
115
- exact: true,
116
- path: '/ebill/create',
117
- name: 'Ebill',
118
- component: withReactRouterV3Compatibility(Ebill),
119
- },
120
- {
121
- exact: true,
122
- path: '/ebill/edit/:id',
123
- name: 'Ebill',
124
- component: withReactRouterV3Compatibility(Ebill),
125
- },
126
- //mobilepush routes v1
127
- {
128
- exact: true,
129
- path: '/mobilepush',
130
- name: 'mobilepush',
131
- component: withReactRouterV3Compatibility(Templates),
132
- },
133
- {
134
- exact: true,
135
- path: '/mobilepush/create/:mode',
136
- name: 'create',
137
- component: withReactRouterV3Compatibility(MobilePushCreate),
138
- },
139
- {
140
- exact: true,
141
- path: '/mobilepush/edit/:id',
142
- name: 'edit',
143
- component: withReactRouterV3Compatibility(MobilePushEdit),
144
- },
145
- // assets routes v1
146
- {
147
- exact: true,
148
- path: '/assets',
149
- name: 'GALLERY',
150
- component: withReactRouterV3Compatibility(Gallary),
151
- },
152
- // line routes v1
153
- {
154
- exact: true,
155
- path: '/line',
156
- name: 'line',
157
- component: withReactRouterV3Compatibility(Templates),
158
- },
159
- {
160
- exact: true,
161
- path: '/line/create/:mode',
162
- name: 'create line',
163
- component: withReactRouterV3Compatibility(LineCreate),
164
- },
165
- {
166
- exact: true,
167
- path: '/line/view/:mode',
168
- name: 'view',
169
- component: withReactRouterV3Compatibility(LineCreate),
170
- },
171
- {
172
- exact: true,
173
- path: '/line/edit/text/:id',
174
- name: 'edit_text',
175
- component: withReactRouterV3Compatibility(LineCreate),
176
- },
177
- {
178
- exact: true,
179
- path: '/line/edit/image/:id',
180
- name: 'edit_image',
181
- component: withReactRouterV3Compatibility(LineCreate),
182
- },
183
- {
184
- exact: true,
185
- path: '/v2/somethingwentwrong',
186
- name: 'somethingwentwrong',
187
- component: withReactRouterV3Compatibility(SomethingWentWrong),
188
- },
189
- {
190
- exact: true,
191
- path: '/v2',
192
- name: 'templatesV2',
193
- component: withReactRouterV3Compatibility(TemplatesV2),
194
- },
195
- {
196
- exact: true,
197
- path: '/v2/loyalty',
198
- name: 'loyalty',
199
- component: withReactRouterV3Compatibility(TemplatesV2),
200
- },
201
- {
7
+ // Utility function to detect if we're in embedded mode
8
+ const isEmbeddedMode = () => {
9
+ // Check if we're in embedded mode by looking for embedded mode indicators
10
+ // This could be from URL params, environment variables, or build configuration
11
+ if (typeof window !== 'undefined') {
12
+ const urlParams = new URLSearchParams(window.location.search);
13
+ return urlParams.get('type') === 'embedded';
14
+ }
15
+ // Fallback: check if containers folder exists (indicating non-embedded mode)
16
+ try {
17
+ // This will throw an error in embedded mode since containers are excluded
18
+ require('./containers/Dashboard');
19
+ return false;
20
+ } catch (error) {
21
+ return true;
22
+ }
23
+ };
24
+
25
+ // Check if we're in embedded mode at module load time
26
+ const isEmbedded = isEmbeddedMode();
27
+
28
+ // Clean all-or-nothing approach for static imports
29
+ const getStaticImports = () => {
30
+ if (isEmbedded) return {}; // Only v2 uses static imports
31
+
32
+ try {
33
+ return {
34
+ Dashboard: require('./containers/Dashboard').default,
35
+ SmsCreate: require('./containers/Sms/Create').default,
36
+ SmsEdit: require('./containers/Sms/Edit').default,
37
+ Templates: require('./containers/Templates').default,
38
+ WeChatMapTemplate: require('./containers/WeChat/MapTemplates').default,
39
+ Gallary: require('./containers/Assets/Gallery').default,
40
+ WeChatRichmediaCreate: require('./containers/WeChat/RichmediaTemplates/Create').default,
41
+ WeChatRichmediaEdit: require('./containers/WeChat/RichmediaTemplates/Edit').default,
42
+ Email: require('./containers/Email').default,
43
+ Ebill: require('./containers/Ebill').default,
44
+ MobilePushCreate: require('./containers/MobilePush/Create').default,
45
+ MobilePushEdit: require('./containers/MobilePush/Edit').default,
46
+ LineCreate: require('./containers/Line/Create').default,
47
+ };
48
+ } catch (error) {
49
+ console.log('Error importing v1 components:', error.message);
50
+ return {}; // Fallback to v2 only
51
+ }
52
+ };
53
+
54
+ // Declarative route configuration
55
+ const ROUTES = [
56
+ // ✅ V2 Routes (always included)
57
+ { path: '/v2/somethingwentwrong', name: 'somethingwentwrong', component: SomethingWentWrong },
58
+ { path: '/v2', name: 'templatesV2', component: TemplatesV2 },
59
+ { path: '/v2/loyalty', name: 'loyalty', component: TemplatesV2 },
60
+
61
+ // ✅ V1 Routes (conditional based on `!isEmbedded`)
62
+ { path: '/', componentKey: 'Dashboard' },
63
+
64
+ // SMS routes v1
65
+ { path: '/sms/create', name: 'create', componentKey: 'SmsCreate' },
66
+ { path: '/sms/view', name: 'view', componentKey: 'SmsCreate' },
67
+ { path: '/sms/edit/:id', name: 'edit', componentKey: 'SmsEdit' },
68
+ { path: '/sms', name: 'sms', componentKey: 'Templates' },
69
+
70
+ // WeChat routes v1
71
+ { path: '/wechat', name: 'wechat', componentKey: 'Templates' },
72
+ { path: '/wechat/create', name: 'create weChat', componentKey: 'WeChatMapTemplate' },
73
+ { path: '/wechat/edit/:id', name: 'edit weChat', componentKey: 'WeChatMapTemplate' },
74
+ { path: '/wechat/richmedia/create', name: 'wechat_richmedia_create', componentKey: 'WeChatRichmediaCreate' },
75
+ { path: '/wechat/richmedia/edit/:id', name: 'wechat_richmedia_edit', componentKey: 'WeChatRichmediaEdit' },
76
+
77
+ // Email routes v1
78
+ { path: '/email', name: 'email', componentKey: 'Templates' },
79
+ { path: '/email/create', name: 'EmailCreate', componentKey: 'Email' },
80
+ { path: '/email/view', name: 'EmailView', componentKey: 'Email' },
81
+ { path: '/email/edit/:id', name: 'EmailEdit', componentKey: 'Email' },
82
+
83
+ // Ebill routes v1
84
+ { path: '/ebill', name: 'Ebill', componentKey: 'Templates' },
85
+ { path: '/ebill/create', name: 'Ebill', componentKey: 'Ebill' },
86
+ { path: '/ebill/edit/:id', name: 'Ebill', componentKey: 'Ebill' },
87
+
88
+ // MobilePush routes v1
89
+ { path: '/mobilepush', name: 'mobilepush', componentKey: 'Templates' },
90
+ { path: '/mobilepush/create/:mode', name: 'create', componentKey: 'MobilePushCreate' },
91
+ { path: '/mobilepush/edit/:id', name: 'edit', componentKey: 'MobilePushEdit' },
92
+
93
+ // Assets routes v1
94
+ { path: '/assets', name: 'GALLERY', componentKey: 'Gallary' },
95
+
96
+ // Line routes v1
97
+ { path: '/line', name: 'line', componentKey: 'Templates' },
98
+ { path: '/line/create/:mode', name: 'create line', componentKey: 'LineCreate' },
99
+ { path: '/line/view/:mode', name: 'view', componentKey: 'LineCreate' },
100
+ { path: '/line/edit/text/:id', name: 'edit_text', componentKey: 'LineCreate' },
101
+ { path: '/line/edit/image/:id', name: 'edit_image', componentKey: 'LineCreate' },
102
+ ];
103
+
104
+ // Simplified route creation
105
+ const createRoutes = (components = {}) => {
106
+ const routes = ROUTES.flatMap(({ path, component, componentKey, name }) => {
107
+ // V2 component is statically imported
108
+ if (component) {
109
+ return [{
110
+ exact: true,
111
+ path,
112
+ name,
113
+ component: withReactRouterV3Compatibility(component),
114
+ }];
115
+ }
116
+
117
+ // V1 component: only include if available
118
+ const resolved = components[componentKey];
119
+ if (resolved) {
120
+ return [{
121
+ exact: true,
122
+ path,
123
+ name,
124
+ component: withReactRouterV3Compatibility(resolved),
125
+ }];
126
+ }
127
+
128
+ return []; // Skip if not in embedded or missing
129
+ });
130
+
131
+ // Catch-all fallback
132
+ routes.push({
202
133
  path: '*',
203
134
  name: 'notfound',
204
135
  component: withReactRouterV3Compatibility(NotFoundPage),
205
- },
206
- ];
136
+ });
137
+
138
+ return routes;
139
+ };
207
140
 
208
- // export function createRoutes(store) {
209
- // updateCharCount("", false); // TODO:: React18, need to see why this call was made from here and can we remove this?
210
- // }
141
+ // Initialize routes synchronously with available components
142
+ const staticImports = getStaticImports();
143
+ const routes = createRoutes(staticImports);
211
144
 
145
+ // Export the routes array
212
146
  export default routes;
@@ -8,7 +8,7 @@ import { routerActions } from 'connected-react-router';
8
8
  // import { routerActions } from 'react-router-redux';
9
9
  // import { UserAuthWrapper } from 'redux-auth-wrapper';
10
10
  import { createSelector } from 'reselect';
11
- import { makeSelectAuthenticated } from '../containers/Cap/selectors';
11
+ import { makeSelectAuthenticated } from '../v2Containers/Cap/selectors';
12
12
  // import config from '../config/app';
13
13
  const orginUrl = window.location.origin;
14
14
  // const loginUrl = '/auth/login';