@openlettermarketing/olc-react-sdk 2.1.4 → 2.1.5-beta.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.
Files changed (230) hide show
  1. package/.eslintignore +1 -0
  2. package/.eslintrc.cjs +18 -0
  3. package/.eslintrc.yml +47 -0
  4. package/.github/workflows/publish-beta.yml +154 -0
  5. package/.github/workflows/publish-production.yml +143 -0
  6. package/.prettierignore +3 -0
  7. package/.prettierrc.yml +5 -0
  8. package/CHANGELOG.md +4 -0
  9. package/babel.config.json +10 -0
  10. package/build/index.js +82 -82
  11. package/build/index.js.map +1 -1
  12. package/build/types/version.d.ts +1 -1
  13. package/examples/.eslintrc.yml +4 -0
  14. package/index.html +18 -0
  15. package/package.json +1 -1
  16. package/public/vite.svg +1 -0
  17. package/src/App.tsx +209 -0
  18. package/src/assets/Fonts/Lexi-Regular.ttf +0 -0
  19. package/src/assets/images/create-template/prebuilt.svg +13 -0
  20. package/src/assets/images/create-template/scratch.svg +4 -0
  21. package/src/assets/images/input/cancel.tsx +20 -0
  22. package/src/assets/images/input/search.tsx +20 -0
  23. package/src/assets/images/input/select-cancel.tsx +17 -0
  24. package/src/assets/images/modal-icons/add.tsx +36 -0
  25. package/src/assets/images/modal-icons/cancel-file.tsx +12 -0
  26. package/src/assets/images/modal-icons/cancel-input.tsx +13 -0
  27. package/src/assets/images/modal-icons/cancel.tsx +35 -0
  28. package/src/assets/images/modal-icons/close-new.svg +3 -0
  29. package/src/assets/images/modal-icons/confirm-close-icon.tsx +14 -0
  30. package/src/assets/images/modal-icons/confirm-new.tsx +22 -0
  31. package/src/assets/images/modal-icons/confirm.svg +12 -0
  32. package/src/assets/images/modal-icons/cross.tsx +23 -0
  33. package/src/assets/images/modal-icons/del.tsx +19 -0
  34. package/src/assets/images/modal-icons/design-icon.tsx +22 -0
  35. package/src/assets/images/modal-icons/doc.tsx +43 -0
  36. package/src/assets/images/modal-icons/docx.tsx +43 -0
  37. package/src/assets/images/modal-icons/envelope-icon.tsx +26 -0
  38. package/src/assets/images/modal-icons/info.tsx +19 -0
  39. package/src/assets/images/modal-icons/jpeg.tsx +43 -0
  40. package/src/assets/images/modal-icons/jpg.tsx +43 -0
  41. package/src/assets/images/modal-icons/modal-cros.svg +4 -0
  42. package/src/assets/images/modal-icons/modal-cross.tsx +37 -0
  43. package/src/assets/images/modal-icons/new-cancel.tsx +11 -0
  44. package/src/assets/images/modal-icons/order-download.tsx +42 -0
  45. package/src/assets/images/modal-icons/pdf.tsx +51 -0
  46. package/src/assets/images/modal-icons/png.tsx +43 -0
  47. package/src/assets/images/modal-icons/save.tsx +23 -0
  48. package/src/assets/images/modal-icons/template-copy.tsx +25 -0
  49. package/src/assets/images/modal-icons/tool-cancel.tsx +25 -0
  50. package/src/assets/images/products/bi-new.svg +23 -0
  51. package/src/assets/images/products/left-arrow.svg +17 -0
  52. package/src/assets/images/products/personal-new.tsx +31 -0
  53. package/src/assets/images/products/postcard-new.tsx +27 -0
  54. package/src/assets/images/products/professional-new.tsx +24 -0
  55. package/src/assets/images/products/real-new.tsx +30 -0
  56. package/src/assets/images/products/right-arrow.svg +17 -0
  57. package/src/assets/images/products/snap-new.svg +31 -0
  58. package/src/assets/images/templates/actions.svg +3 -0
  59. package/src/assets/images/templates/address-block-icon.tsx +62 -0
  60. package/src/assets/images/templates/archive.svg +3 -0
  61. package/src/assets/images/templates/arrow-down.tsx +27 -0
  62. package/src/assets/images/templates/back-arrow.tsx +19 -0
  63. package/src/assets/images/templates/bi-fold-self-mailers.tsx +28 -0
  64. package/src/assets/images/templates/check.svg +3 -0
  65. package/src/assets/images/templates/code.svg +10 -0
  66. package/src/assets/images/templates/content-copy-icon.tsx +24 -0
  67. package/src/assets/images/templates/custom-add-on-icon.tsx +18 -0
  68. package/src/assets/images/templates/custom-qr-section-icon.tsx +9 -0
  69. package/src/assets/images/templates/custom-template.tsx +23 -0
  70. package/src/assets/images/templates/designer.tsx +43 -0
  71. package/src/assets/images/templates/dot.tsx +22 -0
  72. package/src/assets/images/templates/download-v2.svg +4 -0
  73. package/src/assets/images/templates/download.svg +4 -0
  74. package/src/assets/images/templates/dummy-template.tsx +76 -0
  75. package/src/assets/images/templates/dynamic-field.tsx +119 -0
  76. package/src/assets/images/templates/edit-pencil-icon.tsx +21 -0
  77. package/src/assets/images/templates/edit.svg +3 -0
  78. package/src/assets/images/templates/epo-icon.tsx +16 -0
  79. package/src/assets/images/templates/field.tsx +29 -0
  80. package/src/assets/images/templates/gsv-icon.tsx +31 -0
  81. package/src/assets/images/templates/info-icon.tsx +37 -0
  82. package/src/assets/images/templates/left-arrow.svg +17 -0
  83. package/src/assets/images/templates/pencil.svg +3 -0
  84. package/src/assets/images/templates/personal-letter.tsx +53 -0
  85. package/src/assets/images/templates/postcard.tsx +32 -0
  86. package/src/assets/images/templates/professional-letter.tsx +53 -0
  87. package/src/assets/images/templates/qr-code.tsx +13 -0
  88. package/src/assets/images/templates/real-penned-letters.tsx +57 -0
  89. package/src/assets/images/templates/right-arrow.svg +17 -0
  90. package/src/assets/images/templates/size-image-lg.tsx +20 -0
  91. package/src/assets/images/templates/size-image-mid.tsx +20 -0
  92. package/src/assets/images/templates/size-image-xl.tsx +20 -0
  93. package/src/assets/images/templates/size-image.tsx +20 -0
  94. package/src/assets/images/templates/snap-pack.tsx +67 -0
  95. package/src/assets/images/templates/template-default-design.tsx +21 -0
  96. package/src/assets/images/templates/trash-upload.svg +3 -0
  97. package/src/assets/images/templates/trash.svg +3 -0
  98. package/src/assets/images/templates/tri-fold-self-mailers.tsx +93 -0
  99. package/src/assets/images/templates/upload-image.svg +10 -0
  100. package/src/assets/images/templates/x.svg +3 -0
  101. package/src/assets/images/thumbnails/one.svg +9 -0
  102. package/src/assets/images/tooltip/tool-arrow.tsx +25 -0
  103. package/src/components/CreateTemplate/V2/index.tsx +525 -0
  104. package/src/components/CreateTemplate/V2/styles.scss +372 -0
  105. package/src/components/CreateTemplate/index.tsx +508 -0
  106. package/src/components/CreateTemplate/styles.scss +404 -0
  107. package/src/components/GenericUIBlocks/Button/index.tsx +54 -0
  108. package/src/components/GenericUIBlocks/Button/styles.scss +43 -0
  109. package/src/components/GenericUIBlocks/CircularProgress/index.tsx +18 -0
  110. package/src/components/GenericUIBlocks/CircularProgress/styles.scss +93 -0
  111. package/src/components/GenericUIBlocks/CustomTooltip/index.tsx +88 -0
  112. package/src/components/GenericUIBlocks/CustomTooltip/styles.scss +19 -0
  113. package/src/components/GenericUIBlocks/Dialog/V2/index.tsx +227 -0
  114. package/src/components/GenericUIBlocks/Dialog/V2/styles.scss +289 -0
  115. package/src/components/GenericUIBlocks/Dialog/index.tsx +185 -0
  116. package/src/components/GenericUIBlocks/Dialog/styles.scss +227 -0
  117. package/src/components/GenericUIBlocks/Divider/index.tsx +12 -0
  118. package/src/components/GenericUIBlocks/Divider/styles.scss +7 -0
  119. package/src/components/GenericUIBlocks/GeneralSelect/index.tsx +114 -0
  120. package/src/components/GenericUIBlocks/GeneralSelect/styles.scss +406 -0
  121. package/src/components/GenericUIBlocks/GeneralTooltip/index.tsx +25 -0
  122. package/src/components/GenericUIBlocks/GeneralTooltip/styles.scss +20 -0
  123. package/src/components/GenericUIBlocks/GenericSnackbar/Toast/index.tsx +91 -0
  124. package/src/components/GenericUIBlocks/GenericSnackbar/Toast/styles.scss +92 -0
  125. package/src/components/GenericUIBlocks/Grid/index.tsx +82 -0
  126. package/src/components/GenericUIBlocks/Input/index.tsx +269 -0
  127. package/src/components/GenericUIBlocks/Input/styles.scss +332 -0
  128. package/src/components/GenericUIBlocks/Tabs/index.tsx +71 -0
  129. package/src/components/GenericUIBlocks/Tabs/styles.scss +42 -0
  130. package/src/components/GenericUIBlocks/Typography/index.tsx +18 -0
  131. package/src/components/GenericUIBlocks/Typography/styles.scss +27 -0
  132. package/src/components/SidePanel/CustomAddOns/index.tsx +342 -0
  133. package/src/components/SidePanel/CustomAddOns/styles.scss +86 -0
  134. package/src/components/SidePanel/CustomBlockColors/index.tsx +211 -0
  135. package/src/components/SidePanel/CustomBlockColors/styles.scss +80 -0
  136. package/src/components/SidePanel/CustomFields/customFieldSection.tsx +547 -0
  137. package/src/components/SidePanel/CustomFields/styles.scss +64 -0
  138. package/src/components/SidePanel/CustomQRCode/V2/QRCodeModal/index.tsx +172 -0
  139. package/src/components/SidePanel/CustomQRCode/V2/QRCodeModal/styles.scss +46 -0
  140. package/src/components/SidePanel/CustomQRCode/index.tsx +1070 -0
  141. package/src/components/SidePanel/CustomQRCode/styles.scss +149 -0
  142. package/src/components/SidePanel/CustomUploads/V2/index.tsx +542 -0
  143. package/src/components/SidePanel/CustomUploads/V2/styles.scss +267 -0
  144. package/src/components/SidePanel/CustomUploads/index.tsx +301 -0
  145. package/src/components/SidePanel/Templates/ModalGallery/HireDesigner/index.tsx +424 -0
  146. package/src/components/SidePanel/Templates/ModalGallery/HireDesigner/styles.scss +180 -0
  147. package/src/components/SidePanel/Templates/ModalGallery/V2/index.tsx +235 -0
  148. package/src/components/SidePanel/Templates/ModalGallery/V2/styles.scss +244 -0
  149. package/src/components/SidePanel/Templates/ModalGallery/index.tsx +231 -0
  150. package/src/components/SidePanel/Templates/SideBarGallery/index.tsx +233 -0
  151. package/src/components/SidePanel/Templates/SideBarGallery/styles.scss +152 -0
  152. package/src/components/SidePanel/Templates/TemplatesCard/V2/index.tsx +149 -0
  153. package/src/components/SidePanel/Templates/TemplatesCard/V2/styles.scss +156 -0
  154. package/src/components/SidePanel/Templates/TemplatesCard/index.tsx +160 -0
  155. package/src/components/SidePanel/Templates/TemplatesCard/styles.scss +98 -0
  156. package/src/components/SidePanel/Templates/customTemplateSection.tsx +793 -0
  157. package/src/components/SidePanel/Templates/styles.scss +244 -0
  158. package/src/components/SidePanel/index.tsx +160 -0
  159. package/src/components/TemplateBuilder/index.tsx +585 -0
  160. package/src/components/TemplateBuilder/styles.scss +100 -0
  161. package/src/components/TemplateTypes/index.tsx +96 -0
  162. package/src/components/TemplateTypes/styles.scss +91 -0
  163. package/src/components/TopNavigation/ConfirmNavigateDialog/index.tsx +81 -0
  164. package/src/components/TopNavigation/ConfirmNavigateDialog/styles.scss +123 -0
  165. package/src/components/TopNavigation/DuplicateTemplateModal.tsx +103 -0
  166. package/src/components/TopNavigation/EditTemplateNameModel/index.tsx +71 -0
  167. package/src/components/TopNavigation/EditTemplateNameModel/styles.scss +88 -0
  168. package/src/components/TopNavigation/SaveTemplateModel/index.tsx +201 -0
  169. package/src/components/TopNavigation/SaveTemplateModel/styles.scss +128 -0
  170. package/src/components/TopNavigation/index.tsx +938 -0
  171. package/src/components/TopNavigation/styles.scss +303 -0
  172. package/src/importMeta.d.ts +31 -0
  173. package/src/index.scss +131 -0
  174. package/src/index.tsx +238 -0
  175. package/src/libs/test.ts +7 -0
  176. package/src/redux/actions/action-types.ts +52 -0
  177. package/src/redux/actions/customQRCodeActions.ts +54 -0
  178. package/src/redux/actions/snackbarActions.ts +16 -0
  179. package/src/redux/actions/templateActions.ts +236 -0
  180. package/src/redux/reducers/customFieldReducer.ts +99 -0
  181. package/src/redux/reducers/customQRCodeReducer.ts +58 -0
  182. package/src/redux/reducers/index.ts +15 -0
  183. package/src/redux/reducers/snackbarReducer.ts +40 -0
  184. package/src/redux/reducers/templateReducer.ts +485 -0
  185. package/src/redux/store.ts +18 -0
  186. package/src/styles/colors.scss +61 -0
  187. package/src/test/mocks.js +89 -0
  188. package/src/test/setupJest.js +1 -0
  189. package/src/utils/api.ts +36 -0
  190. package/src/utils/constants.ts +182 -0
  191. package/src/utils/customStyles.ts +45 -0
  192. package/src/utils/fetchWrapper.ts +73 -0
  193. package/src/utils/fonts.json +1597 -0
  194. package/src/utils/helper.ts +205 -0
  195. package/src/utils/local-storage.ts +15 -0
  196. package/src/utils/message.ts +162 -0
  197. package/src/utils/products.ts +186 -0
  198. package/src/utils/template-builder.ts +328 -0
  199. package/src/utils/templateIdentifierArea/biFold.ts +107 -0
  200. package/src/utils/templateIdentifierArea/index.ts +35 -0
  201. package/src/utils/templateIdentifierArea/personal.ts +107 -0
  202. package/src/utils/templateIdentifierArea/postCards.ts +163 -0
  203. package/src/utils/templateIdentifierArea/professional.ts +125 -0
  204. package/src/utils/templateIdentifierArea/snapPack.ts +107 -0
  205. package/src/utils/templateIdentifierArea/triFold.ts +107 -0
  206. package/src/utils/templateRestrictedArea/biFold.ts +329 -0
  207. package/src/utils/templateRestrictedArea/nonWindowProfessional.ts +90 -0
  208. package/src/utils/templateRestrictedArea/personal.ts +90 -0
  209. package/src/utils/templateRestrictedArea/postCard.ts +334 -0
  210. package/src/utils/templateRestrictedArea/postCardJumbo.tsx +408 -0
  211. package/src/utils/templateRestrictedArea/professional.ts +318 -0
  212. package/src/utils/templateRestrictedArea/realPenned.ts +233 -0
  213. package/src/utils/templateRestrictedArea/snapPack.ts +1009 -0
  214. package/src/utils/templateRestrictedArea/triFold.ts +330 -0
  215. package/src/utils/templateSafetyBorders/biFold.ts +91 -0
  216. package/src/utils/templateSafetyBorders/index.ts +43 -0
  217. package/src/utils/templateSafetyBorders/personal.ts +41 -0
  218. package/src/utils/templateSafetyBorders/postCards.ts +259 -0
  219. package/src/utils/templateSafetyBorders/professional.ts +78 -0
  220. package/src/utils/templateSafetyBorders/snapPack.ts +165 -0
  221. package/src/utils/templateSafetyBorders/triFold.ts +114 -0
  222. package/src/utils/templateSafetyBorders/types.d.ts +68 -0
  223. package/src/utils/types.ts +12 -0
  224. package/src/v2Theme.scss +142 -0
  225. package/tsconfig.json +29 -0
  226. package/tsconfig.node.json +12 -0
  227. package/update-version.js +23 -0
  228. package/version.js +1 -0
  229. package/vite.config.ts +8 -0
  230. package/webpack.config.js +80 -0
@@ -0,0 +1,52 @@
1
+ // Snakbar Actions
2
+ export const SET_SUCCESS_SNACKBAR = 'SET_SUCCESS_SNACKBAR';
3
+ export const SET_ERROR_SNACKBAR = 'SET_ERROR_SNACKBAR';
4
+ export const CLEAR_SNACKBAR = 'CLEAR_SNACKBAR';
5
+
6
+ // Templates Action
7
+ export const GET_ONE_TEMPLATE: string = 'GET_ONE_TEMPLATE';
8
+ export const TEMPLATE_LOADING: string = 'TEMPLATE_LOADING';
9
+ export const TEMPLATE_PAGINATION_CHANGE: string = 'TEMPLATE_PAGINATION_CHANGE';
10
+ export const TEMPLATE_SEARCH: string = 'TEMPLATE_SEARCH';
11
+ export const SET_UPLOADED_IMAGES: string = 'SET_UPLOADED_IMAGES';
12
+ export const SET_ROS_OFFER_PERCENTAGE = 'SET_ROS_OFFER_PERCENTAGE';
13
+ export const CLEAR_ALL_TEMPLATE: string = 'CLEAR_ALL_TEMPLATE';
14
+ export const CLEAR_TEMPLATE_FIELDS: string = 'CLEAR_TEMPLATE_FIELDS';
15
+ export const LOAD_DATA_FROM_LOCAL_STORAGE: string =
16
+ 'LOAD_DATA_FROM_LOCAL_STORAGE';
17
+ export const CLEAR_TEMPLATE: string = 'CLEAR_TEMPLATE';
18
+
19
+ //Product
20
+ export const SELECT_PRODUCT: string = 'SELECT_PRODUCT';
21
+ export const SELECT_POSTCARD: string = 'SELECT_POSTCARD';
22
+ export const SET_PRODUCTS: string = 'SET_PRODUCTS';
23
+
24
+ // Custom Fields Actions
25
+ export const SET_CUSTOM_FIELDS = 'SET_CUSTOM_FIELDS';
26
+ export const SET_CUSTOM_FIELDS_V2 = 'SET_CUSTOM_FIELDS_V2';
27
+ export const SET_PLATFORM_FIELDS = 'SET_PLATFORM_FIELDS';
28
+
29
+ //Hire Designer Actions
30
+ export const SET_HIRE_DESIGNER_FORM_FIELDS = 'SET_HIRE_DESIGNER_FORM_FIELDS';
31
+ export const CLEAR_HIRE_DESIGNER_FORM_FIELDS =
32
+ 'CLEAR_HIRE_DESIGNER_FORM_FIELDS';
33
+
34
+ // QR Code Actions
35
+ export const SET_QR_URL = 'SET_QR_URL';
36
+ export const SET_UTM_SOURCE = 'SET_UTM_SOURCE';
37
+ export const SET_UTM_MEDIUM = 'SET_UTM_MEDIUM';
38
+ export const SET_UTM_CAMPAIGN_NAME = 'SET_UTM_CAMPAIGN_NAME';
39
+ export const SET_CUSTOM_UTMS = 'SET_CUSTOM_UTMS';
40
+ export const CLEAR_QR_FIELDS = 'CLEAR_QR_FIELDS';
41
+ export const SET_IS_QR = 'SET_IS_QR';
42
+ export const SET_QR_DIALOG = 'SET_QR_DIALOG';
43
+ export const CLOSE_QR_DIALOG = 'CLOSE_QR_DIALOG';
44
+
45
+ // Block Colors Actions
46
+ export const SET_BLOCK_COLOR = 'SET_BLOCK_COLOR';
47
+
48
+ // Page Management Actions
49
+ export const SET_PAGE_COUNT = 'SET_PAGE_COUNT';
50
+
51
+ // Clear Redux
52
+ export const CLEAR_REDUX: string = 'CLEAR_REDUX';
@@ -0,0 +1,54 @@
1
+ import {
2
+ SET_QR_URL,
3
+ SET_UTM_SOURCE,
4
+ SET_UTM_MEDIUM,
5
+ SET_UTM_CAMPAIGN_NAME,
6
+ SET_CUSTOM_UTMS,
7
+ CLEAR_QR_FIELDS,
8
+ SET_IS_QR,
9
+ SET_QR_DIALOG,
10
+ CLOSE_QR_DIALOG,
11
+ } from '../actions/action-types';
12
+
13
+ export const setIsQR = (isQR: boolean) => ({
14
+ type: SET_IS_QR,
15
+ payload: isQR,
16
+ });
17
+
18
+ export const setQrUrl = (url: string) => ({
19
+ type: SET_QR_URL,
20
+ payload: url,
21
+ });
22
+
23
+ export const setUtmSource = (utmSource: string) => ({
24
+ type: SET_UTM_SOURCE,
25
+ payload: utmSource,
26
+ });
27
+
28
+ export const setUtmMedium = (utmMedium: string) => ({
29
+ type: SET_UTM_MEDIUM,
30
+ payload: utmMedium,
31
+ });
32
+
33
+ export const setUtmCampaignName = (utmCampaignName: string) => ({
34
+ type: SET_UTM_CAMPAIGN_NAME,
35
+ payload: utmCampaignName,
36
+ });
37
+
38
+ export const setCustomUtms = (customUtms: Record<string, any>) => ({
39
+ type: SET_CUSTOM_UTMS,
40
+ payload: customUtms,
41
+ });
42
+
43
+ export const clearQrFields = () => ({
44
+ type: CLEAR_QR_FIELDS,
45
+ });
46
+
47
+ export const setQrDialog = (open: boolean, model: string = '') => ({
48
+ type: SET_QR_DIALOG,
49
+ payload: { open, model },
50
+ });
51
+
52
+ export const closeQrDialog = () => ({
53
+ type: CLOSE_QR_DIALOG,
54
+ });
@@ -0,0 +1,16 @@
1
+ import { AppDispatch } from "../store";
2
+ import { SET_SUCCESS_SNACKBAR, SET_ERROR_SNACKBAR, CLEAR_SNACKBAR } from "./action-types"
3
+
4
+ const success = (message: string, heading: string = '') => (dispatch: AppDispatch) => {
5
+ dispatch({ type: SET_SUCCESS_SNACKBAR, payload: { message, heading } });
6
+ }
7
+
8
+ const failure = (message: string, heading: string = '') => (dispatch: AppDispatch) => {
9
+ dispatch({ type: SET_ERROR_SNACKBAR, payload: { message, heading } });
10
+ }
11
+
12
+ const closeSnackbar = () => (dispatch: AppDispatch) => {
13
+ dispatch({ type: CLEAR_SNACKBAR });
14
+ }
15
+
16
+ export { success, failure, closeSnackbar }
@@ -0,0 +1,236 @@
1
+ import { AppDispatch } from '../store';
2
+
3
+ // Utils
4
+ import { get, post, patch } from '../../utils/api';
5
+
6
+ // Action Types
7
+ import {
8
+ TEMPLATE_SEARCH,
9
+ CLEAR_ALL_TEMPLATE,
10
+ SELECT_PRODUCT,
11
+ SELECT_POSTCARD,
12
+ CLEAR_TEMPLATE_FIELDS,
13
+ LOAD_DATA_FROM_LOCAL_STORAGE,
14
+ SET_PAGE_COUNT,
15
+ SET_PRODUCTS,
16
+ } from './action-types';
17
+
18
+ /**
19
+ * Uploads a template using the provided template form data.
20
+ *
21
+ * @param {FormData} templateFormData - The form data containing the template files to upload.
22
+ * @returns {Promise<any>} - A promise that resolves with the response from the server.
23
+ * @throws {Error} - If an error occurs during the upload process.
24
+ */
25
+ const uploadTemplate = async (templateFormData: FormData): Promise<unknown> => {
26
+ try {
27
+ const response = await post('/templates/upload', templateFormData);
28
+ return response;
29
+ } catch (error: any) {
30
+ return error.response;
31
+ }
32
+ };
33
+
34
+
35
+ const getAllTemplatesByTab = async (payload: any) => {
36
+ try {
37
+ const response: any = await post('/templates/by-tab', payload);
38
+ return response?.data?.data;
39
+ } catch (error: any) {
40
+ return error.response;
41
+ }
42
+ }
43
+
44
+ /**
45
+ * Loads form data to the store.
46
+ *
47
+ * @param {string} data - The form data in JSON format.
48
+ * @returns {void} - Dispatches an action to the Redux store.
49
+ */
50
+ const loadFormDataToStore = (data: string) => (dispatch: AppDispatch): void => {
51
+ try {
52
+ const parsedData = JSON.parse(data);
53
+ dispatch({
54
+ type: LOAD_DATA_FROM_LOCAL_STORAGE,
55
+ payload: { data: parsedData },
56
+ });
57
+ } catch (error) {
58
+ console.error(error);
59
+ }
60
+ };
61
+
62
+ /**
63
+ * Downloads the proof for the provided data.
64
+ *
65
+ * @param {object} data - The data for which the proof is requested.
66
+ * @returns {Promise<any>} - The response object from the POST request.
67
+ * @throws {object} - The error response if there is an error.
68
+ */
69
+ const downloadProof = async (data: object): Promise<unknown> => {
70
+ try {
71
+ const response = await post('/view-proof-cloud', data);
72
+ return response;
73
+ } catch (error: any) {
74
+ return error.response;
75
+ }
76
+ };
77
+
78
+
79
+ /**
80
+ * Downloads the envelope for the provided data.
81
+ *
82
+ * @param {object} data - The data for which the proof is requested.
83
+ * @returns {Promise<any>} - The response object from the POST request.
84
+ * @throws {object} - The error response if there is an error.
85
+ */
86
+ const envelopeProof = async (data: object): Promise<unknown> => {
87
+ try {
88
+ const response = await post('/download-envelope-proof', data);
89
+ return response;
90
+ } catch (error: any) {
91
+ return error.response;
92
+ }
93
+ };
94
+
95
+
96
+ /**
97
+ * Uploads a file.
98
+ *
99
+ * @param {File} file - The file to upload.
100
+ * @returns {Promise<string>} - The file path of the uploaded file.
101
+ * @throws {object} - The error response if there is an error.
102
+ */
103
+ const uploadFile = async (file: File): Promise<any> => {
104
+ try {
105
+ const formData = new FormData();
106
+ formData.append('image', file);
107
+ const response = await post('/uploadFile', formData) as Record<string, any>;
108
+
109
+ if (response?.data?.data?.filePath) {
110
+ return response?.data?.data?.filePath;
111
+ } else {
112
+ return false;
113
+ }
114
+ } catch (error: any) {
115
+ return error?.response;
116
+ }
117
+ };
118
+
119
+
120
+ /**
121
+ * Clears template fields.
122
+ *
123
+ * @returns {Function} - The thunk function.
124
+ */
125
+ const clearTemplateFields = () => (dispatch: AppDispatch) => {
126
+ dispatch({ type: CLEAR_TEMPLATE_FIELDS });
127
+ };
128
+
129
+
130
+ /**
131
+ * Selects a product.
132
+ *
133
+ * @param {any} product - The selected product.
134
+ * @param {string} [productType=''] - The type of the selected product.
135
+ * @returns {Function} - The thunk function.
136
+ */
137
+ const selectProduct =
138
+ (product: any, productType = '') =>
139
+ (dispatch: AppDispatch) => {
140
+ dispatch({ type: SELECT_PRODUCT, payload: { product, productType } });
141
+ };
142
+
143
+
144
+ /**
145
+ * Selects a postcard.
146
+ *
147
+ * @param {any} product - The selected product.
148
+ * @param {string} productType - The type of the selected product.
149
+ * @returns {Function} - The thunk function.
150
+ */
151
+ const selectPostCard = (product: any, productType: string) => (dispatch: AppDispatch) => {
152
+ dispatch({ type: SELECT_POSTCARD, payload: { product, productType } });
153
+ };
154
+
155
+ /**
156
+ * Clears all templates.
157
+ *
158
+ * @returns {Function} - The thunk function.
159
+ */
160
+ const clearAllTemplates = () => (dispatch: AppDispatch) => {
161
+ dispatch({ type: CLEAR_ALL_TEMPLATE });
162
+ };
163
+
164
+ /**
165
+ * Searches and advances change.
166
+ *
167
+ * @param {string} name - The name of the field.
168
+ * @param {any} value - The value of the field.
169
+ * @returns {Function} - The thunk function.
170
+ */
171
+ const searchAndAdvanceChange = (name: string, value: any) => (dispatch: AppDispatch) => {
172
+ dispatch({ type: TEMPLATE_SEARCH, payload: { name, value } });
173
+ };
174
+
175
+ /**
176
+ * Retrieves all template categories from the server using an HTTP GET request.
177
+ *
178
+ * @returns {Promise<any>} - A promise that resolves with the response from the server.
179
+ * @throws {object} - The error response if there is an error.
180
+ */
181
+ const getAllTemplateCategories = async (): Promise<any> => {
182
+ try {
183
+ const response = await get('/categories');
184
+ return response;
185
+ } catch (error: any) {
186
+ return error.response;
187
+ }
188
+ };
189
+
190
+ /**
191
+ * Sets the page count for the current template.
192
+ *
193
+ * @param {number} count - The number of pages.
194
+ * @returns {Function} - The thunk function.
195
+ */
196
+ const setPageCount = (count: number) => (dispatch: AppDispatch) => {
197
+ dispatch({ type: SET_PAGE_COUNT, payload: count });
198
+ };
199
+
200
+ /**
201
+ * Fetches products from the API and updates the store.
202
+ *
203
+ * @returns {Function} - The thunk function.
204
+ */
205
+ const fetchProducts = () => async (dispatch: AppDispatch) => {
206
+ try {
207
+ const response: any = await get('/products');
208
+ if (response?.data?.data) {
209
+ dispatch({ type: SET_PRODUCTS, payload: response.data.data });
210
+ } else {
211
+ dispatch({ type: SET_PRODUCTS, payload: [] });
212
+ }
213
+ return response;
214
+ } catch (error: any) {
215
+ console.error('Error fetching products:', error);
216
+ return error;
217
+ }
218
+ };
219
+
220
+ export {
221
+ uploadTemplate,
222
+ getAllTemplatesByTab,
223
+ searchAndAdvanceChange,
224
+ clearAllTemplates,
225
+ selectProduct,
226
+ selectPostCard,
227
+ clearTemplateFields,
228
+ loadFormDataToStore,
229
+ uploadFile,
230
+ downloadProof,
231
+ envelopeProof,
232
+ getAllTemplateCategories,
233
+ setPageCount,
234
+ fetchProducts
235
+ };
236
+
@@ -0,0 +1,99 @@
1
+ import {
2
+ SET_CUSTOM_FIELDS,
3
+ SET_PLATFORM_FIELDS,
4
+ SET_CUSTOM_FIELDS_V2,
5
+ } from '../actions/action-types';
6
+
7
+ export interface CustomFieldState {
8
+ customFields: any[];
9
+ customFieldsV2: any[];
10
+ platformFields: any[];
11
+ defaultDynamicFields: any[];
12
+ }
13
+
14
+ const initialState: CustomFieldState = {
15
+ customFields: [],
16
+ customFieldsV2: [],
17
+ platformFields: [],
18
+ defaultDynamicFields: [
19
+ {
20
+ value: "First Name",
21
+ key: "{{C.FIRST_NAME}}",
22
+ defaultValue: "John",
23
+ },
24
+ {
25
+ value: "Last Name",
26
+ key: "{{C.LAST_NAME}}",
27
+ defaultValue: "Doe",
28
+ },
29
+ {
30
+ value: "Full Name",
31
+ key: "{{C.FIRST_NAME}} {{C.LAST_NAME}}",
32
+ defaultValue: "John Doe",
33
+ },
34
+ {
35
+ value: "Company Name",
36
+ key: "{{C.COMPANY_NAME}}",
37
+ defaultValue: "ABC Company, Inc.",
38
+ },
39
+ {
40
+ value: "Mailing Address 1",
41
+ key: "{{C.ADDRESS_1}}",
42
+ defaultValue: "123 Main Street",
43
+ },
44
+ {
45
+ value: "Mailing Address 2",
46
+ key: "{{C.ADDRESS_2}}",
47
+ defaultValue: "Suite 2",
48
+ },
49
+ {
50
+ value: "Mailing City",
51
+ key: "{{C.CITY}}",
52
+ defaultValue: "Lawrence",
53
+ },
54
+ {
55
+ value: "Mailing State",
56
+ key: "{{C.STATE}}",
57
+ defaultValue: "MA",
58
+ },
59
+ {
60
+ value: "Mailing Zip Code",
61
+ key: "{{C.ZIP_CODE}}",
62
+ defaultValue: "01843",
63
+ },
64
+ {
65
+ value: "Contact Phone Number",
66
+ key: "{{C.PHONE_NUMBER}}",
67
+ defaultValue: "(555) 278-9389",
68
+ },
69
+ {
70
+ value: "Contact Email",
71
+ key: "{{C.EMAIL}}",
72
+ defaultValue: "johndoe@gmail.com",
73
+ },
74
+ ],
75
+ };
76
+
77
+ const customFieldReducer = (state = initialState, action: any): CustomFieldState => {
78
+ switch (action.type) {
79
+ case SET_CUSTOM_FIELDS:
80
+ return {
81
+ ...state,
82
+ customFields: action.payload,
83
+ };
84
+ case SET_CUSTOM_FIELDS_V2:
85
+ return {
86
+ ...state,
87
+ customFieldsV2: action.payload,
88
+ };
89
+ case SET_PLATFORM_FIELDS:
90
+ return {
91
+ ...state,
92
+ platformFields: action.payload,
93
+ };
94
+ default:
95
+ return state;
96
+ }
97
+ };
98
+
99
+ export { customFieldReducer };
@@ -0,0 +1,58 @@
1
+ import { SET_QR_URL, SET_UTM_SOURCE, SET_UTM_MEDIUM, SET_UTM_CAMPAIGN_NAME, SET_CUSTOM_UTMS, CLEAR_QR_FIELDS, SET_IS_QR, SET_QR_DIALOG, CLOSE_QR_DIALOG } from '../actions/action-types';
2
+
3
+ export interface CustomQRCodeState {
4
+ url: string;
5
+ utmSource: string;
6
+ utmMedium: string;
7
+ utmCampaignName: string;
8
+ customUtms: Record<string, any>;
9
+ isQR: boolean;
10
+ dialog: {
11
+ open: boolean;
12
+ model: string;
13
+ };
14
+ }
15
+
16
+ const initialState: CustomQRCodeState = {
17
+ url: '',
18
+ utmSource: 'direct mail',
19
+ utmMedium: 'QR Code',
20
+ utmCampaignName: '',
21
+ customUtms: {},
22
+ isQR: false,
23
+ dialog: {
24
+ open: false,
25
+ model: '',
26
+ },
27
+ };
28
+
29
+
30
+ const customQRCodeReducer = (
31
+ state = initialState,
32
+ action: any
33
+ ): CustomQRCodeState => {
34
+ switch (action.type) {
35
+ case SET_QR_URL:
36
+ return { ...state, url: action.payload };
37
+ case SET_UTM_SOURCE:
38
+ return { ...state, utmSource: action.payload };
39
+ case SET_UTM_MEDIUM:
40
+ return { ...state, utmMedium: action.payload };
41
+ case SET_UTM_CAMPAIGN_NAME:
42
+ return { ...state, utmCampaignName: action.payload };
43
+ case SET_CUSTOM_UTMS:
44
+ return { ...state, customUtms: action.payload };
45
+ case SET_IS_QR:
46
+ return { ...state, isQR: action.payload };
47
+ case SET_QR_DIALOG:
48
+ return { ...state, dialog: action.payload };
49
+ case CLOSE_QR_DIALOG:
50
+ return { ...state, dialog: { open: false, model: '' } };
51
+ case CLEAR_QR_FIELDS:
52
+ return { ...initialState };
53
+ default:
54
+ return state;
55
+ }
56
+ }
57
+
58
+ export { customQRCodeReducer };
@@ -0,0 +1,15 @@
1
+ import { combineReducers } from 'redux';
2
+ import { templateReducer } from './templateReducer';
3
+ import { customFieldReducer } from './customFieldReducer';
4
+ import { snackbarReducers } from './snackbarReducer';
5
+ import { customQRCodeReducer } from './customQRCodeReducer';
6
+
7
+ const rootReducer = combineReducers({
8
+ templates: templateReducer,
9
+ customFields: customFieldReducer,
10
+ snackbarReducers,
11
+ customQRCode: customQRCodeReducer,
12
+ });
13
+
14
+ export type RootState = ReturnType<typeof rootReducer>;
15
+ export default rootReducer;
@@ -0,0 +1,40 @@
1
+ //Actions
2
+ import { SET_SUCCESS_SNACKBAR, SET_ERROR_SNACKBAR, CLEAR_SNACKBAR } from "../actions/action-types"
3
+
4
+ // Define the initial state type
5
+ interface SnackbarState {
6
+ snackbar: {
7
+ open: boolean;
8
+ status: 'success' | 'error';
9
+ heading: string;
10
+ message: string;
11
+ };
12
+ }
13
+
14
+ const initialState: SnackbarState = {
15
+ snackbar: {
16
+ open: false,
17
+ status: 'success',
18
+ heading: '',
19
+ message: '',
20
+ },
21
+ };
22
+ export type ActionPayload = {
23
+ type: string;
24
+ payload: any;
25
+ }
26
+
27
+ const snackbarReducers = (state: SnackbarState = initialState, { type, payload } : ActionPayload) => {
28
+ switch (type) {
29
+ case SET_SUCCESS_SNACKBAR:
30
+ return { ...state, snackbar: { ...state.snackbar, ...payload, open: true, status: 'success' } };
31
+ case SET_ERROR_SNACKBAR:
32
+ return { ...state, snackbar: { ...state.snackbar, ...payload, open: true, status: 'error' } };
33
+ case CLEAR_SNACKBAR:
34
+ return { ...state, snackbar: { ...state.snackbar, open: false, status: 'success', message: '', heading: '' } };
35
+ default:
36
+ return state;
37
+ }
38
+ };
39
+
40
+ export { snackbarReducers };