@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,508 @@
|
|
|
1
|
+
import React, { ReactElement, useEffect, useState } from 'react';
|
|
2
|
+
|
|
3
|
+
//hooks
|
|
4
|
+
import { NavLink, useNavigate } from 'react-router-dom';
|
|
5
|
+
import { useDispatch, useSelector } from 'react-redux';
|
|
6
|
+
import { AppDispatch, RootState } from '../../redux/store';
|
|
7
|
+
|
|
8
|
+
//actions
|
|
9
|
+
import {
|
|
10
|
+
clearTemplateFields,
|
|
11
|
+
searchAndAdvanceChange,
|
|
12
|
+
selectPostCard,
|
|
13
|
+
selectProduct,
|
|
14
|
+
} from '../../redux/actions/templateActions';
|
|
15
|
+
import { CLEAR_TEMPLATE } from '../../redux/actions/action-types';
|
|
16
|
+
import { clearQrFields } from '../../redux/actions/customQRCodeActions';
|
|
17
|
+
|
|
18
|
+
//utils
|
|
19
|
+
import { PRODUCT_LEARN_URL, sortOrderForTemplates } from '../../utils/constants';
|
|
20
|
+
import { removeItem } from '../../utils/local-storage';
|
|
21
|
+
import { MESSAGES } from '../../utils/message';
|
|
22
|
+
import { envelopeTypes } from '../../utils/template-builder';
|
|
23
|
+
|
|
24
|
+
// UI Components
|
|
25
|
+
import { GridContainer, GridItem } from '../GenericUIBlocks/Grid';
|
|
26
|
+
import Typography from '../GenericUIBlocks/Typography';
|
|
27
|
+
import Button from '../GenericUIBlocks/Button';
|
|
28
|
+
import GeneralSelect from '../GenericUIBlocks/GeneralSelect';
|
|
29
|
+
import GenericSnackbar from '../GenericUIBlocks/GenericSnackbar/Toast';
|
|
30
|
+
import GeneralTooltip from '../GenericUIBlocks/GeneralTooltip';
|
|
31
|
+
|
|
32
|
+
// Images
|
|
33
|
+
//@ts-ignore
|
|
34
|
+
import Postcard from '../../assets/images/templates/postcard.tsx';
|
|
35
|
+
//@ts-ignore
|
|
36
|
+
import PersonalLetter from '../../assets/images/templates/personal-letter.tsx';
|
|
37
|
+
//@ts-ignore
|
|
38
|
+
import ProfessionalLetter from '../../assets/images/templates/professional-letter.tsx';
|
|
39
|
+
//@ts-ignore
|
|
40
|
+
import RealPennedLetter from '../../assets/images/templates/real-penned-letters.tsx';
|
|
41
|
+
//@ts-ignore
|
|
42
|
+
import TriFoldSelfMailers from '../../assets/images/templates/tri-fold-self-mailers.tsx';
|
|
43
|
+
//@ts-ignore
|
|
44
|
+
import BiFoldSelfMailers from '../../assets/images/templates/bi-fold-self-mailers.tsx';
|
|
45
|
+
//@ts-ignore
|
|
46
|
+
import SnapPackMailers from '../../assets/images/templates/snap-pack.tsx';
|
|
47
|
+
//@ts-ignore
|
|
48
|
+
import InfoIcon from '../../assets/images/templates/info-icon';
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
import SizeImage from '../../assets/images/templates/size-image';
|
|
52
|
+
import SizeImageMid from '../../assets/images/templates/size-image-mid';
|
|
53
|
+
import SizeImageLarge from '../../assets/images/templates/size-image-lg';
|
|
54
|
+
import SizeImageXLarge from '../../assets/images/templates/size-image-xl';
|
|
55
|
+
|
|
56
|
+
import Input from '../GenericUIBlocks/Input';
|
|
57
|
+
import Divider from '../GenericUIBlocks/Divider';
|
|
58
|
+
|
|
59
|
+
// styles
|
|
60
|
+
import './styles.scss';
|
|
61
|
+
|
|
62
|
+
const templateHeadingStyles: React.CSSProperties = {
|
|
63
|
+
color: `var(--primary-color)`,
|
|
64
|
+
fontSize: `24px`,
|
|
65
|
+
fontStyle: `normal`,
|
|
66
|
+
fontWeight: `600`,
|
|
67
|
+
lineHeight: `normal`,
|
|
68
|
+
marginBottom: `20px`,
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const templateTextStyles: React.CSSProperties = {
|
|
72
|
+
color: `var(--text-color)`,
|
|
73
|
+
fontSize: `14px`,
|
|
74
|
+
fontStyle: `normal`,
|
|
75
|
+
fontWeight: `400`,
|
|
76
|
+
lineHeight: `normal`,
|
|
77
|
+
marginBottom: `16px`,
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
const footerButtonStyles: React.CSSProperties = {
|
|
81
|
+
width: '100%',
|
|
82
|
+
maxWidth: '100px',
|
|
83
|
+
height: '100%',
|
|
84
|
+
minHeight: '40px',
|
|
85
|
+
textTransform: 'capitalize',
|
|
86
|
+
borderRadius: '3px',
|
|
87
|
+
backgroundColor: 'transparent',
|
|
88
|
+
color: `var(--text-color)`,
|
|
89
|
+
fontSize: `14px`,
|
|
90
|
+
fontWeight: `500`,
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
const Images: Record<string, ReactElement> = {
|
|
94
|
+
Postcards: <Postcard fill="var(--svg-color)" />,
|
|
95
|
+
'Professional Letters': <ProfessionalLetter fill="var(--svg-color)" />,
|
|
96
|
+
'Personal Letters': <PersonalLetter fill="var(--svg-color)" />,
|
|
97
|
+
'Real Penned Letter': <RealPennedLetter fill="var(--svg-color)" />,
|
|
98
|
+
'Tri-Fold Self-Mailers': <TriFoldSelfMailers fill="var(--svg-color)" />,
|
|
99
|
+
'Bi-Fold Self-Mailers': <BiFoldSelfMailers fill="var(--svg-color)" />,
|
|
100
|
+
'Snap Pack Mailers': <SnapPackMailers fill="var(--svg-color)" />
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
interface CreateTemplateProps {
|
|
104
|
+
onReturnAndNavigate?: () => void;
|
|
105
|
+
createTemplateRoute?: string | null;
|
|
106
|
+
templateBuilderRoute?: string | null;
|
|
107
|
+
restrictedProducts?: any;
|
|
108
|
+
disallowedProducts?: string[] | null | undefined;
|
|
109
|
+
currentTheme?: string | null | undefined;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const CreateTemplate: React.FC<CreateTemplateProps> = ({
|
|
113
|
+
onReturnAndNavigate,
|
|
114
|
+
createTemplateRoute,
|
|
115
|
+
templateBuilderRoute,
|
|
116
|
+
restrictedProducts,
|
|
117
|
+
disallowedProducts,
|
|
118
|
+
currentTheme
|
|
119
|
+
}) => {
|
|
120
|
+
const [isError, setIsError] = useState<boolean>(false);
|
|
121
|
+
const [envelopeType, setEnvelopeType] = useState<[]>([]);
|
|
122
|
+
const [inputValue, setInputValue] = useState('');
|
|
123
|
+
|
|
124
|
+
const title = useSelector((state: RootState) => state.templates.title) || '';
|
|
125
|
+
const product = useSelector(
|
|
126
|
+
(state: RootState) => state.templates.product
|
|
127
|
+
) as Record<string, any>;
|
|
128
|
+
const products = useSelector((state: RootState) => state.templates.products);
|
|
129
|
+
const templateType = useSelector(
|
|
130
|
+
(state: RootState) => state.templates.templateType
|
|
131
|
+
);
|
|
132
|
+
|
|
133
|
+
const dispatch: AppDispatch = useDispatch();
|
|
134
|
+
const navigate = useNavigate();
|
|
135
|
+
|
|
136
|
+
const restrictedSet = new Set(
|
|
137
|
+
(restrictedProducts ?? []).map((id: any) => String(id))
|
|
138
|
+
);
|
|
139
|
+
|
|
140
|
+
const disallowedSet = new Set(disallowedProducts ?? []);
|
|
141
|
+
const sortedProducts = products
|
|
142
|
+
?.sort((a, b) => {
|
|
143
|
+
const indexA = sortOrderForTemplates.indexOf(a.productType);
|
|
144
|
+
const indexB = sortOrderForTemplates.indexOf(b.productType);
|
|
145
|
+
return indexA - indexB;
|
|
146
|
+
})
|
|
147
|
+
.filter((product) => {
|
|
148
|
+
return (
|
|
149
|
+
!restrictedSet.has(String(product.id)) &&
|
|
150
|
+
!disallowedSet.has(product.productType.toLowerCase().replace(/\s+/g, '_'))
|
|
151
|
+
);
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
const filteredEnvelopeTypes = envelopeTypes.filter((type) => {
|
|
155
|
+
return !restrictedProducts?.includes(type.productId);
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
const handleNext = () => {
|
|
159
|
+
const trimedTitle = title.trim();
|
|
160
|
+
if (
|
|
161
|
+
!trimedTitle ||
|
|
162
|
+
trimedTitle?.length > 50 ||
|
|
163
|
+
!templateType ||
|
|
164
|
+
!product ||
|
|
165
|
+
(product &&
|
|
166
|
+
product.productType === 'Postcards' &&
|
|
167
|
+
!product?.selectedSize) ||
|
|
168
|
+
(product &&
|
|
169
|
+
product.productType === 'Professional Letters' &&
|
|
170
|
+
!Object.keys(envelopeType).length)
|
|
171
|
+
) {
|
|
172
|
+
setIsError(true);
|
|
173
|
+
} else {
|
|
174
|
+
let envelope: string | string[] = '';
|
|
175
|
+
if (product.productType === 'Professional Letters') {
|
|
176
|
+
//@ts-ignore
|
|
177
|
+
envelope = envelopeTypes.find(
|
|
178
|
+
//@ts-ignore
|
|
179
|
+
(envelope) => envelope?.label === envelopeType.label
|
|
180
|
+
)?.type;
|
|
181
|
+
}
|
|
182
|
+
dispatch(searchAndAdvanceChange('title', trimedTitle));
|
|
183
|
+
dispatch(searchAndAdvanceChange('envelopeType', envelope));
|
|
184
|
+
navigate(
|
|
185
|
+
templateBuilderRoute ? templateBuilderRoute : '/template-builder'
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
const ProductTooltipContent = ({ product }: { product: any }) => (
|
|
191
|
+
<div className="productTooltipContent">
|
|
192
|
+
<Typography className='heading'>{product?.productType}</Typography>
|
|
193
|
+
<div className='contentWrapper'>
|
|
194
|
+
{product?.size && product?.size.map((size: any, idx: any) => (
|
|
195
|
+
<Typography key={idx}><span>Size:</span> {size.size}</Typography>
|
|
196
|
+
))}
|
|
197
|
+
{product?.paper && <Typography><span>Paper: </span> {product?.paper} </Typography>}
|
|
198
|
+
{+product?.id !== 2 && product?.envelope && <Typography><span>Envelope: </span> {product?.envelope} </Typography>}
|
|
199
|
+
{+product?.id === 2 && product?.envelope && <Typography><span>Windowed Envelope: </span> {product?.envelope} </Typography>}
|
|
200
|
+
{+product?.id === 2 && product?.nonEnvelope && <Typography><span>Non-Windowed Envelope: </span> {product?.nonEnvelope} </Typography>}
|
|
201
|
+
{/* {product?.ink && <Typography><span>Ink: </span> {product?.ink} </Typography>} */}
|
|
202
|
+
</div>
|
|
203
|
+
</div>
|
|
204
|
+
);
|
|
205
|
+
|
|
206
|
+
useEffect(() => {
|
|
207
|
+
dispatch(clearTemplateFields());
|
|
208
|
+
dispatch(clearQrFields());
|
|
209
|
+
removeItem('formData');
|
|
210
|
+
dispatch({ type: CLEAR_TEMPLATE });
|
|
211
|
+
}, []);
|
|
212
|
+
|
|
213
|
+
useEffect(() => {
|
|
214
|
+
if (sortedProducts?.length) {
|
|
215
|
+
dispatch(selectProduct(sortedProducts[0]));
|
|
216
|
+
}
|
|
217
|
+
}, [products]);
|
|
218
|
+
|
|
219
|
+
useEffect(() => {
|
|
220
|
+
if (product && product?.productType === 'Professional Letters') {
|
|
221
|
+
if (Object.keys(envelopeType).length) {
|
|
222
|
+
setIsError(false);
|
|
223
|
+
}
|
|
224
|
+
//@ts-ignore
|
|
225
|
+
if (envelopeType?.label === 'Non-Windowed Envelope') {
|
|
226
|
+
dispatch(
|
|
227
|
+
selectProduct(sortedProducts.find((item) => item.windowed === false))
|
|
228
|
+
);
|
|
229
|
+
//@ts-ignore
|
|
230
|
+
} else if (envelopeType?.label === 'Windowed Envelope') {
|
|
231
|
+
dispatch(
|
|
232
|
+
selectProduct(sortedProducts.find((item) => item.windowed === true))
|
|
233
|
+
);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}, [envelopeType]);
|
|
237
|
+
|
|
238
|
+
return (
|
|
239
|
+
<>
|
|
240
|
+
<Typography className="hideTemplateBuilder">
|
|
241
|
+
{MESSAGES.TEMPLATE_MESSAGE_ON_SMALL_SCREEN}
|
|
242
|
+
</Typography>
|
|
243
|
+
<div className="createTemplateMaindiv">
|
|
244
|
+
<div>
|
|
245
|
+
<GridContainer>
|
|
246
|
+
<GridItem lg={6} md={6} sm={12} xs={12}>
|
|
247
|
+
<div className="createTemplateHeader">
|
|
248
|
+
<Typography style={templateHeadingStyles}>
|
|
249
|
+
{MESSAGES.TEMPLATE.CREATE.TITLE}
|
|
250
|
+
</Typography>
|
|
251
|
+
<div className="templateInputWrapper">
|
|
252
|
+
<Input
|
|
253
|
+
type="text"
|
|
254
|
+
value={inputValue}
|
|
255
|
+
onChange={(e: any) => {
|
|
256
|
+
setInputValue(e.target.value);
|
|
257
|
+
dispatch(searchAndAdvanceChange('title', e.target.value));
|
|
258
|
+
}}
|
|
259
|
+
placeholder="Template Name"
|
|
260
|
+
inputIcon={false}
|
|
261
|
+
error={
|
|
262
|
+
!title.trim() && isError
|
|
263
|
+
? MESSAGES.TEMPLATE.NAME_REQUIRED
|
|
264
|
+
: title.length > 50 && isError
|
|
265
|
+
? MESSAGES.TEMPLATE.NAME_LESS_50
|
|
266
|
+
: ''
|
|
267
|
+
}
|
|
268
|
+
label={MESSAGES.TEMPLATE.CREATE.TEMPLATE_LABEL}
|
|
269
|
+
/>
|
|
270
|
+
</div>
|
|
271
|
+
</div>
|
|
272
|
+
</GridItem>
|
|
273
|
+
</GridContainer>
|
|
274
|
+
<Divider />
|
|
275
|
+
<GridContainer>
|
|
276
|
+
<GridItem lg={12} md={12} sm={12} xs={12}>
|
|
277
|
+
<div className="productTypeWrapper">
|
|
278
|
+
<div className="productHeading">
|
|
279
|
+
<Typography
|
|
280
|
+
style={{ ...templateTextStyles, marginBottom: '0px' }}
|
|
281
|
+
>
|
|
282
|
+
{MESSAGES.TEMPLATE.CREATE.PRODUCT_LABEL}
|
|
283
|
+
</Typography>
|
|
284
|
+
<NavLink to={PRODUCT_LEARN_URL} target="_blank">
|
|
285
|
+
<Typography>
|
|
286
|
+
{' '}
|
|
287
|
+
{MESSAGES.TEMPLATE.CREATE.LEARN_TEXT}
|
|
288
|
+
</Typography>
|
|
289
|
+
</NavLink>
|
|
290
|
+
</div>
|
|
291
|
+
<div
|
|
292
|
+
className="productsWrapper"
|
|
293
|
+
style={{
|
|
294
|
+
marginBottom:
|
|
295
|
+
product &&
|
|
296
|
+
(product.productType.includes('Postcards') || product.productType.includes('Professional Letters') || product.productType.includes('Real Penned Letter'))
|
|
297
|
+
? undefined
|
|
298
|
+
: '100px',
|
|
299
|
+
}}
|
|
300
|
+
>
|
|
301
|
+
{sortedProducts &&
|
|
302
|
+
sortedProducts
|
|
303
|
+
?.filter((prod) => {
|
|
304
|
+
if (restrictedSet.has('2') || restrictedSet.has('4')) {
|
|
305
|
+
return true;
|
|
306
|
+
} else {
|
|
307
|
+
return prod.windowed !== false;
|
|
308
|
+
}
|
|
309
|
+
})
|
|
310
|
+
.map((prod, index) => {
|
|
311
|
+
return (
|
|
312
|
+
<div
|
|
313
|
+
className={`productCard ${prod.productType ===
|
|
314
|
+
(product && product.productType)
|
|
315
|
+
? 'active'
|
|
316
|
+
: ''
|
|
317
|
+
} ${isError && !product ? 'error' : ''} `}
|
|
318
|
+
key={index}
|
|
319
|
+
onClick={() => dispatch(selectProduct(prod))}
|
|
320
|
+
>
|
|
321
|
+
{Images[prod.productType]}
|
|
322
|
+
<Typography>{prod.productType}</Typography>
|
|
323
|
+
<div className={`productTooltip productTooltip-${index}`}>
|
|
324
|
+
<InfoIcon fill="var(--primary-color)" className={`productTooltipIcon-${index}`} />
|
|
325
|
+
<GeneralTooltip
|
|
326
|
+
anchorSelect={`.productTooltipIcon-${index}`}
|
|
327
|
+
place="right"
|
|
328
|
+
className='customTooltipClass'
|
|
329
|
+
title={<ProductTooltipContent product={prod} />}
|
|
330
|
+
/>
|
|
331
|
+
</div>
|
|
332
|
+
</div>
|
|
333
|
+
);
|
|
334
|
+
})}
|
|
335
|
+
</div>
|
|
336
|
+
{isError && !product && (
|
|
337
|
+
<Typography className="error-field">
|
|
338
|
+
*{MESSAGES.TEMPLATE.PRODUCT_TYPE_REQUIRED}
|
|
339
|
+
</Typography>
|
|
340
|
+
)}
|
|
341
|
+
</div>
|
|
342
|
+
</GridItem>
|
|
343
|
+
</GridContainer>
|
|
344
|
+
{product?.productType?.includes('Postcards') ||
|
|
345
|
+
product?.productType?.includes('Professional Letters') || product?.productType?.includes('Real Penned Letter') ? (
|
|
346
|
+
<Divider />
|
|
347
|
+
) : null}
|
|
348
|
+
{product && product.productType === 'Professional Letters' && (
|
|
349
|
+
<GridContainer>
|
|
350
|
+
<GridItem lg={6} md={6} sm={12} xs={12}>
|
|
351
|
+
<div className="templateSelectWrapper">
|
|
352
|
+
<GeneralSelect
|
|
353
|
+
className={isError && ![envelopeType].length ? 'error' : ''}
|
|
354
|
+
//@ts-ignore
|
|
355
|
+
selectedValue={envelopeType}
|
|
356
|
+
//@ts-ignore
|
|
357
|
+
setSelectedValue={setEnvelopeType}
|
|
358
|
+
//@ts-ignore
|
|
359
|
+
options={filteredEnvelopeTypes}
|
|
360
|
+
placeholder="Envelope Type"
|
|
361
|
+
error={MESSAGES.TEMPLATE.ENVELOPE_TYPE_REQUIRED}
|
|
362
|
+
isError={isError && !Object.keys(envelopeType).length}
|
|
363
|
+
label="Envelope Type*"
|
|
364
|
+
/>
|
|
365
|
+
</div>
|
|
366
|
+
</GridItem>
|
|
367
|
+
</GridContainer>
|
|
368
|
+
)}
|
|
369
|
+
{product && (product?.productType === 'Postcards' || product?.productType === 'Real Penned Letter') && product?.size && (
|
|
370
|
+
<GridContainer>
|
|
371
|
+
<GridItem lg={12} md={12} sm={12} xs={12}>
|
|
372
|
+
<div className="postCardSizeWrapper">
|
|
373
|
+
<div className="postCardHeading">
|
|
374
|
+
<Typography style={templateTextStyles}>
|
|
375
|
+
{product?.productType === 'Real Penned Letter' ? 'Real Penned Letter Size*' : 'Postcard Size*'}
|
|
376
|
+
</Typography>
|
|
377
|
+
</div>
|
|
378
|
+
<div className="postCardWrapper">
|
|
379
|
+
{product?.size
|
|
380
|
+
.sort((a: any, b: any) => a.id.localeCompare(b.id))
|
|
381
|
+
.map((type: any, index: any) => {
|
|
382
|
+
const size = type?.label?.split('x') || type?.size?.split('x');
|
|
383
|
+
return (
|
|
384
|
+
<div
|
|
385
|
+
onClick={() => {
|
|
386
|
+
if (product?.productType === 'Real Penned Letter') {
|
|
387
|
+
dispatch(selectPostCard({
|
|
388
|
+
...product,
|
|
389
|
+
id: type.id,
|
|
390
|
+
size: product.size,
|
|
391
|
+
selectedSize: type.size,
|
|
392
|
+
}, 'Real Penned Letter'));
|
|
393
|
+
} else {
|
|
394
|
+
dispatch(selectPostCard({
|
|
395
|
+
...type,
|
|
396
|
+
size: product.size,
|
|
397
|
+
selectedSize: type.size,
|
|
398
|
+
},
|
|
399
|
+
'Postcards'
|
|
400
|
+
));
|
|
401
|
+
}
|
|
402
|
+
}}
|
|
403
|
+
className={
|
|
404
|
+
product?.productType === 'Real Penned Letter' ?
|
|
405
|
+
`postCard ${product.selectedSize === type.size
|
|
406
|
+
? 'active'
|
|
407
|
+
: ''
|
|
408
|
+
}` :
|
|
409
|
+
index === 0
|
|
410
|
+
? `postCard postCard-small ${product.selectedSize === type.size
|
|
411
|
+
? 'active'
|
|
412
|
+
: ''
|
|
413
|
+
}`
|
|
414
|
+
: index === 1
|
|
415
|
+
? `postCard postCard-mid ${product.selectedSize === type.size
|
|
416
|
+
? 'active'
|
|
417
|
+
: ''
|
|
418
|
+
}`
|
|
419
|
+
: index === 2
|
|
420
|
+
? `postCard postCard-large ${product.selectedSize === type.size
|
|
421
|
+
? 'active'
|
|
422
|
+
: ''
|
|
423
|
+
}`
|
|
424
|
+
: `postCard ${product.selectedSize === type.size
|
|
425
|
+
? 'active'
|
|
426
|
+
: ''
|
|
427
|
+
}`
|
|
428
|
+
}
|
|
429
|
+
key={index}
|
|
430
|
+
>
|
|
431
|
+
<Typography>
|
|
432
|
+
{product?.productType === 'Real Penned Letter'
|
|
433
|
+
? type?.title
|
|
434
|
+
: `${size[0]}" x ${size[1]}"`}
|
|
435
|
+
</Typography>
|
|
436
|
+
{product?.productType === 'Real Penned Letter' ?
|
|
437
|
+
<>
|
|
438
|
+
{index === 0 &&
|
|
439
|
+
<div className='rplSubCards'>
|
|
440
|
+
<PersonalLetter fill="var(--svg-color)" />
|
|
441
|
+
</div>
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
{index === 1 &&
|
|
445
|
+
<div className='rplSubCards'>
|
|
446
|
+
<ProfessionalLetter fill="var(--svg-color)" />
|
|
447
|
+
</div>
|
|
448
|
+
}
|
|
449
|
+
</> :
|
|
450
|
+
index === 0 ? (
|
|
451
|
+
<SizeImage />
|
|
452
|
+
) : index === 1 ? (
|
|
453
|
+
<SizeImageMid />
|
|
454
|
+
) : index === 2 ? (
|
|
455
|
+
<SizeImageLarge />
|
|
456
|
+
) : <SizeImageXLarge />
|
|
457
|
+
}
|
|
458
|
+
</div>
|
|
459
|
+
);
|
|
460
|
+
})}
|
|
461
|
+
</div>
|
|
462
|
+
{isError &&
|
|
463
|
+
product &&
|
|
464
|
+
product.productType === 'Postcards' &&
|
|
465
|
+
!product.selectedSize && (
|
|
466
|
+
<Typography className="error-field">
|
|
467
|
+
*{MESSAGES.TEMPLATE.POSTCARD_SIZE_REQUIRED}
|
|
468
|
+
</Typography>
|
|
469
|
+
)}
|
|
470
|
+
</div>
|
|
471
|
+
</GridItem>
|
|
472
|
+
</GridContainer>
|
|
473
|
+
)}
|
|
474
|
+
</div>
|
|
475
|
+
<div className="footerBtns">
|
|
476
|
+
<div className="createTemplateBtns">
|
|
477
|
+
<Button
|
|
478
|
+
style={{
|
|
479
|
+
...footerButtonStyles,
|
|
480
|
+
border: '0.5px solid var(--border-color)',
|
|
481
|
+
}}
|
|
482
|
+
onClick={() =>
|
|
483
|
+
onReturnAndNavigate
|
|
484
|
+
? onReturnAndNavigate()
|
|
485
|
+
: navigate(createTemplateRoute || '/create-template')
|
|
486
|
+
}
|
|
487
|
+
>
|
|
488
|
+
{MESSAGES.TEMPLATE.CREATE.CANCEL_BUTTON}
|
|
489
|
+
</Button>
|
|
490
|
+
<Button
|
|
491
|
+
style={{
|
|
492
|
+
...footerButtonStyles,
|
|
493
|
+
color: '#ffffff',
|
|
494
|
+
backgroundColor: 'var(--primary-color)',
|
|
495
|
+
}}
|
|
496
|
+
onClick={handleNext}
|
|
497
|
+
>
|
|
498
|
+
{MESSAGES.TEMPLATE.CREATE.SUBMIT_BUTTON}
|
|
499
|
+
</Button>
|
|
500
|
+
</div>
|
|
501
|
+
</div>
|
|
502
|
+
<GenericSnackbar />
|
|
503
|
+
</div>
|
|
504
|
+
</>
|
|
505
|
+
);
|
|
506
|
+
};
|
|
507
|
+
|
|
508
|
+
export default CreateTemplate;
|