@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,80 @@
1
+ .block-colors-section {
2
+ padding: 16px;
3
+
4
+ .block-colors-header {
5
+ margin-bottom: 20px;
6
+
7
+ .title {
8
+ font-size: 14px;
9
+ font-weight: 600;
10
+ color: var(--text-color);
11
+ margin-bottom: 8px;
12
+ line-height: 1.4;
13
+ }
14
+
15
+ .description {
16
+ font-size: 12px;
17
+ color: var(--text-color);
18
+ opacity: 0.8;
19
+ line-height: 1.4;
20
+ }
21
+ }
22
+
23
+ .color-palette {
24
+ display: grid;
25
+ grid-template-columns: repeat(6, 1fr);
26
+ gap: 8px;
27
+ max-width: 100%;
28
+
29
+ .color-swatch {
30
+ width: 100%;
31
+ aspect-ratio: 1;
32
+ border: 1px solid #e0e0e0;
33
+ border-radius: 4px;
34
+ cursor: pointer;
35
+ transition: all 0.2s ease;
36
+ position: relative;
37
+
38
+ &:hover {
39
+ transform: scale(1.05);
40
+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
41
+ }
42
+
43
+ &.selected {
44
+ border: 2px solid var(--primary-color);
45
+ box-shadow: 0 0 0 2px rgba(var(--primary-color-rgb), 0.2);
46
+
47
+ &::after {
48
+ content: '✓';
49
+ position: absolute;
50
+ top: 50%;
51
+ left: 50%;
52
+ transform: translate(-50%, -50%);
53
+ color: #000;
54
+ font-weight: bold;
55
+ font-size: 12px;
56
+ text-shadow: 0 0 2px rgba(255, 255, 255, 0.8);
57
+ }
58
+ }
59
+ }
60
+ }
61
+ }
62
+
63
+ // Responsive adjustments
64
+ @media (max-width: 768px) {
65
+ .block-colors-section {
66
+ .color-palette {
67
+ grid-template-columns: repeat(4, 1fr);
68
+ gap: 6px;
69
+ }
70
+ }
71
+ }
72
+
73
+ @media (max-width: 480px) {
74
+ .block-colors-section {
75
+ .color-palette {
76
+ grid-template-columns: repeat(3, 1fr);
77
+ gap: 4px;
78
+ }
79
+ }
80
+ }
@@ -0,0 +1,547 @@
1
+ import React, { useEffect, useState } from 'react';
2
+
3
+ // Polotno and thrid party libraries
4
+ import { observer } from 'mobx-react-lite';
5
+ import { SectionTab, } from 'polotno/side-panel';
6
+ import type { StoreType } from 'polotno/model/store';
7
+ import type { TemplatesSection } from 'polotno/side-panel';
8
+
9
+ // Hooks
10
+ import { useDispatch, useSelector } from 'react-redux';
11
+ import { AppDispatch, RootState } from '../../../redux/store';
12
+
13
+ // Actions
14
+ import { failure, success } from '../../../redux/actions/snackbarActions';
15
+ import { SET_CUSTOM_FIELDS, SET_CUSTOM_FIELDS_V2, SET_PLATFORM_FIELDS } from '../../../redux/actions/action-types';
16
+
17
+ // Components
18
+ import Button from '../../GenericUIBlocks/Button';
19
+ import GeneralTootip from '../../GenericUIBlocks/GeneralTooltip';
20
+
21
+ // Utils
22
+ import { copyToClipboard } from '../../../utils/helper';
23
+
24
+ // Icons
25
+ import InfoIcon from '../../../assets/images/templates/info-icon';
26
+ import ContentCopyIcon from '../../..//assets/images/templates/content-copy-icon';
27
+ import Field from '../../../assets/images/templates/field';
28
+
29
+ // Styles
30
+ import './styles.scss'
31
+
32
+
33
+ type SideSection = typeof TemplatesSection;
34
+
35
+ const iconButtonStyles = {
36
+ backgroundColor: 'transparent',
37
+ }
38
+
39
+ type CustomFieldsSectionProps = {
40
+ store: StoreType;
41
+ active: boolean;
42
+ allowSenderFields?: boolean;
43
+ allowPropertyFields?: boolean;
44
+ excludedFields?: string[] | null;
45
+ platformName?: string,
46
+ onClick: () => void;
47
+ onGetCustomFields?: () => Promise<any>;
48
+ };
49
+
50
+ const CustomFieldSection: SideSection = {
51
+ name: 'Fields',
52
+ Tab: observer(
53
+ (props: { store: StoreType; active: boolean; onClick: () => void }) => (
54
+ <SectionTab name="Fields" {...props}>
55
+ <Field fill="var(--text-color)" />
56
+ </SectionTab>
57
+ )
58
+ ) as SideSection['Tab'],
59
+
60
+ Panel: observer(({ store, onGetCustomFields, allowSenderFields, excludedFields, allowPropertyFields, platformName }: CustomFieldsSectionProps) => {
61
+ const [isShowDialog, setIsShowDialog] = useState(false);
62
+ const [search, setSearch] = useState('');
63
+ const [filteredDynamicFields, setFilteredDynamicFields] = useState([]);
64
+ const [filteredCustomFields, setFilteredCustomFields] = useState([]);
65
+ const [filteredMiscFields, setFilteredMiscFields] = useState([]);
66
+ const [filteredPropertyFields, setFilteredPropertyFields] = useState([]);
67
+ const [filteredCustomFieldsV2, setFilteredCustomFieldsV2] = useState([]);
68
+ const [filteredSenderFields, setFilteredSenderFields] = useState([]);
69
+ const [filteredPlatformFields, setFilteredPlatformFields] = useState([]);
70
+
71
+
72
+ const dispatch = useDispatch<AppDispatch>();
73
+
74
+ const customFields = useSelector(
75
+ (state: RootState) => state.customFields.customFields
76
+ ) as Record<string, any>;
77
+
78
+ const customFieldsV2 = useSelector(
79
+ (state: RootState) => state.customFields.customFieldsV2
80
+ ) as Record<string, any>;
81
+
82
+ const platformFields = useSelector(
83
+ (state: RootState) => state.customFields.platformFields
84
+ ) as Record<string, any>;
85
+
86
+ const defaultDynamicFields = useSelector(
87
+ (state: RootState) => state.customFields.defaultDynamicFields
88
+ ) as Record<string, any>;
89
+
90
+ const defaultSenderFields = useSelector(
91
+ (state: RootState) => state.templates.defaultSenderFields
92
+ ) as Record<string, any>;
93
+
94
+ const defaultPropertyFields = useSelector(
95
+ (state: RootState) => state.templates.defaultPropertyFields
96
+ ) as Record<string, any>;
97
+
98
+ const defaultMiscFields = useSelector(
99
+ (state: RootState) => state.templates.defaultMiscFields
100
+ ) as Record<string, any>;
101
+
102
+ const product = useSelector((state: RootState) => state.templates.product);
103
+ const currentTemplateType = product?.productType;
104
+ const currentProductId = product?.id || '';
105
+
106
+ const handleShowDialog = () => {
107
+ setIsShowDialog((prev) => !prev);
108
+ };
109
+
110
+ const fetchCustomFields = async () => {
111
+ if (onGetCustomFields) {
112
+ const allCustomFields: any = await onGetCustomFields();
113
+ const platformFields: any = [];
114
+ const customFields: any = [];
115
+
116
+
117
+ if (allCustomFields?.version === 'v2') {
118
+ const flattenedFields = allCustomFields.customFields.flatMap((section: { fields: any; }) => section.fields);
119
+
120
+ for (const field of flattenedFields) {
121
+ (field.isPlatformField ? platformFields : customFields).push(field);
122
+ }
123
+ const filteredCustomFields = allCustomFields?.customFields
124
+ .map((customField: any) => ({
125
+ ...customField,
126
+ fields: customField.fields.filter((field: any) => customFields.includes(field))
127
+ }))
128
+ .filter((section: { fields: any[] }) => section.fields.length > 0);
129
+
130
+ if (allCustomFields?.customFields?.length) {
131
+ dispatch({ type: SET_CUSTOM_FIELDS, payload: [] });
132
+ dispatch({ type: SET_CUSTOM_FIELDS_V2, payload: filteredCustomFields });
133
+ } else {
134
+ dispatch({ type: SET_CUSTOM_FIELDS, payload: [] });
135
+ dispatch({ type: SET_CUSTOM_FIELDS_V2, payload: [] });
136
+ }
137
+
138
+ if (platformFields.length) {
139
+ dispatch({ type: SET_PLATFORM_FIELDS, payload: platformFields });
140
+ } else {
141
+ dispatch({ type: SET_PLATFORM_FIELDS, payload: [] });
142
+ }
143
+
144
+ } else {
145
+
146
+ for (const field of allCustomFields) {
147
+ (field.isPlatformField ? platformFields : customFields).push(field);
148
+ }
149
+
150
+ if (customFields.length) {
151
+ dispatch({ type: SET_CUSTOM_FIELDS, payload: customFields });
152
+ } else {
153
+ dispatch({ type: SET_CUSTOM_FIELDS, payload: [] });
154
+ }
155
+
156
+ if (platformFields.length) {
157
+ dispatch({ type: SET_PLATFORM_FIELDS, payload: platformFields });
158
+ } else {
159
+ dispatch({ type: SET_PLATFORM_FIELDS, payload: [] });
160
+ }
161
+ }
162
+ }
163
+ };
164
+
165
+ const copyCustomFieldText = (key: string, value: string = '') => {
166
+ if (currentTemplateType === 'Real Penned Letter' && +currentProductId === 16) {
167
+ let modifiedString = key.replace(/{{/g, '((').replace(/}}/g, '))');
168
+ copyToClipboard(modifiedString);
169
+ dispatch(success(`${value} Copied`));
170
+ } else {
171
+ copyToClipboard(key);
172
+ dispatch(success(`${value} Copied`));
173
+ }
174
+ };
175
+
176
+ useEffect(() => {
177
+ fetchCustomFields();
178
+ }, []);
179
+
180
+ useEffect(() => {
181
+ setFilteredDynamicFields(
182
+ defaultDynamicFields
183
+ ?.filter(({ key }: any) => !excludedFields?.includes(key))
184
+ .filter(({ value }: any) =>
185
+ value?.toLowerCase().includes(search?.toLowerCase())
186
+ )
187
+ );
188
+
189
+ setFilteredMiscFields(defaultMiscFields.filter(({ value }: any) =>
190
+ value?.toLowerCase().includes(search?.toLowerCase())
191
+ ))
192
+
193
+ setFilteredPropertyFields(
194
+ allowPropertyFields
195
+ ? defaultPropertyFields
196
+ ?.filter(({ key }: any) => !excludedFields?.includes(key))
197
+ ?.filter(({ value }: any) =>
198
+ value?.toLowerCase().includes(search?.toLowerCase())
199
+ )
200
+ : []
201
+ );
202
+
203
+ setFilteredSenderFields(
204
+ allowSenderFields
205
+ ? defaultSenderFields?.filter(({ key }: any) => !excludedFields?.includes(key))?.filter(({ value }: any) =>
206
+ value?.toLowerCase().includes(search?.toLowerCase())
207
+ )
208
+ : []
209
+ );
210
+
211
+ setFilteredPlatformFields(platformFields
212
+ ?.filter(({ key }: any) => !excludedFields?.includes(key))
213
+ ?.filter(({ value }: any) =>
214
+ value?.toLowerCase().includes(search?.toLowerCase())
215
+ ));
216
+
217
+ setFilteredCustomFields(customFields
218
+ ?.filter(({ key }: any) => !excludedFields?.includes(key))
219
+ ?.filter(({ value }: any) =>
220
+ value?.toLowerCase().includes(search?.toLowerCase())
221
+ ));
222
+
223
+ if (customFieldsV2.length) {
224
+ const newFilteredData = customFieldsV2
225
+ .map((section: { fields: any[]; }) => ({
226
+ ...section,
227
+ fields: section.fields.filter((field: { value: string; }) =>
228
+ field.value?.toLowerCase().includes(search?.toLowerCase())
229
+ )
230
+ })).filter((section: any) => section?.fields?.length > 0);
231
+
232
+ setFilteredCustomFieldsV2(newFilteredData);
233
+ } else {
234
+ setFilteredDynamicFields(
235
+ defaultDynamicFields
236
+ ?.filter(({ key }: any) => !excludedFields?.includes(key))
237
+ ?.filter(({ value }: any) =>
238
+ value?.toLowerCase().includes(search?.toLowerCase())
239
+ )
240
+ );
241
+ }
242
+
243
+ }, [search, defaultSenderFields, platformFields, customFields, defaultDynamicFields, customFieldsV2]);
244
+
245
+ return (
246
+ <div style={{
247
+ height: "100%",
248
+ display: "flex",
249
+ flexDirection: "column"
250
+ }}>
251
+ <div className="bp5-input-group fields-search">
252
+ <span aria-hidden="true" className="bp5-icon bp5-icon-search">
253
+ <svg data-icon="search" height="16" role="img" viewBox="0 0 16 16" width="16">
254
+ <path d="M15.55 13.43l-2.67-2.68a6.94 6.94 0 001.11-3.76c0-3.87-3.13-7-7-7s-7 3.13-7 7 3.13 7 7 7c1.39 0 2.68-.42 3.76-1.11l2.68 2.67a1.498 1.498 0 102.12-2.12zm-8.56-1.44c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5z" fillRule="evenodd"></path>
255
+ </svg>
256
+ </span>
257
+ <input type="search" placeholder="Search..." className="bp5-input"
258
+ onChange={(e) => setSearch(e.target.value)}
259
+ value={search}
260
+ />
261
+ </div>
262
+ <div className="dynamic-content">
263
+ {filteredDynamicFields.length > 0 &&
264
+ <>
265
+ <div className="dynamic-content__top">
266
+ <div>
267
+ <span className="title">Contact Fields</span>
268
+ <InfoIcon fill="var(--primary-color)" className="infoIcon" />
269
+ <GeneralTootip
270
+ anchorSelect=".infoIcon"
271
+ place="bottom"
272
+ className='contact-info-tooltip'
273
+ title="Merge fields allow you to personalize your mailer with contact information."
274
+ />
275
+ </div>
276
+ </div>
277
+ {filteredDynamicFields
278
+ ?.map(
279
+ ({ key, value }: { key: string; value: string }, i: number) => (
280
+ <div style={{ display: 'flex', alignItems: 'center' }} key={i + '_contact'}>
281
+ <span
282
+ className="contact-element"
283
+ onClick={() =>
284
+ copyCustomFieldText(key, value)
285
+ }
286
+ >
287
+ {value}
288
+ </span>
289
+ <Button
290
+ style={iconButtonStyles}
291
+ onClick={() => copyCustomFieldText(key, value)}
292
+ backdrop={false}
293
+ >
294
+ <ContentCopyIcon className="copy" />
295
+ </Button>
296
+ </div>
297
+ )
298
+ )}
299
+ </>}
300
+ {allowPropertyFields && filteredPropertyFields.length > 0 && <>
301
+ <hr className="divider" />
302
+ <div className="dynamic-content__top">
303
+ <div>
304
+ <span className="title">Property Address</span>
305
+ <InfoIcon fill="var(--primary-color)" className="property" />
306
+ <GeneralTootip
307
+ anchorSelect=".property"
308
+ place="bottom"
309
+ title="You can add property fields to your template."
310
+ />
311
+ </div>
312
+ </div>
313
+ {filteredPropertyFields
314
+ ?.map(
315
+ ({ key, value }: { key: string; value: string }, i: number) => (
316
+ <div style={{ display: 'flex', alignItems: 'center' }} key={i + '_property'}>
317
+ <span
318
+ className="contact-element"
319
+ onClick={() =>
320
+ copyCustomFieldText(key, value)
321
+ }
322
+ >
323
+ {value}
324
+ </span>
325
+ <Button
326
+ style={iconButtonStyles}
327
+ onClick={() => copyCustomFieldText(key, value)}
328
+ backdrop={false}
329
+ >
330
+ <ContentCopyIcon className="copy" />
331
+ </Button>
332
+ </div>
333
+ )
334
+ )}
335
+ </>}
336
+ {allowSenderFields && filteredSenderFields.length > 0 && <>
337
+ <hr className="divider" />
338
+ <div className="dynamic-content__top">
339
+ <div>
340
+ <span className="title">Sender Fields</span>
341
+ <InfoIcon fill="var(--primary-color)" className="sender" />
342
+ <GeneralTootip
343
+ anchorSelect=".sender"
344
+ place="bottom"
345
+ title="You can add sender fields to your template."
346
+ />
347
+ </div>
348
+ </div>
349
+ {filteredSenderFields
350
+ ?.map(
351
+ ({ key, value }: { key: string; value: string }, i: number) => (
352
+ <div style={{ display: 'flex', alignItems: 'center' }} key={i + '_sender'}>
353
+ <span
354
+ className="contact-element"
355
+ onClick={() =>
356
+ copyCustomFieldText(key, value)
357
+ }
358
+ >
359
+ {value}
360
+ </span>
361
+ <Button
362
+ style={iconButtonStyles}
363
+ onClick={() => copyCustomFieldText(key, value)}
364
+ backdrop={false}
365
+ >
366
+ <ContentCopyIcon className="copy" />
367
+ </Button>
368
+ </div>
369
+ )
370
+ )}
371
+ </>}
372
+ <GeneralTootip anchorSelect=".copy" place="bottom" title="Copy" />
373
+ {onGetCustomFields && platformFields?.length > 0 && (
374
+ <>
375
+ <hr className="divider" />
376
+ <div className="dynamic-content__top">
377
+ <div>
378
+ <span className="title">{platformName ? `${platformName} Fields` : 'OLC Fields'}</span>
379
+ <InfoIcon fill="var(--primary-color)" className="platform" />
380
+ <GeneralTootip
381
+ anchorSelect=".platform"
382
+ place="bottom"
383
+ title={`You can add ${platformName ? `${platformName} Fields` : 'OLC Fields'} to your template.`}
384
+ />
385
+ </div>
386
+ <Button onClick={handleShowDialog}></Button>
387
+ </div>
388
+ {filteredPlatformFields
389
+ ?.map(
390
+ ({ key, value }: { key: string; value: string }, i: number) => (
391
+ <div style={{ display: 'flex', alignItems: 'center' }} key={i + '_platform'}>
392
+ <span
393
+ className="contact-element"
394
+ onClick={() =>
395
+ copyCustomFieldText(key, value)
396
+ }
397
+ >
398
+ {value}
399
+ </span>
400
+ <Button
401
+ style={iconButtonStyles}
402
+ onClick={() => copyCustomFieldText(key, value)}
403
+ backdrop={false}
404
+ >
405
+ <ContentCopyIcon className="copy" />
406
+ </Button>
407
+ </div>
408
+ )
409
+ )}
410
+ </>
411
+ )
412
+ }
413
+ {onGetCustomFields && filteredCustomFieldsV2.length > 0 ?
414
+ filteredCustomFieldsV2.map((section: any, index: number): any => (
415
+ <div key={index + 'custom-section'}>
416
+ <hr className="divider" />
417
+ <div className="dynamic-content__top">
418
+ <div>
419
+ <span className="title">{section?.section}</span>
420
+ <InfoIcon fill="var(--primary-color)" className={section?.section
421
+ ?.toLowerCase()
422
+ .replace(/[^a-z0-9\s]/g, '')
423
+ .trim()
424
+ .replace(/\s+/g, '-')} />
425
+ <GeneralTootip
426
+ anchorSelect={`.${section?.section
427
+ ?.toLowerCase()
428
+ .replace(/[^a-z0-9\s]/g, '')
429
+ .trim()
430
+ .replace(/\s+/g, '-')}`}
431
+ place="bottom"
432
+ title={`You can add ${section?.section} to your template.`}
433
+ />
434
+ </div>
435
+
436
+ <Button onClick={handleShowDialog}></Button>
437
+ </div>
438
+
439
+ {section.fields.map(({ key, value }: { key: string; value: string }, i: number) => (
440
+ <div style={{ display: 'flex', alignItems: 'center' }} key={i + value}>
441
+ <span
442
+ className="contact-element"
443
+ onClick={() =>
444
+ copyCustomFieldText(key, value)
445
+ }
446
+ >
447
+ {value}
448
+ </span>
449
+ <Button
450
+ style={iconButtonStyles}
451
+ onClick={() => copyCustomFieldText(key, value)}
452
+ backdrop={false}
453
+ >
454
+ <ContentCopyIcon className="copy" />
455
+ </Button>
456
+ </div>
457
+ ))}
458
+ </div>
459
+ ))
460
+ : onGetCustomFields && customFields?.length > 0 && filteredCustomFields.length > 0 && (
461
+ <>
462
+ <hr className="divider" />
463
+ <div className="dynamic-content__top">
464
+ <div>
465
+ <span className="title">Custom Fields</span>
466
+ <InfoIcon fill="var(--primary-color)" className="custom" />
467
+ <GeneralTootip
468
+ anchorSelect=".custom"
469
+ place="bottom"
470
+ title="You can add custom fields to your template."
471
+ />
472
+ </div>
473
+ <Button onClick={handleShowDialog}></Button>
474
+ </div>
475
+ {filteredCustomFields
476
+ ?.map(
477
+ ({ key, value }: { key: string; value: string }, i: number) => (
478
+ <div style={{ display: 'flex', alignItems: 'center' }} key={i + '_custom'}>
479
+ <span
480
+ className="contact-element"
481
+ onClick={() =>
482
+ copyCustomFieldText(key, value)
483
+ }
484
+ >
485
+ {value}
486
+ </span>
487
+ <Button
488
+ style={iconButtonStyles}
489
+ onClick={() => copyCustomFieldText(key, value)}
490
+ backdrop={false}
491
+ >
492
+ <ContentCopyIcon className="copy" />
493
+ </Button>
494
+ </div>
495
+ )
496
+ )}
497
+ </>
498
+ )
499
+ }
500
+ {defaultMiscFields && filteredMiscFields.length > 0 && <>
501
+ <hr className="divider" />
502
+ <div className="dynamic-content__top">
503
+ <div>
504
+ <span className="title">Miscellaneous Fields</span>
505
+ <InfoIcon fill="var(--primary-color)" className="miscellaneous" />
506
+ <GeneralTootip
507
+ anchorSelect=".miscellaneous"
508
+ place="bottom"
509
+ title="You can add miscellaneous fields to your template."
510
+ />
511
+ </div>
512
+ </div>
513
+ {filteredMiscFields
514
+ ?.filter(({ key }) => !excludedFields?.includes(key))
515
+ ?.map(
516
+ ({ key, value }: { key: string; value: string }, i: number) => (
517
+ <div style={{ display: 'flex', alignItems: 'center' }} key={i + '_property'}>
518
+ <span
519
+ className="contact-element"
520
+ onClick={() =>
521
+ copyCustomFieldText(key, value)
522
+ }
523
+ >
524
+ {value}
525
+ </span>
526
+ <Button
527
+ style={iconButtonStyles}
528
+ onClick={() => copyCustomFieldText(key, value)}
529
+ backdrop={false}
530
+ >
531
+ <ContentCopyIcon className="copy" />
532
+ </Button>
533
+ </div>
534
+ )
535
+ )}
536
+ </>}
537
+ {filteredDynamicFields.length <= 0 && filteredCustomFieldsV2.length <= 0 && filteredPropertyFields.length <= 0 && filteredSenderFields.length <= 0 && filteredPlatformFields.length <= 0 && filteredCustomFields.length <= 0 &&
538
+ filteredMiscFields.length <= 0 &&
539
+ <div className="no-result">No results</div>
540
+ }
541
+ </div >
542
+ </div>
543
+ );
544
+ }) as unknown as SideSection['Panel'],
545
+ };
546
+
547
+ export default CustomFieldSection;
@@ -0,0 +1,64 @@
1
+ .dynamic-content {
2
+ & .dynamic-content__top {
3
+ display: flex;
4
+ flex-direction: row;
5
+ justify-content: space-between;
6
+ align-items: center;
7
+ margin: 8px auto;
8
+ & .title {
9
+ font-weight: 600;
10
+ font-size: 16px;
11
+ line-height: 19.36px;
12
+ color: var(--primary-color);
13
+ margin-right: 5px;
14
+ }
15
+ & .icon {
16
+ width: 12px;
17
+ height: 12px;
18
+ cursor: pointer;
19
+ }
20
+ & .contact-info-tooltip {
21
+ width: 90% !important;
22
+ max-width: fit-content !important;
23
+ }
24
+ & .custom-add-on-tooltip {
25
+ width: 90% !important;
26
+ max-width: fit-content !important;
27
+ }
28
+ svg{
29
+ &:focus{
30
+ outline: none !important;
31
+ }
32
+ }
33
+ }
34
+
35
+ & .divider {
36
+ margin-top: 10px;
37
+ color: #44424145;
38
+ }
39
+
40
+ & .contact-element {
41
+ width: 100%;
42
+ border-radius: 3px;
43
+ border: 0.5px solid var(--border-color);
44
+ text-align: center;
45
+ height: 35px;
46
+ line-height: 35px;
47
+ margin: 5px auto;
48
+ cursor: pointer;
49
+ transition: 0.1s ease-in all;
50
+
51
+ &:hover {
52
+ background-color: var(--secondary-color);
53
+ }
54
+ }
55
+ .copy {
56
+ fill: #000 !important;
57
+ }
58
+ }
59
+
60
+ .no-result {
61
+ display: flex;
62
+ justify-content: center;
63
+ margin: 20px;
64
+ }