Skip to content

Commit

Permalink
Merge branch 'dev' of github.com:edenia/eden-spend-explorer into fix/…
Browse files Browse the repository at this point in the history
…dont-show-data-on-expense-364
  • Loading branch information
JAMares committed Dec 30, 2022
2 parents 64ddb51 + 1a41425 commit ce13db6
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
25 changes: 20 additions & 5 deletions webapp/src/App.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import React, { Suspense, useEffect, useMemo } from 'react'
import React, { Suspense, useEffect, useMemo, useState } from 'react'
import { BrowserRouter, Navigate, Route, Routes } from 'react-router-dom'
import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns'
import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider'
import { StylesProvider, createGenerateClassName } from '@mui/styles'
import { ThemeProvider } from '@mui/material/styles'
import CssBaseline from '@mui/material/CssBaseline'
import '@edenia/ui-kit/dist/index.css'
import { useLazyQuery } from '@apollo/client'
import ReactGA from 'react-ga'

import useTresuryBalanceState from './hooks/customHooks/useTresuryBalanceState'
Expand All @@ -15,6 +16,7 @@ import DashboardLayout from './layouts/Dashboard'
import { useSharedState } from './context/state.context'
import getTheme from './theme'
import './i18n'
import { GET_DELEGATES } from '../src/gql/general.gql'

const TRACKING_ID = 'G-3MY19MHQWY'

Expand All @@ -26,13 +28,18 @@ const generateClassName = createGenerateClassName({

const App = () => {
const [state, { setEOSTrasuryBalance }] = useSharedState()
const [role, setRole] = useState('guest')
const [{ eosRate, currencyBalance, nextEdenDisbursement }] =
useTresuryBalanceState()
const theme = useMemo(() => getTheme(state.useDarkMode), [state.useDarkMode])
const userRoutes = useMemo(
() => routes(state?.user?.accountName ? 'member' : 'guest'),
[state?.user]
)

const [loadDelegates, { data: isDelegate }] = useLazyQuery(GET_DELEGATES, {
variables: {
delegate: state?.user?.accountName ? state?.user?.accountName : ''
}
})

const userRoutes = useMemo(() => routes(role), [role])

const renderRoute = ({ component: Component, ...route }, index) => (
<Route
Expand All @@ -43,6 +50,14 @@ const App = () => {
/>
)

useEffect(() => {
loadDelegates()
}, [])

useEffect(() => {
isDelegate?.eden_delegates.length > 0 ? setRole('member') : setRole('guest')
}, [isDelegate])

useEffect(() => {
setEOSTrasuryBalance({
eosRate,
Expand Down
8 changes: 8 additions & 0 deletions webapp/src/gql/general.gql.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,11 @@ export const GET_ELECTIONS = gql`
}
}
`

export const GET_DELEGATES = gql`
query MyQuery($delegate: String) {
eden_delegates(where: { account: { _eq: $delegate } }) {
account
}
}
`

0 comments on commit ce13db6

Please sign in to comment.