@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,424 @@
|
|
|
1
|
+
import React, {useEffect, useState} from 'react';
|
|
2
|
+
|
|
3
|
+
// Hooks
|
|
4
|
+
import {useDispatch, useSelector} from 'react-redux';
|
|
5
|
+
import { RootState } from '../../../../../redux/reducers';
|
|
6
|
+
import {AppDispatch} from '../../../../../redux/store';
|
|
7
|
+
|
|
8
|
+
// Actions
|
|
9
|
+
import {success} from '../../../../../redux/actions/snackbarActions';
|
|
10
|
+
|
|
11
|
+
// Utils
|
|
12
|
+
import {post} from '../../../../../utils/api';
|
|
13
|
+
import { getItem, removeItem, setItem } from '../../../../../utils/local-storage';
|
|
14
|
+
import { dataURLtoBlob } from '../../../../../utils/helper';
|
|
15
|
+
import {EMAIL_REGEX, VIDEO_URL_REGEX} from '../../../../../utils/constants';
|
|
16
|
+
import { MESSAGES } from '../../../../../utils/message';
|
|
17
|
+
|
|
18
|
+
// Components
|
|
19
|
+
import Dialog from '../../../../GenericUIBlocks/Dialog';
|
|
20
|
+
import Input from '../../../../GenericUIBlocks/Input';
|
|
21
|
+
import Typography from '../../../../GenericUIBlocks/Typography';
|
|
22
|
+
import Button from '../../../../GenericUIBlocks/Button';
|
|
23
|
+
|
|
24
|
+
// Icons
|
|
25
|
+
import PDF from '../../../../../assets/images/modal-icons/pdf';
|
|
26
|
+
import PNG from '../../../../../assets/images/modal-icons/png';
|
|
27
|
+
import DOC from '../../../../../assets/images/modal-icons/doc';
|
|
28
|
+
import DOCX from '../../../../../assets/images/modal-icons/docx';
|
|
29
|
+
import JPG from '../../../../../assets/images/modal-icons/jpg';
|
|
30
|
+
import JPEG from '../../../../../assets/images/modal-icons/jpeg';
|
|
31
|
+
import CancelFile from '../../../../../assets/images/modal-icons/cancel-file';
|
|
32
|
+
import Add from '../../../../../assets/images/modal-icons/add';
|
|
33
|
+
|
|
34
|
+
// Styles
|
|
35
|
+
import './styles.scss';
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
const hireModalStyles = {
|
|
39
|
+
maxWidth: '725px',
|
|
40
|
+
minHeight: '760px',
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const hireModalButtonStyles = {
|
|
44
|
+
fontWeight: '600',
|
|
45
|
+
fontSize: '18px',
|
|
46
|
+
maxWidth: '643px',
|
|
47
|
+
minHeight: '55px',
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const errorStyles = {
|
|
51
|
+
color: 'var(--error-color)',
|
|
52
|
+
fontWeight: '400',
|
|
53
|
+
fontSize: '14px',
|
|
54
|
+
margin: '0',
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const HireDesigner = (props: any) => {
|
|
58
|
+
const { open, onClose, onCreateCustomTemplateQuery, productId } = props;
|
|
59
|
+
|
|
60
|
+
const [queryTitle, setQueryTitle] = useState('');
|
|
61
|
+
const [queryEmail, setQueryEmail] = useState('');
|
|
62
|
+
const [queryFile, setQueryFile] = useState([]);
|
|
63
|
+
const [queryVideoUrl, setQueryVideoUrl] = useState('');
|
|
64
|
+
const [queryComments, setQueryComments] = useState('');
|
|
65
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
66
|
+
const [formErrors, setFormErrors] = useState({
|
|
67
|
+
title: '',
|
|
68
|
+
email: '',
|
|
69
|
+
files: '',
|
|
70
|
+
videoUrl: '',
|
|
71
|
+
comments: '',
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
const dispatch: AppDispatch = useDispatch();
|
|
75
|
+
|
|
76
|
+
const designerFormStates = useSelector((state: RootState) => state.templates.hireDesignerForm);
|
|
77
|
+
|
|
78
|
+
const handleTitleChange = (event: any) => {
|
|
79
|
+
const newTitle = event.target.value;
|
|
80
|
+
setQueryTitle(newTitle);
|
|
81
|
+
setFormErrors((prevErrors) => ({
|
|
82
|
+
...prevErrors,
|
|
83
|
+
title: newTitle.trim() && '',
|
|
84
|
+
}));
|
|
85
|
+
dispatch({type: 'SET_HIRE_DESIGNER_FORM_FIELDS', payload: { queryTitle: newTitle }});
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
const handleEmailChange = (event: any) => {
|
|
89
|
+
const newEmail = event.target.value;
|
|
90
|
+
setQueryEmail(newEmail);
|
|
91
|
+
setFormErrors((prevErrors) => ({
|
|
92
|
+
...prevErrors,
|
|
93
|
+
email: newEmail.trim() && '',
|
|
94
|
+
}));
|
|
95
|
+
dispatch({type: 'SET_HIRE_DESIGNER_FORM_FIELDS', payload: { queryEmail: newEmail }});
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
const handleVideoUrlChange = (event: any) => {
|
|
99
|
+
const newVideoUrl = event.target.value;
|
|
100
|
+
setQueryVideoUrl(newVideoUrl);
|
|
101
|
+
setFormErrors((prevErrors) => ({
|
|
102
|
+
...prevErrors,
|
|
103
|
+
videoUrl: newVideoUrl.trim() && '',
|
|
104
|
+
}));
|
|
105
|
+
dispatch({type: 'SET_HIRE_DESIGNER_FORM_FIELDS', payload: { queryVideoUrl: newVideoUrl }});
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
const handleCommentsChange = (event: any) => {
|
|
109
|
+
const newComments = event.target.value;
|
|
110
|
+
setQueryComments(newComments);
|
|
111
|
+
setFormErrors((prevErrors: any) => ({
|
|
112
|
+
...prevErrors,
|
|
113
|
+
comments: newComments.trim() && '',
|
|
114
|
+
}));
|
|
115
|
+
dispatch({type: 'SET_HIRE_DESIGNER_FORM_FIELDS', payload: { queryComments: newComments }})
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
const saveFilesToLocalStorage = (files: File[]) => {
|
|
119
|
+
const fileData = files.map((file) => ({
|
|
120
|
+
name: file.name,
|
|
121
|
+
type: file.type,
|
|
122
|
+
size: file.size,
|
|
123
|
+
content: "",
|
|
124
|
+
}));
|
|
125
|
+
|
|
126
|
+
files.forEach((file, index) => {
|
|
127
|
+
const reader = new FileReader();
|
|
128
|
+
reader.onload = () => {
|
|
129
|
+
fileData[index].content = reader.result as string;
|
|
130
|
+
if (index === files.length - 1) {
|
|
131
|
+
dispatch({type: 'SET_HIRE_DESIGNER_FORM_FIELDS', payload: { queryFiles: fileData }});
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
reader.readAsDataURL(file);
|
|
135
|
+
});
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
// Retrieve files from localStorage
|
|
139
|
+
const getFilesFromLocalStorage = () => {
|
|
140
|
+
const savedFiles = designerFormStates.queryFiles;
|
|
141
|
+
if (!savedFiles) return [];
|
|
142
|
+
const fileData = savedFiles;
|
|
143
|
+
|
|
144
|
+
return fileData.map((file: any) => {
|
|
145
|
+
const blob = dataURLtoBlob(file.content, file.type);
|
|
146
|
+
return new File([blob], file.name, { type: file.type });
|
|
147
|
+
});
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
const handleFileChange = (event: any) => {
|
|
151
|
+
const newFilesArray = Array.from(event.target.files);
|
|
152
|
+
const acceptableTypes = ['image/png', 'image/jpeg', 'image/jpg', 'application/pdf', 'application/msword', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'];
|
|
153
|
+
|
|
154
|
+
const validFiles = newFilesArray.filter((file: any) => acceptableTypes.includes(file.type));
|
|
155
|
+
const invalidFiles = newFilesArray.filter((file: any) => !acceptableTypes.includes(file.type));
|
|
156
|
+
|
|
157
|
+
if (invalidFiles.length > 0) {
|
|
158
|
+
setFormErrors((prevErrors) => ({
|
|
159
|
+
...prevErrors,
|
|
160
|
+
files: MESSAGES.TEMPLATE.HIRE_DESIGNER.FILE_VALLIDATION,
|
|
161
|
+
}));
|
|
162
|
+
setTimeout(() => {
|
|
163
|
+
setFormErrors((prevErrors) => ({
|
|
164
|
+
...prevErrors,
|
|
165
|
+
files: '',
|
|
166
|
+
}));
|
|
167
|
+
}, 6000);
|
|
168
|
+
} else {
|
|
169
|
+
setFormErrors((prevErrors) => ({
|
|
170
|
+
...prevErrors,
|
|
171
|
+
files: '',
|
|
172
|
+
}));
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
if (validFiles.length > 0) {
|
|
176
|
+
setQueryFile((prevFiles: any) => [...prevFiles, ...validFiles] as never[]);
|
|
177
|
+
saveFilesToLocalStorage([...queryFile, ...validFiles] as never[]);
|
|
178
|
+
}
|
|
179
|
+
event.target.value = null;
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
const handleFileRemove = (file: any) => {
|
|
183
|
+
const updatedFiles = queryFile.filter((f: any) => f.name !== file.name);
|
|
184
|
+
setQueryFile(updatedFiles);
|
|
185
|
+
updatedFiles.length ?
|
|
186
|
+
saveFilesToLocalStorage([...updatedFiles] as never[])
|
|
187
|
+
: dispatch({ type: 'SET_HIRE_DESIGNER_FORM_FIELDS', payload: { queryFiles: [] as never[] } });
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
const validateForm = (formData: any, setFormErrors: any) => {
|
|
191
|
+
const errors: any = {};
|
|
192
|
+
|
|
193
|
+
if (!formData.queryTitle.trim()) {
|
|
194
|
+
errors.title = MESSAGES.TEMPLATE.HIRE_DESIGNER.TITLE_REQUIRED;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
if (!formData.queryVideoUrl.trim()) {
|
|
198
|
+
errors.videoUrl = MESSAGES.TEMPLATE.HIRE_DESIGNER.URL_REQUIRED;
|
|
199
|
+
} else if (!VIDEO_URL_REGEX.test(formData.queryVideoUrl.trim())) {
|
|
200
|
+
errors.videoUrl = MESSAGES.TEMPLATE.HIRE_DESIGNER.URL_VAIDATION;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
if (!formData.queryComments.trim()) {
|
|
204
|
+
errors.comments = MESSAGES.TEMPLATE.HIRE_DESIGNER.COMMENT_REQUIRED;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
if (!formData.queryEmail.trim()) {
|
|
208
|
+
errors.email = MESSAGES.TEMPLATE.HIRE_DESIGNER.EMAIL_REQUIRED;
|
|
209
|
+
} else if (!EMAIL_REGEX.test(formData.queryEmail.trim())) {
|
|
210
|
+
errors.email = MESSAGES.TEMPLATE.HIRE_DESIGNER.EMAIL_VALIDATION;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
setFormErrors(errors);
|
|
214
|
+
|
|
215
|
+
return Object.keys(errors).length === 0;
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
const resetForm = () => {
|
|
219
|
+
setQueryTitle('');
|
|
220
|
+
setQueryEmail('');
|
|
221
|
+
setQueryVideoUrl('');
|
|
222
|
+
setQueryFile([]);
|
|
223
|
+
setQueryComments('');
|
|
224
|
+
setFormErrors({
|
|
225
|
+
title: '',
|
|
226
|
+
email: '',
|
|
227
|
+
files: '',
|
|
228
|
+
videoUrl: '',
|
|
229
|
+
comments: '',
|
|
230
|
+
});
|
|
231
|
+
removeItem('hireDesignerFormState');
|
|
232
|
+
removeItem('queryFiles');
|
|
233
|
+
dispatch({type: 'CLEAR_HIRE_DESIGNER_FORM_FIELDS'});
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
const handleSubmit = async (event: any) => {
|
|
237
|
+
try {
|
|
238
|
+
event.preventDefault();
|
|
239
|
+
|
|
240
|
+
const formData = {
|
|
241
|
+
queryTitle,
|
|
242
|
+
queryVideoUrl,
|
|
243
|
+
queryComments,
|
|
244
|
+
queryFile,
|
|
245
|
+
queryEmail,
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
const isValid = validateForm(formData, setFormErrors);
|
|
249
|
+
if (!isValid) return;
|
|
250
|
+
setIsLoading(true);
|
|
251
|
+
|
|
252
|
+
const form = new FormData();
|
|
253
|
+
form.append('title', queryTitle);
|
|
254
|
+
form.append('comments', queryComments);
|
|
255
|
+
form.append('email', queryEmail);
|
|
256
|
+
form.append('productId', productId);
|
|
257
|
+
form.append('url', queryVideoUrl);
|
|
258
|
+
|
|
259
|
+
queryFile.forEach((file: any) => {
|
|
260
|
+
form.append('files', file);
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
const response: any = await post('/custom-template-queries/create', form);
|
|
264
|
+
if (response && response.status === 200) {
|
|
265
|
+
setIsLoading(false);
|
|
266
|
+
closeHireModal();
|
|
267
|
+
dispatch(success(response.data.message));
|
|
268
|
+
onCreateCustomTemplateQuery(response.data);
|
|
269
|
+
} else {
|
|
270
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
271
|
+
}
|
|
272
|
+
} catch (error) {
|
|
273
|
+
return error;
|
|
274
|
+
} finally {
|
|
275
|
+
setIsLoading(false);
|
|
276
|
+
}
|
|
277
|
+
};
|
|
278
|
+
|
|
279
|
+
const closeHireModal = () => {
|
|
280
|
+
onClose();
|
|
281
|
+
resetForm();
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
useEffect(() => {
|
|
285
|
+
setQueryTitle(designerFormStates.queryTitle);
|
|
286
|
+
setQueryEmail(designerFormStates.queryEmail);
|
|
287
|
+
setQueryVideoUrl(designerFormStates.queryVideoUrl);
|
|
288
|
+
setQueryComments(designerFormStates.queryComments);
|
|
289
|
+
const savedFiles: any = getFilesFromLocalStorage();
|
|
290
|
+
setQueryFile(savedFiles);
|
|
291
|
+
}, [open])
|
|
292
|
+
|
|
293
|
+
return (
|
|
294
|
+
<Dialog
|
|
295
|
+
open={open}
|
|
296
|
+
customStyles={hireModalStyles}
|
|
297
|
+
handleClose={closeHireModal}
|
|
298
|
+
isGallery={true}
|
|
299
|
+
submitText="Next"
|
|
300
|
+
>
|
|
301
|
+
<div className="designerFormWrapper">
|
|
302
|
+
<Typography variant="h2">{MESSAGES.TEMPLATE.HIRE_DESIGNER.TITLE}</Typography>
|
|
303
|
+
<form className="designerForm">
|
|
304
|
+
<Input
|
|
305
|
+
type="text"
|
|
306
|
+
placeholder="Template Name"
|
|
307
|
+
label="Template Name*"
|
|
308
|
+
value={queryTitle}
|
|
309
|
+
onChange={handleTitleChange}
|
|
310
|
+
error={formErrors.title}
|
|
311
|
+
/>
|
|
312
|
+
<div className={`input-layout`}>
|
|
313
|
+
<label className="basic-label">{MESSAGES.TEMPLATE.HIRE_DESIGNER.UPLOAD_HEADING}</label>
|
|
314
|
+
<div className="file-upload-wrapper">
|
|
315
|
+
<input
|
|
316
|
+
type="file"
|
|
317
|
+
onChange={handleFileChange}
|
|
318
|
+
multiple
|
|
319
|
+
accept=".png, .jpg, .jpeg, .pdf, .doc, .docx"
|
|
320
|
+
className="file-input"
|
|
321
|
+
/>
|
|
322
|
+
<div className="upload-area">
|
|
323
|
+
<div className="upload-icon">
|
|
324
|
+
<Add />
|
|
325
|
+
</div>
|
|
326
|
+
<label htmlFor="fileInput" className="upload-text">
|
|
327
|
+
Upload a File
|
|
328
|
+
</label>{' '}
|
|
329
|
+
or drag and drop
|
|
330
|
+
<div className="upload-info">
|
|
331
|
+
Supported formats: .png, .jpg, .jpeg, .pdf, .doc, .docx
|
|
332
|
+
</div>
|
|
333
|
+
</div>
|
|
334
|
+
</div>
|
|
335
|
+
{formErrors.files && (
|
|
336
|
+
<Typography variant="p" style={errorStyles}>
|
|
337
|
+
{formErrors.files}
|
|
338
|
+
</Typography>
|
|
339
|
+
)}
|
|
340
|
+
{queryFile.length > 0 && (
|
|
341
|
+
<div className="uploaded-files">
|
|
342
|
+
<h3>{MESSAGES.TEMPLATE.HIRE_DESIGNER.UPLOADED_TEXT}</h3>
|
|
343
|
+
{queryFile.map((file: File, index: number) => (
|
|
344
|
+
<div className="file-item" key={index}>
|
|
345
|
+
<div className="file-icon">
|
|
346
|
+
{file.type === 'application/pdf' ? (
|
|
347
|
+
<PDF />
|
|
348
|
+
) : file.type === 'image/jpeg' ? (
|
|
349
|
+
<JPEG />
|
|
350
|
+
) : file.type === 'image/png' ? (
|
|
351
|
+
<PNG />
|
|
352
|
+
) : file.type === 'image/jpg' ? (
|
|
353
|
+
<JPG />
|
|
354
|
+
) : file.type === 'application/msword' ? (
|
|
355
|
+
<DOC />
|
|
356
|
+
) : file.type ===
|
|
357
|
+
'application/vnd.openxmlformats-officedocument.wordprocessingml.document' ? (
|
|
358
|
+
<DOCX />
|
|
359
|
+
) : null}
|
|
360
|
+
</div>
|
|
361
|
+
<div className="file-details">
|
|
362
|
+
<p className="file-name">{file.name}</p>
|
|
363
|
+
<p className="file-size">
|
|
364
|
+
{(file.size / (1024 * 1024)).toFixed(2)} MB
|
|
365
|
+
</p>
|
|
366
|
+
</div>
|
|
367
|
+
<div
|
|
368
|
+
className="file-remove"
|
|
369
|
+
onClick={() => handleFileRemove(file)}
|
|
370
|
+
>
|
|
371
|
+
<CancelFile />
|
|
372
|
+
</div>
|
|
373
|
+
</div>
|
|
374
|
+
))}
|
|
375
|
+
</div>
|
|
376
|
+
)}
|
|
377
|
+
</div>
|
|
378
|
+
<Input
|
|
379
|
+
type="text"
|
|
380
|
+
placeholder="https://www.example.com"
|
|
381
|
+
label="Video URL*"
|
|
382
|
+
videoTooltip={true}
|
|
383
|
+
value={queryVideoUrl}
|
|
384
|
+
onChange={handleVideoUrlChange}
|
|
385
|
+
error={formErrors.videoUrl}
|
|
386
|
+
/>
|
|
387
|
+
<Input
|
|
388
|
+
type="email"
|
|
389
|
+
placeholder="Email"
|
|
390
|
+
label="Email*"
|
|
391
|
+
value={queryEmail}
|
|
392
|
+
onChange={handleEmailChange}
|
|
393
|
+
error={formErrors.email}
|
|
394
|
+
/>
|
|
395
|
+
<Input
|
|
396
|
+
type="textarea"
|
|
397
|
+
placeholder="Comments"
|
|
398
|
+
label="Comments*"
|
|
399
|
+
value={queryComments}
|
|
400
|
+
onChange={handleCommentsChange}
|
|
401
|
+
error={formErrors.comments}
|
|
402
|
+
/>
|
|
403
|
+
</form>
|
|
404
|
+
<div className="button-container">
|
|
405
|
+
<Button
|
|
406
|
+
onClick={handleSubmit}
|
|
407
|
+
disabled={isLoading}
|
|
408
|
+
style={hireModalButtonStyles}
|
|
409
|
+
>
|
|
410
|
+
{isLoading ? (
|
|
411
|
+
<div className="loading-container">
|
|
412
|
+
<div className="loading-icon" />
|
|
413
|
+
</div>
|
|
414
|
+
) : (
|
|
415
|
+
'Next'
|
|
416
|
+
)}
|
|
417
|
+
</Button>
|
|
418
|
+
</div>
|
|
419
|
+
</div>
|
|
420
|
+
</Dialog>
|
|
421
|
+
);
|
|
422
|
+
};
|
|
423
|
+
|
|
424
|
+
export default HireDesigner;
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
.designerFormWrapper {
|
|
2
|
+
width: 100%;
|
|
3
|
+
display: flex;
|
|
4
|
+
flex-direction: column;
|
|
5
|
+
align-items: center;
|
|
6
|
+
h2 {
|
|
7
|
+
color: var(--primary-color);
|
|
8
|
+
font-weight: 600;
|
|
9
|
+
font-size: 18px;
|
|
10
|
+
margin: 0;
|
|
11
|
+
}
|
|
12
|
+
.designerForm {
|
|
13
|
+
width: 100%;
|
|
14
|
+
display: flex;
|
|
15
|
+
flex-direction: column;
|
|
16
|
+
gap: 20px;
|
|
17
|
+
height: 635px;
|
|
18
|
+
overflow-y: auto;
|
|
19
|
+
padding: 20px 40px 24px;
|
|
20
|
+
&::-webkit-scrollbar {
|
|
21
|
+
width: 8px;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
&::-webkit-scrollbar-thumb {
|
|
25
|
+
background: var(--scrollbar-thumb-color) !important;
|
|
26
|
+
border-radius: 3px;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
@supports not selector(::-webkit-scrollbar) {
|
|
30
|
+
body {
|
|
31
|
+
scrollbar-color: var(--scrollbar-thumb-color)
|
|
32
|
+
var(--scrollbar-track-color);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.file-upload-wrapper {
|
|
38
|
+
display: flex;
|
|
39
|
+
justify-content: center;
|
|
40
|
+
align-items: center;
|
|
41
|
+
border: 0.5px solid var(--border-color);
|
|
42
|
+
border-radius: 8px;
|
|
43
|
+
padding: 20px;
|
|
44
|
+
background-color: #fff;
|
|
45
|
+
width: 100%;
|
|
46
|
+
height: 135px;
|
|
47
|
+
position: relative;
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
.file-input {
|
|
51
|
+
position: absolute;
|
|
52
|
+
width: 100%;
|
|
53
|
+
height: 100%;
|
|
54
|
+
opacity: 0;
|
|
55
|
+
cursor: pointer;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
.upload-area {
|
|
60
|
+
text-align: center;
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
.upload-icon {
|
|
64
|
+
font-size: 32px;
|
|
65
|
+
color: var(--svg-color); /* Customize color */
|
|
66
|
+
margin-bottom: 10px;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
.upload-text {
|
|
71
|
+
color: var(--primary-color); /* Customize color */
|
|
72
|
+
font-weight: 400;
|
|
73
|
+
text-decoration: underline;
|
|
74
|
+
cursor: pointer;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
.upload-info {
|
|
79
|
+
margin-top: 10px;
|
|
80
|
+
color: #545454;
|
|
81
|
+
font-size: 12px;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.uploaded-files {
|
|
87
|
+
width: 100%;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
h3 {
|
|
92
|
+
font-size: 14px;
|
|
93
|
+
font-weight: 400;
|
|
94
|
+
color: var(--text-color);
|
|
95
|
+
margin-bottom: 10px;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.file-item {
|
|
99
|
+
display: flex;
|
|
100
|
+
align-items: center;
|
|
101
|
+
border: 1px solid #ddd;
|
|
102
|
+
border-radius: 8px;
|
|
103
|
+
padding: 10px;
|
|
104
|
+
margin-bottom: 10px;
|
|
105
|
+
background-color: #fff;
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
.file-icon {
|
|
109
|
+
display: flex;
|
|
110
|
+
align-items: center;
|
|
111
|
+
justify-content: center;
|
|
112
|
+
padding: 5px;
|
|
113
|
+
border-radius: 4px;
|
|
114
|
+
margin-right: 10px;
|
|
115
|
+
width: 50px;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
.file-details {
|
|
120
|
+
flex-grow: 1;
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
.file-name {
|
|
124
|
+
font-size: 14px !important;
|
|
125
|
+
margin: 0;
|
|
126
|
+
font-weight: 500;
|
|
127
|
+
color: #303030 !important;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
.file-size {
|
|
132
|
+
font-size: 12px !important;
|
|
133
|
+
color: #b3b3b3 !important;
|
|
134
|
+
font-weight: 300 !important;
|
|
135
|
+
margin: 0 !important;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
.file-remove {
|
|
141
|
+
display: flex;
|
|
142
|
+
align-items: center;
|
|
143
|
+
cursor: pointer;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
.loading-container {
|
|
148
|
+
display: flex;
|
|
149
|
+
justify-content: center;
|
|
150
|
+
align-items: center;
|
|
151
|
+
width: 100%;
|
|
152
|
+
height: 100%;
|
|
153
|
+
.loading-icon {
|
|
154
|
+
width: 20px;
|
|
155
|
+
height: 20px;
|
|
156
|
+
border-radius: 50%;
|
|
157
|
+
border: 2px solid white;
|
|
158
|
+
border-top-color: transparent;
|
|
159
|
+
animation: spin 1s linear infinite;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
.button-container {
|
|
164
|
+
width: 100%;
|
|
165
|
+
display: flex;
|
|
166
|
+
justify-content: center;
|
|
167
|
+
align-items: center;
|
|
168
|
+
gap: 10px;
|
|
169
|
+
padding: 0 40px;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
@keyframes spin {
|
|
174
|
+
0% {
|
|
175
|
+
transform: rotate(0deg);
|
|
176
|
+
}
|
|
177
|
+
100% {
|
|
178
|
+
transform: rotate(360deg);
|
|
179
|
+
}
|
|
180
|
+
}
|