@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.
- package/.eslintignore +1 -0
- package/.eslintrc.cjs +18 -0
- package/.eslintrc.yml +47 -0
- package/.github/workflows/publish-beta.yml +154 -0
- package/.github/workflows/publish-production.yml +143 -0
- package/.prettierignore +3 -0
- package/.prettierrc.yml +5 -0
- package/CHANGELOG.md +4 -0
- package/babel.config.json +10 -0
- package/build/index.js +82 -82
- package/build/index.js.map +1 -1
- package/build/types/version.d.ts +1 -1
- package/examples/.eslintrc.yml +4 -0
- package/index.html +18 -0
- package/package.json +1 -1
- package/public/vite.svg +1 -0
- package/src/App.tsx +209 -0
- package/src/assets/Fonts/Lexi-Regular.ttf +0 -0
- package/src/assets/images/create-template/prebuilt.svg +13 -0
- package/src/assets/images/create-template/scratch.svg +4 -0
- package/src/assets/images/input/cancel.tsx +20 -0
- package/src/assets/images/input/search.tsx +20 -0
- package/src/assets/images/input/select-cancel.tsx +17 -0
- package/src/assets/images/modal-icons/add.tsx +36 -0
- package/src/assets/images/modal-icons/cancel-file.tsx +12 -0
- package/src/assets/images/modal-icons/cancel-input.tsx +13 -0
- package/src/assets/images/modal-icons/cancel.tsx +35 -0
- package/src/assets/images/modal-icons/close-new.svg +3 -0
- package/src/assets/images/modal-icons/confirm-close-icon.tsx +14 -0
- package/src/assets/images/modal-icons/confirm-new.tsx +22 -0
- package/src/assets/images/modal-icons/confirm.svg +12 -0
- package/src/assets/images/modal-icons/cross.tsx +23 -0
- package/src/assets/images/modal-icons/del.tsx +19 -0
- package/src/assets/images/modal-icons/design-icon.tsx +22 -0
- package/src/assets/images/modal-icons/doc.tsx +43 -0
- package/src/assets/images/modal-icons/docx.tsx +43 -0
- package/src/assets/images/modal-icons/envelope-icon.tsx +26 -0
- package/src/assets/images/modal-icons/info.tsx +19 -0
- package/src/assets/images/modal-icons/jpeg.tsx +43 -0
- package/src/assets/images/modal-icons/jpg.tsx +43 -0
- package/src/assets/images/modal-icons/modal-cros.svg +4 -0
- package/src/assets/images/modal-icons/modal-cross.tsx +37 -0
- package/src/assets/images/modal-icons/new-cancel.tsx +11 -0
- package/src/assets/images/modal-icons/order-download.tsx +42 -0
- package/src/assets/images/modal-icons/pdf.tsx +51 -0
- package/src/assets/images/modal-icons/png.tsx +43 -0
- package/src/assets/images/modal-icons/save.tsx +23 -0
- package/src/assets/images/modal-icons/template-copy.tsx +25 -0
- package/src/assets/images/modal-icons/tool-cancel.tsx +25 -0
- package/src/assets/images/products/bi-new.svg +23 -0
- package/src/assets/images/products/left-arrow.svg +17 -0
- package/src/assets/images/products/personal-new.tsx +31 -0
- package/src/assets/images/products/postcard-new.tsx +27 -0
- package/src/assets/images/products/professional-new.tsx +24 -0
- package/src/assets/images/products/real-new.tsx +30 -0
- package/src/assets/images/products/right-arrow.svg +17 -0
- package/src/assets/images/products/snap-new.svg +31 -0
- package/src/assets/images/templates/actions.svg +3 -0
- package/src/assets/images/templates/address-block-icon.tsx +62 -0
- package/src/assets/images/templates/archive.svg +3 -0
- package/src/assets/images/templates/arrow-down.tsx +27 -0
- package/src/assets/images/templates/back-arrow.tsx +19 -0
- package/src/assets/images/templates/bi-fold-self-mailers.tsx +28 -0
- package/src/assets/images/templates/check.svg +3 -0
- package/src/assets/images/templates/code.svg +10 -0
- package/src/assets/images/templates/content-copy-icon.tsx +24 -0
- package/src/assets/images/templates/custom-add-on-icon.tsx +18 -0
- package/src/assets/images/templates/custom-qr-section-icon.tsx +9 -0
- package/src/assets/images/templates/custom-template.tsx +23 -0
- package/src/assets/images/templates/designer.tsx +43 -0
- package/src/assets/images/templates/dot.tsx +22 -0
- package/src/assets/images/templates/download-v2.svg +4 -0
- package/src/assets/images/templates/download.svg +4 -0
- package/src/assets/images/templates/dummy-template.tsx +76 -0
- package/src/assets/images/templates/dynamic-field.tsx +119 -0
- package/src/assets/images/templates/edit-pencil-icon.tsx +21 -0
- package/src/assets/images/templates/edit.svg +3 -0
- package/src/assets/images/templates/epo-icon.tsx +16 -0
- package/src/assets/images/templates/field.tsx +29 -0
- package/src/assets/images/templates/gsv-icon.tsx +31 -0
- package/src/assets/images/templates/info-icon.tsx +37 -0
- package/src/assets/images/templates/left-arrow.svg +17 -0
- package/src/assets/images/templates/pencil.svg +3 -0
- package/src/assets/images/templates/personal-letter.tsx +53 -0
- package/src/assets/images/templates/postcard.tsx +32 -0
- package/src/assets/images/templates/professional-letter.tsx +53 -0
- package/src/assets/images/templates/qr-code.tsx +13 -0
- package/src/assets/images/templates/real-penned-letters.tsx +57 -0
- package/src/assets/images/templates/right-arrow.svg +17 -0
- package/src/assets/images/templates/size-image-lg.tsx +20 -0
- package/src/assets/images/templates/size-image-mid.tsx +20 -0
- package/src/assets/images/templates/size-image-xl.tsx +20 -0
- package/src/assets/images/templates/size-image.tsx +20 -0
- package/src/assets/images/templates/snap-pack.tsx +67 -0
- package/src/assets/images/templates/template-default-design.tsx +21 -0
- package/src/assets/images/templates/trash-upload.svg +3 -0
- package/src/assets/images/templates/trash.svg +3 -0
- package/src/assets/images/templates/tri-fold-self-mailers.tsx +93 -0
- package/src/assets/images/templates/upload-image.svg +10 -0
- package/src/assets/images/templates/x.svg +3 -0
- package/src/assets/images/thumbnails/one.svg +9 -0
- package/src/assets/images/tooltip/tool-arrow.tsx +25 -0
- package/src/components/CreateTemplate/V2/index.tsx +525 -0
- package/src/components/CreateTemplate/V2/styles.scss +372 -0
- package/src/components/CreateTemplate/index.tsx +508 -0
- package/src/components/CreateTemplate/styles.scss +404 -0
- package/src/components/GenericUIBlocks/Button/index.tsx +54 -0
- package/src/components/GenericUIBlocks/Button/styles.scss +43 -0
- package/src/components/GenericUIBlocks/CircularProgress/index.tsx +18 -0
- package/src/components/GenericUIBlocks/CircularProgress/styles.scss +93 -0
- package/src/components/GenericUIBlocks/CustomTooltip/index.tsx +88 -0
- package/src/components/GenericUIBlocks/CustomTooltip/styles.scss +19 -0
- package/src/components/GenericUIBlocks/Dialog/V2/index.tsx +227 -0
- package/src/components/GenericUIBlocks/Dialog/V2/styles.scss +289 -0
- package/src/components/GenericUIBlocks/Dialog/index.tsx +185 -0
- package/src/components/GenericUIBlocks/Dialog/styles.scss +227 -0
- package/src/components/GenericUIBlocks/Divider/index.tsx +12 -0
- package/src/components/GenericUIBlocks/Divider/styles.scss +7 -0
- package/src/components/GenericUIBlocks/GeneralSelect/index.tsx +114 -0
- package/src/components/GenericUIBlocks/GeneralSelect/styles.scss +406 -0
- package/src/components/GenericUIBlocks/GeneralTooltip/index.tsx +25 -0
- package/src/components/GenericUIBlocks/GeneralTooltip/styles.scss +20 -0
- package/src/components/GenericUIBlocks/GenericSnackbar/Toast/index.tsx +91 -0
- package/src/components/GenericUIBlocks/GenericSnackbar/Toast/styles.scss +92 -0
- package/src/components/GenericUIBlocks/Grid/index.tsx +82 -0
- package/src/components/GenericUIBlocks/Input/index.tsx +269 -0
- package/src/components/GenericUIBlocks/Input/styles.scss +332 -0
- package/src/components/GenericUIBlocks/Tabs/index.tsx +71 -0
- package/src/components/GenericUIBlocks/Tabs/styles.scss +42 -0
- package/src/components/GenericUIBlocks/Typography/index.tsx +18 -0
- package/src/components/GenericUIBlocks/Typography/styles.scss +27 -0
- package/src/components/SidePanel/CustomAddOns/index.tsx +342 -0
- package/src/components/SidePanel/CustomAddOns/styles.scss +86 -0
- package/src/components/SidePanel/CustomBlockColors/index.tsx +211 -0
- package/src/components/SidePanel/CustomBlockColors/styles.scss +80 -0
- package/src/components/SidePanel/CustomFields/customFieldSection.tsx +547 -0
- package/src/components/SidePanel/CustomFields/styles.scss +64 -0
- package/src/components/SidePanel/CustomQRCode/V2/QRCodeModal/index.tsx +172 -0
- package/src/components/SidePanel/CustomQRCode/V2/QRCodeModal/styles.scss +46 -0
- package/src/components/SidePanel/CustomQRCode/index.tsx +1070 -0
- package/src/components/SidePanel/CustomQRCode/styles.scss +149 -0
- package/src/components/SidePanel/CustomUploads/V2/index.tsx +542 -0
- package/src/components/SidePanel/CustomUploads/V2/styles.scss +267 -0
- package/src/components/SidePanel/CustomUploads/index.tsx +301 -0
- package/src/components/SidePanel/Templates/ModalGallery/HireDesigner/index.tsx +424 -0
- package/src/components/SidePanel/Templates/ModalGallery/HireDesigner/styles.scss +180 -0
- package/src/components/SidePanel/Templates/ModalGallery/V2/index.tsx +235 -0
- package/src/components/SidePanel/Templates/ModalGallery/V2/styles.scss +244 -0
- package/src/components/SidePanel/Templates/ModalGallery/index.tsx +231 -0
- package/src/components/SidePanel/Templates/SideBarGallery/index.tsx +233 -0
- package/src/components/SidePanel/Templates/SideBarGallery/styles.scss +152 -0
- package/src/components/SidePanel/Templates/TemplatesCard/V2/index.tsx +149 -0
- package/src/components/SidePanel/Templates/TemplatesCard/V2/styles.scss +156 -0
- package/src/components/SidePanel/Templates/TemplatesCard/index.tsx +160 -0
- package/src/components/SidePanel/Templates/TemplatesCard/styles.scss +98 -0
- package/src/components/SidePanel/Templates/customTemplateSection.tsx +793 -0
- package/src/components/SidePanel/Templates/styles.scss +244 -0
- package/src/components/SidePanel/index.tsx +160 -0
- package/src/components/TemplateBuilder/index.tsx +585 -0
- package/src/components/TemplateBuilder/styles.scss +100 -0
- package/src/components/TemplateTypes/index.tsx +96 -0
- package/src/components/TemplateTypes/styles.scss +91 -0
- package/src/components/TopNavigation/ConfirmNavigateDialog/index.tsx +81 -0
- package/src/components/TopNavigation/ConfirmNavigateDialog/styles.scss +123 -0
- package/src/components/TopNavigation/DuplicateTemplateModal.tsx +103 -0
- package/src/components/TopNavigation/EditTemplateNameModel/index.tsx +71 -0
- package/src/components/TopNavigation/EditTemplateNameModel/styles.scss +88 -0
- package/src/components/TopNavigation/SaveTemplateModel/index.tsx +201 -0
- package/src/components/TopNavigation/SaveTemplateModel/styles.scss +128 -0
- package/src/components/TopNavigation/index.tsx +938 -0
- package/src/components/TopNavigation/styles.scss +303 -0
- package/src/importMeta.d.ts +31 -0
- package/src/index.scss +131 -0
- package/src/index.tsx +238 -0
- package/src/libs/test.ts +7 -0
- package/src/redux/actions/action-types.ts +52 -0
- package/src/redux/actions/customQRCodeActions.ts +54 -0
- package/src/redux/actions/snackbarActions.ts +16 -0
- package/src/redux/actions/templateActions.ts +236 -0
- package/src/redux/reducers/customFieldReducer.ts +99 -0
- package/src/redux/reducers/customQRCodeReducer.ts +58 -0
- package/src/redux/reducers/index.ts +15 -0
- package/src/redux/reducers/snackbarReducer.ts +40 -0
- package/src/redux/reducers/templateReducer.ts +485 -0
- package/src/redux/store.ts +18 -0
- package/src/styles/colors.scss +61 -0
- package/src/test/mocks.js +89 -0
- package/src/test/setupJest.js +1 -0
- package/src/utils/api.ts +36 -0
- package/src/utils/constants.ts +182 -0
- package/src/utils/customStyles.ts +45 -0
- package/src/utils/fetchWrapper.ts +73 -0
- package/src/utils/fonts.json +1597 -0
- package/src/utils/helper.ts +205 -0
- package/src/utils/local-storage.ts +15 -0
- package/src/utils/message.ts +162 -0
- package/src/utils/products.ts +186 -0
- package/src/utils/template-builder.ts +328 -0
- package/src/utils/templateIdentifierArea/biFold.ts +107 -0
- package/src/utils/templateIdentifierArea/index.ts +35 -0
- package/src/utils/templateIdentifierArea/personal.ts +107 -0
- package/src/utils/templateIdentifierArea/postCards.ts +163 -0
- package/src/utils/templateIdentifierArea/professional.ts +125 -0
- package/src/utils/templateIdentifierArea/snapPack.ts +107 -0
- package/src/utils/templateIdentifierArea/triFold.ts +107 -0
- package/src/utils/templateRestrictedArea/biFold.ts +329 -0
- package/src/utils/templateRestrictedArea/nonWindowProfessional.ts +90 -0
- package/src/utils/templateRestrictedArea/personal.ts +90 -0
- package/src/utils/templateRestrictedArea/postCard.ts +334 -0
- package/src/utils/templateRestrictedArea/postCardJumbo.tsx +408 -0
- package/src/utils/templateRestrictedArea/professional.ts +318 -0
- package/src/utils/templateRestrictedArea/realPenned.ts +233 -0
- package/src/utils/templateRestrictedArea/snapPack.ts +1009 -0
- package/src/utils/templateRestrictedArea/triFold.ts +330 -0
- package/src/utils/templateSafetyBorders/biFold.ts +91 -0
- package/src/utils/templateSafetyBorders/index.ts +43 -0
- package/src/utils/templateSafetyBorders/personal.ts +41 -0
- package/src/utils/templateSafetyBorders/postCards.ts +259 -0
- package/src/utils/templateSafetyBorders/professional.ts +78 -0
- package/src/utils/templateSafetyBorders/snapPack.ts +165 -0
- package/src/utils/templateSafetyBorders/triFold.ts +114 -0
- package/src/utils/templateSafetyBorders/types.d.ts +68 -0
- package/src/utils/types.ts +12 -0
- package/src/v2Theme.scss +142 -0
- package/tsconfig.json +29 -0
- package/tsconfig.node.json +12 -0
- package/update-version.js +23 -0
- package/version.js +1 -0
- package/vite.config.ts +8 -0
- package/webpack.config.js +80 -0
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
/* eslint-disable no-useless-catch */
|
|
2
|
+
|
|
3
|
+
// Utils
|
|
4
|
+
import { multiPageLetters, BARCODE_IMAGE_URL, DEMO_S3_URL, PROD_S3_URL, emojiRegex, STAGE_S3_URL, LOCAL_S3_URL } from './constants';
|
|
5
|
+
import { cleanString, getEnv, getIsSandbox } from './helper';
|
|
6
|
+
|
|
7
|
+
// Restricted Area Files
|
|
8
|
+
import { addRestrictedAreaToBiFold } from './templateRestrictedArea/biFold';
|
|
9
|
+
import { addRestrictedAreaToPostCard } from './templateRestrictedArea/postCard';
|
|
10
|
+
import { addAreaToProfessionalLetters } from './templateRestrictedArea/professional';
|
|
11
|
+
import { addAreaToNonWindowProfessionalLetters } from './templateRestrictedArea/nonWindowProfessional';
|
|
12
|
+
import { addAreaToPersonalLetters } from './templateRestrictedArea/personal';
|
|
13
|
+
import { addRestrictedAreaToTriFold } from './templateRestrictedArea/triFold';
|
|
14
|
+
import { addRestrictedAreaToSnapPackMailer } from './templateRestrictedArea/snapPack';
|
|
15
|
+
import { addRestrictedAreaToPostCardJumbo } from './templateRestrictedArea/postCardJumbo';
|
|
16
|
+
|
|
17
|
+
// Safety Borders Files
|
|
18
|
+
import { addSafetyBordersForTemplates } from './templateSafetyBorders';
|
|
19
|
+
|
|
20
|
+
export const addressPrinting: { [key: string]: boolean } = {
|
|
21
|
+
'Postcards-': true,
|
|
22
|
+
'Tri-Fold Self-Mailers-': true,
|
|
23
|
+
'Bi-Fold Self-Mailers-': true,
|
|
24
|
+
'Personal Letters-': true,
|
|
25
|
+
'Snap Pack Mailers-': true,
|
|
26
|
+
'Professional Letters-#10 Double-Window': true,
|
|
27
|
+
'Professional Letters-#10 Grey': true,
|
|
28
|
+
'Real Penned Letter-': true
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export const multiPageTemplates: string[] = [
|
|
32
|
+
'Postcards',
|
|
33
|
+
'Snap Pack Mailers',
|
|
34
|
+
'Tri-Fold Self-Mailers',
|
|
35
|
+
'Bi-Fold Self-Mailers',
|
|
36
|
+
];
|
|
37
|
+
|
|
38
|
+
export interface EnvelopeType {
|
|
39
|
+
id: number,
|
|
40
|
+
label: string,
|
|
41
|
+
type: string,
|
|
42
|
+
productId: number
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface DesignType {
|
|
46
|
+
id: number,
|
|
47
|
+
type: string,
|
|
48
|
+
label: string,
|
|
49
|
+
productId: number
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
export const envelopeTypes: EnvelopeType[] = [
|
|
54
|
+
{ id: 1, label: 'Windowed Envelope', type: '#10 Double-Window', productId: 2 },
|
|
55
|
+
{ id: 2, label: 'Non-Windowed Envelope', type: '#10 Grey', productId: 4 },
|
|
56
|
+
];
|
|
57
|
+
|
|
58
|
+
export const designTypes: DesignType[] = [
|
|
59
|
+
{ id: 0, type: "Bi-Fold Self-Mailers", label: "Bi-Fold Self Mailer", productId: 9 },
|
|
60
|
+
{ id: 1, type: "Tri-Fold Self-Mailers", label: "Tri-Fold Self Mailer", productId: 11 },
|
|
61
|
+
];
|
|
62
|
+
|
|
63
|
+
export const selfMailerProduct = {
|
|
64
|
+
id: "9",
|
|
65
|
+
title: "Self Mailer",
|
|
66
|
+
productType: "Bi-Fold Self-Mailers",
|
|
67
|
+
hasEnvelope: false,
|
|
68
|
+
paper: '80# text',
|
|
69
|
+
finish: 'Glass Coated',
|
|
70
|
+
size: [
|
|
71
|
+
{
|
|
72
|
+
id: "9",
|
|
73
|
+
size: "6x18"
|
|
74
|
+
}
|
|
75
|
+
],
|
|
76
|
+
types: [
|
|
77
|
+
{
|
|
78
|
+
id: "9", defaultSize: "6x18", title: "Self Mailer", productType: "Bi-Fold Self-Mailers", hasEnvelope: false, paper: '80# text',
|
|
79
|
+
finish: 'Glass Coated', size: [
|
|
80
|
+
{
|
|
81
|
+
id: "9",
|
|
82
|
+
size: "6x18"
|
|
83
|
+
}
|
|
84
|
+
],
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
id: "11", defaultSize: "12x9", title: "Self Mailer", productType: "Tri-Fold Self-Mailers", hasEnvelope: false, paper: '80# text', label: '8.5x11',
|
|
88
|
+
finish: 'Glass Coated', size: [{
|
|
89
|
+
id: "11",
|
|
90
|
+
size: "12x9",
|
|
91
|
+
label: "8.5x11"
|
|
92
|
+
}]
|
|
93
|
+
},
|
|
94
|
+
],
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export const getFileAsBlob = async (url: string, returnType: string = 'json'): Promise<any> => {
|
|
98
|
+
try {
|
|
99
|
+
const response = await fetch(url);
|
|
100
|
+
const blob = await response.blob();
|
|
101
|
+
return returnType === 'json'
|
|
102
|
+
? blobToJSON(blob)
|
|
103
|
+
: blobToString(blob);
|
|
104
|
+
} catch (error) {
|
|
105
|
+
throw error; // Optionally rethrow the error for further handling
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
const blobToJSON = (jsonBlob: Blob): Promise<any> => {
|
|
110
|
+
return new Promise((resolve, reject) => {
|
|
111
|
+
const reader = new FileReader();
|
|
112
|
+
|
|
113
|
+
reader.onload = function () {
|
|
114
|
+
try {
|
|
115
|
+
// Parse the result as JSON
|
|
116
|
+
const parsedData = JSON.parse(reader.result as string);
|
|
117
|
+
|
|
118
|
+
// Resolve the promise with the parsed JSON data
|
|
119
|
+
resolve(parsedData);
|
|
120
|
+
} catch (error) {
|
|
121
|
+
reject(error);
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
reader.onerror = function (error) {
|
|
126
|
+
reject(error);
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
reader.readAsText(jsonBlob);
|
|
130
|
+
});
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
export const blobToString = (blob: Blob): Promise<string> => {
|
|
134
|
+
return new Promise((resolve, reject) => {
|
|
135
|
+
const reader = new FileReader();
|
|
136
|
+
|
|
137
|
+
reader.onloadend = function () {
|
|
138
|
+
// The result property contains the data as a string
|
|
139
|
+
const blobString = reader.result as string;
|
|
140
|
+
|
|
141
|
+
// Resolve the Promise with the blobString
|
|
142
|
+
resolve(blobString);
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
reader.onerror = function (error) {
|
|
146
|
+
reject(error);
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
reader.readAsText(blob);
|
|
150
|
+
});
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
export const downloadPDF = (title: string, url: string): void => {
|
|
154
|
+
const link = document.createElement('a');
|
|
155
|
+
link.href = url;
|
|
156
|
+
link.download = title + '.pdf';
|
|
157
|
+
|
|
158
|
+
// Append the link to the document
|
|
159
|
+
document.body.appendChild(link);
|
|
160
|
+
|
|
161
|
+
// Trigger a click on the link
|
|
162
|
+
link.click();
|
|
163
|
+
|
|
164
|
+
// Remove the link from the document
|
|
165
|
+
document.body.removeChild(link);
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
export interface Product {
|
|
169
|
+
id: string;
|
|
170
|
+
productType: string;
|
|
171
|
+
selectedSize: string;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
export const drawRestrictedAreaOnPage = (store: any, product: Product, envelopeType: string) => {
|
|
175
|
+
const barcodeSrc =
|
|
176
|
+
(getEnv() === 'local' || getEnv() === 'staging'
|
|
177
|
+
? STAGE_S3_URL
|
|
178
|
+
: getIsSandbox()
|
|
179
|
+
? DEMO_S3_URL
|
|
180
|
+
: PROD_S3_URL) + BARCODE_IMAGE_URL;
|
|
181
|
+
if (addressPrinting[`${product.productType}-${envelopeType}`]) {
|
|
182
|
+
if (
|
|
183
|
+
product.productType === "Professional Letters" &&
|
|
184
|
+
envelopeType === "#10 Double-Window"
|
|
185
|
+
) {
|
|
186
|
+
addAreaToProfessionalLetters(store, barcodeSrc);
|
|
187
|
+
} else if (
|
|
188
|
+
product.productType === "Professional Letters" &&
|
|
189
|
+
envelopeType === "#10 Grey"
|
|
190
|
+
) {
|
|
191
|
+
addAreaToNonWindowProfessionalLetters(store);
|
|
192
|
+
} else if (product.productType === "Personal Letters") {
|
|
193
|
+
addAreaToPersonalLetters(store);
|
|
194
|
+
} else if (product.productType === multiPageLetters[0] && +product.id !== 21) {
|
|
195
|
+
addRestrictedAreaToPostCard(
|
|
196
|
+
store,
|
|
197
|
+
[3.2835, 2.375],
|
|
198
|
+
barcodeSrc
|
|
199
|
+
);
|
|
200
|
+
|
|
201
|
+
} else if (product.productType === multiPageLetters[0] && +product.id === 21) {
|
|
202
|
+
addRestrictedAreaToPostCardJumbo(store, barcodeSrc);
|
|
203
|
+
}
|
|
204
|
+
else if (product.productType === multiPageLetters[1]) {
|
|
205
|
+
addRestrictedAreaToTriFold(store, [3.2835, 2.375], barcodeSrc);
|
|
206
|
+
} else if (product.productType === multiPageLetters[2]) {
|
|
207
|
+
addRestrictedAreaToBiFold(store, [3.2835, 2.375], barcodeSrc);
|
|
208
|
+
} else if (product.productType === multiPageLetters[3]) {
|
|
209
|
+
addRestrictedAreaToSnapPackMailer(store, barcodeSrc);
|
|
210
|
+
}
|
|
211
|
+
addSafetyBordersForTemplates(product?.id, store);
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
export const extractFontFamilies = (jsonData: any[]): string[] => {
|
|
216
|
+
const fontFamilies: string[] = [];
|
|
217
|
+
|
|
218
|
+
// Iterate through each object in the JSON data
|
|
219
|
+
jsonData.forEach((obj) => {
|
|
220
|
+
if (obj.children) {
|
|
221
|
+
obj.children.forEach((child: any) => {
|
|
222
|
+
if (child.type === 'text' && child.fontFamily) {
|
|
223
|
+
// Extract font family from text objects
|
|
224
|
+
fontFamilies.push(child.fontFamily);
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
});
|
|
229
|
+
return fontFamilies;
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
export const removeBracketsFromRPL = (jsonData: any[]) => {
|
|
233
|
+
let clonedData = JSON.parse(JSON.stringify(jsonData));
|
|
234
|
+
const updatedJson = clonedData.pages.map((obj: any) => {
|
|
235
|
+
if (obj.children) {
|
|
236
|
+
obj.children = obj.children.map((child: any) => {
|
|
237
|
+
if (child.type === 'text' && typeof child.text === 'string') {
|
|
238
|
+
const cleanedText = cleanString(child.text);
|
|
239
|
+
child.text = cleanedText.replace(/[{}\[\]]/g, '');
|
|
240
|
+
}
|
|
241
|
+
return child;
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
return obj;
|
|
245
|
+
});
|
|
246
|
+
clonedData.pages = updatedJson;
|
|
247
|
+
return clonedData;
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
export const changeColorOfBoxesForSnapPack = (jsonData: any[], preFill = false, isLoading = false) => {
|
|
251
|
+
let clonedData = JSON.parse(JSON.stringify(jsonData));
|
|
252
|
+
const updatedJson = clonedData.pages.map((obj: any) => {
|
|
253
|
+
if (obj.children) {
|
|
254
|
+
obj.children = obj.children.map((child: any) => {
|
|
255
|
+
if (child?.custom?.replaceBg) {
|
|
256
|
+
child.fill = child?.custom?.preFill || 'white';
|
|
257
|
+
child.strokeWidth = 0;
|
|
258
|
+
}
|
|
259
|
+
if ((child.id === "mailing-address-window-box-1" || child.id === "mailing-address-window-box-2")) {
|
|
260
|
+
child.fill = isLoading ? "rgba(233,233,233,1)" : "white",
|
|
261
|
+
child.custom.preFill = 'rgba(233,233,233,1)';
|
|
262
|
+
child.custom.postFill = 'white';
|
|
263
|
+
}
|
|
264
|
+
return child;
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
return obj;
|
|
268
|
+
});
|
|
269
|
+
clonedData.pages = updatedJson;
|
|
270
|
+
return clonedData;
|
|
271
|
+
};
|
|
272
|
+
|
|
273
|
+
export const extractCustomRistrictedBoxColor = (jsonData: any) => {
|
|
274
|
+
let boxColor = null;
|
|
275
|
+
jsonData?.pages?.forEach((page: any) => {
|
|
276
|
+
page.children.forEach((el: any) => {
|
|
277
|
+
if (el.id.includes("custom-")) {
|
|
278
|
+
return boxColor = el.fill;
|
|
279
|
+
}
|
|
280
|
+
});
|
|
281
|
+
});
|
|
282
|
+
return boxColor;
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
export const validateGSV = (pages: any) => {
|
|
286
|
+
const hasMultipleGSV = (children: any) =>
|
|
287
|
+
children.filter(
|
|
288
|
+
({ custom }: any) => custom?.elementType === "GOOGLE_STREET_VIEW"
|
|
289
|
+
).length > 1;
|
|
290
|
+
|
|
291
|
+
for (const page of pages) {
|
|
292
|
+
if (hasMultipleGSV(page.children)) {
|
|
293
|
+
return false;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
return true;
|
|
297
|
+
};
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
export const validateEmoji = (pages: any) => {
|
|
301
|
+
const textElements = (children: any) =>
|
|
302
|
+
children.filter(
|
|
303
|
+
({ type, text }: any) => type === "text" && emojiRegex.test(text)
|
|
304
|
+
);
|
|
305
|
+
|
|
306
|
+
|
|
307
|
+
for (const page of pages) {
|
|
308
|
+
if (textElements(page.children).length) {
|
|
309
|
+
return true;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
return false;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
export const isValidQR = (pages: any) => {
|
|
316
|
+
const QRElements = (children: any) =>
|
|
317
|
+
children.filter(
|
|
318
|
+
({ name, custom }: any) => name === "qr" && custom.value === ''
|
|
319
|
+
);
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+
for (const page of pages) {
|
|
323
|
+
if (QRElements(page.children).length) {
|
|
324
|
+
return false;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
return true;
|
|
328
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
// Define the type for the element being added
|
|
2
|
+
interface Element {
|
|
3
|
+
id: string;
|
|
4
|
+
type: string;
|
|
5
|
+
name: string;
|
|
6
|
+
opacity: number;
|
|
7
|
+
visible: boolean;
|
|
8
|
+
selectable: boolean;
|
|
9
|
+
removable: boolean;
|
|
10
|
+
alwaysOnTop: boolean;
|
|
11
|
+
showInExport: boolean;
|
|
12
|
+
x: number;
|
|
13
|
+
y: number;
|
|
14
|
+
width: number;
|
|
15
|
+
height: number;
|
|
16
|
+
rotation: number;
|
|
17
|
+
animations?: any[];
|
|
18
|
+
draggable?: boolean;
|
|
19
|
+
resizable?: boolean;
|
|
20
|
+
contentEditable: boolean;
|
|
21
|
+
styleEditable: boolean;
|
|
22
|
+
text: string;
|
|
23
|
+
fontSize: number;
|
|
24
|
+
fontFamily: string;
|
|
25
|
+
fontStyle: string;
|
|
26
|
+
fontWeight: string;
|
|
27
|
+
fill: string;
|
|
28
|
+
align: string;
|
|
29
|
+
verticalAlign: string;
|
|
30
|
+
lineHeight: number;
|
|
31
|
+
letterSpacing: number;
|
|
32
|
+
backgroundEnabled?: boolean;
|
|
33
|
+
backgroundColor?: string;
|
|
34
|
+
backgroundOpacity?: number;
|
|
35
|
+
backgroundCornerRadius?: number;
|
|
36
|
+
backgroundPadding?: number;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Define the type for the page
|
|
40
|
+
interface Page {
|
|
41
|
+
addElement: (element: Element) => void;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Define the type for the store
|
|
45
|
+
interface Store {
|
|
46
|
+
pages: Page[];
|
|
47
|
+
history: {
|
|
48
|
+
clear: () => void;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Reusable function to create text elements
|
|
53
|
+
const createTextElement = (
|
|
54
|
+
id: string,
|
|
55
|
+
text: string,
|
|
56
|
+
x: number,
|
|
57
|
+
y: number,
|
|
58
|
+
width: number
|
|
59
|
+
): Element => ({
|
|
60
|
+
id,
|
|
61
|
+
type: "text",
|
|
62
|
+
name: "",
|
|
63
|
+
opacity: 1,
|
|
64
|
+
visible: true,
|
|
65
|
+
selectable: false,
|
|
66
|
+
removable: false,
|
|
67
|
+
alwaysOnTop: true,
|
|
68
|
+
showInExport: true,
|
|
69
|
+
x,
|
|
70
|
+
y,
|
|
71
|
+
width,
|
|
72
|
+
height: 11,
|
|
73
|
+
rotation: 0,
|
|
74
|
+
draggable: true,
|
|
75
|
+
resizable: true,
|
|
76
|
+
contentEditable: true,
|
|
77
|
+
styleEditable: false,
|
|
78
|
+
text,
|
|
79
|
+
fontSize: 7,
|
|
80
|
+
fontFamily: "Roboto",
|
|
81
|
+
fontStyle: "normal",
|
|
82
|
+
fontWeight: "normal",
|
|
83
|
+
fill: "grey",
|
|
84
|
+
align: "center",
|
|
85
|
+
verticalAlign: "top",
|
|
86
|
+
lineHeight: 1.2,
|
|
87
|
+
letterSpacing: 0,
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
export const addIdentifierAreaToBiFold = (store: Store): void => {
|
|
92
|
+
const page = store.pages[0];
|
|
93
|
+
|
|
94
|
+
const elements: Element[] = [
|
|
95
|
+
createTextElement("cont-id-placeholder", "C:", 691, 541.5, 11),
|
|
96
|
+
createTextElement("contId", "0000001", 700, 541.5, 30),
|
|
97
|
+
createTextElement("sequence-id-placeholder", "| S:", 727, 541.5, 12),
|
|
98
|
+
createTextElement("sequence", "0000001", 739, 541.5, 29),
|
|
99
|
+
createTextElement("template-id-placeholder", "| T:", 765, 541.5, 14),
|
|
100
|
+
createTextElement("templateId", "0001034", 778, 541.5, 29),
|
|
101
|
+
createTextElement("order-id-placeholder", "| O:", 807, 541.5, 11),
|
|
102
|
+
createTextElement("orderId", "0000127", 818, 541.5, 29),
|
|
103
|
+
];
|
|
104
|
+
|
|
105
|
+
elements.forEach(element => page.addElement(element));
|
|
106
|
+
store.history.clear();
|
|
107
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { StoreType } from "polotno/model/store";
|
|
2
|
+
|
|
3
|
+
// Safety Border Files
|
|
4
|
+
import { addIdentifierAreaTo4x6PostCard, addIdentifierAreaTo6x9PostCard, addIdentifierAreaTo6x11PostCard, addIdentifierAreaTo12x9PostCard } from './postCards'
|
|
5
|
+
import { addIdentifierAreaToProfessionalWindow, addIdentifierAreaToProfessionalNonWindow } from './professional'
|
|
6
|
+
import { addIdentifierAreaToPersonalLetter } from './personal'
|
|
7
|
+
import { addIdentifierAreaToBiFold } from './biFold'
|
|
8
|
+
import { addIdentifierAreaToTriFold } from './triFold'
|
|
9
|
+
import { addIdentifierAreaToSnapPackMailer } from './snapPack'
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
export const addIdentifiersForTemplates = (productId: string, store: StoreType) => {
|
|
13
|
+
if (!productId) return;
|
|
14
|
+
if (+productId === 13) {
|
|
15
|
+
addIdentifierAreaTo4x6PostCard(store);
|
|
16
|
+
} else if (+productId === 14) {
|
|
17
|
+
addIdentifierAreaTo6x9PostCard(store);
|
|
18
|
+
} else if (+productId === 15) {
|
|
19
|
+
addIdentifierAreaTo6x11PostCard(store);
|
|
20
|
+
} else if (+productId === 2) {
|
|
21
|
+
addIdentifierAreaToProfessionalWindow(store);
|
|
22
|
+
} else if (+productId === 4) {
|
|
23
|
+
addIdentifierAreaToProfessionalNonWindow(store);
|
|
24
|
+
} else if (+productId === 5) {
|
|
25
|
+
addIdentifierAreaToPersonalLetter(store);
|
|
26
|
+
} else if (+productId === 9) {
|
|
27
|
+
addIdentifierAreaToBiFold(store);
|
|
28
|
+
} else if (+productId === 11) {
|
|
29
|
+
addIdentifierAreaToTriFold(store);
|
|
30
|
+
} else if (+productId === 18) {
|
|
31
|
+
addIdentifierAreaToSnapPackMailer(store);
|
|
32
|
+
} else if (+productId === 21) {
|
|
33
|
+
addIdentifierAreaTo12x9PostCard(store);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
// Define the type for the element being added
|
|
2
|
+
interface Element {
|
|
3
|
+
id: string;
|
|
4
|
+
type: string;
|
|
5
|
+
name: string;
|
|
6
|
+
opacity: number;
|
|
7
|
+
visible: boolean;
|
|
8
|
+
selectable: boolean;
|
|
9
|
+
removable: boolean;
|
|
10
|
+
alwaysOnTop: boolean;
|
|
11
|
+
showInExport: boolean;
|
|
12
|
+
x: number;
|
|
13
|
+
y: number;
|
|
14
|
+
width: number;
|
|
15
|
+
height: number;
|
|
16
|
+
rotation: number;
|
|
17
|
+
animations?: any[];
|
|
18
|
+
draggable?: boolean;
|
|
19
|
+
resizable?: boolean;
|
|
20
|
+
contentEditable: boolean;
|
|
21
|
+
styleEditable: boolean;
|
|
22
|
+
text: string;
|
|
23
|
+
fontSize: number;
|
|
24
|
+
fontFamily: string;
|
|
25
|
+
fontStyle: string;
|
|
26
|
+
fontWeight: string;
|
|
27
|
+
fill: string;
|
|
28
|
+
align: string;
|
|
29
|
+
verticalAlign: string;
|
|
30
|
+
lineHeight: number;
|
|
31
|
+
letterSpacing: number;
|
|
32
|
+
backgroundEnabled?: boolean;
|
|
33
|
+
backgroundColor?: string;
|
|
34
|
+
backgroundOpacity?: number;
|
|
35
|
+
backgroundCornerRadius?: number;
|
|
36
|
+
backgroundPadding?: number;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Define the type for the page
|
|
40
|
+
interface Page {
|
|
41
|
+
addElement: (element: Element) => void;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Define the type for the store
|
|
45
|
+
interface Store {
|
|
46
|
+
pages: Page[];
|
|
47
|
+
history: {
|
|
48
|
+
clear: () => void;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Reusable function to create text elements
|
|
53
|
+
const createTextElement = (
|
|
54
|
+
id: string,
|
|
55
|
+
text: string,
|
|
56
|
+
x: number,
|
|
57
|
+
y: number,
|
|
58
|
+
width: number
|
|
59
|
+
): Element => ({
|
|
60
|
+
id,
|
|
61
|
+
type: "text",
|
|
62
|
+
name: "",
|
|
63
|
+
opacity: 1,
|
|
64
|
+
visible: true,
|
|
65
|
+
selectable: false,
|
|
66
|
+
removable: false,
|
|
67
|
+
alwaysOnTop: true,
|
|
68
|
+
showInExport: true,
|
|
69
|
+
x,
|
|
70
|
+
y,
|
|
71
|
+
width,
|
|
72
|
+
height: 11,
|
|
73
|
+
rotation: 0,
|
|
74
|
+
draggable: true,
|
|
75
|
+
resizable: true,
|
|
76
|
+
contentEditable: true,
|
|
77
|
+
styleEditable: false,
|
|
78
|
+
text,
|
|
79
|
+
fontSize: 7,
|
|
80
|
+
fontFamily: "Roboto",
|
|
81
|
+
fontStyle: "normal",
|
|
82
|
+
fontWeight: "normal",
|
|
83
|
+
fill: "grey",
|
|
84
|
+
align: "center",
|
|
85
|
+
verticalAlign: "top",
|
|
86
|
+
lineHeight: 1.2,
|
|
87
|
+
letterSpacing: 0,
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
export const addIdentifierAreaToPersonalLetter = (store: Store): void => {
|
|
92
|
+
const page = store.pages[0];
|
|
93
|
+
|
|
94
|
+
const elements: Element[] = [
|
|
95
|
+
createTextElement("cont-id-placeholder", "C:", 23.5, 796, 11),
|
|
96
|
+
createTextElement("contId", "0000001", 32, 796, 30),
|
|
97
|
+
createTextElement("sequence-id-placeholder", "| S:", 59.5, 796, 12),
|
|
98
|
+
createTextElement("sequence", "0000001", 69.8, 796, 29),
|
|
99
|
+
createTextElement("template-id-placeholder", "| T:", 95, 796, 14),
|
|
100
|
+
createTextElement("templateId", "0001034", 106.4, 796, 29),
|
|
101
|
+
createTextElement("order-id-placeholder", "| O:", 135.4, 796, 11),
|
|
102
|
+
createTextElement("orderId", "0000127", 146.4, 796, 29),
|
|
103
|
+
];
|
|
104
|
+
|
|
105
|
+
elements.forEach(element => page.addElement(element));
|
|
106
|
+
store.history.clear();
|
|
107
|
+
};
|