@openlettermarketing/olc-react-sdk 0.0.19 → 0.0.21
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 +2 -2
- package/build/index.js.map +1 -1
- package/package.json +1 -1
- package/.eslintignore +0 -1
- package/.eslintrc.cjs +0 -18
- package/.eslintrc.yml +0 -47
- 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 -72
- package/src/assets/Fonts/Lexi-Regular.ttf +0 -0
- package/src/assets/images/input/cancel.tsx +0 -20
- package/src/assets/images/input/search.tsx +0 -20
- package/src/assets/images/modal-icons/cancelIcon.png +0 -0
- package/src/assets/images/modal-icons/del.tsx +0 -19
- package/src/assets/images/modal-icons/delete.svg +0 -3
- package/src/assets/images/modal-icons/modal-cross.tsx +0 -23
- package/src/assets/images/modal-icons/save.tsx +0 -23
- package/src/assets/images/templates/add-icon.svg +0 -5
- package/src/assets/images/templates/back-arrow.tsx +0 -19
- package/src/assets/images/templates/back-dialog-icon.png +0 -0
- package/src/assets/images/templates/back-dialog-icon.svg +0 -3
- package/src/assets/images/templates/barcode.png +0 -0
- package/src/assets/images/templates/bi-fold-self-mailers.tsx +0 -28
- package/src/assets/images/templates/black-trash-icon.svg +0 -3
- package/src/assets/images/templates/cancel.svg +0 -4
- package/src/assets/images/templates/cancelIcon.png +0 -0
- package/src/assets/images/templates/clipboard.svg +0 -3
- package/src/assets/images/templates/contact-search.svg +0 -3
- package/src/assets/images/templates/content-copy-icon.tsx +0 -24
- package/src/assets/images/templates/cross.svg +0 -3
- package/src/assets/images/templates/custom-template-icon-black.svg +0 -3
- package/src/assets/images/templates/custom-template-icon.svg +0 -3
- package/src/assets/images/templates/custom-template.tsx +0 -23
- package/src/assets/images/templates/dummy-template.svg +0 -21
- 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/filter-2.svg +0 -13
- package/src/assets/images/templates/info-icon.svg +0 -12
- package/src/assets/images/templates/info-icon.tsx +0 -37
- package/src/assets/images/templates/one-barcode.png +0 -0
- package/src/assets/images/templates/personal-letter.tsx +0 -53
- package/src/assets/images/templates/plus-icon.svg +0 -5
- package/src/assets/images/templates/postcard.tsx +0 -32
- package/src/assets/images/templates/professional-letter.tsx +0 -53
- package/src/assets/images/templates/real-penned-letters.tsx +0 -57
- package/src/assets/images/templates/search.svg +0 -3
- 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.tsx +0 -20
- package/src/assets/images/templates/template-copy.svg +0 -3
- package/src/assets/images/templates/template-default-design.tsx +0 -21
- package/src/assets/images/templates/template-delete.svg +0 -3
- package/src/assets/images/templates/template-edit.svg +0 -4
- package/src/assets/images/templates/template-save-icon.svg +0 -3
- package/src/assets/images/templates/template-search-2.svg +0 -9
- package/src/assets/images/templates/template-search.svg +0 -4
- package/src/assets/images/templates/thumbnail.svg +0 -10
- package/src/assets/images/templates/trash-icon.svg +0 -13
- package/src/assets/images/templates/tri-fold-self-mailers.tsx +0 -93
- package/src/components/CreateTemplate/index.tsx +0 -381
- package/src/components/CreateTemplate/styles.scss +0 -363
- package/src/components/GenericUIBlocks/Button/index.tsx +0 -21
- package/src/components/GenericUIBlocks/Button/styles.scss +0 -15
- package/src/components/GenericUIBlocks/CircularProgress/index.tsx +0 -18
- package/src/components/GenericUIBlocks/CircularProgress/styles.scss +0 -98
- package/src/components/GenericUIBlocks/Dialog/index.tsx +0 -127
- package/src/components/GenericUIBlocks/Dialog/styles.scss +0 -106
- 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 -86
- package/src/components/GenericUIBlocks/GeneralSelect/styles.scss +0 -77
- package/src/components/GenericUIBlocks/GeneralTooltip/index.tsx +0 -24
- package/src/components/GenericUIBlocks/GeneralTooltip/styles.scss +0 -9
- package/src/components/GenericUIBlocks/GenericSnackbar/index.tsx +0 -53
- package/src/components/GenericUIBlocks/GenericSnackbar/styles.scss +0 -34
- package/src/components/GenericUIBlocks/Grid/index.tsx +0 -82
- package/src/components/GenericUIBlocks/Input/index.tsx +0 -89
- package/src/components/GenericUIBlocks/Input/styles.scss +0 -80
- package/src/components/GenericUIBlocks/Typography/index.tsx +0 -18
- package/src/components/GenericUIBlocks/Typography/styles.scss +0 -27
- package/src/components/SidePanel/customFields/customFieldSection.tsx +0 -173
- package/src/components/SidePanel/customFields/styles.scss +0 -47
- package/src/components/SidePanel/index.tsx +0 -42
- package/src/components/SidePanel/templates/customTemplateSection.tsx +0 -503
- package/src/components/SidePanel/templates/styles.scss +0 -151
- package/src/components/TemplateBuilder/index.tsx +0 -301
- package/src/components/TemplateBuilder/styles.scss +0 -66
- package/src/components/TopNavigation/ConfirmNavigateDialog/index.tsx +0 -58
- package/src/components/TopNavigation/ConfirmNavigateDialog/styles.scss +0 -123
- package/src/components/TopNavigation/EditTemplateNameModel/index.tsx +0 -98
- package/src/components/TopNavigation/EditTemplateNameModel/styles.scss +0 -88
- package/src/components/TopNavigation/SaveTemplateModel/index.tsx +0 -60
- package/src/components/TopNavigation/SaveTemplateModel/styles.scss +0 -128
- package/src/components/TopNavigation/index.tsx +0 -406
- package/src/components/TopNavigation/styles.scss +0 -83
- package/src/importMeta.d.ts +0 -9
- package/src/index.scss +0 -137
- package/src/index.tsx +0 -79
- package/src/libs/test.ts +0 -7
- package/src/redux/actions/action-types.ts +0 -42
- package/src/redux/actions/customFieldAction.ts +0 -28
- package/src/redux/actions/snackbarActions.ts +0 -16
- package/src/redux/actions/templateActions.ts +0 -456
- package/src/redux/reducers/customFieldReducer.ts +0 -97
- package/src/redux/reducers/index.ts +0 -14
- package/src/redux/reducers/snackbarReducer.ts +0 -41
- package/src/redux/reducers/templateReducer.ts +0 -353
- 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 -40
- package/src/utils/customStyles.ts +0 -135
- package/src/utils/fetchWrapper.ts +0 -68
- package/src/utils/fonts.json +0 -1597
- package/src/utils/helper.ts +0 -19
- package/src/utils/local-storage.ts +0 -15
- package/src/utils/message.ts +0 -71
- package/src/utils/template-builder.ts +0 -147
- package/src/utils/templateRestrictedArea/biFold.ts +0 -433
- package/src/utils/templateRestrictedArea/postCard.ts +0 -439
- package/src/utils/templateRestrictedArea/professional.ts +0 -422
- package/src/utils/templateRestrictedArea/realPenned.ts +0 -244
- package/src/utils/templateRestrictedArea/triFold.ts +0 -434
- package/tsconfig.json +0 -29
- package/tsconfig.node.json +0 -12
- package/vite.config.ts +0 -8
- package/webpack.config.js +0 -80
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
.editTemplateNameModal {
|
|
2
|
-
.MuiPaper-root {
|
|
3
|
-
width: 100% !important;
|
|
4
|
-
max-width: 623px !important;
|
|
5
|
-
height: 100% !important;
|
|
6
|
-
max-height: 230px !important;
|
|
7
|
-
margin: 0 auto !important;
|
|
8
|
-
border-radius: 11px;
|
|
9
|
-
background: #fff8ee;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
.editTemplateNameModalTitle {
|
|
13
|
-
color: #ed5c2f;
|
|
14
|
-
text-align: center;
|
|
15
|
-
font-size: 22px;
|
|
16
|
-
font-style: normal;
|
|
17
|
-
font-weight: 700;
|
|
18
|
-
line-height: normal;
|
|
19
|
-
padding: 16px 16px 0px !important;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
.editTemplateNameModalContent {
|
|
23
|
-
padding: 0px 30px !important;
|
|
24
|
-
|
|
25
|
-
p {
|
|
26
|
-
color: #303030;
|
|
27
|
-
font-size: 14px;
|
|
28
|
-
font-style: normal;
|
|
29
|
-
font-weight: 400;
|
|
30
|
-
line-height: normal;
|
|
31
|
-
margin: 10px 0px 10px 0px;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
.MuiInputBase-root {
|
|
35
|
-
border-radius: 7px;
|
|
36
|
-
border: 0.5px solid #303030;
|
|
37
|
-
background: #fff;
|
|
38
|
-
width: 100%;
|
|
39
|
-
padding: 9.8px 22px;
|
|
40
|
-
|
|
41
|
-
&:focus,
|
|
42
|
-
&:focus-visible {
|
|
43
|
-
outline: none !important;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
&::after,
|
|
47
|
-
&::before {
|
|
48
|
-
display: none !important;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
.actionBtns {
|
|
54
|
-
justify-content: center;
|
|
55
|
-
align-items: center;
|
|
56
|
-
margin: 20px 0px;
|
|
57
|
-
gap: 20px;
|
|
58
|
-
|
|
59
|
-
button {
|
|
60
|
-
border-radius: 5px;
|
|
61
|
-
text-transform: capitalize;
|
|
62
|
-
width: 100%;
|
|
63
|
-
max-width: 107px;
|
|
64
|
-
height: 100%;
|
|
65
|
-
min-height: 41px;
|
|
66
|
-
|
|
67
|
-
&:first-child {
|
|
68
|
-
border: 0.5px solid rgba(48, 48, 48, 0.5);
|
|
69
|
-
background: #fff;
|
|
70
|
-
color: #000;
|
|
71
|
-
font-size: 16px;
|
|
72
|
-
font-style: normal;
|
|
73
|
-
font-weight: 600;
|
|
74
|
-
line-height: normal;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
&:last-child {
|
|
78
|
-
color: #fff;
|
|
79
|
-
font-size: 16px;
|
|
80
|
-
font-style: normal;
|
|
81
|
-
font-weight: 600;
|
|
82
|
-
line-height: normal;
|
|
83
|
-
background: #ed5c2f;
|
|
84
|
-
margin: 0;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
// Utils
|
|
4
|
-
import { MESSAGES } from '../../../utils/message';
|
|
5
|
-
|
|
6
|
-
// Components
|
|
7
|
-
import Dialog from '../../GenericUIBlocks/Dialog';
|
|
8
|
-
|
|
9
|
-
// Icons
|
|
10
|
-
import Save from '../../../assets/images/modal-icons/save';
|
|
11
|
-
|
|
12
|
-
// Styles
|
|
13
|
-
import './styles.scss';
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Renders a modal dialog for deleting a template.
|
|
17
|
-
*
|
|
18
|
-
* @param {function} handleSave - Callback function to handle the save action.
|
|
19
|
-
* @param {function} handleClose - Callback function to handle the close action.
|
|
20
|
-
* @param {boolean} open - Boolean value indicating whether the modal is open or not.
|
|
21
|
-
* @returns {JSX.Element} The delete template modal component.
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
const saveDialogStyles = {
|
|
25
|
-
maxWidth: '433px',
|
|
26
|
-
minHeight: '280px',
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
interface SaveTemplateModelProps {
|
|
30
|
-
open: boolean;
|
|
31
|
-
loading: boolean;
|
|
32
|
-
handleClose: () => void;
|
|
33
|
-
handleSave: () => void;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const SaveTemplateModel: React.FC<SaveTemplateModelProps> = ({
|
|
37
|
-
handleSave,
|
|
38
|
-
handleClose,
|
|
39
|
-
open,
|
|
40
|
-
loading,
|
|
41
|
-
}) => {
|
|
42
|
-
return (
|
|
43
|
-
<Dialog
|
|
44
|
-
icon={<Save fill="var(--primaryColor)" />}
|
|
45
|
-
open={open}
|
|
46
|
-
loading={loading}
|
|
47
|
-
handleClose={handleClose}
|
|
48
|
-
title={MESSAGES.TEMPLATE.SAVE.TITLE}
|
|
49
|
-
subHeading={MESSAGES.TEMPLATE.SAVE.HEADING}
|
|
50
|
-
description={MESSAGES.TEMPLATE.SAVE.PARAGRAPH}
|
|
51
|
-
cancelText={MESSAGES.TEMPLATE.SAVE.CANCEL_BUTTON}
|
|
52
|
-
submitText={MESSAGES.TEMPLATE.SAVE.SUBMIT_BUTTON}
|
|
53
|
-
customStyles={saveDialogStyles}
|
|
54
|
-
onSubmit={handleSave}
|
|
55
|
-
onCancel={handleClose}
|
|
56
|
-
/>
|
|
57
|
-
);
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
export default SaveTemplateModel;
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
.confirmTemplateSaveModal {
|
|
2
|
-
.MuiPaper-root {
|
|
3
|
-
width: 100% !important;
|
|
4
|
-
max-width: 433px !important;
|
|
5
|
-
height: 100% !important;
|
|
6
|
-
max-height: 290px !important;
|
|
7
|
-
margin: 0 auto !important;
|
|
8
|
-
border-radius: 11px;
|
|
9
|
-
background: #fff8ee;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
.confirmTemplateSaveModalTitle {
|
|
13
|
-
color: #ed5c2f;
|
|
14
|
-
text-align: center;
|
|
15
|
-
font-size: 22px;
|
|
16
|
-
font-style: normal;
|
|
17
|
-
font-weight: 700;
|
|
18
|
-
line-height: normal;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
.confirmTemplateSaveModalContent {
|
|
22
|
-
display: flex;
|
|
23
|
-
flex-direction: column;
|
|
24
|
-
gap: 20px;
|
|
25
|
-
padding: 16px 16px 0px;
|
|
26
|
-
|
|
27
|
-
.trashIconWrapper {
|
|
28
|
-
text-align: center;
|
|
29
|
-
|
|
30
|
-
p {
|
|
31
|
-
color: #ed5c2f;
|
|
32
|
-
text-align: center;
|
|
33
|
-
font-size: 22px;
|
|
34
|
-
font-style: normal;
|
|
35
|
-
font-weight: 700;
|
|
36
|
-
line-height: normal;
|
|
37
|
-
margin-top: 10px;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
.confirmTemplateSaveText {
|
|
42
|
-
display: flex;
|
|
43
|
-
flex-direction: column;
|
|
44
|
-
justify-content: center;
|
|
45
|
-
align-items: center;
|
|
46
|
-
gap: 10px;
|
|
47
|
-
|
|
48
|
-
p {
|
|
49
|
-
color: #000;
|
|
50
|
-
text-align: center;
|
|
51
|
-
font-size: 16px;
|
|
52
|
-
font-style: normal;
|
|
53
|
-
font-weight: 600;
|
|
54
|
-
line-height: normal;
|
|
55
|
-
|
|
56
|
-
&:last-child {
|
|
57
|
-
color: #000;
|
|
58
|
-
text-align: center;
|
|
59
|
-
font-size: 14px;
|
|
60
|
-
font-style: normal;
|
|
61
|
-
font-weight: 400;
|
|
62
|
-
line-height: 16px;
|
|
63
|
-
/* 114.286% */
|
|
64
|
-
letter-spacing: 0.28px;
|
|
65
|
-
margin: 0;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
.MuiInputBase-root {
|
|
71
|
-
border-radius: 7px;
|
|
72
|
-
border: 0.5px solid #303030;
|
|
73
|
-
background: #fff;
|
|
74
|
-
width: 100%;
|
|
75
|
-
padding: 10px 22px;
|
|
76
|
-
|
|
77
|
-
&:focus,
|
|
78
|
-
&:focus-visible {
|
|
79
|
-
outline: none !important;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
&::after,
|
|
83
|
-
&::before {
|
|
84
|
-
display: none !important;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
.actionBtns {
|
|
90
|
-
justify-content: center;
|
|
91
|
-
align-items: center;
|
|
92
|
-
margin-bottom: 10px;
|
|
93
|
-
gap: 20px;
|
|
94
|
-
|
|
95
|
-
button {
|
|
96
|
-
border-radius: 5px;
|
|
97
|
-
text-transform: capitalize;
|
|
98
|
-
width: 100%;
|
|
99
|
-
max-width: 107px;
|
|
100
|
-
height: 100%;
|
|
101
|
-
min-height: 41px;
|
|
102
|
-
|
|
103
|
-
&:first-child {
|
|
104
|
-
border: 0.5px solid rgba(48, 48, 48, 0.5);
|
|
105
|
-
background: #fff;
|
|
106
|
-
color: #000;
|
|
107
|
-
font-size: 16px;
|
|
108
|
-
font-style: normal;
|
|
109
|
-
font-weight: 600;
|
|
110
|
-
line-height: normal;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
&:last-child {
|
|
114
|
-
color: #fff;
|
|
115
|
-
font-size: 16px;
|
|
116
|
-
font-style: normal;
|
|
117
|
-
font-weight: 600;
|
|
118
|
-
line-height: normal;
|
|
119
|
-
background: #ed5c2f;
|
|
120
|
-
margin: 0;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
&:disabled {
|
|
124
|
-
opacity: 0.5;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
}
|
|
@@ -1,406 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useState } from 'react';
|
|
2
|
-
|
|
3
|
-
// Hooks
|
|
4
|
-
import { useDispatch, useSelector } from 'react-redux';
|
|
5
|
-
import { useNavigate, useParams } from 'react-router-dom';
|
|
6
|
-
import { AppDispatch, RootState } from '../../redux/store';
|
|
7
|
-
|
|
8
|
-
// Actions
|
|
9
|
-
import {
|
|
10
|
-
uploadTemplate,
|
|
11
|
-
createTemplate,
|
|
12
|
-
updateTemplate,
|
|
13
|
-
clearTemplateFields,
|
|
14
|
-
loadFormDataToStore,
|
|
15
|
-
downloadProof,
|
|
16
|
-
} from '../../redux/actions/templateActions';
|
|
17
|
-
import { failure, success } from '../../redux/actions/snackbarActions';
|
|
18
|
-
|
|
19
|
-
// Components
|
|
20
|
-
import SaveTemplateModel from './SaveTemplateModel';
|
|
21
|
-
import ConfirmNavigateDialog from './ConfirmNavigateDialog';
|
|
22
|
-
import EditTemplateNameModel from './EditTemplateNameModel';
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
// Utils
|
|
26
|
-
import { downloadPDF, extractFontFamilies, multiPageTemplates } from '../../utils/template-builder';
|
|
27
|
-
import { getItem, setItem } from '../../utils/local-storage';
|
|
28
|
-
import { MESSAGES } from '../../utils/message';
|
|
29
|
-
// @ts-ignore
|
|
30
|
-
import fonts from '../../utils/fonts.json';
|
|
31
|
-
|
|
32
|
-
// UI Components
|
|
33
|
-
import Typography from "../GenericUIBlocks/Typography";
|
|
34
|
-
import Button from "../GenericUIBlocks/Button";
|
|
35
|
-
import CircularProgress from "../GenericUIBlocks/CircularProgress";
|
|
36
|
-
import { GridContainer, GridItem } from '../GenericUIBlocks/Grid';
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
// Icons
|
|
40
|
-
// @ts-ignore
|
|
41
|
-
import EditIcon from '../../assets/images/templates/edit-pencil-icon.tsx';
|
|
42
|
-
|
|
43
|
-
// Styles
|
|
44
|
-
import './styles.scss';
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Represents the top navigation bar of a template builder application.
|
|
49
|
-
* Handles saving and navigation logic, as well as displaying a confirmation dialog for unsaved changes.
|
|
50
|
-
*
|
|
51
|
-
* @param {Object} props - The component props.
|
|
52
|
-
* @param {Object} props.store - The store object used for saving the template.
|
|
53
|
-
* @param {boolean} props.isStoreUpdated - Indicates whether the store has been updated.
|
|
54
|
-
* @returns {JSX.Element} The top navigation bar component.
|
|
55
|
-
*/
|
|
56
|
-
|
|
57
|
-
const buttonStyles: React.CSSProperties = {
|
|
58
|
-
maxWidth: '120px',
|
|
59
|
-
minHeight: '40px',
|
|
60
|
-
backgroundColor: 'var(--secondaryButtonBgColor)',
|
|
61
|
-
color: 'var(--secondaryButtonTextColor)',
|
|
62
|
-
border: '0.5px solid var(--borderColor)',
|
|
63
|
-
fontSize: '15px',
|
|
64
|
-
fontWeight: '500'
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
const progressStyles: React.CSSProperties = {
|
|
68
|
-
width: '20px',
|
|
69
|
-
height: '20px',
|
|
70
|
-
border: '2px solid var(--primaryColor)',
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
interface TopNavigationProps {
|
|
74
|
-
store: any;
|
|
75
|
-
returnRoute?: string | null;
|
|
76
|
-
isStoreUpdated: boolean;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
const TopNavigation: React.FC<TopNavigationProps> = ({
|
|
80
|
-
store,
|
|
81
|
-
returnRoute,
|
|
82
|
-
isStoreUpdated,
|
|
83
|
-
}) => {
|
|
84
|
-
|
|
85
|
-
const [showNavigateDialog, setShowNavigateDialog] = useState<boolean>(false);
|
|
86
|
-
const [isShowModel, setIsShowModel] = useState<{
|
|
87
|
-
open: boolean;
|
|
88
|
-
model: string;
|
|
89
|
-
loading: boolean;
|
|
90
|
-
}>({
|
|
91
|
-
open: false,
|
|
92
|
-
model: '',
|
|
93
|
-
loading: false,
|
|
94
|
-
});
|
|
95
|
-
const [downloadingProof, setDownloaingProof] = useState<boolean>(false);
|
|
96
|
-
|
|
97
|
-
const { id } = useParams<{ id: string }>();
|
|
98
|
-
|
|
99
|
-
const dispatch: AppDispatch = useDispatch();
|
|
100
|
-
const navigate = useNavigate();
|
|
101
|
-
|
|
102
|
-
const title = useSelector((state: RootState) => state.templates.title);
|
|
103
|
-
const product = useSelector((state: RootState) => state.templates.product) as Record<string, any>;
|
|
104
|
-
|
|
105
|
-
const dynamicFields = useSelector(
|
|
106
|
-
(state: RootState) => state.templates.dynamicFields
|
|
107
|
-
);
|
|
108
|
-
const defaultFields = useSelector(
|
|
109
|
-
(state: RootState) => state.templates.defaultDynamicFields
|
|
110
|
-
);
|
|
111
|
-
const templateType = useSelector(
|
|
112
|
-
(state: RootState) => state.templates.templateType
|
|
113
|
-
);
|
|
114
|
-
const envelopeType = useSelector(
|
|
115
|
-
(state: RootState) => state.templates.envelopeType
|
|
116
|
-
);
|
|
117
|
-
|
|
118
|
-
useEffect(() => {
|
|
119
|
-
if (!id) {
|
|
120
|
-
const formData = getItem('formData');
|
|
121
|
-
if (formData && !title) {
|
|
122
|
-
dispatch(loadFormDataToStore(formData));
|
|
123
|
-
} else {
|
|
124
|
-
handleSaveFormData();
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
}, [title]);
|
|
128
|
-
|
|
129
|
-
const handleSaveFormData = () => {
|
|
130
|
-
const data = { title, product, templateType, envelopeType };
|
|
131
|
-
setItem('formData', JSON.stringify(data));
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
const handleBackPress = () => {
|
|
135
|
-
if (isStoreUpdated) {
|
|
136
|
-
setShowNavigateDialog(!showNavigateDialog);
|
|
137
|
-
} else {
|
|
138
|
-
handleNavigation(returnRoute ? returnRoute : '/create-template');
|
|
139
|
-
}
|
|
140
|
-
};
|
|
141
|
-
|
|
142
|
-
const handleNavigation = async (route = '/') => {
|
|
143
|
-
handleClearFilters();
|
|
144
|
-
if (templateType === 'json' && product?.productType !== 'Real Penned Letter') {
|
|
145
|
-
await store.history.clear();
|
|
146
|
-
}
|
|
147
|
-
navigate(route);
|
|
148
|
-
};
|
|
149
|
-
|
|
150
|
-
const handleClearFilters = () => dispatch(clearTemplateFields());
|
|
151
|
-
|
|
152
|
-
const handleViewProofWithLamda = async () => {
|
|
153
|
-
try {
|
|
154
|
-
setDownloaingProof(true);
|
|
155
|
-
const fields = [...defaultFields, ...Object.values(dynamicFields)];
|
|
156
|
-
let json = store.toJSON();
|
|
157
|
-
if (product?.productType === "Real Penned Letter") {
|
|
158
|
-
let clonedJson = JSON.stringify(json)
|
|
159
|
-
.replace(/\(\(/g, "{{")
|
|
160
|
-
.replace(/\)\)/g, "}}");
|
|
161
|
-
json = JSON.parse(clonedJson);
|
|
162
|
-
}
|
|
163
|
-
let jsonString = JSON.stringify(json);
|
|
164
|
-
fields.forEach(({ key, defaultValue, value }) => {
|
|
165
|
-
const regex = new RegExp(key, 'g');
|
|
166
|
-
jsonString = jsonString.replace(regex, defaultValue || value);
|
|
167
|
-
});
|
|
168
|
-
const jsonWithDummyData = JSON.parse(jsonString);
|
|
169
|
-
const response: any = await downloadProof({
|
|
170
|
-
json: jsonWithDummyData,
|
|
171
|
-
});
|
|
172
|
-
if (response.status === 200) {
|
|
173
|
-
const binaryData = atob(response.data.data.base64);
|
|
174
|
-
// Create a Uint8Array from the binary data
|
|
175
|
-
const uint8Array = new Uint8Array(binaryData.length);
|
|
176
|
-
for (let i = 0; i < binaryData.length; i++) {
|
|
177
|
-
uint8Array[i] = binaryData.charCodeAt(i);
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
// Create a Blob from the Uint8Array
|
|
181
|
-
const blob = new Blob([uint8Array], { type: 'application/pdf' });
|
|
182
|
-
|
|
183
|
-
// Create an Object URL for the Blob
|
|
184
|
-
const url = URL.createObjectURL(blob);
|
|
185
|
-
downloadPDF(title.substring(0, 20), url);
|
|
186
|
-
dispatch(success('Download Proof generated successfully'));
|
|
187
|
-
} else {
|
|
188
|
-
dispatch(failure(response?.data?.message));
|
|
189
|
-
}
|
|
190
|
-
} catch (error: any) {
|
|
191
|
-
dispatch(
|
|
192
|
-
failure(
|
|
193
|
-
error?.response?.data?.message ||
|
|
194
|
-
error?.message ||
|
|
195
|
-
'Error while downloading proof'
|
|
196
|
-
)
|
|
197
|
-
);
|
|
198
|
-
} finally {
|
|
199
|
-
setDownloaingProof(false);
|
|
200
|
-
}
|
|
201
|
-
};
|
|
202
|
-
|
|
203
|
-
const handleSave = async () => {
|
|
204
|
-
try {
|
|
205
|
-
const formData = new FormData();
|
|
206
|
-
const allFields = [...defaultFields, ...Object.values(dynamicFields)];
|
|
207
|
-
let selectedFields: typeof allFields = [];
|
|
208
|
-
if (templateType === 'json') {
|
|
209
|
-
const blob = await store.toBlob();
|
|
210
|
-
let jsonData = store.toJSON();
|
|
211
|
-
|
|
212
|
-
if (product?.productType === "Real Penned Letter") {
|
|
213
|
-
let clonedJson = JSON.stringify(jsonData)
|
|
214
|
-
.replace(/\(\(/g, "{{")
|
|
215
|
-
.replace(/\)\)/g, "}}");
|
|
216
|
-
jsonData = JSON.parse(clonedJson);
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
// get all fonts family from json
|
|
220
|
-
const fontFamilies = extractFontFamilies(jsonData?.pages);
|
|
221
|
-
|
|
222
|
-
// extract custom fonts and remove google fonts from that array
|
|
223
|
-
const customFonts = fontFamilies.filter((item: any) => !fonts.includes(item));
|
|
224
|
-
|
|
225
|
-
const availableBase64inJson = jsonData?.fonts?.map((font: any) => font?.fontFamily);
|
|
226
|
-
|
|
227
|
-
const unAvailableFonts = customFonts.filter((item: any) => !availableBase64inJson?.includes(item));
|
|
228
|
-
|
|
229
|
-
if (unAvailableFonts?.length) {
|
|
230
|
-
dispatch(failure(`Please upload ${unAvailableFonts[0]} font in My Fonts section.`));
|
|
231
|
-
return
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
if (multiPageTemplates.includes(product.productType)) {
|
|
235
|
-
const backJsonData = { ...jsonData, pages: [jsonData.pages[1]] }
|
|
236
|
-
await store.loadJSON(backJsonData);
|
|
237
|
-
await store.waitLoading();
|
|
238
|
-
const backBlob = await store.toBlob();
|
|
239
|
-
formData.append('backThumbnail', backBlob, 'backLogo.png');
|
|
240
|
-
store.loadJSON(jsonData);
|
|
241
|
-
}
|
|
242
|
-
const jsonString = JSON.stringify(jsonData);
|
|
243
|
-
const blobData = new Blob([jsonString], { type: 'application/json' });
|
|
244
|
-
formData.append('json', blobData, 'template.json');
|
|
245
|
-
formData.append('thumbnail', blob, 'logo.png');
|
|
246
|
-
selectedFields = allFields.filter(field => jsonString.includes(field.key));
|
|
247
|
-
}
|
|
248
|
-
setIsShowModel((prev) => ({ ...prev, loading: true }));
|
|
249
|
-
|
|
250
|
-
const response: any = await uploadTemplate(formData);
|
|
251
|
-
if (response?.status === 200) {
|
|
252
|
-
if (!id) {
|
|
253
|
-
setTimeout(async () => await handleCreateTemplate(response?.data?.data, selectedFields), 1000);
|
|
254
|
-
} else {
|
|
255
|
-
setTimeout(async () => await handleUpdateTemplate(response?.data?.data, selectedFields), 1000)
|
|
256
|
-
}
|
|
257
|
-
} else if (response?.status === 418 && response?.data?.message == "You have reached your Templates limit, updgrade you Plan to add more") {
|
|
258
|
-
handleChangeModel('', 'false');
|
|
259
|
-
} else {
|
|
260
|
-
dispatch(
|
|
261
|
-
failure(
|
|
262
|
-
response?.data?.message ||
|
|
263
|
-
MESSAGES.GENERAL_ERROR
|
|
264
|
-
)
|
|
265
|
-
);
|
|
266
|
-
handleChangeModel('', 'false');
|
|
267
|
-
}
|
|
268
|
-
} catch (error) {
|
|
269
|
-
return error;
|
|
270
|
-
}
|
|
271
|
-
};
|
|
272
|
-
|
|
273
|
-
const handleCreateTemplate = async (data: any, selectedFields: any) => {
|
|
274
|
-
try {
|
|
275
|
-
const response: any = await createTemplate({
|
|
276
|
-
title: title,
|
|
277
|
-
productId: product?.id,
|
|
278
|
-
fields: selectedFields,
|
|
279
|
-
thumbnailPath: data.thumbnailPath,
|
|
280
|
-
templatePath: data.templatePath,
|
|
281
|
-
backTemplatePath: data.backTemplatePath || '',
|
|
282
|
-
backThumbnailPath: data.backThumbnailPath || '',
|
|
283
|
-
envelopeType,
|
|
284
|
-
});
|
|
285
|
-
if (response.status === 200) {
|
|
286
|
-
dispatch(success(response.data.message));
|
|
287
|
-
setTimeout(() => {
|
|
288
|
-
handleNavigation();
|
|
289
|
-
}, 2000);
|
|
290
|
-
} else if (response.status == 418) {
|
|
291
|
-
// nothing to do
|
|
292
|
-
} else {
|
|
293
|
-
dispatch(failure(response?.data?.message || response?.message));
|
|
294
|
-
}
|
|
295
|
-
} catch (error) {
|
|
296
|
-
handleChangeModel('', 'false');
|
|
297
|
-
} finally {
|
|
298
|
-
setTimeout(() => {
|
|
299
|
-
setIsShowModel((prev) => ({ ...prev, loading: false }));
|
|
300
|
-
}, 2000);
|
|
301
|
-
}
|
|
302
|
-
};
|
|
303
|
-
|
|
304
|
-
const handleUpdateTemplate = async (data: any, selectedFields: any) => {
|
|
305
|
-
// @ts-ignore
|
|
306
|
-
const response: any = await updateTemplate(id, {
|
|
307
|
-
title: title,
|
|
308
|
-
fields: selectedFields,
|
|
309
|
-
thumbnailPath: data.thumbnailPath,
|
|
310
|
-
templatePath: data.templatePath,
|
|
311
|
-
backTemplatePath: data.backTemplatePath || '',
|
|
312
|
-
backThumbnailPath: data.backThumbnailPath || '',
|
|
313
|
-
});
|
|
314
|
-
if (response.status === 200) {
|
|
315
|
-
dispatch(success(response.data.message));
|
|
316
|
-
handleNavigation();
|
|
317
|
-
} else {
|
|
318
|
-
dispatch(failure(response.data.message));
|
|
319
|
-
}
|
|
320
|
-
handleChangeModel('', 'false');
|
|
321
|
-
};
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
const handleChangeModel = (model: string = '', loading: string | null = null) => {
|
|
325
|
-
setIsShowModel((prev) => ({
|
|
326
|
-
...prev,
|
|
327
|
-
open: !prev.open,
|
|
328
|
-
loading: loading === 'false' ? false : prev.loading,
|
|
329
|
-
model,
|
|
330
|
-
}));
|
|
331
|
-
};
|
|
332
|
-
|
|
333
|
-
return (
|
|
334
|
-
<div className="top-navigation-container">
|
|
335
|
-
{showNavigateDialog && (
|
|
336
|
-
<ConfirmNavigateDialog
|
|
337
|
-
open={showNavigateDialog}
|
|
338
|
-
handleClose={() => setShowNavigateDialog(false)}
|
|
339
|
-
handleNavigateAction={() => handleNavigation(returnRoute ? returnRoute : '/create-template')}
|
|
340
|
-
/>
|
|
341
|
-
)}
|
|
342
|
-
{isShowModel?.open && isShowModel?.model === 'edit' && (
|
|
343
|
-
<EditTemplateNameModel
|
|
344
|
-
open={isShowModel?.open}
|
|
345
|
-
handleClose={() => handleChangeModel()}
|
|
346
|
-
/>
|
|
347
|
-
)}
|
|
348
|
-
{isShowModel.open && isShowModel.model === 'save' && (
|
|
349
|
-
<SaveTemplateModel
|
|
350
|
-
loading={isShowModel.loading}
|
|
351
|
-
open={isShowModel.open}
|
|
352
|
-
handleClose={() => handleChangeModel()}
|
|
353
|
-
handleSave={handleSave}
|
|
354
|
-
/>
|
|
355
|
-
)}
|
|
356
|
-
<GridContainer style={{ alignItems: 'center' }}>
|
|
357
|
-
<GridItem lg={4} md={4} sm={2} xs={12}></GridItem>
|
|
358
|
-
<GridItem lg={4} md={2} sm={2} xs={12}>
|
|
359
|
-
<div className="middle">
|
|
360
|
-
<Typography>{title}</Typography>
|
|
361
|
-
<div onClick={() => handleChangeModel('edit')}>
|
|
362
|
-
<EditIcon fill="var(--textColor)" />
|
|
363
|
-
</div>
|
|
364
|
-
</div>
|
|
365
|
-
</GridItem>
|
|
366
|
-
<GridItem lg={4} md={6} sm={8} xs={12}>
|
|
367
|
-
<div className="actionsBtnWrapper right">
|
|
368
|
-
<Button
|
|
369
|
-
style={{ ...buttonStyles, maxWidth: 'auto', minWidth: '100px' }}
|
|
370
|
-
onClick={handleViewProofWithLamda}
|
|
371
|
-
>
|
|
372
|
-
{downloadingProof ? (
|
|
373
|
-
<CircularProgress style={progressStyles} />
|
|
374
|
-
) : (
|
|
375
|
-
MESSAGES.TEMPLATE.DOWNLOAD_PROOF_BUTTON
|
|
376
|
-
)}
|
|
377
|
-
</Button>
|
|
378
|
-
<Button
|
|
379
|
-
style={{
|
|
380
|
-
...buttonStyles,
|
|
381
|
-
border: '0.5px solid var(--primaryColor)',
|
|
382
|
-
color: 'var(--primaryColor)',
|
|
383
|
-
}}
|
|
384
|
-
onClick={() => handleBackPress()}
|
|
385
|
-
>
|
|
386
|
-
{MESSAGES.TEMPLATE.CANCEL_BUTTON}
|
|
387
|
-
</Button>
|
|
388
|
-
<Button
|
|
389
|
-
style={{
|
|
390
|
-
...buttonStyles,
|
|
391
|
-
border: 'none',
|
|
392
|
-
backgroundColor: 'var(--primaryColor)',
|
|
393
|
-
color: 'var(--primaryButtonTextColor)',
|
|
394
|
-
}}
|
|
395
|
-
onClick={() => handleChangeModel('save')}
|
|
396
|
-
>
|
|
397
|
-
{MESSAGES.TEMPLATE.SUBMIT_BUTTON}
|
|
398
|
-
</Button>
|
|
399
|
-
</div>
|
|
400
|
-
</GridItem>
|
|
401
|
-
</GridContainer>
|
|
402
|
-
</div>
|
|
403
|
-
);
|
|
404
|
-
};
|
|
405
|
-
|
|
406
|
-
export default TopNavigation;
|