@ukpc-lib/react 0.1.25 → 0.1.27

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.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../index-a2ff7df9.cjs"),l=require("axios"),i=require("react/jsx-runtime"),g=require("react"),R=require("react-router-dom");require("react-dom");require("@mui/material");require("moment");function E({config:t,pushError:n=o.pushError}){const r=l.create(t);r.interceptors.request.use(async e=>(e.headers={Accept:"application/json","Content-Type":"application/json"},e),e=>Promise.reject(e)),r.interceptors.response.use(e=>e,async e=>s(e));async function s(e){var h,p,P;console.error("Error 🚨:",e);const a=e.config,u=(p=(h=e.response)==null?void 0:h.data)==null?void 0:p.errorMessage,m=u===o.ERROR_MESSAGE.TOKEN_EXPIRED;return((P=e.response)==null?void 0:P.status)===401?m&&!a._retry?(a._retry=!0,r.post("/authentication/api/v1/auth/refresh-token").then(()=>r(a)).catch(()=>o.login(t.baseURL))):((!u||!m)&&o.login(t.baseURL),Promise.reject("Unauthorized! Please login again.")):(n(u||"Something went wrong!"),Promise.reject(e.response.data))}return r}const d=t=>{const[n,r]=g.useState([]);return g.useEffect(()=>{l.get(`${t}/user-management/api/v1/users/my-account/permissions`,{withCredentials:!0}).then(s=>r(s.data)).catch(s=>{console.error("Getting user permission error:",s)})},[t]),n},c=t=>(n,r)=>{const s=d(t);return r?n.every(e=>s==null?void 0:s.includes(e)):n.some(e=>s==null?void 0:s.includes(e))},f=({baseUrl:t,accessWith:n,requireAll:r,children:s})=>c(t)(n,r)?i.jsx(i.Fragment,{children:s}):null,j=({accessWith:t,requireAll:n,baseUrl:r,unAuthorizedPath:s,children:e})=>c(r)(t,n)?i.jsx(i.Fragment,{children:e}):i.jsx(R.Navigate,{to:s,replace:!0});exports.AuthProvider=o.AuthProvider;exports.search=o.search;exports.useAuth=o.useAuth;exports.HasPermission=f;exports.PermissionRoute=j;exports.getAxiosInstance=E;exports.getUseHasPermission=c;exports.useGetPermission=d;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../index.module-35d2f1ab.cjs"),l=require("axios"),i=require("react/jsx-runtime"),g=require("react"),R=require("react-router-dom");require("react-dom");require("@mui/material");require("moment");function E({config:t,pushError:n=o.pushError}){const r=l.create(t);r.interceptors.request.use(async e=>(e.headers={Accept:"application/json","Content-Type":"application/json"},e),e=>Promise.reject(e)),r.interceptors.response.use(e=>e,async e=>s(e));async function s(e){var h,p,P;console.error("Error 🚨:",e);const u=e.config,a=(p=(h=e.response)==null?void 0:h.data)==null?void 0:p.errorMessage,m=a===o.ERROR_MESSAGE.TOKEN_EXPIRED;return((P=e.response)==null?void 0:P.status)===401?m&&!u._retry?(u._retry=!0,r.post("/authentication/api/v1/auth/refresh-token").then(()=>r(u)).catch(()=>o.login(t.baseURL))):((!a||!m)&&o.login(t.baseURL),Promise.reject("Unauthorized! Please login again.")):(n(a||"Something went wrong!"),Promise.reject(e.response.data))}return r}const d=t=>{const[n,r]=g.useState([]);return g.useEffect(()=>{l.get(`${t}/user-management/api/v1/users/my-account/permissions`,{withCredentials:!0}).then(s=>r(s.data)).catch(s=>{console.error("Getting user permission error:",s)})},[t]),n},c=t=>(n,r)=>{const s=d(t);return r?n.every(e=>s==null?void 0:s.includes(e)):n.some(e=>s==null?void 0:s.includes(e))},f=({baseUrl:t,accessWith:n,requireAll:r,children:s})=>c(t)(n,r)?i.jsx(i.Fragment,{children:s}):null,j=({accessWith:t,requireAll:n,baseUrl:r,unAuthorizedPath:s,children:e})=>c(r)(t,n)?i.jsx(i.Fragment,{children:e}):i.jsx(R.Navigate,{to:s,replace:!0});exports.AuthProvider=o.AuthProvider;exports.search=o.search;exports.useAuth=o.useAuth;exports.HasPermission=f;exports.PermissionRoute=j;exports.getAxiosInstance=E;exports.getUseHasPermission=c;exports.useGetPermission=d;
@@ -1,5 +1,5 @@
1
- import { k as h, p as E, E as g } from "../index-9cc0ba79.js";
2
- import { A as C, f as H, u as L } from "../index-9cc0ba79.js";
1
+ import { t as h, p as E, E as g } from "../index.module-ebc563e0.js";
2
+ import { A as C, i as H, u as L } from "../index.module-ebc563e0.js";
3
3
  import f from "axios";
4
4
  import { jsx as a, Fragment as P } from "react/jsx-runtime";
5
5
  import { useState as d, useEffect as R } from "react";
@@ -7,7 +7,7 @@ import { Navigate as y } from "react-router-dom";
7
7
  import "react-dom";
8
8
  import "@mui/material";
9
9
  import "moment";
10
- function I({
10
+ function M({
11
11
  config: t,
12
12
  pushError: n = E
13
13
  }) {
@@ -46,12 +46,12 @@ const x = (t) => {
46
46
  ) : n.some(
47
47
  (e) => r == null ? void 0 : r.includes(e)
48
48
  );
49
- }, M = ({
49
+ }, T = ({
50
50
  baseUrl: t,
51
51
  accessWith: n,
52
52
  requireAll: s,
53
53
  children: r
54
- }) => l(t)(n, s) ? /* @__PURE__ */ a(P, { children: r }) : null, T = ({
54
+ }) => l(t)(n, s) ? /* @__PURE__ */ a(P, { children: r }) : null, U = ({
55
55
  accessWith: t,
56
56
  requireAll: n,
57
57
  baseUrl: s,
@@ -60,9 +60,9 @@ const x = (t) => {
60
60
  }) => l(s)(t, n) ? /* @__PURE__ */ a(P, { children: e }) : /* @__PURE__ */ a(y, { to: r, replace: !0 });
61
61
  export {
62
62
  C as AuthProvider,
63
- M as HasPermission,
64
- T as PermissionRoute,
65
- I as getAxiosInstance,
63
+ T as HasPermission,
64
+ U as PermissionRoute,
65
+ M as getAxiosInstance,
66
66
  l as getUseHasPermission,
67
67
  H as search,
68
68
  L as useAuth,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ukpc-lib/react",
3
3
  "private": false,
4
- "version": "0.1.25",
4
+ "version": "0.1.27",
5
5
  "type": "module",
6
6
  "main": "./dist/",
7
7
  "module": "./dist/",
@@ -45,9 +45,10 @@
45
45
  "@mui/material": "^5.15.4",
46
46
  "@r2wc/react-to-web-component": "^2.0.3",
47
47
  "@rollup/plugin-replace": "^5.0.5",
48
- "axios": "^1.6.5",
48
+ "axios": "1.6.2",
49
49
  "bootstrap-daterangepicker": "^3.1.0",
50
50
  "cssnano": "^6.0.3",
51
+ "firebase": "^10.8.1",
51
52
  "framer-motion": "^10.18.0",
52
53
  "jquery": "^3.7.1",
53
54
  "moment": "^2.30.1",