@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 +4 -2
- package/package.json +1 -1
- package/routes.js +136 -202
- package/utils/authWrapper.js +1 -1
- package/utils/jed.js +1497 -0
- package/utils/smsCharCount.js +351 -0
- package/v2Containers/Sms/Create/index.js +1 -1
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
|
-
|
|
142
|
-
export {default as
|
|
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
package/routes.js
CHANGED
|
@@ -1,212 +1,146 @@
|
|
|
1
1
|
import withReactRouterV3Compatibility from './hoc/withReactRouterV3Compatibility';
|
|
2
|
-
|
|
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 './
|
|
4
|
+
import NotFoundPage from './v2Containers/NotFoundPage';
|
|
17
5
|
import TemplatesV2 from './v2Containers/TemplatesV2';
|
|
18
|
-
import { updateCharCount } from './utils/smsCharCountV2';
|
|
19
6
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
{
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
{
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
{
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
},
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
},
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
},
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
},
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
},
|
|
114
|
-
{
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
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
|
-
//
|
|
209
|
-
|
|
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;
|
package/utils/authWrapper.js
CHANGED
|
@@ -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 '../
|
|
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';
|