@nyris/nyris-webapp 0.3.40 → 0.3.41

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nyris/nyris-webapp",
3
- "version": "0.3.40",
3
+ "version": "0.3.41",
4
4
  "homepage": "./",
5
5
  "dependencies": {
6
6
  "@algolia/autocomplete-js": "^1.7.1",
@@ -12,8 +12,8 @@
12
12
  "@material-ui/data-grid": "^4.0.0-alpha.37",
13
13
  "@material-ui/icons": "^4.4.1",
14
14
  "@material-ui/lab": "^4.0.0-alpha.60",
15
- "@nyris/nyris-api": "^0.3.40",
16
- "@nyris/nyris-react-components": "^0.3.40",
15
+ "@nyris/nyris-api": "^0.3.41",
16
+ "@nyris/nyris-react-components": "^0.3.41",
17
17
  "@reduxjs/toolkit": "^1.6.1",
18
18
  "@splidejs/react-splide": "^0.7.12",
19
19
  "@types/blueimp-load-image": "^2.23.4",
@@ -17,6 +17,7 @@ export const defaultSettings: AppSettings = {
17
17
  '^https?://(www.)?dai.ly/',
18
18
  ],
19
19
  theme: {},
20
+ templateId: '',
20
21
  field: {
21
22
  ctaLinkField: '',
22
23
  productName: '',
@@ -77,71 +77,72 @@ export default function InquiryModal({
77
77
  ? getCroppedCanvas(canvas, selectedRegion)
78
78
  : null;
79
79
  const serviceId = 'service_zfsxshi';
80
- const templateId = 'template_rxsi7w9';
81
80
  setIsInquiryModalOpen(false);
82
- try {
83
- setInquiryStatus('loading');
84
- await emailjs.send(serviceId, templateId, {
85
- email_id: email.trim(),
86
- information_text: information,
87
- request_image: croppedImage?.toDataURL(),
88
- prefilter_values: preFilterValues.join(', '),
89
- });
90
- setInquiryStatus('sent');
91
- ToastHelper.success('Request sent successfully');
92
- } catch (error) {
93
- setInquiryStatus('inactive');
81
+ if (settings.templateId) {
82
+ try {
83
+ setInquiryStatus('loading');
84
+ await emailjs.send(serviceId, settings.templateId, {
85
+ email_id: email.trim(),
86
+ information_text: information,
87
+ request_image: croppedImage?.toDataURL(),
88
+ prefilter_values: preFilterValues.join(', '),
89
+ });
90
+ setInquiryStatus('sent');
91
+ ToastHelper.success('Request sent successfully');
92
+ } catch (error) {
93
+ setInquiryStatus('inactive');
94
94
 
95
- toast(
96
- t => {
97
- return (
98
- <div
99
- style={{
100
- display: 'flex',
101
- flexDirection: 'column',
102
- fontSize: '14px',
103
- width: '294px',
104
- }}
105
- >
106
- <span style={{ fontWeight: 'bold' }}>Email not sent</span>
107
- <span>{getErrorMessage(error)}</span>
108
- <a
109
- href={`mailto:support@nyris.io?subject=Request for quotation&body=${encodeURIComponent(`Hello,
95
+ toast(
96
+ t => {
97
+ return (
98
+ <div
99
+ style={{
100
+ display: 'flex',
101
+ flexDirection: 'column',
102
+ fontSize: '14px',
103
+ width: '294px',
104
+ }}
105
+ >
106
+ <span style={{ fontWeight: 'bold' }}>Email not sent</span>
107
+ <span>{getErrorMessage(error)}</span>
108
+ <a
109
+ href={`mailto:support@nyris.io?subject=Request for quotation&body=${encodeURIComponent(`Hello,
110
110
  I filled out the support form on the Search Suite, but it failed. I inquired the following:
111
111
  email:
112
112
  Pre-filter:
113
113
  Additional Text: `)}`}
114
- style={{
115
- padding: '8px 16px 8px 16px',
116
- border: '1px solid #000',
117
- marginTop: '16px',
118
- backgroundColor: 'transparent',
119
- color: '#000',
120
- cursor: 'pointer',
121
- width: 'fit-content',
122
- }}
123
- >
124
- support@nyris.io
125
- </a>
126
- </div>
127
- );
128
- },
129
- {
130
- duration: 5000,
131
- style: {
132
- background: '#FFE5EF',
133
- color: '#000000',
134
- maxWidth: '400px',
114
+ style={{
115
+ padding: '8px 16px 8px 16px',
116
+ border: '1px solid #000',
117
+ marginTop: '16px',
118
+ backgroundColor: 'transparent',
119
+ color: '#000',
120
+ cursor: 'pointer',
121
+ width: 'fit-content',
122
+ }}
123
+ >
124
+ support@nyris.io
125
+ </a>
126
+ </div>
127
+ );
135
128
  },
136
- icon: (
137
- <div style={{ minWidth: '20px', minHeight: '20px' }}>
138
- <ErrorIcon />
139
- </div>
140
- ),
141
- },
142
- );
129
+ {
130
+ duration: 5000,
131
+ style: {
132
+ background: '#FFE5EF',
133
+ color: '#000000',
134
+ maxWidth: '400px',
135
+ },
136
+ icon: (
137
+ <div style={{ minWidth: '20px', minHeight: '20px' }}>
138
+ <ErrorIcon />
139
+ </div>
140
+ ),
141
+ },
142
+ );
143
+ }
144
+ setIsInquiryModalOpen(false);
143
145
  }
144
- setIsInquiryModalOpen(false);
145
146
  };
146
147
 
147
148
  return (
@@ -9,6 +9,7 @@ import { TextareaAutosize } from '@material-ui/core';
9
9
  import toast from 'react-hot-toast';
10
10
  import { ReactComponent as ErrorIcon } from 'common/assets/icons/error.svg';
11
11
  import { useMediaQuery } from 'react-responsive';
12
+ import { useAppSelector } from '../../Store/Store';
12
13
  interface Props {
13
14
  requestImage: any;
14
15
  selectedRegion: any;
@@ -43,6 +44,7 @@ export default function RfqModal({
43
44
  const [email, setEmail] = useState('');
44
45
  const [emailValid, setEmailValid] = useState<boolean | undefined>(undefined);
45
46
  const isMobile = useMediaQuery({ query: '(max-width: 776px)' });
47
+ const { settings } = useAppSelector(state => state);
46
48
 
47
49
  const [information, setInformation] = useState('');
48
50
  const setFormattedContent = React.useCallback(
@@ -62,66 +64,67 @@ export default function RfqModal({
62
64
  const { canvas }: any = requestImage;
63
65
  const croppedImage = getCroppedCanvas(canvas, selectedRegion);
64
66
  const serviceId = 'service_zfsxshi';
65
- const templateId = 'template_jlgc9le';
66
67
  setIsRfqModalOpen(false);
67
- try {
68
- setRfqStatus('loading');
69
- await emailjs.send(serviceId, templateId, {
70
- email_id: email.trim(),
71
- information_text: information,
72
- request_image: croppedImage?.toDataURL(),
73
- });
74
- setRfqStatus('sent');
75
- ToastHelper.success('Request sent successfully');
76
- } catch (error) {
77
- setRfqStatus('inactive');
68
+ if (settings.templateId) {
69
+ try {
70
+ setRfqStatus('loading');
71
+ await emailjs.send(serviceId, settings.templateId, {
72
+ email_id: email.trim(),
73
+ information_text: information,
74
+ request_image: croppedImage?.toDataURL(),
75
+ });
76
+ setRfqStatus('sent');
77
+ ToastHelper.success('Request sent successfully');
78
+ } catch (error) {
79
+ setRfqStatus('inactive');
78
80
 
79
- toast(
80
- t => {
81
- return (
82
- <div
83
- style={{
84
- display: 'flex',
85
- flexDirection: 'column',
86
- fontSize: '14px',
87
- width: '294px',
88
- }}
89
- >
90
- <span style={{ fontWeight: 'bold' }}>Email not sent</span>
91
- <span>{getErrorMessage(error)}</span>
92
- <a
93
- href={`mailto:support@nyris.io?subject=Request for quotation&body=${information}`}
81
+ toast(
82
+ t => {
83
+ return (
84
+ <div
94
85
  style={{
95
- padding: '8px 16px 8px 16px',
96
- border: '1px solid #000',
97
- marginTop: '16px',
98
- backgroundColor: 'transparent',
99
- color: '#000',
100
- cursor: 'pointer',
101
- width: 'fit-content',
86
+ display: 'flex',
87
+ flexDirection: 'column',
88
+ fontSize: '14px',
89
+ width: '294px',
102
90
  }}
103
91
  >
104
- support@nyris.io
105
- </a>
106
- </div>
107
- );
108
- },
109
- {
110
- duration: 5000,
111
- style: {
112
- background: '#FFE5EF',
113
- color: '#000000',
114
- maxWidth: '400px',
92
+ <span style={{fontWeight: 'bold'}}>Email not sent</span>
93
+ <span>{getErrorMessage(error)}</span>
94
+ <a
95
+ href={`mailto:support@nyris.io?subject=Request for quotation&body=${information}`}
96
+ style={{
97
+ padding: '8px 16px 8px 16px',
98
+ border: '1px solid #000',
99
+ marginTop: '16px',
100
+ backgroundColor: 'transparent',
101
+ color: '#000',
102
+ cursor: 'pointer',
103
+ width: 'fit-content',
104
+ }}
105
+ >
106
+ support@nyris.io
107
+ </a>
108
+ </div>
109
+ );
115
110
  },
116
- icon: (
117
- <div style={{ minWidth: '20px', minHeight: '20px' }}>
118
- <ErrorIcon />
119
- </div>
120
- ),
121
- },
122
- );
111
+ {
112
+ duration: 5000,
113
+ style: {
114
+ background: '#FFE5EF',
115
+ color: '#000000',
116
+ maxWidth: '400px',
117
+ },
118
+ icon: (
119
+ <div style={{minWidth: '20px', minHeight: '20px'}}>
120
+ <ErrorIcon/>
121
+ </div>
122
+ ),
123
+ },
124
+ );
125
+ }
126
+ setIsRfqModalOpen(false);
123
127
  }
124
- setIsRfqModalOpen(false);
125
128
  };
126
129
 
127
130
  return (
package/src/types.ts CHANGED
@@ -39,6 +39,7 @@ export interface AppSettings extends NyrisAPISettings {
39
39
  cadenas3dWebView?: boolean;
40
40
  rfq?: boolean;
41
41
  inquiry?: boolean;
42
+ templateId?: string;
42
43
  warehouseVariant?: boolean;
43
44
  preFilterTitle?: string;
44
45
  postFilterOption?: boolean;