@carbonorm/carbonreact 3.0.6 → 3.0.7

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": "@carbonorm/carbonreact",
3
- "version": "3.0.6",
3
+ "version": "3.0.7",
4
4
  "main": "dist/index.cjs.js",
5
5
  "module": "dist/index.esm.js",
6
6
  "types": "dist/index.d.ts",
@@ -0,0 +1,34 @@
1
+ import {AxiosResponse} from "axios";
2
+
3
+
4
+ export default function setCookies(cookies: string[], req: AxiosResponse | undefined = undefined): void {
5
+
6
+ console.log("Setting cookies", cookies);
7
+
8
+ cookies.map(cookie => {
9
+
10
+ const newCookie = cookie
11
+ .replace("HttpOnly", "")
12
+ .replace("secure", "");
13
+
14
+ if (document === undefined || document === null) {
15
+
16
+ const getStackTrace = function () {
17
+ let obj: any = {};
18
+ Error.captureStackTrace(obj, getStackTrace);
19
+ return obj.stack;
20
+ };
21
+
22
+ console.error(req)
23
+
24
+ console.log('Testing error, document not defined', req)
25
+
26
+ throw new Error("Document is undefined while trying to set cookie: (" + newCookie + ") in axiosInterceptors.tsx after (" + JSON.stringify([req?.config, req?.data], undefined, 4) + ") Please make sure all requests are wrapped in an act() from import {act} from '@testing-library/react'; (" + JSON.stringify(getStackTrace(), undefined, 4) + ")");
27
+
28
+ }
29
+
30
+ document.cookie = newCookie
31
+
32
+ });
33
+
34
+ }
package/src/index.ts CHANGED
@@ -37,6 +37,8 @@ export * from "./hoc/isEdgeBrowser";
37
37
  export * from "./hoc/parseMultipleJson";
38
38
  export { default as scrollIntoView } from "./hoc/scrollIntoView";
39
39
  export * from "./hoc/scrollIntoView";
40
+ export { default as setCookies } from "./hoc/setCookies";
41
+ export * from "./hoc/setCookies";
40
42
  export { default as setUrl } from "./hoc/setUrl";
41
43
  export * from "./hoc/setUrl";
42
44
  export { default as updateRestfulObjectArrays } from "./hoc/updateRestfulObjectArrays";