@devgateway/dvz-ui-react
Version:
A modular, embeddable React component library for data visualization and UI, built with TypeScript. Provides reusable components for charts, maps, dashboards, and more, with built-in support for internationalization and Redux integration.
2 lines (1 loc) • 1.4 kB
JavaScript
"use strict";const e=require("react/jsx-runtime"),u=require("react"),d=require("react-redux"),D=require("./DataContext.js"),x=require("../reducers/data.js"),l=require("semantic-ui-react"),I=g=>{const{app:r,filters:o,source:a,store:j,params:t={},csv:n,group:v,editing:p,children:C}=g,f=d.useDispatch(),[P,m]=u.useState(!1),s=u.useRef({filters:o,params:t,app:r,source:a,csv:n}),c=["data","categories",r];t.dvzProxyDatasetId&&c.push(t.dvzProxyDatasetId);const h=d.useSelector(i=>i.getIn([...c,"items"])),q=d.useSelector(i=>i.getIn([...c,"error"])),S=d.useSelector(i=>i.getIn([...c,"loading"]));return u.useEffect(()=>{!h&&!S&&f(x.getCategories(g))},[]),u.useEffect(()=>{(o!==s.current.filters||JSON.stringify(t)!==JSON.stringify(s.current.params)||r!==s.current.app||s.current.source!==a||n!==s.current.csv)&&(r==="csv"?f(x.setData({app:r,csv:n,store:j,params:t,group:v})):(p&&(t.v=(Math.random()+1).toString(36).substring(7)),m(!1),f(x.getCategories(g)))),s.current={filters:o,params:t,app:r,source:a,csv:n}},[o,t,r,a,n,p]),S?e.jsx(l.Container,{}):h?e.jsx(D.CategoriesContext.Provider,{value:h.toJS(),children:C}):q?e.jsxs(l.Segment,{color:"red",children:[e.jsx("h1",{children:"500"}),e.jsx("p",{children:"Wasn't able to load data"})]}):e.jsx(l.Container,{children:e.jsxs(l.Segment,{color:"red",children:[e.jsx("h1",{children:"404"}),e.jsx("p",{children:"Can't find this page"})]})})};module.exports=I;