ui-soxo-bootstrap-core 2.6.1-dev.25 → 2.6.1-dev.26

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.
@@ -13,7 +13,7 @@ import { GlobalContext } from './../../Store';
13
13
 
14
14
  import { Link, useLocation } from 'react-router-dom';
15
15
 
16
- import { Typography, Avatar, Input } from 'antd';
16
+ import { Typography, Avatar, Input, Tooltip } from "antd";
17
17
 
18
18
  import ProgressBar from '../progress-bar/progress-bar'; // Adjust the path as needed
19
19
 
@@ -21,7 +21,7 @@ import { Button } from '../../elements';
21
21
 
22
22
  import GenericHeader from '../header/generic-header';
23
23
 
24
- import { MenuOutlined, UserOutlined, SettingOutlined } from '@ant-design/icons';
24
+ import { MenuOutlined, UserOutlined, SettingOutlined, QuestionCircleOutlined } from '@ant-design/icons';
25
25
 
26
26
  import { Drawer } from 'antd';
27
27
 
@@ -70,10 +70,12 @@ export default function GlobalHeader({
70
70
 
71
71
  // const [searchModalVisible, setSearchModalVisible] = useState(false);
72
72
 
73
- const { globalCustomerHeader = () => {} } = appSettings;
73
+ const { globalCustomerHeader = () => { } } = appSettings;
74
74
 
75
75
  const { t, i18n } = useTranslation();
76
76
 
77
+ const helpDeskUrl = process.env.REACT_APP_HELP_DESK_URL
78
+
77
79
  const spotlightRef = useRef();
78
80
 
79
81
  useEffect(() => {
@@ -133,7 +135,7 @@ export default function GlobalHeader({
133
135
  animate();
134
136
  }, []);
135
137
 
136
- useEffect(() => {}, [state.theme]);
138
+ useEffect(() => { }, [state.theme]);
137
139
 
138
140
  return (
139
141
  <>
@@ -152,7 +154,7 @@ export default function GlobalHeader({
152
154
  //whileHover="hover"
153
155
  //whileTap="tap"
154
156
  className={`left-bar ${!isConnected && !isMobile ? '' : 'hide'}${!collapsed ? 'open' : 'close'}${kiosk && !isConnected ? 'kioskon' : ''}`}
155
- // style={{ background: state.theme.colors.leftSectionBackground }}
157
+ // style={{ background: state.theme.colors.leftSectionBackground }}
156
158
  >
157
159
  {!isMobile && !isConnected ? (
158
160
  <motion.div
@@ -199,7 +201,7 @@ export default function GlobalHeader({
199
201
  {!isConnected && !kiosk ? (
200
202
  <div
201
203
  className={`page-wrapper ${!collapsed ? 'open' : 'close'}`}
202
- // style={{ background: state.theme.colors.headerBg }}
204
+ // style={{ background: state.theme.colors.headerBg }}
203
205
  >
204
206
  {/* */}
205
207
  <div className="page-header-name">
@@ -280,6 +282,18 @@ export default function GlobalHeader({
280
282
 
281
283
  {/* Reload Button Ends */}
282
284
 
285
+ {/* Help-desk-btn */}
286
+ {helpDeskUrl ? <Tooltip title="Application support">
287
+ <span>
288
+ <Button
289
+ onClick={() => window.open(helpDeskUrl, '_blank')}
290
+ icon={<QuestionCircleOutlined />}
291
+ type="default"
292
+ size="small"
293
+ />
294
+ </span>
295
+ </Tooltip> : null}
296
+
283
297
  {/** Switch Languages starts */}
284
298
  {process.env.REACT_APP_ENABLE_LANGUAGE_SWITCHER ? <LanguageSwitcher /> : null}
285
299
  {/** Switch Languages ends */}
@@ -328,7 +342,7 @@ export default function GlobalHeader({
328
342
  function ProfileAvatar() {
329
343
  const { user = { locations: [] } } = useContext(GlobalContext);
330
344
 
331
- useEffect(() => {}, []);
345
+ useEffect(() => { }, []);
332
346
 
333
347
  return (
334
348
  <Link className="profile-avatar" to="/profile">
@@ -124,28 +124,29 @@ export default class ApiUtils {
124
124
  });
125
125
  };
126
126
 
127
- static upload = async ({ url, data, headers: customHeaders = {}, ...props }) => {
128
- const dbPtr = localStorage.getItem('db_ptr');
129
-
130
- console.log('nura upload called with:',dbPtr);
131
- try {
132
- return await UploadData({
133
- url,
134
- formBody: data, // FormData
135
- settings,
136
- headers: {
137
- ...(settings.headers || {}),
138
- ...(dbPtr ? { db_ptr: dbPtr } : {}),
139
- ...customHeaders,
140
- },
141
- ...props,
127
+ // upload document
128
+ static upload = async ({ url, data, headers: customHeaders = {}, ...props }) => {
129
+ const dbPtr = localStorage.getItem('db_ptr');
130
+
131
+ // Ensure settings object exists to avoid undefined errors in ApiCall
132
+ const settings = {
133
+ headers: {},
134
+ getToken: () => localStorage.getItem('access_token')
135
+ };
136
+
137
+ return UploadData({
138
+ url,
139
+ formBody: data,
140
+ // Your FormData goes here
141
+ isUpload: true, // Indicate that this is an upload request
142
+ settings,
143
+ headers: {
144
+ ...(dbPtr ? { db_ptr: dbPtr } : {}),
145
+ ...customHeaders,
146
+ },
147
+ ...props,
142
148
  });
143
- } catch (error) {
144
- console.log('Upload Error:', error);
145
- throw error;
146
- }
147
- };
148
-
149
+ };
149
150
  /**
150
151
  * Get Auth Status
151
152
  *
@@ -70,13 +70,11 @@ export async function DeleteData({ url, ...props }) {
70
70
  *
71
71
  * @param {*} param
72
72
  */
73
-
74
73
  export async function ApiCall({ url, formBody, method, settings, ...props }) {
75
74
  const token = props.token || (await settings.getToken());
76
75
  const path = window.location.pathname;
77
76
  const baseUrl = props.baseUrl || process.env.REACT_APP_endpoint;
78
77
 
79
- // 1. Check if we are dealing with FormData (Upload)
80
78
  const isFormData = formBody instanceof FormData;
81
79
 
82
80
  const payload = {
@@ -86,14 +84,23 @@ export async function ApiCall({ url, formBody, method, settings, ...props }) {
86
84
  ...(props.headers || {}),
87
85
  Authorization: `Bearer ${token}`,
88
86
  },
89
- // 2. If it's NOT FormData, stringify it. If it IS, pass it raw.
90
- body: isFormData ? formBody : (formBody ? JSON.stringify(formBody) : null),
91
87
  };
92
88
 
93
- // 3. Only add JSON Content-Type if it's NOT a FormData upload
94
- if (!isFormData) {
95
- payload.headers['Content-Type'] = 'application/json';
89
+ // Upload + normal handling
90
+ if (method !== 'GET' && formBody) {
91
+ payload.body = formBody;
92
+
93
+ if (!isFormData && !(props.isUpload)) {
94
+ payload.body = JSON.stringify(formBody);
95
+ payload.headers['Content-Type'] = 'application/json';
96
+ }
97
+
98
+ // ❗ VERY IMPORTANT
99
+ if (isFormData || (props.isUpload)) {
100
+ delete payload.headers['Content-Type'];
101
+ }
96
102
  }
103
+
97
104
  // 🟡 Handles both normal and retried responses
98
105
  const handleResponse = async (res) => {
99
106
  if (props.responseType === 'blob') {
@@ -171,6 +178,7 @@ export async function UploadData({ url, formBody, ...props }) {
171
178
  return ApiCall({
172
179
  url,
173
180
  formBody,
181
+ isUpload: true,
174
182
  method: 'POST',
175
183
  returnResponse: true,
176
184
  ...props,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ui-soxo-bootstrap-core",
3
- "version": "2.6.1-dev.25",
3
+ "version": "2.6.1-dev.26",
4
4
  "description": "All the Core Components for you to start",
5
5
  "keywords": [
6
6
  "all in one"