@openlettermarketing/olc-react-sdk 2.1.7 → 2.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/index.js +1 -1
- package/build/index.js.map +1 -1
- package/build/types/version.d.ts +1 -1
- package/package.json +7 -6
- package/.eslintignore +0 -1
- package/.eslintrc.cjs +0 -18
- package/.eslintrc.yml +0 -47
- package/.github/workflows/publish-beta.yml +0 -154
- package/.github/workflows/publish-production.yml +0 -143
- package/.prettierignore +0 -3
- package/.prettierrc.yml +0 -5
- package/CHANGELOG.md +0 -4
- package/babel.config.json +0 -10
- package/examples/.eslintrc.yml +0 -4
- package/index.html +0 -18
- package/public/vite.svg +0 -1
- package/src/App.tsx +0 -209
- package/src/assets/Fonts/Lexi-Regular.ttf +0 -0
- package/src/assets/images/create-template/prebuilt.svg +0 -13
- package/src/assets/images/create-template/scratch.svg +0 -4
- package/src/assets/images/input/cancel.tsx +0 -20
- package/src/assets/images/input/search.tsx +0 -20
- package/src/assets/images/input/select-cancel.tsx +0 -17
- package/src/assets/images/modal-icons/add.tsx +0 -36
- package/src/assets/images/modal-icons/cancel-file.tsx +0 -12
- package/src/assets/images/modal-icons/cancel-input.tsx +0 -13
- package/src/assets/images/modal-icons/cancel.tsx +0 -35
- package/src/assets/images/modal-icons/close-new.svg +0 -3
- package/src/assets/images/modal-icons/confirm-close-icon.tsx +0 -14
- package/src/assets/images/modal-icons/confirm-new.tsx +0 -22
- package/src/assets/images/modal-icons/confirm.svg +0 -12
- package/src/assets/images/modal-icons/cross.tsx +0 -23
- package/src/assets/images/modal-icons/del.tsx +0 -19
- package/src/assets/images/modal-icons/design-icon.tsx +0 -22
- package/src/assets/images/modal-icons/doc.tsx +0 -43
- package/src/assets/images/modal-icons/docx.tsx +0 -43
- package/src/assets/images/modal-icons/envelope-icon.tsx +0 -26
- package/src/assets/images/modal-icons/info.tsx +0 -19
- package/src/assets/images/modal-icons/jpeg.tsx +0 -43
- package/src/assets/images/modal-icons/jpg.tsx +0 -43
- package/src/assets/images/modal-icons/modal-cros.svg +0 -4
- package/src/assets/images/modal-icons/modal-cross.tsx +0 -37
- package/src/assets/images/modal-icons/new-cancel.tsx +0 -11
- package/src/assets/images/modal-icons/order-download.tsx +0 -42
- package/src/assets/images/modal-icons/pdf.tsx +0 -51
- package/src/assets/images/modal-icons/png.tsx +0 -43
- package/src/assets/images/modal-icons/save.tsx +0 -23
- package/src/assets/images/modal-icons/template-copy.tsx +0 -25
- package/src/assets/images/modal-icons/tool-cancel.tsx +0 -25
- package/src/assets/images/products/bi-new.svg +0 -23
- package/src/assets/images/products/left-arrow.svg +0 -17
- package/src/assets/images/products/personal-new.tsx +0 -31
- package/src/assets/images/products/postcard-new.tsx +0 -27
- package/src/assets/images/products/professional-new.tsx +0 -24
- package/src/assets/images/products/real-new.tsx +0 -30
- package/src/assets/images/products/right-arrow.svg +0 -17
- package/src/assets/images/products/snap-new.svg +0 -31
- package/src/assets/images/templates/actions.svg +0 -3
- package/src/assets/images/templates/address-block-icon.tsx +0 -62
- package/src/assets/images/templates/archive.svg +0 -3
- package/src/assets/images/templates/arrow-down.tsx +0 -27
- package/src/assets/images/templates/back-arrow.tsx +0 -19
- package/src/assets/images/templates/bi-fold-self-mailers.tsx +0 -28
- package/src/assets/images/templates/check.svg +0 -3
- package/src/assets/images/templates/code.svg +0 -10
- package/src/assets/images/templates/content-copy-icon.tsx +0 -24
- package/src/assets/images/templates/custom-add-on-icon.tsx +0 -18
- package/src/assets/images/templates/custom-qr-section-icon.tsx +0 -9
- package/src/assets/images/templates/custom-template.tsx +0 -23
- package/src/assets/images/templates/designer.tsx +0 -43
- package/src/assets/images/templates/dot.tsx +0 -22
- package/src/assets/images/templates/download-v2.svg +0 -4
- package/src/assets/images/templates/download.svg +0 -4
- package/src/assets/images/templates/dummy-template.tsx +0 -76
- package/src/assets/images/templates/dynamic-field.tsx +0 -119
- package/src/assets/images/templates/edit-pencil-icon.tsx +0 -21
- package/src/assets/images/templates/edit.svg +0 -3
- package/src/assets/images/templates/epo-icon.tsx +0 -16
- package/src/assets/images/templates/field.tsx +0 -29
- package/src/assets/images/templates/gsv-icon.tsx +0 -31
- package/src/assets/images/templates/info-icon.tsx +0 -37
- package/src/assets/images/templates/left-arrow.svg +0 -17
- package/src/assets/images/templates/pencil.svg +0 -3
- package/src/assets/images/templates/personal-letter.tsx +0 -53
- package/src/assets/images/templates/postcard.tsx +0 -32
- package/src/assets/images/templates/professional-letter.tsx +0 -53
- package/src/assets/images/templates/qr-code.tsx +0 -13
- package/src/assets/images/templates/real-penned-letters.tsx +0 -57
- package/src/assets/images/templates/right-arrow.svg +0 -17
- package/src/assets/images/templates/size-image-lg.tsx +0 -20
- package/src/assets/images/templates/size-image-mid.tsx +0 -20
- package/src/assets/images/templates/size-image-xl.tsx +0 -20
- package/src/assets/images/templates/size-image.tsx +0 -20
- package/src/assets/images/templates/snap-pack.tsx +0 -67
- package/src/assets/images/templates/template-default-design.tsx +0 -21
- package/src/assets/images/templates/trash-upload.svg +0 -3
- package/src/assets/images/templates/trash.svg +0 -3
- package/src/assets/images/templates/tri-fold-self-mailers.tsx +0 -93
- package/src/assets/images/templates/upload-image.svg +0 -10
- package/src/assets/images/templates/x.svg +0 -3
- package/src/assets/images/thumbnails/one.svg +0 -9
- package/src/assets/images/tooltip/tool-arrow.tsx +0 -25
- package/src/components/CreateTemplate/V2/index.tsx +0 -527
- package/src/components/CreateTemplate/V2/styles.scss +0 -372
- package/src/components/CreateTemplate/index.tsx +0 -508
- package/src/components/CreateTemplate/styles.scss +0 -404
- package/src/components/GenericUIBlocks/Button/index.tsx +0 -54
- package/src/components/GenericUIBlocks/Button/styles.scss +0 -43
- package/src/components/GenericUIBlocks/CircularProgress/index.tsx +0 -18
- package/src/components/GenericUIBlocks/CircularProgress/styles.scss +0 -93
- package/src/components/GenericUIBlocks/CustomTooltip/index.tsx +0 -88
- package/src/components/GenericUIBlocks/CustomTooltip/styles.scss +0 -19
- package/src/components/GenericUIBlocks/Dialog/V2/index.tsx +0 -227
- package/src/components/GenericUIBlocks/Dialog/V2/styles.scss +0 -289
- package/src/components/GenericUIBlocks/Dialog/index.tsx +0 -185
- package/src/components/GenericUIBlocks/Dialog/styles.scss +0 -227
- package/src/components/GenericUIBlocks/Divider/index.tsx +0 -12
- package/src/components/GenericUIBlocks/Divider/styles.scss +0 -7
- package/src/components/GenericUIBlocks/GeneralSelect/index.tsx +0 -114
- package/src/components/GenericUIBlocks/GeneralSelect/styles.scss +0 -406
- package/src/components/GenericUIBlocks/GeneralTooltip/index.tsx +0 -25
- package/src/components/GenericUIBlocks/GeneralTooltip/styles.scss +0 -20
- package/src/components/GenericUIBlocks/GenericSnackbar/Toast/index.tsx +0 -91
- package/src/components/GenericUIBlocks/GenericSnackbar/Toast/styles.scss +0 -92
- package/src/components/GenericUIBlocks/Grid/index.tsx +0 -82
- package/src/components/GenericUIBlocks/Input/index.tsx +0 -269
- package/src/components/GenericUIBlocks/Input/styles.scss +0 -332
- package/src/components/GenericUIBlocks/Tabs/index.tsx +0 -71
- package/src/components/GenericUIBlocks/Tabs/styles.scss +0 -42
- package/src/components/GenericUIBlocks/Typography/index.tsx +0 -18
- package/src/components/GenericUIBlocks/Typography/styles.scss +0 -27
- package/src/components/SidePanel/CustomAddOns/index.tsx +0 -342
- package/src/components/SidePanel/CustomAddOns/styles.scss +0 -86
- package/src/components/SidePanel/CustomBlockColors/index.tsx +0 -211
- package/src/components/SidePanel/CustomBlockColors/styles.scss +0 -80
- package/src/components/SidePanel/CustomFields/customFieldSection.tsx +0 -547
- package/src/components/SidePanel/CustomFields/styles.scss +0 -64
- package/src/components/SidePanel/CustomQRCode/V2/QRCodeModal/index.tsx +0 -172
- package/src/components/SidePanel/CustomQRCode/V2/QRCodeModal/styles.scss +0 -46
- package/src/components/SidePanel/CustomQRCode/index.tsx +0 -1070
- package/src/components/SidePanel/CustomQRCode/styles.scss +0 -149
- package/src/components/SidePanel/CustomUploads/V2/index.tsx +0 -542
- package/src/components/SidePanel/CustomUploads/V2/styles.scss +0 -267
- package/src/components/SidePanel/CustomUploads/index.tsx +0 -301
- package/src/components/SidePanel/Templates/ModalGallery/HireDesigner/index.tsx +0 -424
- package/src/components/SidePanel/Templates/ModalGallery/HireDesigner/styles.scss +0 -180
- package/src/components/SidePanel/Templates/ModalGallery/V2/index.tsx +0 -235
- package/src/components/SidePanel/Templates/ModalGallery/V2/styles.scss +0 -244
- package/src/components/SidePanel/Templates/ModalGallery/index.tsx +0 -231
- package/src/components/SidePanel/Templates/SideBarGallery/index.tsx +0 -233
- package/src/components/SidePanel/Templates/SideBarGallery/styles.scss +0 -152
- package/src/components/SidePanel/Templates/TemplatesCard/V2/index.tsx +0 -149
- package/src/components/SidePanel/Templates/TemplatesCard/V2/styles.scss +0 -156
- package/src/components/SidePanel/Templates/TemplatesCard/index.tsx +0 -160
- package/src/components/SidePanel/Templates/TemplatesCard/styles.scss +0 -98
- package/src/components/SidePanel/Templates/customTemplateSection.tsx +0 -793
- package/src/components/SidePanel/Templates/styles.scss +0 -244
- package/src/components/SidePanel/index.tsx +0 -160
- package/src/components/TemplateBuilder/index.tsx +0 -585
- package/src/components/TemplateBuilder/styles.scss +0 -100
- package/src/components/TemplateTypes/index.tsx +0 -96
- package/src/components/TemplateTypes/styles.scss +0 -91
- package/src/components/TopNavigation/ConfirmNavigateDialog/index.tsx +0 -81
- package/src/components/TopNavigation/ConfirmNavigateDialog/styles.scss +0 -123
- package/src/components/TopNavigation/DuplicateTemplateModal.tsx +0 -103
- package/src/components/TopNavigation/EditTemplateNameModel/index.tsx +0 -71
- package/src/components/TopNavigation/EditTemplateNameModel/styles.scss +0 -88
- package/src/components/TopNavigation/SaveTemplateModel/index.tsx +0 -201
- package/src/components/TopNavigation/SaveTemplateModel/styles.scss +0 -128
- package/src/components/TopNavigation/index.tsx +0 -938
- package/src/components/TopNavigation/styles.scss +0 -303
- package/src/importMeta.d.ts +0 -31
- package/src/index.scss +0 -131
- package/src/index.tsx +0 -238
- package/src/libs/test.ts +0 -7
- package/src/redux/actions/action-types.ts +0 -52
- package/src/redux/actions/customQRCodeActions.ts +0 -54
- package/src/redux/actions/snackbarActions.ts +0 -16
- package/src/redux/actions/templateActions.ts +0 -236
- package/src/redux/reducers/customFieldReducer.ts +0 -99
- package/src/redux/reducers/customQRCodeReducer.ts +0 -58
- package/src/redux/reducers/index.ts +0 -15
- package/src/redux/reducers/snackbarReducer.ts +0 -40
- package/src/redux/reducers/templateReducer.ts +0 -485
- package/src/redux/store.ts +0 -18
- package/src/styles/colors.scss +0 -61
- package/src/test/mocks.js +0 -89
- package/src/test/setupJest.js +0 -1
- package/src/utils/api.ts +0 -36
- package/src/utils/constants.ts +0 -182
- package/src/utils/customStyles.ts +0 -45
- package/src/utils/fetchWrapper.ts +0 -73
- package/src/utils/fonts.json +0 -1597
- package/src/utils/helper.ts +0 -205
- package/src/utils/local-storage.ts +0 -15
- package/src/utils/message.ts +0 -162
- package/src/utils/products.ts +0 -186
- package/src/utils/template-builder.ts +0 -328
- package/src/utils/templateIdentifierArea/biFold.ts +0 -107
- package/src/utils/templateIdentifierArea/index.ts +0 -35
- package/src/utils/templateIdentifierArea/personal.ts +0 -107
- package/src/utils/templateIdentifierArea/postCards.ts +0 -163
- package/src/utils/templateIdentifierArea/professional.ts +0 -125
- package/src/utils/templateIdentifierArea/snapPack.ts +0 -107
- package/src/utils/templateIdentifierArea/triFold.ts +0 -107
- package/src/utils/templateRestrictedArea/biFold.ts +0 -329
- package/src/utils/templateRestrictedArea/nonWindowProfessional.ts +0 -90
- package/src/utils/templateRestrictedArea/personal.ts +0 -90
- package/src/utils/templateRestrictedArea/postCard.ts +0 -334
- package/src/utils/templateRestrictedArea/postCardJumbo.tsx +0 -408
- package/src/utils/templateRestrictedArea/professional.ts +0 -318
- package/src/utils/templateRestrictedArea/realPenned.ts +0 -233
- package/src/utils/templateRestrictedArea/snapPack.ts +0 -1009
- package/src/utils/templateRestrictedArea/triFold.ts +0 -330
- package/src/utils/templateSafetyBorders/biFold.ts +0 -91
- package/src/utils/templateSafetyBorders/index.ts +0 -43
- package/src/utils/templateSafetyBorders/personal.ts +0 -41
- package/src/utils/templateSafetyBorders/postCards.ts +0 -259
- package/src/utils/templateSafetyBorders/professional.ts +0 -78
- package/src/utils/templateSafetyBorders/snapPack.ts +0 -165
- package/src/utils/templateSafetyBorders/triFold.ts +0 -114
- package/src/utils/templateSafetyBorders/types.d.ts +0 -68
- package/src/utils/types.ts +0 -12
- package/src/v2Theme.scss +0 -142
- package/tsconfig.json +0 -29
- package/tsconfig.node.json +0 -12
- package/update-version.js +0 -23
- package/version.js +0 -1
- package/vite.config.ts +0 -8
- package/webpack.config.js +0 -80
|
@@ -1,328 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,107 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,35 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,107 +0,0 @@
|
|
|
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
|
-
};
|