kitchen-simulator 5.0.0-test.13 → 5.0.0-test.15

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.
@@ -1,1517 +0,0 @@
1
- import Dialog from '@material-ui/core/Dialog';
2
- import axios from 'axios';
3
- import convert from 'convert-units';
4
- import { Plugins as PlannerPlugins } from './index';
5
- import PropTypes from 'prop-types';
6
- import React, { Component } from 'react';
7
- import ReactGA from 'react-ga4';
8
- import { hotjar } from 'react-hotjar';
9
- import { connect } from 'react-redux';
10
- import { bindActionCreators } from 'redux';
11
- import styled from 'styled-components';
12
- import SnackBar from './components/atoms/Snackbar';
13
- import * as constants from './constants';
14
- import {
15
- API_SERVER_URL,
16
- BG_COLOR_HOVER,
17
- CLIENTS_NAME,
18
- DEFAULT_FONT_FAMILY,
19
- LOCAL_STORAGE_CART_ACTION,
20
- LOCAL_STORAGE_ORIGINAL_TOKEN,
21
- LOCAL_STORAGE_TOKEN_NAME,
22
- LOCAL_STORAGE_TOKEN_VALUE,
23
- MODE,
24
- PRIMARY_GREEN_COLOR,
25
- SECONDARY_PURPLE_COLOR,
26
- TEXT_COLOR_NEUTRAL_1
27
- } from './constants';
28
- import { base64Decode, getPath } from './utils/helper';
29
- import { isEmpty } from './components/viewer2d/utils';
30
- import actions from './actions/export';
31
- import Catalog from './catalog/catalog';
32
- import { Project } from './class/export';
33
- import {
34
- Content,
35
- FooterBarComponents,
36
- HeaderComponents,
37
- MyProjectsComonents,
38
- SignComponents,
39
- ToolbarComponents,
40
- WizardStepComponents
41
- } from './components/export';
42
- import jwtService from './components/login/jwtService';
43
- import './styles/export';
44
- import Translator from './translator/translator';
45
- import { objectsMap } from './utils/objects-utils';
46
- import { VERSION } from './version';
47
- import ls from 'localstorage-slim';
48
-
49
- const AWS = require('aws-sdk');
50
-
51
- const StyledDialog = styled(Dialog)`
52
- .MuiDialog-paperWidthSm {
53
- border-radius: 10px;
54
- }
55
- `;
56
-
57
- export const StyledDialogContent = styled.span`
58
- font-family: ${DEFAULT_FONT_FAMILY};
59
- color: ${TEXT_COLOR_NEUTRAL_1};
60
- padding: 10px 30px;
61
- padding-top: 30px;
62
- `;
63
-
64
- export const StyledDialogAction = styled.div`
65
- display: flex;
66
- justify-content: flex-end;
67
- padding: 15px 30px 25px;
68
- `;
69
-
70
- export const StyledButton = styled.div`
71
- padding: 10px 20px;
72
- cursor: pointer;
73
- margin-right: 10px;
74
- color: ${SECONDARY_PURPLE_COLOR};
75
- font-weight: bold;
76
- font-family: ${DEFAULT_FONT_FAMILY};
77
- font-size: 16px;
78
- border-radius: 20px;
79
- :hover {
80
- background-color: ${BG_COLOR_HOVER};
81
- }
82
- `;
83
-
84
- const s3 = new AWS.S3({
85
- accessKeyId: process.env.REACT_APP_AWS_ID,
86
- secretAccessKey: process.env.REACT_APP_AWS_SECRET
87
- });
88
-
89
- const { Header } = HeaderComponents;
90
- const { Toolbar } = ToolbarComponents;
91
- const { FooterBar } = FooterBarComponents;
92
- const { WizardStep } = WizardStepComponents;
93
- const { Sign } = SignComponents;
94
- const { MyProjects } = MyProjectsComonents;
95
-
96
- const toolbarW = 0;
97
- const sidebarW = 250;
98
- const footerBarH = 20;
99
-
100
- const wrapperStyle = {
101
- display: 'flex',
102
- flexFlow: 'row nowrap'
103
- };
104
-
105
- const uploadFiles = (data, filePath) => {
106
- var p1 = new Promise((resolve, reject) => {
107
- const params = {
108
- Bucket: process.env.REACT_APP_AWS_BUCKET_NAME,
109
- Key: filePath,
110
- Body: data,
111
- ContentType: 'application/json',
112
- ACL: 'public-read'
113
- };
114
- s3.putObject(params, function (err, data) {
115
- if (err) {
116
- reject(err);
117
- return;
118
- }
119
- console.log('success');
120
- resolve([data.Location]);
121
- });
122
- });
123
- return p1;
124
- };
125
-
126
- let saveAlert = '';
127
- let saveInterval = '';
128
-
129
- class KitchenConfigurator extends Component {
130
- constructor(props) {
131
- super(props);
132
-
133
- // utm tracking
134
- const utmDetailParams = new URLSearchParams(
135
- this.props.location && this.props.location.search
136
- );
137
-
138
- const utmStrEncoded = utmDetailParams.get('details');
139
- let utmRequestData = null;
140
- if (utmStrEncoded) {
141
- try {
142
- utmRequestData = JSON.parse(base64Decode(utmStrEncoded));
143
- utmRequestData = JSON.parse(utmRequestData?.utm);
144
- } catch (e) {
145
- console.error('Cannot parse utm parameter: ', error);
146
- utmRequestData = null;
147
- }
148
- }
149
-
150
- this.state = {
151
- savePopupVisible: false,
152
- quotePopupVisible: false,
153
- assistPopupVisible: false,
154
- newProjectPopupVisible: false,
155
- isModalVisible: false,
156
- submitPromptVisible: false,
157
- stateSubmitType: constants.SUBMIT_REQUEST_ASSIST,
158
- savePromptVisible: false,
159
- isShowProperty: true,
160
- submitTosave: false,
161
- signOpen: false,
162
- myProjectsOpen: false,
163
- myProjectsToLogin: false,
164
- downloadPopupVisible: false,
165
-
166
- // For Toolbar Item
167
- toolbar: '',
168
- reviewQuotePopupOpened: false,
169
- floorOpened: false,
170
- cabinetOpened: false,
171
- applianceOpened: false,
172
- finishingOpened: false,
173
- doorStyleOpen: false,
174
- wizardStepOpend: false,
175
- tutorialMouseEventsAdd: false,
176
- replaceCabinetFlag: false,
177
- isSnackBarOpen: false,
178
- isSnackBar1Open: false,
179
- redirectURL: '',
180
- snackBarMessage: '',
181
- isSaved: false,
182
- isLeaving: false
183
- };
184
-
185
- // For UTM tracking
186
- this.utm = {
187
- utm_source: utmRequestData?.source || 'source',
188
- utm_medium: utmRequestData?.medium || 'medium',
189
- utm_campaign: utmRequestData?.campaign || 'campaign',
190
- utm_term: utmRequestData?.term || 'term',
191
- utm_content: utmRequestData?.content || 'content',
192
- gclid: utmRequestData?.gclid || 'gclid',
193
- msclkid: utmRequestData?.msclkid || 'msclkid',
194
- fbclid: utmRequestData?.fbclid || 'fbclid',
195
- ttclid: utmRequestData?.ttclid || 'ttclid'
196
- };
197
-
198
- this.jwtCheck();
199
-
200
- this.openFloor = this.openFloor.bind(this);
201
- this.openCabinet = this.openCabinet.bind(this);
202
- this.openFinishing = this.openFinishing.bind(this);
203
- this.openAppliance = this.openAppliance.bind(this);
204
- this.toggleDoorStyle = this.toggleDoorStyle.bind(this);
205
- this.onReviewQuoteClicked = this.onReviewQuoteClicked.bind(this);
206
- this.closeFloorTB = this.closeFloorTB.bind(this);
207
- this.closeCabinetTB = this.closeCabinetTB.bind(this);
208
- this.closeFinishingTB = this.closeFinishingTB.bind(this);
209
- this.closeApplianceTB = this.closeApplianceTB.bind(this);
210
- this.setToolbar = this.setToolbar.bind(this);
211
- this.replaceCabinet = this.replaceCabinet.bind(this);
212
- this.setSubmitToSave = this.setSubmitToSave.bind(this);
213
- this.setSignOpen = this.setSignOpen.bind(this);
214
- this.setMyProjectsOpen = this.setMyProjectsOpen.bind(this);
215
- this.setMyProjectsToLogin = this.setMyProjectsToLogin.bind(this);
216
- this.setDownloadPopupVisible = this.setDownloadPopupVisible.bind(this);
217
- this.neverShowInput = React.createRef(null);
218
- this.setShowProperty = this.setShowProperty.bind(this);
219
- }
220
-
221
- // Toolbar control functions
222
-
223
- setToolbar(toolBarKey) {
224
- this.setState({ toolbar: toolBarKey });
225
- }
226
-
227
- setShowProperty(value) {
228
- this.setState({ isShowProperty: value });
229
- }
230
-
231
- setMyProjectsOpen(value) {
232
- this.setState({ myProjectsOpen: value });
233
- this.setState({ signOpen: false });
234
- this.setState({ wizardStepOpend: false });
235
- }
236
-
237
- setMyProjectsToLogin(value) {
238
- this.setState({ myProjectsToLogin: value });
239
- }
240
-
241
- setDownloadPopupVisible(value) {
242
- this.setState({ reviewQuotePopupOpened: false });
243
- this.setState({ savePopupVisible: false });
244
- this.setState({ quotePopupVisible: false });
245
- this.setState({ submitTosave: false });
246
- this.setState({ assistPopupVisible: false });
247
- this.setState({ newProjectPopupVisible: false });
248
- this.setState({ downloadPopupVisible: value });
249
- }
250
-
251
- setSubmitToSave(value) {
252
- this.setState({ submitTosave: value });
253
- }
254
-
255
- setSignOpen(value) {
256
- this.setState({ wizardStepOpend: false });
257
- this.setState({ myProjectsOpen: false });
258
- this.setState({ signOpen: value });
259
- }
260
-
261
- openFloor() {
262
- this.setState({ floorOpened: true });
263
- document.getElementById(
264
- 'make_floorplan_inactive'
265
- ).parentElement.parentElement.style.zIndex = 999;
266
- }
267
-
268
- openCabinet() {
269
- this.setState({ cabinetOpened: true });
270
- document.getElementById(
271
- 'add_cabinets_inactive'
272
- ).parentElement.parentElement.style.zIndex = 999;
273
- }
274
-
275
- toggleDoorStyle(visible) {
276
- this.setState({ doorStyleOpen: visible });
277
- document.getElementById(
278
- 'select_doorstyle_inactive'
279
- ).parentElement.parentElement.style.zIndex = visible ? 999 : 6;
280
- }
281
-
282
- replaceCabinet(value) {
283
- this.setState({ replaceCabinetFlag: value });
284
- }
285
-
286
- openAppliance() {
287
- this.setState({ applianceOpened: true });
288
- document.getElementById(
289
- 'add_appliances_inactive'
290
- ).parentElement.parentElement.style.zIndex = 999;
291
- }
292
-
293
- openFinishing() {
294
- this.setState({ finishingOpened: true });
295
- document.getElementById(
296
- 'finishing_touches_inactive'
297
- ).parentElement.parentElement.style.zIndex = 999;
298
- }
299
-
300
- onReviewQuoteClicked(visible) {
301
- this.setState({ reviewQuotePopupOpened: visible });
302
- document.getElementById(
303
- 'review_quote_inactive'
304
- ).parentElement.parentElement.style.zIndex = visible ? 999 : 6;
305
- }
306
-
307
- closeFloorTB() {
308
- this.setState({ floorOpened: false });
309
- document.getElementById('make_floorplan_inactive') &&
310
- (document.getElementById(
311
- 'make_floorplan_inactive'
312
- ).parentElement.parentElement.style.zIndex = 6);
313
- }
314
-
315
- closeCabinetTB() {
316
- this.setState({ cabinetOpened: false });
317
- document.getElementById(
318
- 'add_cabinets_inactive'
319
- ).parentElement.parentElement.style.zIndex = 6;
320
- }
321
-
322
- closeFinishingTB() {
323
- this.setState({ finishingOpened: false });
324
- document.getElementById(
325
- 'finishing_touches_inactive'
326
- ).parentElement.parentElement.style.zIndex = 6;
327
- }
328
-
329
- closeApplianceTB() {
330
- this.setState({ applianceOpened: false });
331
- document.getElementById(
332
- 'add_appliances_inactive'
333
- ).parentElement.parentElement.style.zIndex = 6;
334
- }
335
-
336
- closeDoorstyle() {
337
- this.setState({});
338
- document.getElementById(
339
- 'select_doorstyle_inactive'
340
- ).parentElement.parentElement.style.zIndex = 6;
341
- }
342
- closeReviewQuote() {
343
- this.setState({});
344
- document.getElementById(
345
- 'review_quote_inactive'
346
- ).parentElement.parentElement.style.zIndex = 6;
347
- }
348
-
349
- jwtCheck() {
350
- jwtService.on('onAutoLogin', () => {
351
- // this.props.showMessage({message: 'Logging in with JWT'});
352
-
353
- /**
354
- * Sign in and retrieve user data from Api
355
- */
356
- jwtService
357
- .signInWithToken()
358
- .then(user => {
359
- //this.props.userActions.setUserData(user);
360
- this.props.userActions.login(
361
- user.id,
362
- user.role,
363
- jwtService.getAccessToken(),
364
- this.utm
365
- );
366
- //this.props.showMessage(option)
367
- //this.props.showMessage({message: 'Logged in with token data', variant: 'success'});
368
- //alert('Logged in with token data');
369
- })
370
- .catch(error => {
371
- //this.props.showMessage({message: error});
372
- this.setState({
373
- isSnackBarOpen: true,
374
- snackBarMessage: error
375
- });
376
- });
377
- });
378
-
379
- jwtService.on('onAutoLogout', message => {
380
- if (message) {
381
- //this.props.showMessage({message, variant: 'error'});
382
- }
383
- this.props.userActions.logout();
384
- });
385
-
386
- jwtService.init();
387
- }
388
-
389
- getChildContext() {
390
- return {
391
- ...objectsMap(actions, actionNamespace => this.props[actionNamespace]),
392
- translator: this.props.translator,
393
- catalog: this.props.catalog
394
- };
395
- }
396
-
397
- saveProjectToStorage() {
398
- let { state, stateExtractor } = this.props;
399
- const extractedState = stateExtractor(state);
400
- const projectData = JSON.stringify(extractedState.get('scene').toJS());
401
- sessionStorage.setItem(window.location.href, projectData);
402
- }
403
-
404
- // debouncedSetIsSaved = _.debounce(
405
- // () => this.setState({ isSaved: false }),
406
- // 200
407
- // );
408
- //
409
- // componentDidUpdate(prevProps) {
410
- // // Only strip properties if the object is not null/undefined
411
- // function stripProperty(obj, properties) {
412
- // if (!obj) return obj;
413
- // let changed = false;
414
- // const newObj = { ...obj };
415
- // for (const prop of properties) {
416
- // if (prop in newObj) {
417
- // delete newObj[prop];
418
- // changed = true;
419
- // }
420
- // }
421
- // return changed ? newObj : obj;
422
- // }
423
- //
424
- // const prevState = this.props.stateExtractor(prevProps.state);
425
- // const currState = this.props.stateExtractor(this.props.state);
426
- //
427
- // // Only convert to JS once per items/areas/lines
428
- // const prevLayer = prevState.scene.selectedLayer;
429
- // const currLayer = currState.scene.selectedLayer;
430
- //
431
- // const prevItems = prevState
432
- // .getIn(['scene', 'layers', prevLayer, 'items'])
433
- // .toJS();
434
- // const currItems = currState
435
- // .getIn(['scene', 'layers', currLayer, 'items'])
436
- // .toJS();
437
- //
438
- // const prevItemsProps = Object.values(prevItems).map(
439
- // ({ x, y, rotation }) => ({ x, y, rotation })
440
- // );
441
- // const currItemsProps = Object.values(currItems).map(
442
- // ({ x, y, rotation }) => ({ x, y, rotation })
443
- // );
444
- //
445
- // const prevDoorStyleRaw = prevState.getIn([
446
- // 'scene',
447
- // 'layers',
448
- // prevLayer,
449
- // 'doorStyle'
450
- // ]);
451
- // const currDoorStyleRaw = currState.getIn([
452
- // 'scene',
453
- // 'layers',
454
- // currLayer,
455
- // 'doorStyle'
456
- // ]);
457
- // const prevDoorStyle = stripProperty(prevDoorStyleRaw, ['doorStyles']);
458
- // const currDoorStyle = stripProperty(currDoorStyleRaw, ['doorStyles']);
459
- //
460
- // const prevAreasRaw = prevState
461
- // .getIn(['scene', 'layers', prevLayer, 'areas'])
462
- // .toJS();
463
- // const currAreasRaw = currState
464
- // .getIn(['scene', 'layers', currLayer, 'areas'])
465
- // .toJS();
466
- // const prevAreas = stripProperty(Object.values(prevAreasRaw)[0], [
467
- // 'selected'
468
- // ]);
469
- // const currAreas = stripProperty(Object.values(currAreasRaw)[0], [
470
- // 'selected'
471
- // ]);
472
- //
473
- // const prevLinesRaw = prevState
474
- // .getIn(['scene', 'layers', prevLayer, 'lines'])
475
- // .toJS();
476
- // const currLinesRaw = currState
477
- // .getIn(['scene', 'layers', currLayer, 'lines'])
478
- // .toJS();
479
- // const prevLines = stripProperty(Object.values(prevLinesRaw)[0], [
480
- // 'selected'
481
- // ]);
482
- // const currLines = stripProperty(Object.values(currLinesRaw)[0], [
483
- // 'selected'
484
- // ]);
485
- //
486
- // const prevCeilingHeight = prevState.getIn([
487
- // 'scene',
488
- // 'layers',
489
- // prevLayer,
490
- // 'ceilHeight'
491
- // ]);
492
- // const currCeilingHeight = currState.getIn([
493
- // 'scene',
494
- // 'layers',
495
- // currLayer,
496
- // 'ceilHeight'
497
- // ]);
498
- //
499
- // let changed =
500
- // !_.isEqual(prevItemsProps, currItemsProps) ||
501
- // !_.isEqual(prevDoorStyle, currDoorStyle) ||
502
- // !_.isEqual(prevAreas, currAreas) ||
503
- // !_.isEqual(prevLines, currLines) ||
504
- // prevCeilingHeight !== currCeilingHeight;
505
- //
506
- // if (changed) {
507
- // this.debouncedSetIsSaved();
508
- //
509
- // const currentItemsLength = Object.keys(currItems).length;
510
- // const prevItemsLength = Object.keys(prevItems).length;
511
- // // make sure prompt appears only when adding cabinets
512
- // const allowedItemLengths = [5, 10, 15];
513
- //
514
- // if (
515
- // allowedItemLengths.includes(currentItemsLength) &&
516
- // prevItemsLength === currentItemsLength - 1 &&
517
- // !this.props.match.params.token
518
- // ) {
519
- // this.setState({ savePromptVisible: true });
520
- // }
521
- // }
522
- // }
523
-
524
- handleBeforeUnload = e => {
525
- const areas = this.props
526
- .stateExtractor(this.props.state)
527
- .getIn([
528
- 'scene',
529
- 'layers',
530
- this.props.stateExtractor(this.props.state).scene.selectedLayer,
531
- 'areas'
532
- ]);
533
-
534
- if (!this.state.isSaved && areas.size > 0) {
535
- setTimeout(() => {
536
- this.setState({ savePromptVisible: true, isLeaving: true });
537
- }, 500);
538
-
539
- this.saveProjectToStorage();
540
-
541
- // This line is required to trigger the browser confirmation dialog
542
- e.preventDefault();
543
- e.returnValue = '';
544
- return '';
545
- }
546
- };
547
-
548
- componentDidMount() {
549
- ReactGA.send({ hitType: 'pageview', page: getPath() });
550
- hotjar.event && hotjar.event(`pageview:${getPath()}`);
551
-
552
- window.addEventListener('beforeunload', this.handleBeforeUnload);
553
-
554
- console.log('context =>', this.context);
555
-
556
- window.forRedo = [];
557
- let { store } = this.context;
558
- let { projectActions, catalog, stateExtractor, state, plugins } =
559
- this.props;
560
-
561
- projectActions.initCatalog(catalog);
562
-
563
- let { match } = this.props;
564
-
565
- if (sessionStorage.getItem(window.location.href)) {
566
- const jsonData = sessionStorage.getItem(window.location.href);
567
- projectActions.loadProject(JSON.parse(jsonData), this.props.categoryData);
568
- sessionStorage.removeItem(window.location.href);
569
- return;
570
- }
571
-
572
- if (match && match.params.pid === undefined) {
573
- let newplugins = [
574
- ...plugins,
575
- PlannerPlugins.Autosave('KitchenConfigurator_v0', false)
576
- ];
577
- newplugins.forEach(newplugin => newplugin(store, stateExtractor));
578
- projectActions.newProject();
579
- sessionStorage.setItem('projectTitle', 'Untitled');
580
- projectActions.rename('Untitled');
581
- sessionStorage.removeItem('projectId');
582
- sessionStorage.removeItem('email');
583
- sessionStorage.removeItem('firstName');
584
- sessionStorage.removeItem('lastName');
585
- sessionStorage.removeItem('usedObjects');
586
- return;
587
- }
588
-
589
- if (match && match.params.pid !== undefined) {
590
- if (match.params.pid === 'new') {
591
- projectActions.newProject();
592
- sessionStorage.setItem('projectTitle', 'Untitled');
593
- projectActions.rename('Untitled');
594
- sessionStorage.removeItem('projectId');
595
- sessionStorage.removeItem('email');
596
- sessionStorage.removeItem('firstName');
597
- sessionStorage.removeItem('lastName');
598
- sessionStorage.removeItem('usedObjects');
599
- } else {
600
- axios
601
- .post(`${constants.API_SERVER_URL}/api/project/loadPidProject`, {
602
- pid: match.params.pid,
603
- visualizerName: sessionStorage.getItem('visualizerName')
604
- })
605
- .then(async response => {
606
- const { projectElement } = response.data;
607
- if (projectElement.length === 0) return;
608
- sessionStorage.setItem('projectTitle', projectElement[0].title);
609
- projectActions.rename(projectElement[0].title);
610
- sessionStorage.setItem('projectId', projectElement[0].id);
611
- sessionStorage.setItem('email', projectElement[0].email);
612
- sessionStorage.setItem('firstName', projectElement[0].firstName);
613
- sessionStorage.setItem('lastName', projectElement[0].lastName);
614
- sessionStorage.setItem('phone', projectElement[0].phone);
615
- let jsonData;
616
- if (projectElement[0].project_data) {
617
- jsonData = JSON.parse(projectElement[0].project_data);
618
- } else {
619
- try {
620
- jsonData = await axios.post(
621
- `${constants.API_SERVER_URL}/api/project/loadPidData`,
622
- { pid: match.params.pid }
623
- ).data.data;
624
- } catch (err) {
625
- this.setState({
626
- isSnackBarOpen: true,
627
- snackBarMessage: err
628
- });
629
- }
630
- }
631
- jsonData.isLoadingCabinet = false;
632
- projectActions.loadProject(jsonData, this.props.categoryData);
633
- });
634
- }
635
-
636
- sessionStorage.removeItem('user_type');
637
- sessionStorage.removeItem('project_type');
638
- sessionStorage.removeItem('project_timeline');
639
- }
640
- }
641
-
642
- componentWillUnmount() {
643
- window.addEventListener('beforeunload', this.handleBeforeUnload);
644
- window.onbeforeunload = null;
645
- }
646
-
647
- componentWillMount() {}
648
-
649
- componentWillReceiveProps(nextProps) {
650
- let { stateExtractor, state, projectActions, catalog } = nextProps;
651
- let plannerState = stateExtractor(state);
652
- let catalogReady = plannerState.getIn(['catalog', 'ready']);
653
- if (!catalogReady) {
654
- projectActions.initCatalog(catalog);
655
- }
656
- }
657
-
658
- isProjectEmpty(scene) {
659
- let { layers, selectedLayer } = scene;
660
- let layer = layers.get(selectedLayer);
661
- return (
662
- layer.areas.size +
663
- layer.lines.size +
664
- layer.holes.size +
665
- layer.items.size ===
666
- 0
667
- );
668
- }
669
-
670
- handleSaveDesign(value) {
671
- let { stateExtractor, state } = this.props;
672
- let plannerState = stateExtractor(state);
673
- let items = plannerState.getIn(['scene', 'layers', 'layer-1', 'items']);
674
- let areas = plannerState.getIn(['scene', 'layers', 'layer-1', 'areas']);
675
- if (areas.size === 0) {
676
- this.setState({
677
- isSnackBarOpen: true,
678
- snackBarMessage: 'Your project is empty.'
679
- });
680
- return;
681
- }
682
- // if (items.size === 0) {
683
- // saveAlert = <StyledAlert text={<span style={{fontSize: 16, fontFamily: DEFAULT_FONT_FAMILY}}>Add at least one item</span>} onClose={() => saveAlert = ""} />
684
- // return;
685
- // } else saveAlert = '';
686
- this.setState({ reviewQuotePopupOpened: false });
687
- this.setState({ savePopupVisible: value });
688
- this.setState({ assistPopupVisible: false });
689
- this.setState({ newProjectPopupVisible: false });
690
- this.setState({ savePromptVisible: false });
691
- this.setState({ submitPromptVisible: false });
692
- }
693
-
694
- handleNewProject(value) {
695
- this.setState({ reviewQuotePopupOpened: false });
696
- this.setState({ savePopupVisible: false });
697
- this.setState({ quotePopupVisible: false });
698
- this.setState({ assistPopupVisible: false });
699
- this.setState({ newProjectPopupVisible: value });
700
- }
701
-
702
- handleSubmitForQuote(
703
- isVisible,
704
- submitType = constants.SUBMIT_REQUEST_ASSIST
705
- ) {
706
- const items = this.props
707
- .stateExtractor(this.props.state)
708
- .getIn([
709
- 'scene',
710
- 'layers',
711
- this.props.stateExtractor(this.props.state).scene.selectedLayer,
712
- 'items'
713
- ]);
714
-
715
- if (submitType === constants.SUBMIT_ADD_CART) {
716
- this.setToolbar('reviewforquote');
717
- }
718
-
719
- if (submitType === constants.SUBMIT_ADD_CART && !items.size) {
720
- this.setState({
721
- isSnackBarOpen: true,
722
- snackBarMessage: 'Your project is empty. Please add at least one item.'
723
- });
724
- } else {
725
- this.setState({ reviewQuotePopupOpened: false });
726
- this.setState({ savePopupVisible: false });
727
- this.setState({ quotePopupVisible: isVisible });
728
- this.setState({ submitTosave: false });
729
- this.setState({ assistPopupVisible: false });
730
- this.setState({ newProjectPopupVisible: false });
731
- this.setState({ stateSubmitType: submitType });
732
- }
733
- }
734
-
735
- saveScreenshotToFile = event => {
736
- event.preventDefault();
737
- let canvas = document.getElementsByID('viewer3D')[1];
738
- let canvas_crop_image = document.getElementById('canvas_crop_image');
739
- let ctx = canvas_crop_image.getContext('2d');
740
-
741
- // Set width and height for the new canvas
742
- let heightAtt = document.createAttribute('height');
743
- heightAtt.value = canvas.height;
744
- canvas_crop_image.setAttributeNode(heightAtt);
745
-
746
- let widthAtt = document.createAttribute('width');
747
- widthAtt.value = canvas.width;
748
- canvas_crop_image.setAttributeNode(widthAtt);
749
-
750
- ctx.fillStyle = 'white';
751
- ctx.fillRect(0, 0, canvas_crop_image.width, canvas_crop_image.height);
752
-
753
- let img = new Image();
754
- img.crossOrigin = 'anonymous';
755
- img.src = canvas.toDataURL();
756
-
757
- img.onload = () => {
758
- ctx.globalAlpha = 0.3;
759
- ctx.drawImage(
760
- img,
761
- 0,
762
- 0,
763
- canvas_crop_image.width,
764
- canvas_crop_image.height
765
- );
766
- this.setState({
767
- isModalVisible: true,
768
- imageUri: canvas.toDataURL(),
769
- image: img
770
- });
771
- canvas_crop_image.style.zIndex = 11;
772
- document.addEventListener('keydown', this.onKeyDown, false);
773
- document.addEventListener(
774
- 'mouseup',
775
- this.onMouseUp_On_New_Save_SQ_DA,
776
- false
777
- );
778
- canvas_crop_image.style.display = 'block';
779
- };
780
- };
781
-
782
- findDelkeys(obj, deleteKeys, path) {
783
- if (typeof obj === 'object') {
784
- let allkeys = Object.keys(obj);
785
- for (let i = 0; i < allkeys.length; i++) {
786
- const value = obj[allkeys[i]];
787
- if (isEmpty(value)) {
788
- deleteKeys.push({
789
- path: path,
790
- key: allkeys[i]
791
- });
792
- } else if (typeof value === 'object') {
793
- let newPath = path + allkeys[i] + ',';
794
- this.findDelkeys(value, deleteKeys, newPath);
795
- }
796
- }
797
- } else if (isEmpty(obj)) {
798
- let tmpkey = path.split(',');
799
- deleteKeys.push({
800
- path: path,
801
- key: tmpkey[tmpkey.length - 1]
802
- });
803
- }
804
- }
805
-
806
- render() {
807
- let { width, height, state, stateExtractor, ...props } = this.props;
808
- let {
809
- savePopupVisible,
810
- quotePopupVisible,
811
- assistPopupVisible,
812
- newProjectPopupVisible,
813
- savePromptVisible,
814
- isLeaving,
815
- submitPromptVisible,
816
- stateSubmitType,
817
- submitTosave,
818
- signOpen,
819
- myProjectsOpen,
820
- myProjectsToLogin,
821
- downloadPopupVisible
822
- } = this.state;
823
- let contentW = width - toolbarW;
824
- let categoryData = this.props.categoryData;
825
- // console.log(categoryData);
826
- // let contentW = width - toolbarW - sidebarW;
827
- // let toolbarH = height - footerBarH;
828
- // let contentH = height - footerBarH;
829
- // let sidebarH = height - footerBarH;
830
- let toolbarH = height;
831
- let contentH = height;
832
- let sidebarH = height;
833
- let headerW = width;
834
- let headerH = 60;
835
-
836
- // const userInfo = this.props.match ? this.props.match.params : [];
837
- const userInfo = [];
838
-
839
- let extractedState = stateExtractor(state);
840
- let doorStyle = extractedState.get('doorStyle');
841
- if (
842
- extractedState.getIn([
843
- 'scene',
844
- 'layers',
845
- extractedState.scene.selectedLayer,
846
- 'doorStyle'
847
- ]) !== undefined &&
848
- extractedState.getIn([
849
- 'scene',
850
- 'layers',
851
- extractedState.scene.selectedLayer,
852
- 'doorStyle'
853
- ]) !== null
854
- ) {
855
- const extractedStateData = extractedState.getIn([
856
- 'scene',
857
- 'layers',
858
- extractedState.scene.selectedLayer,
859
- 'doorStyle'
860
- ]);
861
- let doorIdAvailable = false;
862
- if (
863
- this.props.categoryData.doorStyles &&
864
- this.props.categoryData.doorStyles.items
865
- ) {
866
- this.props.categoryData.doorStyles.items.find(category => {
867
- doorIdAvailable = category.items.find(style => {
868
- let item = style.items.find(it => it.id === extractedStateData.id);
869
- if (item) {
870
- colorItem = item;
871
- return true;
872
- } else {
873
- return false;
874
- }
875
- });
876
- });
877
- }
878
-
879
- if (doorIdAvailable) doorStyle = extractedStateData;
880
- }
881
-
882
- let firstVisit =
883
- this.state.wizardStepOpend && this.isProjectEmpty(extractedState.scene);
884
- let allVisible = firstVisit || signOpen || myProjectsOpen;
885
-
886
- let _scene = extractedState.getIn(['scene']);
887
- let len = convert(_scene.width).from(_scene.unit).to('cm');
888
- let _viewer2D = extractedState.getIn(['viewer2D']);
889
- if (_viewer2D.size > 0) {
890
- let scaleX = (width / len) * 3;
891
- let scaleY = (height / len) * 3;
892
- let scale = scaleX > scaleY ? scaleY : scaleX;
893
- let _e = width - len * scale,
894
- _f = height - len * scale;
895
- let viewer = _viewer2D.toJS();
896
- if (viewer.e === 0 && viewer.f === 0) {
897
- _viewer2D = _viewer2D.merge({
898
- e: viewer.viewerWidth / 2 - viewer.SVGWidth / 2,
899
- f: viewer.viewerHeight / 2 - viewer.SVGHeight / 2,
900
- a: 0.99,
901
- d: 0.99
902
- });
903
- }
904
- }
905
- extractedState = extractedState.merge({
906
- viewer2D: _viewer2D
907
- });
908
-
909
- var history = this.props.history;
910
-
911
- let handleContinueQuote = () => {
912
- this.setToolbar('reviewforquote');
913
- this.setState({ savePopupVisible: false, quotePopupVisible: true });
914
- };
915
-
916
- let newProject = () => {
917
- this.props.projectActions.newProject();
918
- sessionStorage.setItem('projectTitle', 'Untitled');
919
- this.props.projectActions.rename('Untitled');
920
- sessionStorage.removeItem('projectId');
921
- sessionStorage.removeItem('usedObjects');
922
- const visualizerName = sessionStorage.getItem('visualizerName');
923
- const originalAccessToken = ls.get(LOCAL_STORAGE_ORIGINAL_TOKEN);
924
- const tokenName = ls.get(LOCAL_STORAGE_TOKEN_NAME);
925
-
926
- let pathname = `/${visualizerName}`;
927
- if (tokenName && originalAccessToken) {
928
- pathname += `?${tokenName}${originalAccessToken}`;
929
- }
930
-
931
- history.push({ pathname });
932
- this.setState({ wizardStepOpend: false });
933
- };
934
-
935
- /**
936
- * @description Save Projects
937
- * @param {{email,firstName,lastName,notes,projectName}} param Project information to save
938
- */
939
- let saveProject = async param => {
940
- let rlt = { success: false };
941
-
942
- // Get storage info
943
- let title = sessionStorage.getItem('projectTitle');
944
- let projectId = sessionStorage.getItem('projectId');
945
-
946
- let projectTitle =
947
- (param && param.projectName) ||
948
- title ||
949
- `Project-${new Date().toLocaleString()}`;
950
- let utm = this.utm;
951
-
952
- // State
953
- let state = Project.unselectAll(extractedState).updatedState;
954
- let { scene } = state;
955
- state = state.merge({ scene: scene.merge({ title: projectTitle }) });
956
-
957
- // Set storage info
958
- sessionStorage.setItem('projectTitle', projectTitle);
959
- props.projectActions.rename(projectTitle);
960
-
961
- // Filter cds
962
- const itemData = state
963
- .getIn([
964
- 'scene',
965
- 'layers',
966
- state.get('scene').toJS().selectedLayer,
967
- 'items'
968
- ])
969
- .toArray();
970
-
971
- itemData.forEach(it => {
972
- const item = it.toJS();
973
- const doorStyles = item?.doorStyle?.doorStyles;
974
-
975
- // Skip if no doorStyles data at all
976
- if (!doorStyles) return;
977
-
978
- const newCDSdata = Array.isArray(doorStyles.cds)
979
- ? doorStyles.cds.filter(
980
- it1 =>
981
- it1.cabinet_door_style_id === doorStyles.cabinet_door_style_id
982
- )
983
- : [];
984
-
985
- const layerId = state.get('scene').toJS().selectedLayer;
986
- const basePath = [
987
- 'scene',
988
- 'layers',
989
- layerId,
990
- 'items',
991
- it.id,
992
- 'doorStyle',
993
- 'doorStyles'
994
- ];
995
-
996
- if (state.hasIn(basePath)) {
997
- state = state.setIn([...basePath, 'cds'], newCDSdata);
998
- }
999
- });
1000
-
1001
- // Delete null values
1002
-
1003
- let newScene = state.getIn(['scene']);
1004
- let deleteKeys = [];
1005
- this.findDelkeys(newScene.toJS(), deleteKeys, '');
1006
- for (let i = 0; i < deleteKeys.length; i++) {
1007
- let tmp = newScene.toJS();
1008
- let deletePath = deleteKeys[i].path.split(',');
1009
- for (let j = 0; j < deletePath.length; j++) {
1010
- if (!isEmpty(deletePath[j])) {
1011
- tmp = tmp[deletePath[j]];
1012
- }
1013
- }
1014
- if (deletePath.length >= 2) {
1015
- delete tmp[deleteKeys[i].key];
1016
- deletePath.pop();
1017
- if (!isEmpty(newScene.getIn(deletePath)))
1018
- newScene = newScene.setIn(deletePath, tmp);
1019
- } else {
1020
- newScene = newScene.delete(deleteKeys[i].key);
1021
- }
1022
- }
1023
-
1024
- state = state.setIn(['scene'], newScene);
1025
-
1026
- // Data to save
1027
- const projectData = JSON.stringify(state.get('scene').toJS());
1028
-
1029
- const object_count = Object.keys(
1030
- state?.scene?.layers?.get(state?.scene?.selectedLayer)?.items || {}
1031
- ).length;
1032
-
1033
- try {
1034
- const originalAccessToken = ls.get(LOCAL_STORAGE_ORIGINAL_TOKEN);
1035
- const tokenName = ls.get(LOCAL_STORAGE_TOKEN_NAME);
1036
-
1037
- const response = await axios.post('/api/project/saveProject', {
1038
- pid: projectId,
1039
- title: projectTitle,
1040
- mode: MODE,
1041
- access_token: userInfo.token ? userInfo.token : null,
1042
- userrole: userInfo.role ? userInfo.role : null,
1043
- saveData: { ...param, ...utm, projectData, object_count },
1044
- url: window.location.hostname,
1045
- visualizerName: sessionStorage.getItem('visualizerName'),
1046
- ...(originalAccessToken
1047
- ? { original_token: originalAccessToken }
1048
- : undefined),
1049
- ...(tokenName ? { query_params_token_prefix: tokenName } : undefined)
1050
- });
1051
-
1052
- const { success, message, userData, access_token } = response.data;
1053
- if (success === true) {
1054
- rlt.success = true;
1055
-
1056
- const { insertId } = response.data.execResult;
1057
- const currentProjectID =
1058
- insertId !== 0
1059
- ? insertId
1060
- : state.getIn(['scene', 'currentProjectID']);
1061
-
1062
- // Set storage data
1063
- sessionStorage.setItem('projectId', currentProjectID);
1064
- sessionStorage.setItem('email', param.email);
1065
- sessionStorage.setItem('phone', param.phone);
1066
- sessionStorage.setItem('firstName', param.firstName);
1067
- sessionStorage.setItem('lastName', param.lastName);
1068
- props.projectActions.setProjectID({ currentProjectID });
1069
- actions.userActions.login(
1070
- userData[0].id,
1071
- userData[0].role,
1072
- access_token,
1073
- utm
1074
- );
1075
- this.setState({
1076
- toolbar: this.state.toolbar,
1077
- isSaved: true,
1078
- isSnackBarOpen: true,
1079
- snackBarMessage:
1080
- 'Your project has been saved. </br> You can now request <b>Designer Assistance</b> or <b>Add to Cart</b>'
1081
- });
1082
- if (this.state.submitTosave) {
1083
- handleContinueQuote();
1084
- }
1085
- } else {
1086
- rlt.success = false;
1087
- rlt.message = message;
1088
-
1089
- this.setState({
1090
- isSnackBarOpen: true,
1091
- snackBarMessage: `Failed to add project data: ${message}`
1092
- });
1093
- }
1094
- } catch (err) {
1095
- rlt.success = false;
1096
-
1097
- console.error(err);
1098
- this.setState({
1099
- isSnackBarOpen: true,
1100
- snackBarMessage: 'Failed to add project data.'
1101
- });
1102
- }
1103
-
1104
- return rlt;
1105
- };
1106
-
1107
- let pidSplit = userInfo.pid && userInfo.pid.indexOf('?');
1108
- // If pidSplit is undefined pid is undefined
1109
- let pid =
1110
- pidSplit === undefined || pidSplit === -1
1111
- ? userInfo.pid
1112
- : userInfo.pid.slice(0, pidSplit);
1113
-
1114
- let submitForQuote = async param => {
1115
- let rlt = { success: false };
1116
-
1117
- if (!userInfo.token) {
1118
- this.setState({
1119
- isSnackBarOpen: true,
1120
- snackBarMessage: 'You should save the project first.'
1121
- });
1122
- return;
1123
- }
1124
- let apiUrl = '';
1125
- if (param.flag === constants.SUBMIT_REQUEST_ASSIST) {
1126
- apiUrl = `${API_SERVER_URL}/api/project/submitProject`;
1127
- } else if (param.flag === constants.SUBMIT_ADD_CART) {
1128
- apiUrl = `${API_SERVER_URL}/api/project/addCart`;
1129
- }
1130
- try {
1131
- const extraFormData = {
1132
- userType: sessionStorage.getItem('user_type') || '',
1133
- designType: sessionStorage.getItem('project_type') || '',
1134
- startTime: sessionStorage.getItem('project_timeline') || ''
1135
- };
1136
-
1137
- const originalAccessToken = ls.get(LOCAL_STORAGE_ORIGINAL_TOKEN);
1138
- const tokenName = ls.get(LOCAL_STORAGE_TOKEN_NAME);
1139
-
1140
- const customerRequests = param.customer_requests;
1141
- const notes = customerRequests.notes;
1142
- const response = await axios.post(apiUrl, {
1143
- access_token: userInfo.token,
1144
- data: {
1145
- ...param,
1146
- ...(extraFormData.userType
1147
- ? { user_type: extraFormData.userType }
1148
- : undefined),
1149
- ...(extraFormData.designType
1150
- ? { project_type: extraFormData.designType }
1151
- : undefined),
1152
- ...(extraFormData.startTime
1153
- ? { project_timeline: extraFormData.startTime }
1154
- : undefined),
1155
- client_name: sessionStorage.getItem('visualizerName'),
1156
- user_token: ls.get(LOCAL_STORAGE_TOKEN_VALUE),
1157
- cart_action_type: ls.get(LOCAL_STORAGE_CART_ACTION),
1158
- customer_requests: Object.values(customerRequests.reviewOptions)
1159
- .filter(Boolean)
1160
- .join(', '),
1161
- ...(param.flag === constants.SUBMIT_ADD_CART
1162
- ? {
1163
- cart_notes: notes
1164
- }
1165
- : {
1166
- designer_notes: notes
1167
- }),
1168
- question_add_to_cart: param.flag === constants.SUBMIT_ADD_CART,
1169
- ...(originalAccessToken
1170
- ? { original_token: originalAccessToken }
1171
- : undefined),
1172
- ...(tokenName
1173
- ? { query_params_token_prefix: tokenName }
1174
- : undefined)
1175
- },
1176
- num: true,
1177
- projectid: pid,
1178
- search: this.props.location.search,
1179
- userrole: userInfo.role,
1180
- url: window.location.hostname
1181
- });
1182
-
1183
- const { success, message, redirect_url } = response.data;
1184
- if (success) {
1185
- rlt.success = true;
1186
-
1187
- param.email && sessionStorage.setItem('email', param.email);
1188
- param.phone && sessionStorage.setItem('phone', param.phone);
1189
- this.setState({
1190
- redirectURL: redirect_url,
1191
- isSnackBarOpen: true,
1192
- snackBarMessage: `${
1193
- param.flag === constants.SUBMIT_REQUEST_ASSIST
1194
- ? 'Project submitted'
1195
- : 'Added to cart'
1196
- } successfully.${
1197
- customerRequests.reviewOptions.length > 0 ||
1198
- customerRequests.notes
1199
- ? ' <br /> A confirmation has been emailed to you and a designer will be in contact shortly'
1200
- : ''
1201
- }`,
1202
- isSnackBar1Open: param.flag === constants.SUBMIT_ADD_CART
1203
- });
1204
- } else {
1205
- rlt.success = false;
1206
- rlt.message = message;
1207
-
1208
- this.setState({
1209
- isSnackBarOpen: true,
1210
- snackBarMessage: `${
1211
- param.flag === constants.SUBMIT_REQUEST_ASSIST
1212
- ? 'Submitting project'
1213
- : 'Adding to cart'
1214
- } failed: ${message}`
1215
- });
1216
- }
1217
- } catch (err) {
1218
- rlt.success = false;
1219
-
1220
- console.log('err', err);
1221
- this.setState({
1222
- isSnackBarOpen: true,
1223
- snackBarMessage: `${
1224
- param.flag === constants.SUBMIT_REQUEST_ASSIST
1225
- ? 'Submitting project'
1226
- : 'Adding to cart'
1227
- } failed.`
1228
- });
1229
- }
1230
-
1231
- return rlt;
1232
- };
1233
-
1234
- return (
1235
- <section>
1236
- <SnackBar
1237
- isOpen={this.state.isSnackBarOpen}
1238
- message={this.state.snackBarMessage}
1239
- handleClose={() =>
1240
- this.setState({ isSnackBarOpen: false, snackBarMessage: '' })
1241
- }
1242
- autoHideDuration={10000}
1243
- />
1244
- <SnackBar
1245
- style={{ marginTop: this.state.isSnackBarOpen ? 75 : 'unset' }}
1246
- isOpen={this.state.isSnackBar1Open}
1247
- message={`The items in your design have been added to your shopping cart at ${CLIENTS_NAME[sessionStorage.getItem('visualizerName')]}. <br />Please log in with the same email address.`}
1248
- autoHideDuration={20000}
1249
- action={
1250
- <div>
1251
- <a
1252
- href={this.state.redirectURL}
1253
- target="_blank"
1254
- style={{
1255
- fontFamily: DEFAULT_FONT_FAMILY,
1256
- color: PRIMARY_GREEN_COLOR,
1257
- fontWeight: 700,
1258
- marginRight: 10
1259
- }}
1260
- >
1261
- View Cart
1262
- </a>
1263
- <img
1264
- onClick={() => this.setState({ isSnackBar1Open: false })}
1265
- style={{ float: 'right', height: 24, cursor: 'pointer' }}
1266
- src="/assets/img/svg/close.svg"
1267
- />
1268
- </div>
1269
- }
1270
- />
1271
- <div style={{ ...wrapperStyle, height }}>
1272
- {/*<Header*/}
1273
- {/* isTokenPresent={!!this.props.match.params.token}*/}
1274
- {/* isSaved={this.state.isSaved}*/}
1275
- {/* width={headerW}*/}
1276
- {/* height={headerH}*/}
1277
- {/* state={extractedState}*/}
1278
- {/* reviewQuoteHandler={this.onReviewQuoteClicked.bind(this)}*/}
1279
- {/* handleSaveDesign={this.handleSaveDesign.bind(this)}*/}
1280
- {/* handleSubmitForQuote={this.handleSubmitForQuote.bind(this)}*/}
1281
- {/* handleNewProject={this.handleNewProject.bind(this)}*/}
1282
- {/* handleSubmitPrompt={submitType => {*/}
1283
- {/* this.setState({ submitPromptVisible: true });*/}
1284
- {/* this.setState({ stateSubmitType: submitType });*/}
1285
- {/* }}*/}
1286
- {/* logoImage={this.props.logoImage}*/}
1287
- {/* companyURL={this.props.companyURL}*/}
1288
- {/* setToolbar={this.setToolbar}*/}
1289
- {/* saveProject={saveProject}*/}
1290
- {/* newProject={newProject}*/}
1291
- {/* isModalVisible={this.state.isModalVisible}*/}
1292
- {/* allVisible={allVisible}*/}
1293
- {/* wizardStepOpend={firstVisit}*/}
1294
- {/* {...props}*/}
1295
- {/*/>*/}
1296
- {/*{signOpen && (*/}
1297
- {/* <Sign*/}
1298
- {/* setSignOpen={this.setSignOpen.bind(this)}*/}
1299
- {/* setMyProjectsOpen={this.setMyProjectsOpen.bind(this)}*/}
1300
- {/* setMyProjectsToLogin={this.setMyProjectsToLogin.bind(this)}*/}
1301
- {/* myProjectsToLogin={myProjectsToLogin}*/}
1302
- {/* />*/}
1303
- {/*)}*/}
1304
- {/*{!allVisible && (*/}
1305
- {/* // left side bar & top tools bar*/}
1306
- {/* <Toolbar*/}
1307
- {/* width={toolbarW}*/}
1308
- {/* content={contentW}*/}
1309
- {/* height={toolbarH}*/}
1310
- {/* headerH={headerH}*/}
1311
- {/* state={extractedState}*/}
1312
- {/* layers={extractedState.scene.layers}*/}
1313
- {/* selectedLayer={extractedState.scene.selectedLayer}*/}
1314
- {/* {...props}*/}
1315
- {/* handleSaveDesign={this.handleSaveDesign.bind(this)}*/}
1316
- {/* handleSubmitForQuote={this.handleSubmitForQuote.bind(this)}*/}
1317
- {/* handleNewProject={this.handleNewProject.bind(this)}*/}
1318
- {/* handleSubmitPrompt={submitType => {*/}
1319
- {/* this.setState({ submitPromptVisible: true });*/}
1320
- {/* this.setState({*/}
1321
- {/* stateSubmitType: submitType*/}
1322
- {/* });*/}
1323
- {/* }}*/}
1324
- {/* toolBar={this.state.toolbar}*/}
1325
- {/* setToolbar={this.setToolbar}*/}
1326
- {/* setDownloadPopupVisible={this.setDownloadPopupVisible.bind(this)}*/}
1327
- {/* openFloor={this.openFloor}*/}
1328
- {/* openCabinet={this.openCabinet}*/}
1329
- {/* openAppliance={this.openAppliance}*/}
1330
- {/* openFinishing={this.openFinishing}*/}
1331
- {/* closeFloorTB={this.closeFloorTB}*/}
1332
- {/* closeCabinetTB={this.closeCabinetTB}*/}
1333
- {/* closeFinishingTB={this.closeFinishingTB}*/}
1334
- {/* closeApplianceTB={this.closeApplianceTB}*/}
1335
- {/* setShowProperty={this.setShowProperty}*/}
1336
- {/* reviewQuotePopupOpened={this.state.reviewQuotePopupOpened}*/}
1337
- {/* isShowProperty={this.state.isShowProperty}*/}
1338
- {/* categoryData={this.props.categoryData}*/}
1339
- {/* floorOpened={this.state.floorOpened}*/}
1340
- {/* cabinetOpened={this.state.cabinetOpened}*/}
1341
- {/* applianceOpened={this.state.applianceOpened}*/}
1342
- {/* finishingOpened={this.state.finishingOpened}*/}
1343
- {/* doorStyleOpen={this.state.doorStyleOpen}*/}
1344
- {/* toggleDoorStyle={this.toggleDoorStyle}*/}
1345
- {/* onReviewQuoteClicked={this.onReviewQuoteClicked}*/}
1346
- {/* wizardStepOpend={firstVisit}*/}
1347
- {/* replaceCabinetFlag={this.state.replaceCabinetFlag}*/}
1348
- {/* replaceCabinet={this.replaceCabinet}*/}
1349
- {/* />*/}
1350
- {/*)}*/}
1351
- <Content
1352
- width={contentW}
1353
- height={contentH}
1354
- catalog={this.props.catalog}
1355
- state={extractedState}
1356
- toolBar={this.state.toolbar}
1357
- setToolbar={this.setToolbar}
1358
- replaceCabinet={this.replaceCabinet}
1359
- keyDownEnable={
1360
- !savePopupVisible && !quotePopupVisible && !assistPopupVisible
1361
- }
1362
- {...props}
1363
- onWheel={event => event.preventDefault()}
1364
- />
1365
- {/*{!allVisible && (*/}
1366
- {/* <FooterBar*/}
1367
- {/* content={contentW}*/}
1368
- {/* setToolbar={this.setToolbar}*/}
1369
- {/* layers={extractedState.scene.layers}*/}
1370
- {/* setShowProperty={this.setShowProperty}*/}
1371
- {/* state={extractedState}*/}
1372
- {/* selectedLayer={extractedState.scene.selectedLayer}*/}
1373
- {/* {...props}*/}
1374
- {/* />*/}
1375
- {/*)}*/}
1376
- {/*{firstVisit && (*/}
1377
- {/* <WizardStep*/}
1378
- {/* key="first-setting"*/}
1379
- {/* content={contentW}*/}
1380
- {/* layers={extractedState.scene.layers}*/}
1381
- {/* close={() => this.setState({ wizardStepOpend: false })}*/}
1382
- {/* state={extractedState}*/}
1383
- {/* setMyProjectsToLogin={this.setMyProjectsToLogin.bind(this)}*/}
1384
- {/* setSignOpen={this.setSignOpen.bind(this)}*/}
1385
- {/* selectedLayer={extractedState.scene.selectedLayer}*/}
1386
- {/* setMyProjectsOpen={this.setMyProjectsOpen.bind(this)}*/}
1387
- {/* {...props}*/}
1388
- {/* />*/}
1389
- {/*)}*/}
1390
- {/*{myProjectsOpen && (*/}
1391
- {/* <MyProjects*/}
1392
- {/* setMyProjectsOpen={this.setMyProjectsOpen.bind(this)}*/}
1393
- {/* {...props}*/}
1394
- {/* />*/}
1395
- {/*)}*/}
1396
- {/*<SaveDesignPopup*/}
1397
- {/* visible={savePopupVisible}*/}
1398
- {/* submitTosave={submitTosave}*/}
1399
- {/* handleSaveDesign={this.handleSaveDesign.bind(this)}*/}
1400
- {/* saveProject={saveProject}*/}
1401
- {/* state={extractedState}*/}
1402
- {/* {...props}*/}
1403
- {/*/>*/}
1404
- {/*<SubmitForQuotePopup*/}
1405
- {/* categoryData={categoryData}*/}
1406
- {/* curDoorStyle={doorStyle}*/}
1407
- {/* handleSubmitForQuote={this.handleSubmitForQuote.bind(this)}*/}
1408
- {/* submitForQuote={submitForQuote}*/}
1409
- {/* visible={quotePopupVisible}*/}
1410
- {/* setDoorStyle={this.props.itemsActions.setDoorStyle}*/}
1411
- {/* submitType={stateSubmitType}*/}
1412
- {/* {...props}*/}
1413
- {/*/>*/}
1414
- {/*<NewProjectPopup*/}
1415
- {/* isSaved={this.state.isSaved}*/}
1416
- {/* visible={newProjectPopupVisible}*/}
1417
- {/* handleNewProject={this.handleNewProject.bind(this)}*/}
1418
- {/* newProject={newProject}*/}
1419
- {/* areas={extractedState.getIn([*/}
1420
- {/* 'scene',*/}
1421
- {/* 'layers',*/}
1422
- {/* extractedState.scene.selectedLayer,*/}
1423
- {/* 'areas'*/}
1424
- {/* ])}*/}
1425
- {/*/>*/}
1426
- {/*<SubmitPromptPopup*/}
1427
- {/* visible={submitPromptVisible}*/}
1428
- {/* submitType={stateSubmitType}*/}
1429
- {/* handleOk={value =>*/}
1430
- {/* this.handleSaveDesign(value) ||*/}
1431
- {/* this.setState({ submitTosave: true })*/}
1432
- {/* }*/}
1433
- {/* handleClose={() => {*/}
1434
- {/* this.setState({ submitPromptVisible: false });*/}
1435
- {/* }}*/}
1436
- {/*/>*/}
1437
- {/*<AutosavePromptPopup*/}
1438
- {/* isLeaving={isLeaving}*/}
1439
- {/* visible={savePromptVisible}*/}
1440
- {/* handleOk={this.handleSaveDesign.bind(this)}*/}
1441
- {/* handleClose={() =>*/}
1442
- {/* this.setState({ savePromptVisible: false, submitTosave: false })*/}
1443
- {/* }*/}
1444
- {/*/>*/}
1445
- {/*<DownloadSummaryPopup*/}
1446
- {/* visible={downloadPopupVisible}*/}
1447
- {/* state={extractedState}*/}
1448
- {/* catalog={this.props.catalog}*/}
1449
- {/* setDownloadPopupVisible={this.setDownloadPopupVisible.bind(this)}*/}
1450
- {/* {...props}*/}
1451
- {/*/>*/}
1452
- {/*{saveAlert}*/}
1453
- </div>
1454
- </section>
1455
- );
1456
- }
1457
- }
1458
-
1459
- KitchenConfigurator.propTypes = {
1460
- translator: PropTypes.instanceOf(Translator),
1461
-
1462
- catalog: PropTypes.instanceOf(Catalog),
1463
- allowProjectFileSupport: PropTypes.bool,
1464
- plugins: PropTypes.arrayOf(PropTypes.func),
1465
- autosaveKey: PropTypes.string,
1466
- autosaveDelay: PropTypes.number,
1467
- width: PropTypes.number.isRequired,
1468
- height: PropTypes.number.isRequired,
1469
- stateExtractor: PropTypes.func.isRequired,
1470
- toolbarButtons: PropTypes.array,
1471
- sidebarComponents: PropTypes.array,
1472
- footerbarComponents: PropTypes.array,
1473
- customContents: PropTypes.object,
1474
- softwareSignature: PropTypes.string,
1475
- configData: PropTypes.object
1476
- };
1477
-
1478
- KitchenConfigurator.contextTypes = {
1479
- store: PropTypes.object.isRequired
1480
- };
1481
-
1482
- KitchenConfigurator.childContextTypes = {
1483
- ...objectsMap(actions, () => PropTypes.object),
1484
- translator: PropTypes.object,
1485
- catalog: PropTypes.object
1486
- };
1487
-
1488
- KitchenConfigurator.defaultProps = {
1489
- translator: new Translator(),
1490
- catalog: new Catalog(),
1491
- plugins: [],
1492
- allowProjectFileSupport: true,
1493
- softwareSignature: `KitchenConfigurator ${VERSION}`,
1494
- toolbarButtons: [],
1495
- sidebarComponents: [],
1496
- footerbarComponents: [],
1497
- customContents: {},
1498
- configData: {}
1499
- };
1500
-
1501
- //redux connect
1502
- function mapStateToProps(reduxState) {
1503
- return {
1504
- state: reduxState
1505
- };
1506
- }
1507
-
1508
- function mapDispatchToProps(dispatch) {
1509
- return objectsMap(actions, actionNamespace =>
1510
- bindActionCreators(actions[actionNamespace], dispatch)
1511
- );
1512
- }
1513
-
1514
- export default connect(
1515
- mapStateToProps,
1516
- mapDispatchToProps
1517
- )(KitchenConfigurator);