@openlettermarketing/olc-react-sdk 0.0.8 → 0.0.10
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/.eslintignore +1 -0
- package/.eslintrc.cjs +18 -0
- package/.eslintrc.yml +47 -0
- package/.prettierignore +3 -0
- package/.prettierrc.yml +5 -0
- package/CHANGELOG.md +4 -0
- package/babel.config.json +10 -0
- package/build/index.js +2 -2
- package/build/index.js.map +1 -1
- package/examples/.eslintrc.yml +4 -0
- package/index.html +18 -0
- package/package.json +6 -6
- package/public/vite.svg +1 -0
- package/src/App.tsx +76 -0
- package/src/assets/Fonts/Lexi-Regular.ttf +0 -0
- package/src/assets/images/input/cancel.tsx +20 -0
- package/src/assets/images/input/search.tsx +20 -0
- package/src/assets/images/modal-icons/cancelIcon.png +0 -0
- package/src/assets/images/modal-icons/del.tsx +19 -0
- package/src/assets/images/modal-icons/delete.svg +3 -0
- package/src/assets/images/modal-icons/modal-cross.tsx +23 -0
- package/src/assets/images/modal-icons/save.tsx +23 -0
- package/src/assets/images/templates/add-icon.svg +5 -0
- package/src/assets/images/templates/back-arrow.tsx +19 -0
- package/src/assets/images/templates/back-dialog-icon.png +0 -0
- package/src/assets/images/templates/back-dialog-icon.svg +3 -0
- package/src/assets/images/templates/barcode.png +0 -0
- package/src/assets/images/templates/bi-fold-self-mailers.tsx +28 -0
- package/src/assets/images/templates/black-trash-icon.svg +3 -0
- package/src/assets/images/templates/cancel.svg +4 -0
- package/src/assets/images/templates/cancelIcon.png +0 -0
- package/src/assets/images/templates/clipboard.svg +3 -0
- package/src/assets/images/templates/contact-search.svg +3 -0
- package/src/assets/images/templates/content-copy-icon.tsx +24 -0
- package/src/assets/images/templates/cross.svg +3 -0
- package/src/assets/images/templates/custom-template-icon-black.svg +3 -0
- package/src/assets/images/templates/custom-template-icon.svg +3 -0
- package/src/assets/images/templates/custom-template.tsx +23 -0
- package/src/assets/images/templates/dummy-template.svg +21 -0
- package/src/assets/images/templates/dynamic-field.tsx +119 -0
- package/src/assets/images/templates/edit-pencil-icon.tsx +21 -0
- package/src/assets/images/templates/filter-2.svg +13 -0
- package/src/assets/images/templates/info-icon.svg +12 -0
- package/src/assets/images/templates/info-icon.tsx +37 -0
- package/src/assets/images/templates/one-barcode.png +0 -0
- package/src/assets/images/templates/personal-letter.tsx +53 -0
- package/src/assets/images/templates/plus-icon.svg +5 -0
- package/src/assets/images/templates/postcard.tsx +32 -0
- package/src/assets/images/templates/professional-letter.tsx +53 -0
- package/src/assets/images/templates/real-penned-letters.tsx +57 -0
- package/src/assets/images/templates/search.svg +3 -0
- package/src/assets/images/templates/size-image-lg.tsx +20 -0
- package/src/assets/images/templates/size-image-mid.tsx +20 -0
- package/src/assets/images/templates/size-image.tsx +20 -0
- package/src/assets/images/templates/template-copy.svg +3 -0
- package/src/assets/images/templates/template-default-design.tsx +21 -0
- package/src/assets/images/templates/template-delete.svg +3 -0
- package/src/assets/images/templates/template-edit.svg +4 -0
- package/src/assets/images/templates/template-save-icon.svg +3 -0
- package/src/assets/images/templates/template-search-2.svg +9 -0
- package/src/assets/images/templates/template-search.svg +4 -0
- package/src/assets/images/templates/thumbnail.svg +10 -0
- package/src/assets/images/templates/trash-icon.svg +13 -0
- package/src/assets/images/templates/tri-fold-self-mailers.tsx +93 -0
- package/src/components/CreateTemplate/index.tsx +377 -0
- package/src/components/CreateTemplate/styles.scss +363 -0
- package/src/components/GenericUIBlocks/Button/index.tsx +21 -0
- package/src/components/GenericUIBlocks/Button/styles.scss +15 -0
- package/src/components/GenericUIBlocks/CircularProgress/index.tsx +18 -0
- package/src/components/GenericUIBlocks/CircularProgress/styles.scss +98 -0
- package/src/components/GenericUIBlocks/Dialog/index.tsx +127 -0
- package/src/components/GenericUIBlocks/Dialog/styles.scss +106 -0
- package/src/components/GenericUIBlocks/Divider/index.tsx +12 -0
- package/src/components/GenericUIBlocks/Divider/styles.scss +7 -0
- package/src/components/GenericUIBlocks/GeneralSelect/index.tsx +86 -0
- package/src/components/GenericUIBlocks/GeneralSelect/styles.scss +77 -0
- package/src/components/GenericUIBlocks/GeneralTooltip/index.tsx +24 -0
- package/src/components/GenericUIBlocks/GeneralTooltip/styles.scss +9 -0
- package/src/components/GenericUIBlocks/GenericSnackbar/index.tsx +53 -0
- package/src/components/GenericUIBlocks/GenericSnackbar/styles.scss +34 -0
- package/src/components/GenericUIBlocks/Grid/index.tsx +82 -0
- package/src/components/GenericUIBlocks/Input/index.tsx +89 -0
- package/src/components/GenericUIBlocks/Input/styles.scss +80 -0
- package/src/components/GenericUIBlocks/Snackbar/index.tsx +66 -0
- package/src/components/GenericUIBlocks/Typography/index.tsx +18 -0
- package/src/components/GenericUIBlocks/Typography/styles.scss +27 -0
- package/src/components/SidePanel/customFields/customFieldSection.tsx +162 -0
- package/src/components/SidePanel/customFields/styles.scss +47 -0
- package/src/components/SidePanel/index.tsx +30 -0
- package/src/components/SidePanel/templates/customTemplateSection.tsx +505 -0
- package/src/components/SidePanel/templates/styles.scss +151 -0
- package/src/components/TemplateBuilder/index.tsx +295 -0
- package/src/components/TemplateBuilder/styles.scss +66 -0
- package/src/components/TopNavigation/ConfirmNavigateDialog/index.tsx +58 -0
- package/src/components/TopNavigation/ConfirmNavigateDialog/styles.scss +123 -0
- package/src/components/TopNavigation/EditTemplateNameModel/index.tsx +98 -0
- package/src/components/TopNavigation/EditTemplateNameModel/styles.scss +88 -0
- package/src/components/TopNavigation/SaveTemplateModel/index.tsx +60 -0
- package/src/components/TopNavigation/SaveTemplateModel/styles.scss +128 -0
- package/src/components/TopNavigation/index.tsx +388 -0
- package/src/components/TopNavigation/styles.scss +83 -0
- package/src/importMeta.d.ts +9 -0
- package/src/index.scss +130 -0
- package/src/index.tsx +82 -0
- package/src/libs/test.ts +7 -0
- package/src/redux/actions/action-types.ts +42 -0
- package/src/redux/actions/customFieldAction.ts +28 -0
- package/src/redux/actions/snackbarActions.ts +16 -0
- package/src/redux/actions/templateActions.ts +456 -0
- package/src/redux/reducers/customFieldReducer.ts +97 -0
- package/src/redux/reducers/index.ts +14 -0
- package/src/redux/reducers/snackbarReducer.ts +41 -0
- package/src/redux/reducers/templateReducer.ts +353 -0
- package/src/redux/store.ts +18 -0
- package/src/styles/colors.scss +61 -0
- package/src/test/mocks.js +89 -0
- package/src/test/setupJest.js +1 -0
- package/src/utils/api.ts +36 -0
- package/src/utils/constants.ts +40 -0
- package/src/utils/customStyles.ts +135 -0
- package/src/utils/fetchWrapper.ts +68 -0
- package/src/utils/fonts.json +1597 -0
- package/src/utils/helper.ts +19 -0
- package/src/utils/local-storage.ts +15 -0
- package/src/utils/message.ts +71 -0
- package/src/utils/template-builder.ts +147 -0
- package/src/utils/templateRestrictedArea/biFold.ts +433 -0
- package/src/utils/templateRestrictedArea/postCard.ts +439 -0
- package/src/utils/templateRestrictedArea/professional.ts +422 -0
- package/src/utils/templateRestrictedArea/realPenned.ts +283 -0
- package/src/utils/templateRestrictedArea/triFold.ts +434 -0
- package/tsconfig.json +29 -0
- package/tsconfig.node.json +12 -0
- package/vite.config.ts +8 -0
- package/webpack.config.js +80 -0
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
/* eslint-disable no-case-declarations */
|
|
2
|
+
import {
|
|
3
|
+
SET_DYNAMIC_FIELDS,
|
|
4
|
+
SET_DYNAMIC_FIELD_VALUE,
|
|
5
|
+
CLEAR_DYNAMIC_FIELDS,
|
|
6
|
+
REMOVE_FROM_DYNAMIC_FIELDS,
|
|
7
|
+
GET_PRODUCTS,
|
|
8
|
+
GET_ONE_TEMPLATE,
|
|
9
|
+
TEMPLATE_LOADING,
|
|
10
|
+
CLEAR_FIELDS,
|
|
11
|
+
TEMPLATE_PAGINATION_CHANGE,
|
|
12
|
+
TEMPLATE_SEARCH,
|
|
13
|
+
CLEAR_ALL_TEMPLATE,
|
|
14
|
+
SELECT_PRODUCT,
|
|
15
|
+
SELECT_POSTCARD,
|
|
16
|
+
CLEAR_TEMPLATE_FIELDS,
|
|
17
|
+
GET_DYNAMIC_FIELDS_FROM_SERVER,
|
|
18
|
+
LOAD_DATA_FROM_LOCAL_STORAGE,
|
|
19
|
+
SET_PRODUCT_DETAILS,
|
|
20
|
+
CLEAR_TEMPLATE,
|
|
21
|
+
CLEAR_REDUX
|
|
22
|
+
} from "../actions/action-types";
|
|
23
|
+
|
|
24
|
+
export interface DynamicField {
|
|
25
|
+
value: string;
|
|
26
|
+
key: string;
|
|
27
|
+
defaultValue: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface Template {
|
|
31
|
+
title: string;
|
|
32
|
+
product: Product | null;
|
|
33
|
+
templateType: string;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface Product {
|
|
37
|
+
size: Array<{ size: string }>;
|
|
38
|
+
productType: string;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface TemplatesState {
|
|
42
|
+
count: number;
|
|
43
|
+
rows: any[];
|
|
44
|
+
currentPage: number;
|
|
45
|
+
lastPage: number;
|
|
46
|
+
from: number;
|
|
47
|
+
to: number;
|
|
48
|
+
perPage: number;
|
|
49
|
+
total: number;
|
|
50
|
+
loading: boolean;
|
|
51
|
+
totalRecordsInDB: number | null;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface PaginationState {
|
|
55
|
+
page: number;
|
|
56
|
+
pageSize: number;
|
|
57
|
+
loading: boolean;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface TemplateState {
|
|
61
|
+
title: string;
|
|
62
|
+
product: Product | null;
|
|
63
|
+
dynamicField: string;
|
|
64
|
+
dynamicFields: Record<string, DynamicField>;
|
|
65
|
+
defaultDynamicFieldsHashMap: Record<string, DynamicField>;
|
|
66
|
+
defaultDynamicFields: DynamicField[];
|
|
67
|
+
products: any[];
|
|
68
|
+
productDetailByTemplate: any[];
|
|
69
|
+
templates: TemplatesState;
|
|
70
|
+
templatesPagination: PaginationState;
|
|
71
|
+
template: Template | null;
|
|
72
|
+
totalRecordsInDB: number | null;
|
|
73
|
+
search: string;
|
|
74
|
+
searchProductIds: string;
|
|
75
|
+
searchCreator: string;
|
|
76
|
+
templateType: string;
|
|
77
|
+
envelopeType: string;
|
|
78
|
+
templateLoading: boolean | null;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
const initialState: TemplateState = {
|
|
84
|
+
title: "",
|
|
85
|
+
product: null,
|
|
86
|
+
dynamicField: "",
|
|
87
|
+
dynamicFields: {},
|
|
88
|
+
defaultDynamicFieldsHashMap: {
|
|
89
|
+
"{{C.FIRST_NAME}}": {
|
|
90
|
+
value: "First Name",
|
|
91
|
+
key: "{{C.FIRST_NAME}}",
|
|
92
|
+
defaultValue: "John",
|
|
93
|
+
},
|
|
94
|
+
"{{C.LAST_NAME}}": {
|
|
95
|
+
value: "Last Name",
|
|
96
|
+
key: "{{C.LAST_NAME}}",
|
|
97
|
+
defaultValue: "Doe",
|
|
98
|
+
},
|
|
99
|
+
"{{C.FIRST_NAME}} {{C.LAST_NAME}}": {
|
|
100
|
+
value: "Full Name",
|
|
101
|
+
key: "{{C.FIRST_NAME}} {{C.LAST_NAME}}",
|
|
102
|
+
defaultValue: "John Doe",
|
|
103
|
+
},
|
|
104
|
+
"{{C.COMPANY_NAME}}": {
|
|
105
|
+
value: "Company Name",
|
|
106
|
+
key: "{{C.COMPANY_NAME}}",
|
|
107
|
+
defaultValue: "ABC Company, Inc.",
|
|
108
|
+
},
|
|
109
|
+
"{{C.ADDRESS_1}}": {
|
|
110
|
+
value: "Address 1",
|
|
111
|
+
key: "{{C.ADDRESS_1}}",
|
|
112
|
+
defaultValue: "123 Main Street",
|
|
113
|
+
},
|
|
114
|
+
"{{C.ADDRESS_2}}": {
|
|
115
|
+
value: "Address 2",
|
|
116
|
+
key: "{{C.ADDRESS_2}}",
|
|
117
|
+
defaultValue: "Suite 2",
|
|
118
|
+
},
|
|
119
|
+
"{{C.CITY}}": {
|
|
120
|
+
value: "City",
|
|
121
|
+
key: "{{C.CITY}}",
|
|
122
|
+
defaultValue: "Lawrence",
|
|
123
|
+
},
|
|
124
|
+
"{{C.STATE}}": {
|
|
125
|
+
value: "State",
|
|
126
|
+
key: "{{C.STATE}}",
|
|
127
|
+
defaultValue: "MA",
|
|
128
|
+
},
|
|
129
|
+
"{{C.ZIP_CODE}}": {
|
|
130
|
+
value: "Zip Code",
|
|
131
|
+
key: "{{C.ZIP_CODE}}",
|
|
132
|
+
defaultValue: "01843",
|
|
133
|
+
},
|
|
134
|
+
"{{C.PHONE_NUMBER}}": {
|
|
135
|
+
value: "Phone Number",
|
|
136
|
+
key: "{{C.PHONE_NUMBER}}",
|
|
137
|
+
defaultValue: "(555) 278-9389",
|
|
138
|
+
},
|
|
139
|
+
"{{C.EMAIL}}": {
|
|
140
|
+
value: "Email",
|
|
141
|
+
key: "{{C.EMAIL}}",
|
|
142
|
+
defaultValue: "johndoe@gmail.com",
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
defaultDynamicFields: [
|
|
146
|
+
{
|
|
147
|
+
value: "First Name",
|
|
148
|
+
key: "{{C.FIRST_NAME}}",
|
|
149
|
+
defaultValue: "John",
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
value: "Last Name",
|
|
153
|
+
key: "{{C.LAST_NAME}}",
|
|
154
|
+
defaultValue: "Doe",
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
value: "Full Name",
|
|
158
|
+
key: "{{C.FIRST_NAME}} {{C.LAST_NAME}}",
|
|
159
|
+
defaultValue: "John Doe",
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
value: "Company Name",
|
|
163
|
+
key: "{{C.COMPANY_NAME}}",
|
|
164
|
+
defaultValue: "ABC Company, Inc.",
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
value: "Address 1",
|
|
168
|
+
key: "{{C.ADDRESS_1}}",
|
|
169
|
+
defaultValue: "123 Main Street",
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
value: "Address 2",
|
|
173
|
+
key: "{{C.ADDRESS_2}}",
|
|
174
|
+
defaultValue: "Suite 2",
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
value: "City",
|
|
178
|
+
key: "{{C.CITY}}",
|
|
179
|
+
defaultValue: "Lawrence",
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
value: "State",
|
|
183
|
+
key: "{{C.STATE}}",
|
|
184
|
+
defaultValue: "MA",
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
value: "Zip Code",
|
|
188
|
+
key: "{{C.ZIP_CODE}}",
|
|
189
|
+
defaultValue: "01843",
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
value: "Phone Number",
|
|
193
|
+
key: "{{C.PHONE_NUMBER}}",
|
|
194
|
+
defaultValue: "(555) 278-9389",
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
value: "Email",
|
|
198
|
+
key: "{{C.EMAIL}}",
|
|
199
|
+
defaultValue: "johndoe@gmail.com",
|
|
200
|
+
},
|
|
201
|
+
],
|
|
202
|
+
products: [],
|
|
203
|
+
productDetailByTemplate: [],
|
|
204
|
+
templates: {
|
|
205
|
+
count: 0,
|
|
206
|
+
rows: [],
|
|
207
|
+
currentPage: 1,
|
|
208
|
+
lastPage: 1,
|
|
209
|
+
from: 0,
|
|
210
|
+
to: 0,
|
|
211
|
+
perPage: 20,
|
|
212
|
+
total: 0,
|
|
213
|
+
loading: true,
|
|
214
|
+
totalRecordsInDB: null,
|
|
215
|
+
},
|
|
216
|
+
templatesPagination: { page: 0, pageSize: 20, loading: false },
|
|
217
|
+
template: null,
|
|
218
|
+
totalRecordsInDB: null,
|
|
219
|
+
search: "",
|
|
220
|
+
searchProductIds: "",
|
|
221
|
+
searchCreator: "",
|
|
222
|
+
templateType: "json",
|
|
223
|
+
envelopeType: "",
|
|
224
|
+
templateLoading: null,
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
// @ts-ignore
|
|
228
|
+
const templateReducer = (state = initialState, { type, payload }): TemplateState => {
|
|
229
|
+
switch (type) {
|
|
230
|
+
case SET_DYNAMIC_FIELD_VALUE:
|
|
231
|
+
return {
|
|
232
|
+
...state,
|
|
233
|
+
dynamicField: payload.value,
|
|
234
|
+
};
|
|
235
|
+
case SET_DYNAMIC_FIELDS:
|
|
236
|
+
return {
|
|
237
|
+
...state,
|
|
238
|
+
dynamicFields: {
|
|
239
|
+
...state.dynamicFields,
|
|
240
|
+
[state.dynamicField]: {
|
|
241
|
+
value: state.dynamicField,
|
|
242
|
+
key: `{{${state.dynamicField.replace(/ /g, "_").toUpperCase()}}}`,
|
|
243
|
+
defaultValue: `[${state.dynamicField}]`,
|
|
244
|
+
},
|
|
245
|
+
},
|
|
246
|
+
dynamicField: "",
|
|
247
|
+
};
|
|
248
|
+
case REMOVE_FROM_DYNAMIC_FIELDS:
|
|
249
|
+
const dynamicFields = { ...state.dynamicFields };
|
|
250
|
+
delete dynamicFields[payload.value];
|
|
251
|
+
return {
|
|
252
|
+
...state,
|
|
253
|
+
dynamicFields: dynamicFields,
|
|
254
|
+
};
|
|
255
|
+
case GET_PRODUCTS:
|
|
256
|
+
return {
|
|
257
|
+
...state,
|
|
258
|
+
products: payload.products,
|
|
259
|
+
};
|
|
260
|
+
case GET_ONE_TEMPLATE:
|
|
261
|
+
return {
|
|
262
|
+
...state,
|
|
263
|
+
template: payload.data,
|
|
264
|
+
title: payload.type === "copy" ? state.title : payload.data.title,
|
|
265
|
+
product: payload.data.product,
|
|
266
|
+
templateType: payload.data.templateType,
|
|
267
|
+
};
|
|
268
|
+
case CLEAR_TEMPLATE:
|
|
269
|
+
return {
|
|
270
|
+
...state,
|
|
271
|
+
template: null,
|
|
272
|
+
};
|
|
273
|
+
case TEMPLATE_LOADING:
|
|
274
|
+
return {
|
|
275
|
+
...state,
|
|
276
|
+
templateLoading: payload,
|
|
277
|
+
};
|
|
278
|
+
case TEMPLATE_PAGINATION_CHANGE:
|
|
279
|
+
return {
|
|
280
|
+
...state,
|
|
281
|
+
templatesPagination: { ...payload.data },
|
|
282
|
+
};
|
|
283
|
+
case TEMPLATE_SEARCH:
|
|
284
|
+
return {
|
|
285
|
+
...state,
|
|
286
|
+
[payload.name]: payload.value,
|
|
287
|
+
};
|
|
288
|
+
case SELECT_PRODUCT:
|
|
289
|
+
return {
|
|
290
|
+
...state,
|
|
291
|
+
product: {
|
|
292
|
+
...payload.product,
|
|
293
|
+
selectedSize: payload.product.size[0].size,
|
|
294
|
+
...(!payload.productType &&
|
|
295
|
+
payload.product.productType !== "Postcards"
|
|
296
|
+
? { selectedSize: payload.product.size[0].size }
|
|
297
|
+
: {}),
|
|
298
|
+
...(payload.productType ? { productType: payload.productType } : {}),
|
|
299
|
+
},
|
|
300
|
+
};
|
|
301
|
+
case SELECT_POSTCARD:
|
|
302
|
+
return {
|
|
303
|
+
...state,
|
|
304
|
+
product: {
|
|
305
|
+
...payload.product,
|
|
306
|
+
productType: payload.productType,
|
|
307
|
+
},
|
|
308
|
+
};
|
|
309
|
+
case CLEAR_DYNAMIC_FIELDS:
|
|
310
|
+
return initialState;
|
|
311
|
+
case CLEAR_FIELDS:
|
|
312
|
+
return initialState;
|
|
313
|
+
case CLEAR_ALL_TEMPLATE:
|
|
314
|
+
return {
|
|
315
|
+
...state,
|
|
316
|
+
templates: { ...initialState.templates },
|
|
317
|
+
};
|
|
318
|
+
case CLEAR_TEMPLATE_FIELDS:
|
|
319
|
+
return {
|
|
320
|
+
...state,
|
|
321
|
+
title: "",
|
|
322
|
+
product: null,
|
|
323
|
+
dynamicField: "",
|
|
324
|
+
dynamicFields: {},
|
|
325
|
+
templateType: "json",
|
|
326
|
+
envelopeType: "",
|
|
327
|
+
};
|
|
328
|
+
case GET_DYNAMIC_FIELDS_FROM_SERVER:
|
|
329
|
+
return {
|
|
330
|
+
...state,
|
|
331
|
+
dynamicFields: payload.data,
|
|
332
|
+
};
|
|
333
|
+
case SET_PRODUCT_DETAILS:
|
|
334
|
+
return {
|
|
335
|
+
...state,
|
|
336
|
+
productDetailByTemplate: payload,
|
|
337
|
+
};
|
|
338
|
+
case LOAD_DATA_FROM_LOCAL_STORAGE:
|
|
339
|
+
return {
|
|
340
|
+
...state,
|
|
341
|
+
title: payload.data.title,
|
|
342
|
+
product: payload.data.product,
|
|
343
|
+
templateType: payload.data.templateType,
|
|
344
|
+
envelopeType: payload.data.envelopeType,
|
|
345
|
+
};
|
|
346
|
+
case CLEAR_REDUX:
|
|
347
|
+
return initialState;
|
|
348
|
+
default:
|
|
349
|
+
return state;
|
|
350
|
+
}
|
|
351
|
+
};
|
|
352
|
+
|
|
353
|
+
export { templateReducer };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// redux/store.ts
|
|
2
|
+
import { configureStore } from '@reduxjs/toolkit';
|
|
3
|
+
import rootReducer from './reducers';
|
|
4
|
+
|
|
5
|
+
const store = configureStore({
|
|
6
|
+
reducer: rootReducer,
|
|
7
|
+
middleware: (getDefaultMiddleware : any) =>
|
|
8
|
+
getDefaultMiddleware({
|
|
9
|
+
thunk: true,
|
|
10
|
+
serializableCheck: false,
|
|
11
|
+
immutableCheck: false,
|
|
12
|
+
}),
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export type RootState = ReturnType<typeof store.getState>;
|
|
16
|
+
export type AppDispatch = typeof store.dispatch;
|
|
17
|
+
|
|
18
|
+
export default store;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// variables
|
|
2
|
+
|
|
3
|
+
// background colors
|
|
4
|
+
$bgLight: #fff7ea;
|
|
5
|
+
$bgTransparent: rgba(0, 0, 0, 0.5);
|
|
6
|
+
$bgLight300: #fff9f0;
|
|
7
|
+
$bgGrey: #f7fffb;
|
|
8
|
+
$bgPrimary: #f28230;
|
|
9
|
+
$bgPrimary800: #ef7820;
|
|
10
|
+
$bgGrey500: #f9f9f9;
|
|
11
|
+
$formLayoutBg: linear-gradient(
|
|
12
|
+
252deg,
|
|
13
|
+
#eec5b3 11.65%,
|
|
14
|
+
#ffceb3 26.15%,
|
|
15
|
+
#ffe4b4 42.72%,
|
|
16
|
+
#ffe4b3 61.64%,
|
|
17
|
+
#fbcbb4 80.93%,
|
|
18
|
+
#e2b9b3 100%
|
|
19
|
+
);
|
|
20
|
+
// primary color
|
|
21
|
+
$primaryColor: #ed5c2f;
|
|
22
|
+
// dark shades
|
|
23
|
+
$black: #000;
|
|
24
|
+
$black200: rgba(68, 66, 65, 0.3);
|
|
25
|
+
$black300: rgba(0, 0, 0, 0.5);
|
|
26
|
+
$black400: #303030;
|
|
27
|
+
$black700: #000000bf;
|
|
28
|
+
$dark800: #080808;
|
|
29
|
+
$blue: #212b36;
|
|
30
|
+
// yellow shades
|
|
31
|
+
$yellow: #fab331;
|
|
32
|
+
$yellow300: #fff8ee;
|
|
33
|
+
$yellow400: #fdecd3;
|
|
34
|
+
$yellow500: #ffdec0;
|
|
35
|
+
// light shades
|
|
36
|
+
$white: #fff;
|
|
37
|
+
$grey: #545454;
|
|
38
|
+
$grey300: #aaa;
|
|
39
|
+
$grey400: #2b2b2a;
|
|
40
|
+
$grey500: #444241;
|
|
41
|
+
$grey800: #222221;
|
|
42
|
+
$light: rgba(255, 248, 238, 1);
|
|
43
|
+
$light300: #f4f4f4;
|
|
44
|
+
$grey: #696969;
|
|
45
|
+
$greyCheckBox: #d1d5db;
|
|
46
|
+
// red shades
|
|
47
|
+
$red: #ff0000;
|
|
48
|
+
$red400: rgba(255, 0, 0, 1);
|
|
49
|
+
// green shades
|
|
50
|
+
$green500: #03a155;
|
|
51
|
+
$success: #7ed321;
|
|
52
|
+
$bgSuccess: #01bb62;
|
|
53
|
+
// orange shade
|
|
54
|
+
$iconColor: rgba(237, 92, 47, 1);
|
|
55
|
+
// brown shades
|
|
56
|
+
$brown300: rgba(255, 192, 184, 0.23);
|
|
57
|
+
|
|
58
|
+
// Stripe Variables
|
|
59
|
+
$stripeBlue: #0570de;
|
|
60
|
+
$stripeText: #30313d;
|
|
61
|
+
$stripeDanger: #df1b41;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
export const mockElement = () => ({
|
|
2
|
+
mount: jest.fn(),
|
|
3
|
+
destroy: jest.fn(),
|
|
4
|
+
on: jest.fn(),
|
|
5
|
+
update: jest.fn(),
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
export const mockElements = () => {
|
|
9
|
+
const elements = {};
|
|
10
|
+
return {
|
|
11
|
+
create: jest.fn((type) => {
|
|
12
|
+
elements[type] = mockElement();
|
|
13
|
+
return elements[type];
|
|
14
|
+
}),
|
|
15
|
+
getElement: jest.fn((type) => {
|
|
16
|
+
return elements[type] || null;
|
|
17
|
+
}),
|
|
18
|
+
update: jest.fn(),
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const mockCustomCheckoutSession = () => {
|
|
23
|
+
return {
|
|
24
|
+
lineItems: [],
|
|
25
|
+
currency: 'usd',
|
|
26
|
+
shippingOptions: [],
|
|
27
|
+
total: {
|
|
28
|
+
subtotal: 1099,
|
|
29
|
+
taxExclusive: 0,
|
|
30
|
+
taxInclusive: 0,
|
|
31
|
+
shippingRate: 0,
|
|
32
|
+
discount: 0,
|
|
33
|
+
total: 1099,
|
|
34
|
+
},
|
|
35
|
+
confirmationRequirements: [],
|
|
36
|
+
canConfirm: true,
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export const mockCustomCheckoutSdk = () => {
|
|
41
|
+
const elements = {};
|
|
42
|
+
|
|
43
|
+
return {
|
|
44
|
+
changeAppearance: jest.fn(),
|
|
45
|
+
createElement: jest.fn((type) => {
|
|
46
|
+
elements[type] = mockElement();
|
|
47
|
+
return elements[type];
|
|
48
|
+
}),
|
|
49
|
+
getElement: jest.fn((type) => {
|
|
50
|
+
return elements[type] || null;
|
|
51
|
+
}),
|
|
52
|
+
session: jest.fn(() => mockCustomCheckoutSession()),
|
|
53
|
+
applyPromotionCode: jest.fn(),
|
|
54
|
+
removePromotionCode: jest.fn(),
|
|
55
|
+
updateShippingAddress: jest.fn(),
|
|
56
|
+
updateBillingAddress: jest.fn(),
|
|
57
|
+
updatePhoneNumber: jest.fn(),
|
|
58
|
+
updateEmail: jest.fn(),
|
|
59
|
+
updateLineItemQuantity: jest.fn(),
|
|
60
|
+
updateShippingOption: jest.fn(),
|
|
61
|
+
confirm: jest.fn(),
|
|
62
|
+
on: jest.fn(),
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export const mockEmbeddedCheckout = () => ({
|
|
67
|
+
mount: jest.fn(),
|
|
68
|
+
unmount: jest.fn(),
|
|
69
|
+
destroy: jest.fn(),
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
export const mockStripe = () => {
|
|
73
|
+
const customCheckoutSdk = mockCustomCheckoutSdk();
|
|
74
|
+
return {
|
|
75
|
+
elements: jest.fn(() => mockElements()),
|
|
76
|
+
createToken: jest.fn(),
|
|
77
|
+
createSource: jest.fn(),
|
|
78
|
+
createPaymentMethod: jest.fn(),
|
|
79
|
+
confirmCardPayment: jest.fn(),
|
|
80
|
+
confirmCardSetup: jest.fn(),
|
|
81
|
+
paymentRequest: jest.fn(),
|
|
82
|
+
registerAppInfo: jest.fn(),
|
|
83
|
+
_registerWrapper: jest.fn(),
|
|
84
|
+
initCustomCheckout: jest.fn().mockResolvedValue(customCheckoutSdk),
|
|
85
|
+
initEmbeddedCheckout: jest.fn(() =>
|
|
86
|
+
Promise.resolve(mockEmbeddedCheckout())
|
|
87
|
+
),
|
|
88
|
+
};
|
|
89
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@testing-library/jest-dom';
|
package/src/utils/api.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import fetchWrapper from './fetchWrapper';
|
|
2
|
+
|
|
3
|
+
export const get = async (endpoint: string, params?: any) => {
|
|
4
|
+
return await fetchWrapper(endpoint, {
|
|
5
|
+
method: 'GET',
|
|
6
|
+
params,
|
|
7
|
+
});
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export const post = async (endpoint: string, body: any) => {
|
|
11
|
+
return await fetchWrapper(endpoint, {
|
|
12
|
+
method: 'POST',
|
|
13
|
+
body,
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const put = async (endpoint: string, body: any) => {
|
|
18
|
+
return await fetchWrapper(endpoint, {
|
|
19
|
+
method: 'PUT',
|
|
20
|
+
body,
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export const patch = async (endpoint: string, body: any) => {
|
|
25
|
+
return await fetchWrapper(endpoint, {
|
|
26
|
+
method: 'PATCH',
|
|
27
|
+
body,
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export const del = async (endpoint: string, params?: Record<string, string>) => {
|
|
32
|
+
return await fetchWrapper(endpoint, {
|
|
33
|
+
method: 'DELETE',
|
|
34
|
+
params,
|
|
35
|
+
});
|
|
36
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export const DPI: number = 96;
|
|
2
|
+
|
|
3
|
+
export const Barcode: string = 'https://api.openletterconnect.com/api/v1/download/s3/openletterconnect/assets/preview/one-barcode.png';
|
|
4
|
+
export const PRODUCT_LEARN_URL: string = "https://help.openletterconnect.com/getting-support/designing-your-mailers/wip-designing-mail-creatives/wip-mail-piece-design-specs";
|
|
5
|
+
|
|
6
|
+
export const multiPageLetters: string[] = [
|
|
7
|
+
"Postcards",
|
|
8
|
+
"Tri-Fold Self-Mailers",
|
|
9
|
+
"Bi-Fold Self-Mailers",
|
|
10
|
+
];
|
|
11
|
+
|
|
12
|
+
interface TemplateTypes {
|
|
13
|
+
id: string;
|
|
14
|
+
label: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const templateTypes = [
|
|
18
|
+
{
|
|
19
|
+
id: "1",
|
|
20
|
+
label: "My Templates",
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
id: "2",
|
|
24
|
+
label: "Team Templates",
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
id: "3",
|
|
28
|
+
label: "OLC Templates",
|
|
29
|
+
},
|
|
30
|
+
];
|
|
31
|
+
|
|
32
|
+
export const sortOrderForTemplates: string[] = [
|
|
33
|
+
"Postcards",
|
|
34
|
+
"Personal Letters",
|
|
35
|
+
"Professional Letters",
|
|
36
|
+
"Bi-Fold Self-Mailers",
|
|
37
|
+
"Tri-Fold Self-Mailers",
|
|
38
|
+
"Real Penned Letter",
|
|
39
|
+
];
|
|
40
|
+
|