Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
wow-sven committed Nov 4, 2023
1 parent 1b57c87 commit dc8cde0
Show file tree
Hide file tree
Showing 3 changed files with 117 additions and 124 deletions.
110 changes: 55 additions & 55 deletions dashboard/src/pages/scan/state/[tab].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,62 +76,62 @@ const StateList = () => {
}

return (
<TabContext value={activeTab}>
<Grid>
<Grid item xs={12}>
<TabList
variant="scrollable"
scrollButtons="auto"
onChange={handleChange}
aria-label="customized tabs example"
>
<Tab
value="get"
label={
<Box
sx={{
display: 'flex',
alignItems: 'center',
...(!hideText && { '& svg': { mr: 2 } }),
}}
>
<Icon icon="bxs-search" />
{!hideText && 'Get'}
</Box>
}
/>
<Tab
value="list"
label={
<Box
sx={{
display: 'flex',
alignItems: 'center',
...(!hideText && { '& svg': { mr: 2 } }),
}}
>
<Icon icon="bx-list-ul" />
{!hideText && 'List'}
</Box>
}
/>
</TabList>
</Grid>
<TabContext value={activeTab}>
<Grid>
<Grid item xs={12}>
<TabList
variant="scrollable"
scrollButtons="auto"
onChange={handleChange}
aria-label="customized tabs example"
>
<Tab
value="get"
label={
<Box
sx={{
display: 'flex',
alignItems: 'center',
...(!hideText && { '& svg': { mr: 2 } }),
}}
>
<Icon icon="bxs-search" />
{!hideText && 'Get'}
</Box>
}
/>
<Tab
value="list"
label={
<Box
sx={{
display: 'flex',
alignItems: 'center',
...(!hideText && { '& svg': { mr: 2 } }),
}}
>
<Icon icon="bx-list-ul" />
{!hideText && 'List'}
</Box>
}
/>
</TabList>
</Grid>
{isLoading ? (
<Box sx={{ mt: 6, display: 'flex', alignItems: 'center', flexDirection: 'column' }}>
<CircularProgress sx={{ mb: 4 }} />
<Typography>Loading...</Typography>
</Box>
) : (
<TabPanel
sx={{ p: 0, border: 0, boxShadow: 0, backgroundColor: 'transparent' }}
value={activeTab}
>
{tabContentList[activeTab]}
</TabPanel>
)}
</TabContext>
</Grid>
{isLoading ? (
<Box sx={{ mt: 6, display: 'flex', alignItems: 'center', flexDirection: 'column' }}>
<CircularProgress sx={{ mb: 4 }} />
<Typography>Loading...</Typography>
</Box>
) : (
<TabPanel
sx={{ p: 0, border: 0, boxShadow: 0, backgroundColor: 'transparent' }}
value={activeTab}
>
{tabContentList[activeTab]}
</TabPanel>
)}
</TabContext>
)
}

Expand Down
28 changes: 11 additions & 17 deletions dashboard/src/views/feature/SessionKeyList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@
// SPDX-License-Identifier: Apache-2.0

// ** React Imports
import {useState, useRef, useMemo, useEffect} from 'react'
import { useState, useRef, useMemo, useEffect } from 'react'

import {useAuth} from 'src/hooks/useAuth'
import {useSession} from 'src/hooks/useSessionAccount'
import {useRooch} from 'src/hooks/useRooch'
import { useAuth } from 'src/hooks/useAuth'
import { useSession } from 'src/hooks/useSessionAccount'
import { useRooch } from 'src/hooks/useRooch'

import Grid from '@mui/material/Grid'
import Box from '@mui/material/Box'
import Card from '@mui/material/Card'
import CardHeader from '@mui/material/CardHeader'
Expand All @@ -30,8 +29,8 @@ import {
} from '@mui/x-data-grid'

// ** Store & Actions Imports
import {fetchData, removeRow} from 'src/store/session'
import {useAppDispatch, useAppSelector} from 'src/store'
import { fetchData, removeRow } from 'src/store/session'
import { useAppDispatch, useAppSelector } from 'src/store'

const formatDate = (timestamp: number) => {
if (timestamp === 0) {
Expand Down Expand Up @@ -128,7 +127,7 @@ export default function SessionKeyList() {

// ** Hooks
const dispatch = useAppDispatch()
const {result, status, error} = useAppSelector((state) => state.session)
const { result, status, error } = useAppSelector((state) => state.session)

useEffect(() => {
const defaultAccount = auth.defaultAccount
Expand Down Expand Up @@ -235,15 +234,10 @@ export default function SessionKeyList() {

return (
<Card>
<CardHeader title="Session Keys"/>
<CardHeader title="Session Keys" />
<CardContent>
<Box sx={{textAlign: 'right', marginBottom: '10px', mr: '20px'}}>
<Button
variant="contained"
color="primary"
size="small"
onClick={() => handleRefresh()}
>
<Box sx={{ textAlign: 'right', marginBottom: '10px', mr: '20px' }}>
<Button variant="contained" color="primary" size="small" onClick={() => handleRefresh()}>
Refresh
</Button>
</Box>
Expand All @@ -259,7 +253,7 @@ export default function SessionKeyList() {
<Snackbar
open={!!error}
autoHideDuration={6000}
anchorOrigin={{vertical: 'top', horizontal: 'center'}}
anchorOrigin={{ vertical: 'top', horizontal: 'center' }}
>
<Alert severity="error">{error}</Alert>
</Snackbar>
Expand Down
103 changes: 51 additions & 52 deletions dashboard/src/views/scan/state/list/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,25 @@
// SPDX-License-Identifier: Apache-2.0

// ** React Imports
import {useState, useEffect, useRef, useMemo, useCallback} from 'react'
import { useState, useEffect, useRef, useMemo, useCallback } from 'react'

// ** Next Import
import Link from 'next/link'

// ** MUI Imports
import Card from '@mui/material/Card'
import {styled} from '@mui/material/styles'
import { styled } from '@mui/material/styles'
import Typography from '@mui/material/Typography'
import {DataGrid, GridColDef} from '@mui/x-data-grid'
import { DataGrid, GridColDef } from '@mui/x-data-grid'

// ** Store & Actions Imports
import {fetchData} from 'src/store/scan/state/list'
import {useAppDispatch, useAppSelector} from 'src/store'
import { fetchData } from 'src/store/scan/state/list'
import { useAppDispatch, useAppSelector } from 'src/store'

// ** Utils
import {formatAddress} from 'src/@core/utils/format'
import {useRooch} from '../../../../hooks/useRooch'
import { formatAddress } from 'src/@core/utils/format'
import { useRooch } from '../../../../hooks/useRooch'
import CardSnippet from '../../../../@core/components/card-snippet'
import Grid from '@mui/material/Grid'
import Spinner from '../../../../@core/components/spinner'
import CardHeader from '@mui/material/CardHeader'
import CardContent from '@mui/material/CardContent'
Expand All @@ -35,7 +34,7 @@ interface CellType {
}

// ** Styled components
const LinkStyled = styled(Link)(({theme}) => ({
const LinkStyled = styled(Link)(({ theme }) => ({
fontSize: '1rem',
textDecoration: 'none',
color: theme.palette.primary.main,
Expand All @@ -45,13 +44,13 @@ const TransactionList = () => {
// Hook
const rooch = useRooch()
const dispatch = useAppDispatch()
const {result, status, error} = useAppSelector((state) => state.statePageView)
const { result, status, error } = useAppSelector((state) => state.statePageView)

// ** State
const [accessPath, setAccessPath] = useState<string>('/object/0x1')
const [cacheResult, setCacheResult] = useState<{ [page: number]: any[] }>({})

const [paginationModel, setPaginationModel] = useState({page: 0, pageSize: 10})
const [paginationModel, setPaginationModel] = useState({ page: 0, pageSize: 10 })
const [curStateView, setCurStateView] = useState<any | null>(null)
const mapPageToNextCursor = useRef<{ [page: number]: Uint8Array | null }>({})
const queryOptions = useMemo(
Expand All @@ -68,7 +67,7 @@ const TransactionList = () => {
// We add nextCursor when available
mapPageToNextCursor.current[paginationModel.page] = result.next_cursor
cacheResult[paginationModel.page] = result.data
setCacheResult({...cacheResult})
setCacheResult({ ...cacheResult })
const count = Object.values(cacheResult).reduce((sum, data) => sum + data.length, 0)
setCount(count)
}
Expand Down Expand Up @@ -147,7 +146,7 @@ const TransactionList = () => {
minWidth: 90,
field: 'type',
headerName: 'Type',
renderCell: ({row}: CellType) => (
renderCell: ({ row }: CellType) => (
<LinkStyled
href="/"
onClick={(e) => {
Expand All @@ -165,8 +164,8 @@ const TransactionList = () => {
minWidth: 90,
field: 'id',
headerName: 'ID',
renderCell: ({row}: CellType) => (
<Typography sx={{color: 'text.secondary'}}>
renderCell: ({ row }: CellType) => (
<Typography sx={{ color: 'text.secondary' }}>
{formatAddress(row.decoded_value.value.id)}
</Typography>
),
Expand All @@ -177,8 +176,8 @@ const TransactionList = () => {
minWidth: 90,
field: 'owner',
headerName: 'Owner',
renderCell: ({row}: CellType) => (
<Typography sx={{color: 'text.secondary'}}>
renderCell: ({ row }: CellType) => (
<Typography sx={{ color: 'text.secondary' }}>
{formatAddress(row.decoded_value.value.owner)}
</Typography>
),
Expand All @@ -190,7 +189,7 @@ const TransactionList = () => {
return (
<>
<Card>
<CardHeader title="State Filters"/>
<CardHeader title="State Filters" />
<CardContent>
<TextField
id="access-path-id"
Expand All @@ -202,14 +201,14 @@ const TransactionList = () => {
endAdornment: (
<InputAdornment
position="end"
sx={{color: 'text.primary'}}
sx={{ color: 'text.primary' }}
onClick={handleSearch}
>
<Button size="small">
<Typography mr={2} color="text.disabled">
Enter
</Typography>
<Icon icon="bx:search"/>
<Icon icon="bx:search" />
</Button>
</InputAdornment>
),
Expand All @@ -219,43 +218,43 @@ const TransactionList = () => {
</CardContent>
</Card>
{status === 'loading' ? (
<Spinner/>
<Spinner />
) : (
<>
<Card sx={{mt:6}}>
<DataGrid
autoHeight
pagination
disableColumnMenu={true}
rowCount={status === 'finished' ? (result.has_next_page ? count + 1 : count) : 0}
rows={
status === 'finished'
? Object.values(cacheResult)
<Card sx={{ mt: 6 }}>
<DataGrid
autoHeight
pagination
disableColumnMenu={true}
rowCount={status === 'finished' ? (result.has_next_page ? count + 1 : count) : 0}
rows={
status === 'finished'
? Object.values(cacheResult)
.flat()
.map((row: any) => ({...row, id: row.decoded_value.value.id}))
: []
}
columns={defaultColumns.map((v) => ({
...v,
sortable: false,
}))}
paginationModel={paginationModel}
onPaginationModelChange={setPaginationModel}
/>
</Card>
<Typography sx={{color: 'text.secondary', ml: 6, mt: 4, mb:4}}>
.map((row: any) => ({ ...row, id: row.decoded_value.value.id }))
: []
}
columns={defaultColumns.map((v) => ({
...v,
sortable: false,
}))}
paginationModel={paginationModel}
onPaginationModelChange={setPaginationModel}
/>
</Card>
<Typography sx={{ color: 'text.secondary', ml: 6, mt: 4, mb: 4 }}>
{curStateView ? curStateView.decoded_value.type : 'Current Page Raw Data'}
</Typography>
<CardSnippet
defaultShow={true}
fullHeight={true}
codes={[
{
code: JSON.stringify(curStateView ?? cacheResult[paginationModel.page], null, 2),
lng: 'json',
},
]}
/>
<CardSnippet
defaultShow={true}
fullHeight={true}
codes={[
{
code: JSON.stringify(curStateView ?? cacheResult[paginationModel.page], null, 2),
lng: 'json',
},
]}
/>
</>
)}
</>
Expand Down

0 comments on commit dc8cde0

Please sign in to comment.