@guillotinaweb/react-gmi 0.34.1 → 0.34.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/README.md CHANGED
@@ -28,7 +28,7 @@ pnpm add @guillotinaweb/react-gmi
28
28
  `App.tsx`
29
29
 
30
30
  ```tsx
31
- import { useState } from 'react'
31
+ import { useState, useEffect } from 'react'
32
32
  import {
33
33
  Layout,
34
34
  Auth,
@@ -36,18 +36,26 @@ import {
36
36
  Login,
37
37
  getClient,
38
38
  ClientProvider,
39
+ GuillotinaClient,
39
40
  } from '@guillotinaweb/react-gmi'
40
- import '@guillotinaweb/react-gmi/dist/css/style.css'
41
+ import '@guillotinaweb/react-gmi/css/style.css'
41
42
 
42
43
  // Guillotina server URL
43
44
  const url = 'http://localhost:8080'
44
- const schema = '/'
45
+ const schemas = ['/db/container/']
45
46
  const auth = new Auth(url)
46
- const client = getClient(url, schema, auth)
47
47
 
48
48
  function App() {
49
+ const [currentSchema, setCurrentSchema] = useState('/db/container/')
50
+ const [clientInstance, setClientInstance] = useState<
51
+ GuillotinaClient | undefined
52
+ >(undefined)
49
53
  const [isLogged, setLogged] = useState(auth.isLogged)
50
54
 
55
+ useEffect(() => {
56
+ setClientInstance(getClient(url, currentSchema, auth))
57
+ }, [currentSchema])
58
+
51
59
  const onLogin = () => {
52
60
  setLogged(true)
53
61
  }
@@ -56,19 +64,30 @@ function App() {
56
64
  setLogged(false)
57
65
  }
58
66
 
59
- auth.onLogout = onLogout
67
+ if (clientInstance === undefined) {
68
+ return null
69
+ }
60
70
 
61
71
  return (
62
- <ClientProvider client={client}>
72
+ <ClientProvider client={clientInstance}>
63
73
  <Layout auth={auth} onLogout={onLogout}>
64
- {isLogged && <Guillotina auth={auth} url={schema} />}
74
+ {isLogged && (
75
+ <Guillotina
76
+ auth={auth}
77
+ url={currentSchema}
78
+ locale="en"
79
+ registry={{}}
80
+ />
81
+ )}
65
82
  {!isLogged && (
66
83
  <div className="columns is-centered">
67
- <div className="columns is-half">
84
+ <div className="column is-half">
68
85
  <Login
69
86
  onLogin={onLogin}
70
87
  auth={auth}
71
- currentSchema={schema}
88
+ schemas={schemas}
89
+ currentSchema={currentSchema}
90
+ setCurrentSchema={setCurrentSchema}
72
91
  />
73
92
  </div>
74
93
  </div>
package/dist/react-gmi.js CHANGED
@@ -768,13 +768,18 @@ function requireReactIs_development$1() {
768
768
  }
769
769
  return reactIs_development$1;
770
770
  }
771
- if (process.env.NODE_ENV === "production") {
772
- reactIs$2.exports = requireReactIs_production_min$1();
773
- } else {
774
- reactIs$2.exports = requireReactIs_development$1();
771
+ var hasRequiredReactIs;
772
+ function requireReactIs() {
773
+ if (hasRequiredReactIs) return reactIs$2.exports;
774
+ hasRequiredReactIs = 1;
775
+ if (process.env.NODE_ENV === "production") {
776
+ reactIs$2.exports = requireReactIs_production_min$1();
777
+ } else {
778
+ reactIs$2.exports = requireReactIs_development$1();
779
+ }
780
+ return reactIs$2.exports;
775
781
  }
776
- var reactIsExports$1 = reactIs$2.exports;
777
- var reactIs$1 = reactIsExports$1;
782
+ var reactIs$1 = requireReactIs();
778
783
  var REACT_STATICS = {
779
784
  childContextTypes: true,
780
785
  contextType: true,
@@ -5882,7 +5887,7 @@ var hasRequiredFactoryWithTypeCheckers;
5882
5887
  function requireFactoryWithTypeCheckers() {
5883
5888
  if (hasRequiredFactoryWithTypeCheckers) return factoryWithTypeCheckers;
5884
5889
  hasRequiredFactoryWithTypeCheckers = 1;
5885
- var ReactIs = reactIsExports$1;
5890
+ var ReactIs = requireReactIs();
5886
5891
  var assign = requireObjectAssign();
5887
5892
  var ReactPropTypesSecret = requireReactPropTypesSecret();
5888
5893
  var checkPropTypes = requireCheckPropTypes();
@@ -6355,7 +6360,7 @@ function requireFactoryWithThrowingShims() {
6355
6360
  return factoryWithThrowingShims;
6356
6361
  }
6357
6362
  if (process.env.NODE_ENV !== "production") {
6358
- var ReactIs = reactIsExports$1;
6363
+ var ReactIs = requireReactIs();
6359
6364
  var throwOnDirectAccess = true;
6360
6365
  propTypes.exports = requireFactoryWithTypeCheckers()(ReactIs.isElement, throwOnDirectAccess);
6361
6366
  } else {