@openlettermarketing/olc-react-sdk 1.6.8-beta.0 → 1.6.8-beta.2

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,7 +1,7 @@
1
1
  {
2
2
  "name": "@openlettermarketing/olc-react-sdk",
3
3
  "private": false,
4
- "version": "1.6.8-beta.0",
4
+ "version": "1.6.8-beta.2",
5
5
  "type": "module",
6
6
  "description": "Simplify template builder integration for any product.",
7
7
  "main": "build/index.js",
@@ -14,6 +14,7 @@
14
14
  "test": "jest --silent",
15
15
  "coverage": "npm run test -- --coverage",
16
16
  "prepare": "npm run build",
17
+ "publish:beta": "npm publish --access public --beta",
17
18
  "publish": "npm publish --access public"
18
19
  },
19
20
  "publishConfig": {
@@ -13,20 +13,20 @@ const Add = () => {
13
13
  <path
14
14
  d="M12.5 25.4727C19.1274 25.4727 24.5 20.1001 24.5 13.4727C24.5 6.84524 19.1274 1.47266 12.5 1.47266C5.87258 1.47266 0.5 6.84524 0.5 13.4727C0.5 20.1001 5.87258 25.4727 12.5 25.4727Z"
15
15
  stroke="#ED5C2F"
16
- stroke-linecap="round"
17
- stroke-linejoin="round"
16
+ strokeLinecap="round"
17
+ strokeLinejoin="round"
18
18
  />
19
19
  <path
20
20
  d="M7.35547 13.4727H17.6412"
21
21
  stroke="#ED5C2F"
22
- stroke-linecap="round"
23
- stroke-linejoin="round"
22
+ strokeLinecap="round"
23
+ strokeLinejoin="round"
24
24
  />
25
25
  <path
26
26
  d="M12.5 8.33008V18.6158"
27
27
  stroke="#ED5C2F"
28
- stroke-linecap="round"
29
- stroke-linejoin="round"
28
+ strokeLinecap="round"
29
+ strokeLinejoin="round"
30
30
  />
31
31
  </svg>
32
32
  </>
@@ -21,6 +21,7 @@ import Add from '../../../../../assets/images/modal-icons/add';
21
21
 
22
22
  // styles
23
23
  import './styles.scss';
24
+ import {post} from '../../../../../utils/api';
24
25
 
25
26
  const hireModalStyles = {
26
27
  maxWidth: '725px',
@@ -34,6 +35,13 @@ const hireModalButtonStyles = {
34
35
  minHeight: '55px',
35
36
  };
36
37
 
38
+ const errorStyles = {
39
+ color: 'var(--error-color)',
40
+ fontWeight: '400',
41
+ fontSize: '14px',
42
+ margin: '0',
43
+ };
44
+
37
45
  const HireDesigner = (props: any) => {
38
46
  const {open, onClose, onCreateCustomTemplateQuery, productId} = props;
39
47
  const [queryTitle, setQueryTitle] = useState('');
@@ -45,6 +53,7 @@ const HireDesigner = (props: any) => {
45
53
  const [formErrors, setFormErrors] = useState({
46
54
  title: '',
47
55
  email: '',
56
+ files: '',
48
57
  videoUrl: '',
49
58
  comments: '',
50
59
  });
@@ -99,6 +108,10 @@ const HireDesigner = (props: any) => {
99
108
  errors.title = 'Title is required';
100
109
  }
101
110
 
111
+ if (formData.queryFile.length > 5) {
112
+ errors.files = 'You can only upload up to 5 files.';
113
+ }
114
+
102
115
  if (!formData.queryVideoUrl.trim()) {
103
116
  errors.videoUrl = 'Video URL is required';
104
117
  }
@@ -129,6 +142,7 @@ const HireDesigner = (props: any) => {
129
142
  setFormErrors({
130
143
  title: '',
131
144
  email: '',
145
+ files: '',
132
146
  videoUrl: '',
133
147
  comments: '',
134
148
  });
@@ -161,27 +175,12 @@ const HireDesigner = (props: any) => {
161
175
  form.append('files', file);
162
176
  });
163
177
 
164
- const response = await fetch(
165
- 'https://demoapi.openletterconnect.com/api/v1/sdk/custom-template-queries/create',
166
- {
167
- method: 'POST',
168
- headers: {
169
- Authorization:
170
- 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjMiLCJlbWFpbCI6InVzbWFuK2FkbWluQG9wZW5sZXR0ZXJjb25uZWN0LmNvbSIsImlhdCI6MTczNTMwODE3NywiZXhwIjoxNzM1MzIyNTc3fQ.YgO8wC2ZkEa2YWDZ1GEqbIU1bDlUKKXQ9aaHWeZw0PU',
171
- },
172
- body: form,
173
- }
174
- );
175
- if (response.status === 200) {
178
+ const response: any = await post('/custom-template-queries/create', form);
179
+ if (response && response.status === 200) {
176
180
  setIsLoading(false);
177
- const data = await response.json();
178
- console.log(data, 'data');
179
- console.log(response, 'response');
180
-
181
- onCreateCustomTemplateQuery(data);
181
+ onCreateCustomTemplateQuery(response.data);
182
182
  resetForm();
183
183
  onClose();
184
- console.log('closed');
185
184
  } else {
186
185
  throw new Error(`HTTP error! status: ${response.status}`);
187
186
  }
@@ -233,6 +232,11 @@ const HireDesigner = (props: any) => {
233
232
  </div>
234
233
  </div>
235
234
  </div>
235
+ {formErrors.files && (
236
+ <Typography variant="p" style={errorStyles}>
237
+ {formErrors.files}
238
+ </Typography>
239
+ )}
236
240
  </div>
237
241
  {queryFile.length > 0 && (
238
242
  <div className="uploaded-files">
package/src/index.tsx CHANGED
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import ReactDOM from 'react-dom/client';
3
- import { BrowserRouter as Router } from 'react-router-dom';
4
- import { Provider } from 'react-redux';
3
+ import {BrowserRouter as Router} from 'react-router-dom';
4
+ import {Provider} from 'react-redux';
5
5
  import store from './redux/store';
6
6
  import App from './App';
7
7
  import './index.scss';
@@ -13,8 +13,8 @@ import '@fontsource/inter/600.css';
13
13
  import '@fontsource/inter/700.css';
14
14
 
15
15
  // utils
16
- import { CustomCSSProperties } from './utils/customStyles';
17
- import { setIsSandbox, setPublicApiKey } from './utils/helper';
16
+ import {CustomCSSProperties} from './utils/customStyles';
17
+ import {setIsSandbox, setPublicApiKey} from './utils/helper';
18
18
 
19
19
  interface TemplateBuilderProps {
20
20
  container: HTMLElement | null;
@@ -105,34 +105,34 @@ const TemplateBuilder = ({
105
105
  //@ts-ignore
106
106
  return {
107
107
  destroy() {
108
- console.log("React template builder destroyed");
108
+ console.log('React template builder destroyed');
109
109
  root.unmount();
110
- }
111
- }
110
+ },
111
+ };
112
112
  };
113
113
 
114
114
  // Example to run the project locally for development. Comment out these lines when building the application
115
115
 
116
- const rootElement = document.getElementById('root');
117
- if (rootElement) {
118
- console.log("React SDK Loaded");
119
- TemplateBuilder({
120
- container: rootElement,
121
- secretKey: import.meta.env.VITE_APP_PLOTNO_API_KEY,
122
- publicApiKey: import.meta.env.VITE_APP_PUBLIC_API_KEY,
123
- sandbox: true,
124
- allowSenderFields: true,
125
- allowPropertyFields: true,
126
- templateGalleryModal: false,
127
- excludedFields: ['{{C.FIRST_NAME}}', '{{C.ADDRESS_1}}', '{{SPF.FIRST_NAME}}'],
128
- // onGetOneTemplate: getOneTemplate,
129
- // olcTemplate: olcTemplateData,
130
- // onGetTemplates: getAllTemplatesByTab,
131
- // onSubmit: createTemplate,
132
- styles: {}
133
- });
134
- } else {
135
- console.error("Root element '#root' not found in the document.");
136
- }
116
+ // const rootElement = document.getElementById('root');
117
+ // if (rootElement) {
118
+ // console.log("React SDK Loaded");
119
+ // TemplateBuilder({
120
+ // container: rootElement,
121
+ // secretKey: import.meta.env.VITE_APP_PLOTNO_API_KEY,
122
+ // publicApiKey: import.meta.env.VITE_APP_PUBLIC_API_KEY,
123
+ // sandbox: true,
124
+ // allowSenderFields: true,
125
+ // allowPropertyFields: true,
126
+ // templateGalleryModal: false,
127
+ // excludedFields: ['{{C.FIRST_NAME}}', '{{C.ADDRESS_1}}', '{{SPF.FIRST_NAME}}'],
128
+ // // onGetOneTemplate: getOneTemplate,
129
+ // // olcTemplate: olcTemplateData,
130
+ // // onGetTemplates: getAllTemplatesByTab,
131
+ // // onSubmit: createTemplate,
132
+ // styles: {}
133
+ // });
134
+ // } else {
135
+ // console.error("Root element '#root' not found in the document.");
136
+ // }
137
137
 
138
138
  export default TemplateBuilder;