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