@openlettermarketing/olc-react-sdk 0.0.19 → 0.0.21
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/build/index.js +2 -2
- package/build/index.js.map +1 -1
- package/package.json +1 -1
- package/.eslintignore +0 -1
- package/.eslintrc.cjs +0 -18
- package/.eslintrc.yml +0 -47
- package/.prettierignore +0 -3
- package/.prettierrc.yml +0 -5
- package/CHANGELOG.md +0 -4
- package/babel.config.json +0 -10
- package/examples/.eslintrc.yml +0 -4
- package/index.html +0 -18
- package/public/vite.svg +0 -1
- package/src/App.tsx +0 -72
- package/src/assets/Fonts/Lexi-Regular.ttf +0 -0
- package/src/assets/images/input/cancel.tsx +0 -20
- package/src/assets/images/input/search.tsx +0 -20
- package/src/assets/images/modal-icons/cancelIcon.png +0 -0
- package/src/assets/images/modal-icons/del.tsx +0 -19
- package/src/assets/images/modal-icons/delete.svg +0 -3
- package/src/assets/images/modal-icons/modal-cross.tsx +0 -23
- package/src/assets/images/modal-icons/save.tsx +0 -23
- package/src/assets/images/templates/add-icon.svg +0 -5
- package/src/assets/images/templates/back-arrow.tsx +0 -19
- package/src/assets/images/templates/back-dialog-icon.png +0 -0
- package/src/assets/images/templates/back-dialog-icon.svg +0 -3
- package/src/assets/images/templates/barcode.png +0 -0
- package/src/assets/images/templates/bi-fold-self-mailers.tsx +0 -28
- package/src/assets/images/templates/black-trash-icon.svg +0 -3
- package/src/assets/images/templates/cancel.svg +0 -4
- package/src/assets/images/templates/cancelIcon.png +0 -0
- package/src/assets/images/templates/clipboard.svg +0 -3
- package/src/assets/images/templates/contact-search.svg +0 -3
- package/src/assets/images/templates/content-copy-icon.tsx +0 -24
- package/src/assets/images/templates/cross.svg +0 -3
- package/src/assets/images/templates/custom-template-icon-black.svg +0 -3
- package/src/assets/images/templates/custom-template-icon.svg +0 -3
- package/src/assets/images/templates/custom-template.tsx +0 -23
- package/src/assets/images/templates/dummy-template.svg +0 -21
- package/src/assets/images/templates/dynamic-field.tsx +0 -119
- package/src/assets/images/templates/edit-pencil-icon.tsx +0 -21
- package/src/assets/images/templates/filter-2.svg +0 -13
- package/src/assets/images/templates/info-icon.svg +0 -12
- package/src/assets/images/templates/info-icon.tsx +0 -37
- package/src/assets/images/templates/one-barcode.png +0 -0
- package/src/assets/images/templates/personal-letter.tsx +0 -53
- package/src/assets/images/templates/plus-icon.svg +0 -5
- package/src/assets/images/templates/postcard.tsx +0 -32
- package/src/assets/images/templates/professional-letter.tsx +0 -53
- package/src/assets/images/templates/real-penned-letters.tsx +0 -57
- package/src/assets/images/templates/search.svg +0 -3
- package/src/assets/images/templates/size-image-lg.tsx +0 -20
- package/src/assets/images/templates/size-image-mid.tsx +0 -20
- package/src/assets/images/templates/size-image.tsx +0 -20
- package/src/assets/images/templates/template-copy.svg +0 -3
- package/src/assets/images/templates/template-default-design.tsx +0 -21
- package/src/assets/images/templates/template-delete.svg +0 -3
- package/src/assets/images/templates/template-edit.svg +0 -4
- package/src/assets/images/templates/template-save-icon.svg +0 -3
- package/src/assets/images/templates/template-search-2.svg +0 -9
- package/src/assets/images/templates/template-search.svg +0 -4
- package/src/assets/images/templates/thumbnail.svg +0 -10
- package/src/assets/images/templates/trash-icon.svg +0 -13
- package/src/assets/images/templates/tri-fold-self-mailers.tsx +0 -93
- package/src/components/CreateTemplate/index.tsx +0 -381
- package/src/components/CreateTemplate/styles.scss +0 -363
- package/src/components/GenericUIBlocks/Button/index.tsx +0 -21
- package/src/components/GenericUIBlocks/Button/styles.scss +0 -15
- package/src/components/GenericUIBlocks/CircularProgress/index.tsx +0 -18
- package/src/components/GenericUIBlocks/CircularProgress/styles.scss +0 -98
- package/src/components/GenericUIBlocks/Dialog/index.tsx +0 -127
- package/src/components/GenericUIBlocks/Dialog/styles.scss +0 -106
- package/src/components/GenericUIBlocks/Divider/index.tsx +0 -12
- package/src/components/GenericUIBlocks/Divider/styles.scss +0 -7
- package/src/components/GenericUIBlocks/GeneralSelect/index.tsx +0 -86
- package/src/components/GenericUIBlocks/GeneralSelect/styles.scss +0 -77
- package/src/components/GenericUIBlocks/GeneralTooltip/index.tsx +0 -24
- package/src/components/GenericUIBlocks/GeneralTooltip/styles.scss +0 -9
- package/src/components/GenericUIBlocks/GenericSnackbar/index.tsx +0 -53
- package/src/components/GenericUIBlocks/GenericSnackbar/styles.scss +0 -34
- package/src/components/GenericUIBlocks/Grid/index.tsx +0 -82
- package/src/components/GenericUIBlocks/Input/index.tsx +0 -89
- package/src/components/GenericUIBlocks/Input/styles.scss +0 -80
- package/src/components/GenericUIBlocks/Typography/index.tsx +0 -18
- package/src/components/GenericUIBlocks/Typography/styles.scss +0 -27
- package/src/components/SidePanel/customFields/customFieldSection.tsx +0 -173
- package/src/components/SidePanel/customFields/styles.scss +0 -47
- package/src/components/SidePanel/index.tsx +0 -42
- package/src/components/SidePanel/templates/customTemplateSection.tsx +0 -503
- package/src/components/SidePanel/templates/styles.scss +0 -151
- package/src/components/TemplateBuilder/index.tsx +0 -301
- package/src/components/TemplateBuilder/styles.scss +0 -66
- package/src/components/TopNavigation/ConfirmNavigateDialog/index.tsx +0 -58
- package/src/components/TopNavigation/ConfirmNavigateDialog/styles.scss +0 -123
- package/src/components/TopNavigation/EditTemplateNameModel/index.tsx +0 -98
- package/src/components/TopNavigation/EditTemplateNameModel/styles.scss +0 -88
- package/src/components/TopNavigation/SaveTemplateModel/index.tsx +0 -60
- package/src/components/TopNavigation/SaveTemplateModel/styles.scss +0 -128
- package/src/components/TopNavigation/index.tsx +0 -406
- package/src/components/TopNavigation/styles.scss +0 -83
- package/src/importMeta.d.ts +0 -9
- package/src/index.scss +0 -137
- package/src/index.tsx +0 -79
- package/src/libs/test.ts +0 -7
- package/src/redux/actions/action-types.ts +0 -42
- package/src/redux/actions/customFieldAction.ts +0 -28
- package/src/redux/actions/snackbarActions.ts +0 -16
- package/src/redux/actions/templateActions.ts +0 -456
- package/src/redux/reducers/customFieldReducer.ts +0 -97
- package/src/redux/reducers/index.ts +0 -14
- package/src/redux/reducers/snackbarReducer.ts +0 -41
- package/src/redux/reducers/templateReducer.ts +0 -353
- package/src/redux/store.ts +0 -18
- package/src/styles/colors.scss +0 -61
- package/src/test/mocks.js +0 -89
- package/src/test/setupJest.js +0 -1
- package/src/utils/api.ts +0 -36
- package/src/utils/constants.ts +0 -40
- package/src/utils/customStyles.ts +0 -135
- package/src/utils/fetchWrapper.ts +0 -68
- package/src/utils/fonts.json +0 -1597
- package/src/utils/helper.ts +0 -19
- package/src/utils/local-storage.ts +0 -15
- package/src/utils/message.ts +0 -71
- package/src/utils/template-builder.ts +0 -147
- package/src/utils/templateRestrictedArea/biFold.ts +0 -433
- package/src/utils/templateRestrictedArea/postCard.ts +0 -439
- package/src/utils/templateRestrictedArea/professional.ts +0 -422
- package/src/utils/templateRestrictedArea/realPenned.ts +0 -244
- package/src/utils/templateRestrictedArea/triFold.ts +0 -434
- package/tsconfig.json +0 -29
- package/tsconfig.node.json +0 -12
- package/vite.config.ts +0 -8
- package/webpack.config.js +0 -80
|
@@ -1,456 +0,0 @@
|
|
|
1
|
-
import { AppDispatch } from '../store';
|
|
2
|
-
|
|
3
|
-
// Utils
|
|
4
|
-
import { get, post, del, patch } from '../../utils/api';
|
|
5
|
-
|
|
6
|
-
// Action Types
|
|
7
|
-
import {
|
|
8
|
-
FETCH_TEMPLATES_REQUEST,
|
|
9
|
-
SET_TEMPLATES,
|
|
10
|
-
SET_DYNAMIC_FIELDS,
|
|
11
|
-
SET_DYNAMIC_FIELD_VALUE,
|
|
12
|
-
CLEAR_DYNAMIC_FIELDS,
|
|
13
|
-
REMOVE_FROM_DYNAMIC_FIELDS,
|
|
14
|
-
GET_PRODUCTS,
|
|
15
|
-
GET_ONE_TEMPLATE,
|
|
16
|
-
TEMPLATE_LOADING,
|
|
17
|
-
CLEAR_FIELDS,
|
|
18
|
-
TEMPLATE_PAGINATION_CHANGE,
|
|
19
|
-
TEMPLATE_SEARCH,
|
|
20
|
-
CLEAR_ALL_TEMPLATE,
|
|
21
|
-
SELECT_PRODUCT,
|
|
22
|
-
SELECT_POSTCARD,
|
|
23
|
-
CLEAR_TEMPLATE_FIELDS,
|
|
24
|
-
GET_DYNAMIC_FIELDS_FROM_SERVER,
|
|
25
|
-
LOAD_DATA_FROM_LOCAL_STORAGE,
|
|
26
|
-
SET_PRODUCT_DETAILS,
|
|
27
|
-
} from './action-types';
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Makes an HTTP GET request to the 'templates' endpoint and dispatches an action with the retrieved data.
|
|
32
|
-
* @param {number} id - The ID of the template to retrieve.
|
|
33
|
-
* @param {function} dispatch - A function used to dispatch actions to the Redux store.
|
|
34
|
-
* @returns {void}
|
|
35
|
-
*/
|
|
36
|
-
const getOneTemplate =
|
|
37
|
-
(id: number, type = 'edit') =>
|
|
38
|
-
async (dispatch: AppDispatch): Promise<void> => {
|
|
39
|
-
try {
|
|
40
|
-
const { data } = await get(`templates/${id}`) as any;
|
|
41
|
-
dispatch({ type: GET_ONE_TEMPLATE, payload: { data: data.data, type } });
|
|
42
|
-
dispatch({ type: TEMPLATE_LOADING, payload: true });
|
|
43
|
-
} catch (error: any) {
|
|
44
|
-
return error.response;
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Uploads a template using the provided template form data.
|
|
51
|
-
*
|
|
52
|
-
* @param {FormData} templateFormData - The form data containing the template files to upload.
|
|
53
|
-
* @returns {Promise<any>} - A promise that resolves with the response from the server.
|
|
54
|
-
* @throws {Error} - If an error occurs during the upload process.
|
|
55
|
-
*/
|
|
56
|
-
const uploadTemplate = async (templateFormData: FormData): Promise<unknown> => {
|
|
57
|
-
try {
|
|
58
|
-
const response = await post('templates/upload', templateFormData);
|
|
59
|
-
return response;
|
|
60
|
-
} catch (error: any) {
|
|
61
|
-
return error.response;
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Creates a template using the provided data.
|
|
67
|
-
*
|
|
68
|
-
* @param {object} data - The data needed to create the template.
|
|
69
|
-
* @returns {Promise<object>} - A promise that resolves to the response from the successful request or the error response if an error occurs.
|
|
70
|
-
*/
|
|
71
|
-
const createTemplate = async (data: object): Promise<unknown> => {
|
|
72
|
-
try {
|
|
73
|
-
const response = await post('templates', data);
|
|
74
|
-
return response;
|
|
75
|
-
} catch (error: any) {
|
|
76
|
-
return error.response;
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Update a template using the provided data.
|
|
82
|
-
*
|
|
83
|
-
* @param {number} id - The ID of the template to update.
|
|
84
|
-
* @param {object} data - The data needed to create the template.
|
|
85
|
-
* @returns {Promise<object>} - A promise that resolves to the response from the successful request or the error response if an error occurs.
|
|
86
|
-
*/
|
|
87
|
-
const updateTemplate = async (id: number, data: object): Promise<unknown> => {
|
|
88
|
-
try {
|
|
89
|
-
const response = await patch(`templates/${id}`, data);
|
|
90
|
-
return response;
|
|
91
|
-
} catch (error: any) {
|
|
92
|
-
return error.response;
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* Deletes a template by its ID.
|
|
99
|
-
*
|
|
100
|
-
* @param {string} id - The unique identifier of the template to delete.
|
|
101
|
-
* @returns {Promise<any>} A Promise that resolves to the response indicating
|
|
102
|
-
* the success of the template deletion, or rejects
|
|
103
|
-
* with an error response in case of failure.
|
|
104
|
-
*
|
|
105
|
-
* @throws {Error} If the request to delete the template fails.
|
|
106
|
-
*/
|
|
107
|
-
const deleteTemplate = async (id: string): Promise<unknown> => {
|
|
108
|
-
try {
|
|
109
|
-
const response = await del(`templates/${id}`);
|
|
110
|
-
return response;
|
|
111
|
-
} catch (error: any) {
|
|
112
|
-
return error.response;
|
|
113
|
-
}
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* Retrieves the view proof for a template with the given ID.
|
|
118
|
-
*
|
|
119
|
-
* @param {string} id - The ID of the template for which the view proof is requested.
|
|
120
|
-
* @returns {Promise<object>} - The response object from the GET request, containing the view proof for the template with the given ID.
|
|
121
|
-
* @throws {object} - The error response if there is an error.
|
|
122
|
-
*/
|
|
123
|
-
const getViewProof = async (id: string): Promise<unknown> => {
|
|
124
|
-
try {
|
|
125
|
-
const response = await get(`templates/${id}/view-proof`);
|
|
126
|
-
return response;
|
|
127
|
-
} catch (error: any) {
|
|
128
|
-
return error.response;
|
|
129
|
-
}
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* Duplicates a template by its ID.
|
|
134
|
-
*
|
|
135
|
-
* @param {string} id - The unique identifier of the template to duplicate.
|
|
136
|
-
* @param {Object} data - Additional data to be sent with the duplicate request.
|
|
137
|
-
* @returns {Promise<any>} A Promise that resolves to the response containing information
|
|
138
|
-
* about the duplicated template, or rejects with an error response
|
|
139
|
-
* in case of failure.
|
|
140
|
-
*
|
|
141
|
-
* @throws {Error} If the request to duplicate the template fails.
|
|
142
|
-
*/
|
|
143
|
-
const doublicateTemplate = async (id: string, data: object): Promise<unknown> => {
|
|
144
|
-
try {
|
|
145
|
-
const response = await post(`templates/${id}/duplicate`, data);
|
|
146
|
-
return response;
|
|
147
|
-
} catch (error: any) {
|
|
148
|
-
return error.response;
|
|
149
|
-
}
|
|
150
|
-
};
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* Fetches products and dispatches an action with the product data to the Redux store.
|
|
155
|
-
*
|
|
156
|
-
* @param {Function} dispatch - The dispatch function from the Redux store.
|
|
157
|
-
* @returns {Promise<void>} A Promise that resolves after dispatching the action,
|
|
158
|
-
* or rejects if there is an error fetching the products.
|
|
159
|
-
*
|
|
160
|
-
* @throws {Error} If there is an error fetching the products.
|
|
161
|
-
*/
|
|
162
|
-
const getAllProducts = () => async (dispatch: AppDispatch): Promise<void> => {
|
|
163
|
-
try {
|
|
164
|
-
const response = await get('products/types');
|
|
165
|
-
dispatch({
|
|
166
|
-
type: GET_PRODUCTS,
|
|
167
|
-
// @ts-ignore
|
|
168
|
-
payload: { products: response?.data?.data },
|
|
169
|
-
});
|
|
170
|
-
} catch (error: any) {
|
|
171
|
-
console.error(error);
|
|
172
|
-
}
|
|
173
|
-
};
|
|
174
|
-
|
|
175
|
-
/**
|
|
176
|
-
* Fetches custom fields and dispatches an action with the custom fields data to the Redux store.
|
|
177
|
-
*
|
|
178
|
-
* @param {Function} dispatch - The dispatch function from the Redux store.
|
|
179
|
-
* @returns {Promise<void>} A Promise that resolves after dispatching the action,
|
|
180
|
-
* or rejects if there is an error fetching the custom fields.
|
|
181
|
-
*
|
|
182
|
-
* @throws {Error} If there is an error fetching the custom fields.
|
|
183
|
-
*/
|
|
184
|
-
const getAllCustomFields = () => async (dispatch: AppDispatch): Promise<void> => {
|
|
185
|
-
try {
|
|
186
|
-
const response = await get('custom-fields') as Record<string, any>;
|
|
187
|
-
if (response?.status === 200) {
|
|
188
|
-
const data = response?.data?.data.reduce((acc: any, curr: any) => {
|
|
189
|
-
acc[curr.key.replace(/{{|}}/g, '')] = curr;
|
|
190
|
-
return acc;
|
|
191
|
-
}, {});
|
|
192
|
-
|
|
193
|
-
dispatch({ type: GET_DYNAMIC_FIELDS_FROM_SERVER, payload: { data } });
|
|
194
|
-
}
|
|
195
|
-
} catch (error: any) {
|
|
196
|
-
return error.response;
|
|
197
|
-
}
|
|
198
|
-
};
|
|
199
|
-
|
|
200
|
-
/**
|
|
201
|
-
* Fetches product details and dispatches an action with the product details data to the Redux store.
|
|
202
|
-
*
|
|
203
|
-
* @param {object} payload - The payload containing the product details.
|
|
204
|
-
* @returns {Promise<void>} A Promise that resolves after dispatching the action,
|
|
205
|
-
* or rejects if there is an error fetching the product details.
|
|
206
|
-
*
|
|
207
|
-
* @throws {Error} If there is an error fetching the product details.
|
|
208
|
-
*/
|
|
209
|
-
const getProductDetails = (payload: object) => async (dispatch: AppDispatch): Promise<void> => {
|
|
210
|
-
try {
|
|
211
|
-
const response = await post('/products/template/details', payload) as Record<string, any>;
|
|
212
|
-
if (response?.status === 200) {
|
|
213
|
-
dispatch({ type: SET_PRODUCT_DETAILS, payload: response?.data?.data });
|
|
214
|
-
}
|
|
215
|
-
} catch (error: any) {
|
|
216
|
-
return error.response;
|
|
217
|
-
}
|
|
218
|
-
};
|
|
219
|
-
|
|
220
|
-
/**
|
|
221
|
-
* Loads form data to the store.
|
|
222
|
-
*
|
|
223
|
-
* @param {string} data - The form data in JSON format.
|
|
224
|
-
* @returns {void} - Dispatches an action to the Redux store.
|
|
225
|
-
*/
|
|
226
|
-
const loadFormDataToStore = (data: string) => (dispatch: AppDispatch): void => {
|
|
227
|
-
try {
|
|
228
|
-
const parsedData = JSON.parse(data);
|
|
229
|
-
dispatch({
|
|
230
|
-
type: LOAD_DATA_FROM_LOCAL_STORAGE,
|
|
231
|
-
payload: { data: parsedData },
|
|
232
|
-
});
|
|
233
|
-
} catch (error) {
|
|
234
|
-
console.error(error);
|
|
235
|
-
}
|
|
236
|
-
};
|
|
237
|
-
|
|
238
|
-
/**
|
|
239
|
-
* Downloads the proof for the provided data.
|
|
240
|
-
*
|
|
241
|
-
* @param {object} data - The data for which the proof is requested.
|
|
242
|
-
* @returns {Promise<any>} - The response object from the POST request.
|
|
243
|
-
* @throws {object} - The error response if there is an error.
|
|
244
|
-
*/
|
|
245
|
-
const downloadProof = async (data: object): Promise<unknown> => {
|
|
246
|
-
try {
|
|
247
|
-
const response = await post('orders/view-proof-cloud', data);
|
|
248
|
-
return response;
|
|
249
|
-
} catch (error: any) {
|
|
250
|
-
return error.response;
|
|
251
|
-
}
|
|
252
|
-
};
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
/**
|
|
256
|
-
* Uploads a file.
|
|
257
|
-
*
|
|
258
|
-
* @param {File} file - The file to upload.
|
|
259
|
-
* @returns {Promise<string>} - The file path of the uploaded file.
|
|
260
|
-
* @throws {object} - The error response if there is an error.
|
|
261
|
-
*/
|
|
262
|
-
const uploadFile = async (file: File): Promise<string> => {
|
|
263
|
-
try {
|
|
264
|
-
const formData = new FormData();
|
|
265
|
-
formData.append('image', file);
|
|
266
|
-
const response = await post('templates/uploadFile', formData) as Record<string, any>;
|
|
267
|
-
|
|
268
|
-
return response?.data?.data?.filePath;
|
|
269
|
-
} catch (error: any) {
|
|
270
|
-
return error?.response;
|
|
271
|
-
}
|
|
272
|
-
};
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
/**
|
|
276
|
-
* Dispatches an action to indicate that templates are being fetched.
|
|
277
|
-
*
|
|
278
|
-
* @returns {object} - The action object.
|
|
279
|
-
*/
|
|
280
|
-
const fetchTemplatesRequest = () => ({
|
|
281
|
-
type: FETCH_TEMPLATES_REQUEST,
|
|
282
|
-
});
|
|
283
|
-
|
|
284
|
-
/**
|
|
285
|
-
* Dispatches an action with the fetched templates.
|
|
286
|
-
*
|
|
287
|
-
* @param {any[]} templates - The fetched templates.
|
|
288
|
-
* @returns {object} - The action object.
|
|
289
|
-
*/
|
|
290
|
-
const fetchTemplatesSuccess = (templates: any[]) => ({
|
|
291
|
-
type: SET_TEMPLATES,
|
|
292
|
-
payload: templates,
|
|
293
|
-
});
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
/**
|
|
298
|
-
* Clears template fields.
|
|
299
|
-
*
|
|
300
|
-
* @returns {Function} - The thunk function.
|
|
301
|
-
*/
|
|
302
|
-
const clearTemplateFields = () => (dispatch: AppDispatch) => {
|
|
303
|
-
dispatch({ type: CLEAR_TEMPLATE_FIELDS });
|
|
304
|
-
};
|
|
305
|
-
|
|
306
|
-
/**
|
|
307
|
-
* Selects a product.
|
|
308
|
-
*
|
|
309
|
-
* @param {any} product - The selected product.
|
|
310
|
-
* @param {string} [productType=''] - The type of the selected product.
|
|
311
|
-
* @returns {Function} - The thunk function.
|
|
312
|
-
*/
|
|
313
|
-
const selectProduct =
|
|
314
|
-
(product: any, productType = '') =>
|
|
315
|
-
(dispatch: AppDispatch) => {
|
|
316
|
-
dispatch({ type: SELECT_PRODUCT, payload: { product, productType } });
|
|
317
|
-
};
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
/**
|
|
321
|
-
* Selects a postcard.
|
|
322
|
-
*
|
|
323
|
-
* @param {any} product - The selected product.
|
|
324
|
-
* @param {string} productType - The type of the selected product.
|
|
325
|
-
* @returns {Function} - The thunk function.
|
|
326
|
-
*/
|
|
327
|
-
const selectPostCard = (product: any, productType: string) => (dispatch: AppDispatch) => {
|
|
328
|
-
dispatch({ type: SELECT_POSTCARD, payload: { product, productType } });
|
|
329
|
-
};
|
|
330
|
-
|
|
331
|
-
/**
|
|
332
|
-
* Clears all templates.
|
|
333
|
-
*
|
|
334
|
-
* @returns {Function} - The thunk function.
|
|
335
|
-
*/
|
|
336
|
-
const clearAllTemplates = () => (dispatch: AppDispatch) => {
|
|
337
|
-
dispatch({ type: CLEAR_ALL_TEMPLATE });
|
|
338
|
-
};
|
|
339
|
-
|
|
340
|
-
/**
|
|
341
|
-
* Searches and advances change.
|
|
342
|
-
*
|
|
343
|
-
* @param {string} name - The name of the field.
|
|
344
|
-
* @param {any} value - The value of the field.
|
|
345
|
-
* @returns {Function} - The thunk function.
|
|
346
|
-
*/
|
|
347
|
-
const searchAndAdvanceChange = (name: string, value: any) => (dispatch: AppDispatch) => {
|
|
348
|
-
dispatch({ type: TEMPLATE_SEARCH, payload: { name, value } });
|
|
349
|
-
};
|
|
350
|
-
|
|
351
|
-
/**
|
|
352
|
-
* Changes dynamic input.
|
|
353
|
-
*
|
|
354
|
-
* @param {any} value - The value of the dynamic input.
|
|
355
|
-
* @returns {Function} - The thunk function.
|
|
356
|
-
*/
|
|
357
|
-
const dynmicInputChange = (value: any) => (dispatch: AppDispatch) => {
|
|
358
|
-
dispatch({ type: SET_DYNAMIC_FIELD_VALUE, payload: { value } });
|
|
359
|
-
};
|
|
360
|
-
|
|
361
|
-
/**
|
|
362
|
-
* Sets dynamic fields.
|
|
363
|
-
*
|
|
364
|
-
* @returns {Function} - The thunk function.
|
|
365
|
-
*/
|
|
366
|
-
const setDynamicFields = () => (dispatch: AppDispatch) => {
|
|
367
|
-
dispatch({ type: SET_DYNAMIC_FIELDS, payload: {} });
|
|
368
|
-
};
|
|
369
|
-
|
|
370
|
-
/**
|
|
371
|
-
* Removes an item from dynamic fields.
|
|
372
|
-
*
|
|
373
|
-
* @param {any} value - The value of the item to remove.
|
|
374
|
-
* @returns {Function} - The thunk function.
|
|
375
|
-
*/
|
|
376
|
-
const removeItemFromDynamicField = (value: any) => (dispatch: AppDispatch) => {
|
|
377
|
-
dispatch({ type: REMOVE_FROM_DYNAMIC_FIELDS, payload: { value } });
|
|
378
|
-
};
|
|
379
|
-
|
|
380
|
-
/**
|
|
381
|
-
* Clears dynamic fields.
|
|
382
|
-
*
|
|
383
|
-
* @returns {Function} - The thunk function.
|
|
384
|
-
*/
|
|
385
|
-
const clearDynaicFields = () => (dispatch: AppDispatch) => {
|
|
386
|
-
dispatch({ type: CLEAR_DYNAMIC_FIELDS });
|
|
387
|
-
};
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
/**
|
|
391
|
-
* Clears filters.
|
|
392
|
-
*
|
|
393
|
-
* @returns {Function} - The thunk function.
|
|
394
|
-
*/
|
|
395
|
-
const clearFilter = () => (dispatch: AppDispatch) => dispatch({ type: CLEAR_FIELDS });
|
|
396
|
-
|
|
397
|
-
/**
|
|
398
|
-
* Retrieves all template categories from the server using an HTTP GET request.
|
|
399
|
-
*
|
|
400
|
-
* @returns {Promise<any>} - A promise that resolves with the response from the server.
|
|
401
|
-
* @throws {object} - The error response if there is an error.
|
|
402
|
-
*/
|
|
403
|
-
const getAllTemplateCategories = async (): Promise<any> => {
|
|
404
|
-
try {
|
|
405
|
-
const response = await get('templates/categories');
|
|
406
|
-
return response;
|
|
407
|
-
} catch (error: any) {
|
|
408
|
-
return error.response;
|
|
409
|
-
}
|
|
410
|
-
};
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
/**
|
|
414
|
-
* Retrieves templates by tab using the provided payload.
|
|
415
|
-
*
|
|
416
|
-
* @param {object} payload - The payload containing the necessary data to filter templates by tab.
|
|
417
|
-
* @returns {Promise<any>} - A promise that resolves with the response data from the server.
|
|
418
|
-
* @throws {object} - The error response if there is an error.
|
|
419
|
-
*/
|
|
420
|
-
const getAllTemplatesByTab = async (payload: object): Promise<any> => {
|
|
421
|
-
try {
|
|
422
|
-
const response = await post('templates/by-tab', payload);
|
|
423
|
-
return response;
|
|
424
|
-
} catch (error: any) {
|
|
425
|
-
return error.response;
|
|
426
|
-
}
|
|
427
|
-
};
|
|
428
|
-
|
|
429
|
-
export {
|
|
430
|
-
dynmicInputChange,
|
|
431
|
-
setDynamicFields,
|
|
432
|
-
clearDynaicFields,
|
|
433
|
-
removeItemFromDynamicField,
|
|
434
|
-
getAllProducts,
|
|
435
|
-
uploadTemplate,
|
|
436
|
-
getOneTemplate,
|
|
437
|
-
createTemplate,
|
|
438
|
-
updateTemplate,
|
|
439
|
-
clearFilter,
|
|
440
|
-
deleteTemplate,
|
|
441
|
-
getViewProof,
|
|
442
|
-
doublicateTemplate,
|
|
443
|
-
searchAndAdvanceChange,
|
|
444
|
-
clearAllTemplates,
|
|
445
|
-
selectProduct,
|
|
446
|
-
selectPostCard,
|
|
447
|
-
clearTemplateFields,
|
|
448
|
-
getAllCustomFields,
|
|
449
|
-
loadFormDataToStore,
|
|
450
|
-
uploadFile,
|
|
451
|
-
getProductDetails,
|
|
452
|
-
downloadProof,
|
|
453
|
-
getAllTemplateCategories,
|
|
454
|
-
getAllTemplatesByTab
|
|
455
|
-
};
|
|
456
|
-
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
FETCH_CUSTOM_FIELDS_REQUEST,
|
|
3
|
-
SET_CUSTOM_FIELDS,
|
|
4
|
-
} from '../actions/customFieldAction';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
// TODO: Review this
|
|
8
|
-
export interface CustomFieldState {
|
|
9
|
-
customFields: any[];
|
|
10
|
-
defaultDynamicFields: any[];
|
|
11
|
-
loading: boolean;
|
|
12
|
-
error: string | null;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const initialState: CustomFieldState = {
|
|
16
|
-
customFields: [],
|
|
17
|
-
defaultDynamicFields: [
|
|
18
|
-
{
|
|
19
|
-
value: "First Name",
|
|
20
|
-
key: "{{C.FIRST_NAME}}",
|
|
21
|
-
defaultValue: "John",
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
value: "Last Name",
|
|
25
|
-
key: "{{C.LAST_NAME}}",
|
|
26
|
-
defaultValue: "Doe",
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
value: "Full Name",
|
|
30
|
-
key: "{{C.FIRST_NAME}} {{C.LAST_NAME}}",
|
|
31
|
-
defaultValue: "John Doe",
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
value: "Company Name",
|
|
35
|
-
key: "{{C.COMPANY_NAME}}",
|
|
36
|
-
defaultValue: "ABC Company, Inc.",
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
value: "Address 1",
|
|
40
|
-
key: "{{C.ADDRESS_1}}",
|
|
41
|
-
defaultValue: "123 Main Street",
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
value: "Address 2",
|
|
45
|
-
key: "{{C.ADDRESS_2}}",
|
|
46
|
-
defaultValue: "Suite 2",
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
value: "City",
|
|
50
|
-
key: "{{C.CITY}}",
|
|
51
|
-
defaultValue: "Lawrence",
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
value: "State",
|
|
55
|
-
key: "{{C.STATE}}",
|
|
56
|
-
defaultValue: "MA",
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
value: "Zip Code",
|
|
60
|
-
key: "{{C.ZIP_CODE}}",
|
|
61
|
-
defaultValue: "01843",
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
value: "Phone Number",
|
|
65
|
-
key: "{{C.PHONE_NUMBER}}",
|
|
66
|
-
defaultValue: "(555) 278-9389",
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
value: "Email",
|
|
70
|
-
key: "{{C.EMAIL}}",
|
|
71
|
-
defaultValue: "johndoe@gmail.com",
|
|
72
|
-
},
|
|
73
|
-
],
|
|
74
|
-
loading: false,
|
|
75
|
-
error: null,
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
const customFieldReducer = (state = initialState, action: any): CustomFieldState => {
|
|
79
|
-
switch (action.type) {
|
|
80
|
-
case FETCH_CUSTOM_FIELDS_REQUEST:
|
|
81
|
-
return {
|
|
82
|
-
...state,
|
|
83
|
-
loading: true,
|
|
84
|
-
error: null,
|
|
85
|
-
};
|
|
86
|
-
case SET_CUSTOM_FIELDS:
|
|
87
|
-
return {
|
|
88
|
-
...state,
|
|
89
|
-
loading: false,
|
|
90
|
-
customFields: action.payload,
|
|
91
|
-
};
|
|
92
|
-
default:
|
|
93
|
-
return state;
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
export { customFieldReducer };
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { combineReducers } from 'redux';
|
|
2
|
-
import { templateReducer } from './templateReducer';
|
|
3
|
-
import { customFieldReducer } from './customFieldReducer';
|
|
4
|
-
import { snackbarReducers } from './snackbarReducer';
|
|
5
|
-
|
|
6
|
-
const rootReducer = combineReducers({
|
|
7
|
-
templates: templateReducer,
|
|
8
|
-
customFields: customFieldReducer,
|
|
9
|
-
snackbarReducers,
|
|
10
|
-
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
export type RootState = ReturnType<typeof rootReducer>;
|
|
14
|
-
export default rootReducer;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { Payload } from './../../components/SidePanel/templates/customTemplateSection';
|
|
2
|
-
//Actions
|
|
3
|
-
import { SET_SUCCESS_SNACKBAR, SET_ERROR_SNACKBAR, CLEAR_SNACKBAR } from "../actions/action-types"
|
|
4
|
-
|
|
5
|
-
// Define the initial state type
|
|
6
|
-
interface SnackbarState {
|
|
7
|
-
snackbar: {
|
|
8
|
-
open: boolean;
|
|
9
|
-
status: 'success' | 'error';
|
|
10
|
-
heading: string;
|
|
11
|
-
message: string;
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const initialState: SnackbarState = {
|
|
16
|
-
snackbar: {
|
|
17
|
-
open: false,
|
|
18
|
-
status: 'success',
|
|
19
|
-
heading: '',
|
|
20
|
-
message: '',
|
|
21
|
-
},
|
|
22
|
-
};
|
|
23
|
-
export type ActionPayload = {
|
|
24
|
-
type: string;
|
|
25
|
-
payload: any;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const snackbarReducers = (state: SnackbarState = initialState, { type, payload } : ActionPayload) => {
|
|
29
|
-
switch (type) {
|
|
30
|
-
case SET_SUCCESS_SNACKBAR:
|
|
31
|
-
return { ...state, snackbar: { ...state.snackbar, ...payload, open: true, status: 'success' } };
|
|
32
|
-
case SET_ERROR_SNACKBAR:
|
|
33
|
-
return { ...state, snackbar: { ...state.snackbar, ...payload, open: true, status: 'error' } };
|
|
34
|
-
case CLEAR_SNACKBAR:
|
|
35
|
-
return { ...state, snackbar: { ...state.snackbar, open: false, status: 'success', message: '', heading: '' } };
|
|
36
|
-
default:
|
|
37
|
-
return state;
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
export { snackbarReducers };
|