@openlettermarketing/olc-react-sdk 0.0.18 → 0.0.20
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 +3 -3
- package/build/index.js.map +1 -1
- package/build/types/App.d.ts +1 -0
- package/build/types/components/TemplateBuilder/index.d.ts +1 -0
- package/build/types/components/TopNavigation/index.d.ts +1 -0
- package/build/types/index.d.ts +3 -2
- 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 -379
- 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 -405
- 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 -80
- 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,503 +0,0 @@
|
|
|
1
|
-
import React, {useEffect, useState} from 'react';
|
|
2
|
-
import {observer} from 'mobx-react-lite';
|
|
3
|
-
import {SectionTab} from 'polotno/side-panel';
|
|
4
|
-
import {useDispatch, useSelector} from 'react-redux';
|
|
5
|
-
import type {StoreType} from 'polotno/model/store';
|
|
6
|
-
import type {TemplatesSection} from 'polotno/side-panel';
|
|
7
|
-
import {
|
|
8
|
-
clearAllTemplates,
|
|
9
|
-
getOneTemplate,
|
|
10
|
-
getAllTemplateCategories,
|
|
11
|
-
getAllTemplatesByTab,
|
|
12
|
-
} from '../../../../src/redux/actions/templateActions';
|
|
13
|
-
import {AppDispatch, RootState} from '../../../redux/store';
|
|
14
|
-
// @ts-ignore
|
|
15
|
-
import DesignIcon from '../../../assets/images/templates/template-default-design.tsx';
|
|
16
|
-
// @ts-ignore
|
|
17
|
-
import dummyTemplateIcon from '../../../assets/images/templates/dummy-template.svg';
|
|
18
|
-
// @ts-ignore
|
|
19
|
-
import CustomTemplate from '../../../assets/images/templates/custom-template';
|
|
20
|
-
import Typography from '../../GenericUIBlocks/Typography';
|
|
21
|
-
import './styles.scss';
|
|
22
|
-
import Dialog from '../../GenericUIBlocks/Dialog';
|
|
23
|
-
import {multiPageLetters, templateTypes, DPI} from '../../../utils/constants';
|
|
24
|
-
import {drawRestrictedAreaOnPage} from '../../../utils/template-builder';
|
|
25
|
-
import GeneralSelect from '../../GenericUIBlocks/GeneralSelect';
|
|
26
|
-
import Input from '../../GenericUIBlocks/Input';
|
|
27
|
-
import ModalCross from '../../../assets/images/modal-icons/modal-cross';
|
|
28
|
-
import {MESSAGES} from '../../../utils/message';
|
|
29
|
-
import {TEMPLATE_LOADING} from '../../../redux/actions/action-types';
|
|
30
|
-
|
|
31
|
-
type SideSection = typeof TemplatesSection;
|
|
32
|
-
|
|
33
|
-
const designDialogStyles = {
|
|
34
|
-
maxWidth: '600px',
|
|
35
|
-
minHeight: '270px',
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
const templateTextStyles: React.CSSProperties = {
|
|
39
|
-
color: `var(--textColor)`,
|
|
40
|
-
fontSize: `12px`,
|
|
41
|
-
fontStyle: `normal`,
|
|
42
|
-
fontWeight: `500`,
|
|
43
|
-
lineHeight: `normal`,
|
|
44
|
-
marginBottom: `16px`,
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
export type Payload = {
|
|
48
|
-
tab: string;
|
|
49
|
-
page: number;
|
|
50
|
-
pageSize: number;
|
|
51
|
-
productId: string | null;
|
|
52
|
-
search?: string;
|
|
53
|
-
categoryIds?: string[];
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
export type TemplateType = {
|
|
57
|
-
id: string;
|
|
58
|
-
label: string;
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
export type TemplateCategory = {
|
|
62
|
-
id: string;
|
|
63
|
-
title: string;
|
|
64
|
-
totalTemplates: number;
|
|
65
|
-
label?: string;
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
type TemplateRecord = {
|
|
69
|
-
id: string;
|
|
70
|
-
thumbnailUrl: string;
|
|
71
|
-
title: string;
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
const customTemplateSection: SideSection = {
|
|
75
|
-
name: 'Templates',
|
|
76
|
-
Tab: observer(
|
|
77
|
-
(props: {store: StoreType; active: boolean; onClick: () => void}) => (
|
|
78
|
-
<SectionTab name="Templates" {...props}>
|
|
79
|
-
<CustomTemplate fill="var(--sidepanelSVGColor)" />
|
|
80
|
-
</SectionTab>
|
|
81
|
-
)
|
|
82
|
-
) as SideSection['Tab'],
|
|
83
|
-
Panel: observer(({store}) => {
|
|
84
|
-
const dispatch: AppDispatch = useDispatch();
|
|
85
|
-
|
|
86
|
-
const [currentTemplateType, setCurrentTemplateType] =
|
|
87
|
-
useState<TemplateType>(templateTypes[0]);
|
|
88
|
-
const [selectedCategory, setSelectedCategory] =
|
|
89
|
-
useState<TemplateCategory | null>(null);
|
|
90
|
-
const [selectedRecord, setSelectedRecord] = useState<TemplateRecord | null>(
|
|
91
|
-
null
|
|
92
|
-
);
|
|
93
|
-
const [templateCategories, setTemplateCategories] = useState<
|
|
94
|
-
TemplateCategory[]
|
|
95
|
-
>([]);
|
|
96
|
-
const [myTemplates, setMyTemplates] = useState<TemplateRecord[]>([]);
|
|
97
|
-
const [teamTemplates, setTeamTemplates] = useState<TemplateRecord[]>([]);
|
|
98
|
-
const [olcTemplates, setOlcTemplates] = useState<TemplateRecord[]>([]);
|
|
99
|
-
const [searchApplied, setSearchApplied] = useState(false);
|
|
100
|
-
const [search, setSearch] = useState('');
|
|
101
|
-
|
|
102
|
-
const templates = useSelector(
|
|
103
|
-
(state: RootState) => state.templates.templates
|
|
104
|
-
) as Record<string, any>;
|
|
105
|
-
const template = useSelector(
|
|
106
|
-
(state: RootState) => state.templates.template
|
|
107
|
-
) as Record<string, any>;
|
|
108
|
-
const templatesPagination = useSelector(
|
|
109
|
-
(state: any) => state.templates.templatesPagination
|
|
110
|
-
);
|
|
111
|
-
const product = useSelector((state: any) => state.templates.product);
|
|
112
|
-
const envelopeType = useSelector(
|
|
113
|
-
(state: RootState) => state.templates.envelopeType
|
|
114
|
-
);
|
|
115
|
-
const templateLoading = useSelector(
|
|
116
|
-
(state: RootState) => state.templates.templateLoading
|
|
117
|
-
);
|
|
118
|
-
|
|
119
|
-
const [isShowDialog, setIsShowDialog] = useState({
|
|
120
|
-
open: false,
|
|
121
|
-
model: '',
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
const handleLoadTemplateModel = (record: any) => {
|
|
125
|
-
setSelectedRecord(record);
|
|
126
|
-
handleDialogChange('load-template');
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
const getTemplatesByTab = async () => {
|
|
130
|
-
const payload: Payload = {
|
|
131
|
-
tab:
|
|
132
|
-
currentTemplateType?.id === '1'
|
|
133
|
-
? 'my-templates'
|
|
134
|
-
: currentTemplateType?.id === '2'
|
|
135
|
-
? 'team-templates'
|
|
136
|
-
: 'olc-templates',
|
|
137
|
-
page: 1,
|
|
138
|
-
pageSize: 500,
|
|
139
|
-
productId: product?.id,
|
|
140
|
-
};
|
|
141
|
-
search.length ? (payload.search = search) : undefined;
|
|
142
|
-
currentTemplateType?.id === '3'
|
|
143
|
-
? (payload.categoryIds = selectedCategory?.id.split(','))
|
|
144
|
-
: undefined;
|
|
145
|
-
|
|
146
|
-
const templates = await getAllTemplatesByTab(payload);
|
|
147
|
-
if (templates.status === 200) {
|
|
148
|
-
if (currentTemplateType?.id === '1') {
|
|
149
|
-
setMyTemplates(templates?.data?.data?.rows);
|
|
150
|
-
} else if (currentTemplateType?.id === '2') {
|
|
151
|
-
setTeamTemplates(templates?.data?.data?.rows);
|
|
152
|
-
} else {
|
|
153
|
-
setOlcTemplates(templates?.data?.data?.rows);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
};
|
|
157
|
-
|
|
158
|
-
const getAllCategories = async () => {
|
|
159
|
-
const categories: Record<string, any> = await dispatch(
|
|
160
|
-
getAllTemplateCategories
|
|
161
|
-
);
|
|
162
|
-
if (categories?.status === 200) {
|
|
163
|
-
setTemplateCategories(
|
|
164
|
-
categories?.data?.data
|
|
165
|
-
.filter((item: any) => item.totalTemplates > 0)
|
|
166
|
-
.map((item: any) => ({
|
|
167
|
-
...item,
|
|
168
|
-
label: item.title,
|
|
169
|
-
}))
|
|
170
|
-
);
|
|
171
|
-
}
|
|
172
|
-
};
|
|
173
|
-
|
|
174
|
-
const handleSearch = () => {
|
|
175
|
-
if (search) {
|
|
176
|
-
setSearchApplied(true);
|
|
177
|
-
getTemplatesByTab();
|
|
178
|
-
}
|
|
179
|
-
};
|
|
180
|
-
|
|
181
|
-
const removeSearchInput = () => {
|
|
182
|
-
setSearchApplied(false);
|
|
183
|
-
setSearch('');
|
|
184
|
-
};
|
|
185
|
-
|
|
186
|
-
const searchKeyDown = (event: any) => {
|
|
187
|
-
if (event.key === 'Enter') {
|
|
188
|
-
handleSearch();
|
|
189
|
-
}
|
|
190
|
-
};
|
|
191
|
-
|
|
192
|
-
const handleLoadAllTemplate = (pagination = false, initialCall = false) => {
|
|
193
|
-
let page = pagination ? ++templates.currentPage : templates.currentPage;
|
|
194
|
-
if (initialCall) {
|
|
195
|
-
page = 1;
|
|
196
|
-
}
|
|
197
|
-
// Call getAllTemplates if required.
|
|
198
|
-
};
|
|
199
|
-
|
|
200
|
-
const handleLoadTemplate = (id: any) => {
|
|
201
|
-
dispatch(getOneTemplate(id, 'copy'));
|
|
202
|
-
handleDialogChange('');
|
|
203
|
-
};
|
|
204
|
-
|
|
205
|
-
const handleDialogChange = (model = '') => {
|
|
206
|
-
setIsShowDialog((prev) => ({open: !prev.open, model: model}));
|
|
207
|
-
};
|
|
208
|
-
|
|
209
|
-
const processPage = async (index: any, page: any) => {
|
|
210
|
-
return new Promise<void>((resolve, reject) => {
|
|
211
|
-
let pageNumber = page.children.find(
|
|
212
|
-
(el: any) => el.custom?.name === 'page-number'
|
|
213
|
-
);
|
|
214
|
-
const text = index === 0 ? 'Front' : 'Back';
|
|
215
|
-
|
|
216
|
-
if (pageNumber) {
|
|
217
|
-
pageNumber.set({text});
|
|
218
|
-
resolve();
|
|
219
|
-
} else {
|
|
220
|
-
page.addElement({
|
|
221
|
-
type: 'text',
|
|
222
|
-
custom: {name: 'page-number'},
|
|
223
|
-
text,
|
|
224
|
-
width: store.width,
|
|
225
|
-
align: 'center',
|
|
226
|
-
fontSize: 40,
|
|
227
|
-
x: -150,
|
|
228
|
-
y: -50,
|
|
229
|
-
selectable: false,
|
|
230
|
-
alwaysOnTop: true,
|
|
231
|
-
});
|
|
232
|
-
resolve();
|
|
233
|
-
}
|
|
234
|
-
});
|
|
235
|
-
};
|
|
236
|
-
|
|
237
|
-
const checkPageNumbers = async () => {
|
|
238
|
-
const promises = store.pages.map(async (page: any, index: any) => {
|
|
239
|
-
await processPage(index, page);
|
|
240
|
-
});
|
|
241
|
-
|
|
242
|
-
await Promise.all(promises); // Wait for all promises to resolve
|
|
243
|
-
};
|
|
244
|
-
|
|
245
|
-
const handleClearStore = () => {
|
|
246
|
-
store.clear();
|
|
247
|
-
let size: string | string[] = '';
|
|
248
|
-
let isPostCards = false;
|
|
249
|
-
let _product = product;
|
|
250
|
-
if (template?.product) {
|
|
251
|
-
size = template?.product?.paperSize;
|
|
252
|
-
isPostCards = template.product.productType === 'Postcards' || false;
|
|
253
|
-
_product = template.product;
|
|
254
|
-
} else if (product) {
|
|
255
|
-
size = product.selectedSize;
|
|
256
|
-
isPostCards = product.productType === 'Postcards' || false;
|
|
257
|
-
}
|
|
258
|
-
store.setUnit({
|
|
259
|
-
unit: 'in',
|
|
260
|
-
dpi: DPI,
|
|
261
|
-
});
|
|
262
|
-
size = (size as string)?.split('x');
|
|
263
|
-
store.setSize(+size[1] * DPI, +size[0] * DPI);
|
|
264
|
-
store.addPage();
|
|
265
|
-
|
|
266
|
-
if (multiPageLetters.includes(_product.productType)) {
|
|
267
|
-
store.addPage();
|
|
268
|
-
store.selectPage(store.pages[0].id);
|
|
269
|
-
}
|
|
270
|
-
drawRestrictedAreaOnPage(store, product, envelopeType);
|
|
271
|
-
handleDialogChange('');
|
|
272
|
-
};
|
|
273
|
-
|
|
274
|
-
useEffect(() => {
|
|
275
|
-
if (templateLoading !== null && templateLoading === false) {
|
|
276
|
-
handleDialogChange('');
|
|
277
|
-
dispatch({type: TEMPLATE_LOADING, payload: null});
|
|
278
|
-
}
|
|
279
|
-
}, [templateLoading]);
|
|
280
|
-
|
|
281
|
-
useEffect(() => {
|
|
282
|
-
if (!search) {
|
|
283
|
-
setSearchApplied(false);
|
|
284
|
-
setSearch('');
|
|
285
|
-
getTemplatesByTab();
|
|
286
|
-
}
|
|
287
|
-
}, [search]);
|
|
288
|
-
|
|
289
|
-
useEffect(() => {
|
|
290
|
-
handleLoadAllTemplate(true, true);
|
|
291
|
-
getAllCategories();
|
|
292
|
-
return () => {
|
|
293
|
-
dispatch(clearAllTemplates());
|
|
294
|
-
};
|
|
295
|
-
}, []);
|
|
296
|
-
|
|
297
|
-
useEffect(() => {
|
|
298
|
-
getTemplatesByTab();
|
|
299
|
-
}, [currentTemplateType, selectedCategory]);
|
|
300
|
-
|
|
301
|
-
useEffect(() => {
|
|
302
|
-
const div = document.querySelector('.polotno-panel-container');
|
|
303
|
-
const handleScroll = () => {
|
|
304
|
-
if (div) {
|
|
305
|
-
const isAtBottom =
|
|
306
|
-
div.scrollTop + div.clientHeight >= div.scrollHeight;
|
|
307
|
-
const isNeedToLoadMore =
|
|
308
|
-
templates.currentPage * templates.perPage < templates.count;
|
|
309
|
-
if (isAtBottom && !templatesPagination.loading && isNeedToLoadMore) {
|
|
310
|
-
handleLoadAllTemplate(true);
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
};
|
|
314
|
-
|
|
315
|
-
if (div) {
|
|
316
|
-
div.removeEventListener('scroll', handleScroll);
|
|
317
|
-
div.addEventListener('scroll', handleScroll);
|
|
318
|
-
}
|
|
319
|
-
return () => {
|
|
320
|
-
div?.removeEventListener('scroll', handleScroll);
|
|
321
|
-
};
|
|
322
|
-
}, [templates]);
|
|
323
|
-
|
|
324
|
-
return (
|
|
325
|
-
<div className="custom-template-section">
|
|
326
|
-
{isShowDialog.open && isShowDialog.model === 'design-own' && (
|
|
327
|
-
<Dialog
|
|
328
|
-
icon={<ModalCross fill="var(--primaryColor)" />}
|
|
329
|
-
title={MESSAGES.TEMPLATE.DESIGN_YOUR_OWN.TITLE}
|
|
330
|
-
subHeading={MESSAGES.TEMPLATE.DESIGN_YOUR_OWN.HEADING}
|
|
331
|
-
description={MESSAGES.TEMPLATE.DESIGN_YOUR_OWN.PARAGRAPH}
|
|
332
|
-
open={isShowDialog.open}
|
|
333
|
-
handleClose={() => handleDialogChange('')}
|
|
334
|
-
onCancel={() => handleDialogChange('')}
|
|
335
|
-
onSubmit={handleClearStore}
|
|
336
|
-
customStyles={designDialogStyles}
|
|
337
|
-
cancelText="Cancel"
|
|
338
|
-
submitText="OK"
|
|
339
|
-
/>
|
|
340
|
-
)}
|
|
341
|
-
{isShowDialog.open && isShowDialog.model === 'load-template' && (
|
|
342
|
-
<Dialog
|
|
343
|
-
icon={<ModalCross />}
|
|
344
|
-
title={MESSAGES.TEMPLATE.SELECT_TEMPLATE.TITLE}
|
|
345
|
-
subHeading={MESSAGES.TEMPLATE.SELECT_TEMPLATE.HEADING}
|
|
346
|
-
description={MESSAGES.TEMPLATE.SELECT_TEMPLATE.PARAGRAPH}
|
|
347
|
-
open={isShowDialog.open}
|
|
348
|
-
handleClose={() => handleDialogChange('')}
|
|
349
|
-
onCancel={() => handleDialogChange('')}
|
|
350
|
-
onSubmit={() => handleLoadTemplate(selectedRecord?.id)}
|
|
351
|
-
customStyles={designDialogStyles}
|
|
352
|
-
cancelText="Cancel"
|
|
353
|
-
submitText="OK"
|
|
354
|
-
/>
|
|
355
|
-
)}
|
|
356
|
-
<div
|
|
357
|
-
className="templateTabsWrapper"
|
|
358
|
-
style={{
|
|
359
|
-
maxWidth: window.innerWidth <= 600 ? '320px' : '480px',
|
|
360
|
-
backgroundColor: '#fff',
|
|
361
|
-
}}
|
|
362
|
-
>
|
|
363
|
-
<div style={{marginTop: '8px'}}>
|
|
364
|
-
<GeneralSelect
|
|
365
|
-
placeholder="Template Types"
|
|
366
|
-
options={templateTypes as any}
|
|
367
|
-
setSelectedValue={setCurrentTemplateType as any}
|
|
368
|
-
selectedValue={currentTemplateType as any}
|
|
369
|
-
// @ts-ignore
|
|
370
|
-
search={() => {}}
|
|
371
|
-
updateErrors={() => {}}
|
|
372
|
-
disableClearable={true}
|
|
373
|
-
templateBuilder={true}
|
|
374
|
-
/>
|
|
375
|
-
</div>
|
|
376
|
-
{currentTemplateType?.id === '3' && (
|
|
377
|
-
<div style={{marginTop: 8}}>
|
|
378
|
-
<GeneralSelect
|
|
379
|
-
placeholder="Select Category"
|
|
380
|
-
options={templateCategories as any}
|
|
381
|
-
setSelectedValue={setSelectedCategory as any}
|
|
382
|
-
selectedValue={selectedCategory as any}
|
|
383
|
-
// @ts-ignore
|
|
384
|
-
search={(() => {}) as any}
|
|
385
|
-
updateErrors={() => {}}
|
|
386
|
-
disableClearable={false}
|
|
387
|
-
templateBuilder={true}
|
|
388
|
-
/>
|
|
389
|
-
</div>
|
|
390
|
-
)}
|
|
391
|
-
<div
|
|
392
|
-
className="searchWrapper"
|
|
393
|
-
style={{marginTop: '16px', marginBottom: '16px'}}
|
|
394
|
-
>
|
|
395
|
-
<Input
|
|
396
|
-
type="text"
|
|
397
|
-
value={search}
|
|
398
|
-
name="search"
|
|
399
|
-
// @ts-ignore
|
|
400
|
-
onKeyDown={searchKeyDown}
|
|
401
|
-
onChange={(e: any) => setSearch(e.target.value.trimStart())}
|
|
402
|
-
placeholder="Search by template name"
|
|
403
|
-
inputIcon={true}
|
|
404
|
-
onClick={handleSearch}
|
|
405
|
-
searchApplied={searchApplied}
|
|
406
|
-
removeSearchInput={removeSearchInput}
|
|
407
|
-
/>
|
|
408
|
-
</div>
|
|
409
|
-
{currentTemplateType?.id === '1' ? (
|
|
410
|
-
<>
|
|
411
|
-
<div
|
|
412
|
-
className="default-design"
|
|
413
|
-
onClick={() => handleDialogChange('design-own')}
|
|
414
|
-
>
|
|
415
|
-
<DesignIcon fill="var(--svgColorSecondary)" />
|
|
416
|
-
<Typography style={templateTextStyles}>
|
|
417
|
-
Design Your Own
|
|
418
|
-
</Typography>
|
|
419
|
-
</div>
|
|
420
|
-
{myTemplates.length ? (
|
|
421
|
-
myTemplates.map((template: any, i: number) => (
|
|
422
|
-
<div
|
|
423
|
-
className="design-template"
|
|
424
|
-
key={i}
|
|
425
|
-
onClick={() => handleLoadTemplateModel(template)}
|
|
426
|
-
>
|
|
427
|
-
<img
|
|
428
|
-
src={template.thumbnailUrl}
|
|
429
|
-
alt={template.title}
|
|
430
|
-
onError={({currentTarget}) => {
|
|
431
|
-
currentTarget.onerror = null; // prevents looping
|
|
432
|
-
currentTarget.src = dummyTemplateIcon;
|
|
433
|
-
currentTarget.classList.add('dummy-image');
|
|
434
|
-
}}
|
|
435
|
-
/>
|
|
436
|
-
</div>
|
|
437
|
-
))
|
|
438
|
-
) : (
|
|
439
|
-
<div className="noTemplateText">
|
|
440
|
-
<Typography>No My Templates to show</Typography>
|
|
441
|
-
</div>
|
|
442
|
-
)}
|
|
443
|
-
</>
|
|
444
|
-
) : currentTemplateType?.id === '2' ? (
|
|
445
|
-
<>
|
|
446
|
-
{teamTemplates.length ? (
|
|
447
|
-
teamTemplates?.map((template, i) => (
|
|
448
|
-
<div
|
|
449
|
-
className="design-template"
|
|
450
|
-
key={i}
|
|
451
|
-
onClick={() => handleLoadTemplateModel(template)}
|
|
452
|
-
>
|
|
453
|
-
<img
|
|
454
|
-
src={template.thumbnailUrl}
|
|
455
|
-
alt={template.title}
|
|
456
|
-
onError={({currentTarget}) => {
|
|
457
|
-
currentTarget.onerror = null; // prevents looping
|
|
458
|
-
currentTarget.src = dummyTemplateIcon;
|
|
459
|
-
currentTarget.classList.add('dummy-image');
|
|
460
|
-
}}
|
|
461
|
-
/>
|
|
462
|
-
</div>
|
|
463
|
-
))
|
|
464
|
-
) : (
|
|
465
|
-
<div className="noTemplateText">
|
|
466
|
-
<Typography>No Team Templates to show</Typography>
|
|
467
|
-
</div>
|
|
468
|
-
)}
|
|
469
|
-
</>
|
|
470
|
-
) : currentTemplateType?.id === '3' ? (
|
|
471
|
-
<>
|
|
472
|
-
{olcTemplates.length ? (
|
|
473
|
-
olcTemplates?.map((template, i) => (
|
|
474
|
-
<div
|
|
475
|
-
className="design-template"
|
|
476
|
-
key={i}
|
|
477
|
-
onClick={() => handleLoadTemplateModel(template)}
|
|
478
|
-
>
|
|
479
|
-
<img
|
|
480
|
-
src={template.thumbnailUrl}
|
|
481
|
-
alt={template.title}
|
|
482
|
-
onError={({currentTarget}) => {
|
|
483
|
-
currentTarget.onerror = null; // prevents looping
|
|
484
|
-
currentTarget.src = dummyTemplateIcon;
|
|
485
|
-
currentTarget.classList.add('dummy-image');
|
|
486
|
-
}}
|
|
487
|
-
/>
|
|
488
|
-
</div>
|
|
489
|
-
))
|
|
490
|
-
) : (
|
|
491
|
-
<div className="noTemplateText">
|
|
492
|
-
<Typography>No OLC Templates to show</Typography>
|
|
493
|
-
</div>
|
|
494
|
-
)}
|
|
495
|
-
</>
|
|
496
|
-
) : null}
|
|
497
|
-
</div>
|
|
498
|
-
</div>
|
|
499
|
-
);
|
|
500
|
-
}) as SideSection['Panel'],
|
|
501
|
-
};
|
|
502
|
-
|
|
503
|
-
export default customTemplateSection;
|
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
.polotno-panel-container {
|
|
2
|
-
overflow-y: auto;
|
|
3
|
-
|
|
4
|
-
& .custom-template-section {
|
|
5
|
-
display: "flex";
|
|
6
|
-
flex-wrap: "wrap";
|
|
7
|
-
overflow-y: "scroll";
|
|
8
|
-
|
|
9
|
-
& .title {
|
|
10
|
-
& span {
|
|
11
|
-
font-size: 16px;
|
|
12
|
-
font-weight: 600;
|
|
13
|
-
color: #ed5c2f;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
@mixin designCommonStyles {
|
|
17
|
-
width: 320px;
|
|
18
|
-
height: 224px;
|
|
19
|
-
border-radius: 3px;
|
|
20
|
-
border: 0.5px solid #303030;
|
|
21
|
-
margin: 10px auto;
|
|
22
|
-
cursor: pointer;
|
|
23
|
-
}
|
|
24
|
-
& .default-design {
|
|
25
|
-
@include designCommonStyles;
|
|
26
|
-
display: flex;
|
|
27
|
-
flex-direction: column;
|
|
28
|
-
align-items: center;
|
|
29
|
-
justify-content: center;
|
|
30
|
-
& p {
|
|
31
|
-
color: #303030;
|
|
32
|
-
font-weight: 600;
|
|
33
|
-
font-size: 12px;
|
|
34
|
-
line-height: 14.52px;
|
|
35
|
-
margin-top: 5px;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
& .design-template {
|
|
39
|
-
@include designCommonStyles;
|
|
40
|
-
& img {
|
|
41
|
-
width: 100%;
|
|
42
|
-
height: 100%;
|
|
43
|
-
object-fit: cover;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
.dummy-image {
|
|
50
|
-
padding: 85px;
|
|
51
|
-
object-fit: fill !important;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
.MuiTabs-indicator {
|
|
55
|
-
background-color: #ed5c2f !important;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
.templateTabsWrapper {
|
|
59
|
-
background-color: var(--sidepanelBgColor) !important;
|
|
60
|
-
.templateTabs {
|
|
61
|
-
.MuiTabScrollButton-root {
|
|
62
|
-
width: 15px;
|
|
63
|
-
opacity: 1 !important;
|
|
64
|
-
&:hover {
|
|
65
|
-
svg {
|
|
66
|
-
color: #ed5c2f !important;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
.Mui-disabled {
|
|
70
|
-
opacity: 1 !important;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
.noTemplateText {
|
|
77
|
-
height: 100%;
|
|
78
|
-
min-height: 200px;
|
|
79
|
-
display: flex;
|
|
80
|
-
justify-content: center;
|
|
81
|
-
align-items: center;
|
|
82
|
-
p {
|
|
83
|
-
color: var(--textColor);
|
|
84
|
-
font-size: 18px;
|
|
85
|
-
font-style: normal;
|
|
86
|
-
font-weight: 500;
|
|
87
|
-
line-height: normal;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
.searchWrapper {
|
|
92
|
-
display: flex;
|
|
93
|
-
justify-content: flex-start;
|
|
94
|
-
align-items: center;
|
|
95
|
-
width: 100%;
|
|
96
|
-
gap: 10px;
|
|
97
|
-
position: relative;
|
|
98
|
-
|
|
99
|
-
.searchInput {
|
|
100
|
-
border-radius: 3px;
|
|
101
|
-
border: 0.5px solid rgba(68, 66, 65, 0.5);
|
|
102
|
-
background: #fff;
|
|
103
|
-
width: 100%;
|
|
104
|
-
max-width: 520px;
|
|
105
|
-
padding: 5px 20px;
|
|
106
|
-
color: #000;
|
|
107
|
-
font-size: 16px;
|
|
108
|
-
font-style: normal;
|
|
109
|
-
font-weight: 400;
|
|
110
|
-
line-height: normal;
|
|
111
|
-
height: 40px;
|
|
112
|
-
width: 514px;
|
|
113
|
-
// position: relative;
|
|
114
|
-
&::after,
|
|
115
|
-
&::before {
|
|
116
|
-
display: none;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
.searchIcon {
|
|
120
|
-
position: relative;
|
|
121
|
-
color: #ed5c2f;
|
|
122
|
-
|
|
123
|
-
&::before {
|
|
124
|
-
position: absolute;
|
|
125
|
-
content: "";
|
|
126
|
-
width: 1px;
|
|
127
|
-
height: 90%;
|
|
128
|
-
background-color: #000;
|
|
129
|
-
left: -5px;
|
|
130
|
-
opacity: 0.5;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
.searchApplied {
|
|
137
|
-
background: #fff8ee;
|
|
138
|
-
input {
|
|
139
|
-
padding-right: 28px;
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
.clearSerach {
|
|
144
|
-
position: absolute;
|
|
145
|
-
top: 10px;
|
|
146
|
-
right: 55px;
|
|
147
|
-
font-size: 18px;
|
|
148
|
-
opacity: 0.6;
|
|
149
|
-
cursor: pointer;
|
|
150
|
-
}
|
|
151
|
-
}
|