ui-soxo-bootstrap-core 2.6.1-dev.23 → 2.6.1-dev.25
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.
|
@@ -63,7 +63,7 @@ function resolveLicenseAlert(data) {
|
|
|
63
63
|
if (status === 'ACTIVE' && isExpiringSoon) {
|
|
64
64
|
let descriptionText = '';
|
|
65
65
|
// customize message based on how soon the license is expiring
|
|
66
|
-
if (expiresInDays ===
|
|
66
|
+
if (expiresInDays === 0) {
|
|
67
67
|
descriptionText = 'Your license will expire today. Please renew immediately.';
|
|
68
68
|
} else {
|
|
69
69
|
descriptionText = `Your license will expire in ${expiresInDays} days. Please plan for renewal.`;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PostData, GetData, PutData, PatchData, DeleteData } from './../http/http.utils';
|
|
1
|
+
import { PostData, GetData, PutData, PatchData, DeleteData,UploadData } from './../http/http.utils';
|
|
2
2
|
|
|
3
3
|
let headers = {};
|
|
4
4
|
|
|
@@ -124,32 +124,27 @@ export default class ApiUtils {
|
|
|
124
124
|
});
|
|
125
125
|
};
|
|
126
126
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
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,
|
|
131
136
|
headers: {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
// type:'multipart/formData'
|
|
136
|
-
},
|
|
137
|
-
// credentials: 'include',
|
|
138
|
-
body: data,
|
|
139
|
-
}).then(
|
|
140
|
-
(result) => {
|
|
141
|
-
return result.json();
|
|
142
|
-
},
|
|
143
|
-
(error) => {
|
|
144
|
-
console.log(error);
|
|
145
|
-
return error;
|
|
137
|
+
...(settings.headers || {}),
|
|
138
|
+
...(dbPtr ? { db_ptr: dbPtr } : {}),
|
|
139
|
+
...customHeaders,
|
|
146
140
|
},
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
}
|
|
141
|
+
...props,
|
|
142
|
+
});
|
|
143
|
+
} catch (error) {
|
|
144
|
+
console.log('Upload Error:', error);
|
|
145
|
+
throw error;
|
|
146
|
+
}
|
|
147
|
+
};
|
|
153
148
|
|
|
154
149
|
/**
|
|
155
150
|
* Get Auth Status
|
|
@@ -76,18 +76,24 @@ export async function ApiCall({ url, formBody, method, settings, ...props }) {
|
|
|
76
76
|
const path = window.location.pathname;
|
|
77
77
|
const baseUrl = props.baseUrl || process.env.REACT_APP_endpoint;
|
|
78
78
|
|
|
79
|
+
// 1. Check if we are dealing with FormData (Upload)
|
|
80
|
+
const isFormData = formBody instanceof FormData;
|
|
81
|
+
|
|
79
82
|
const payload = {
|
|
80
83
|
method,
|
|
81
84
|
headers: {
|
|
82
85
|
...settings.headers,
|
|
83
|
-
...headers,
|
|
84
86
|
...(props.headers || {}),
|
|
85
|
-
|
|
86
|
-
'Content-Type': 'application/json',
|
|
87
|
+
Authorization: `Bearer ${token}`,
|
|
87
88
|
},
|
|
88
|
-
|
|
89
|
+
// 2. If it's NOT FormData, stringify it. If it IS, pass it raw.
|
|
90
|
+
body: isFormData ? formBody : (formBody ? JSON.stringify(formBody) : null),
|
|
89
91
|
};
|
|
90
92
|
|
|
93
|
+
// 3. Only add JSON Content-Type if it's NOT a FormData upload
|
|
94
|
+
if (!isFormData) {
|
|
95
|
+
payload.headers['Content-Type'] = 'application/json';
|
|
96
|
+
}
|
|
91
97
|
// 🟡 Handles both normal and retried responses
|
|
92
98
|
const handleResponse = async (res) => {
|
|
93
99
|
if (props.responseType === 'blob') {
|
|
@@ -156,3 +162,17 @@ export async function ApiCall({ url, formBody, method, settings, ...props }) {
|
|
|
156
162
|
throw err;
|
|
157
163
|
}
|
|
158
164
|
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Method for uploading documents
|
|
168
|
+
* @public
|
|
169
|
+
*/
|
|
170
|
+
export async function UploadData({ url, formBody, ...props }) {
|
|
171
|
+
return ApiCall({
|
|
172
|
+
url,
|
|
173
|
+
formBody,
|
|
174
|
+
method: 'POST',
|
|
175
|
+
returnResponse: true,
|
|
176
|
+
...props,
|
|
177
|
+
});
|
|
178
|
+
}
|