Skip to content

Commit

Permalink
Fix route setting from tabs on Identity page
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeyandreevsky committed Dec 12, 2024
1 parent 04ecd17 commit bd6ac8a
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions packages/frontend/src/app/identity/[identifier]/Identity.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ import './Identity.scss'

const tabs = [
'transactions',
'transfers',
'datacontracts',
'documents',
'datacontracts'
'transfers'
]

const defaultTabName = 'transactions'
Expand All @@ -36,7 +36,10 @@ function Identity ({ identifier }) {
const [transactions, setTransactions] = useState({ data: {}, loading: true, error: false })
const [transfers, setTransfers] = useState({ data: {}, loading: true, error: false })
const [rate, setRate] = useState({ data: {}, loading: true, error: false })
const [activeTab, setActiveTab] = useState(tabs.indexOf(defaultTabName.toLowerCase()) !== -1 ? tabs.indexOf(defaultTabName.toLowerCase()) : 0)
const [activeTab, setActiveTab] = useState(tabs.indexOf(defaultTabName.toLowerCase()) !== -1
? tabs.indexOf(defaultTabName.toLowerCase())
: tabs.indexOf(defaultTabName)
)

useEffect(() => {
setBreadcrumbs([
Expand All @@ -46,10 +49,6 @@ function Identity ({ identifier }) {
])
}, [setBreadcrumbs, identifier])

console.log('identity', identity)
console.log('documents', documents)
console.log('dataContracts', dataContracts)

// mock //

if (!identity.error && !identity.data?.lastWithdrawal) identity.data.lastWithdrawal = '6AC5EDA942093A9275A2837CFDF2C18CAAD9D922BA211BD5EA5E6333FE904CE7'
Expand Down Expand Up @@ -123,6 +122,9 @@ function Identity ({ identifier }) {
useEffect(() => {
const tab = searchParams.get('tab')

console.log('tab from url', tab)
console.log('tab && tabs.indexOf(tab.toLowerCase()) !== -1', tab && tabs.indexOf(tab.toLowerCase()) !== -1)
console.log('tabs.indexOf(tab.toLowerCase())', tabs.indexOf(tab.toLowerCase()))
if (tab && tabs.indexOf(tab.toLowerCase()) !== -1) {
setActiveTab(tabs.indexOf(tab.toLowerCase()))
return
Expand All @@ -142,7 +144,7 @@ function Identity ({ identifier }) {
}

router.push(`${pathname}?${urlParameters.toString()}`, { scroll: false })
}, [activeTab, router, pathname, searchParams])
}, [activeTab])

return (
<PageDataContainer
Expand All @@ -153,7 +155,7 @@ function Identity ({ identifier }) {
<IdentityTotalCard identity={identity} rate={rate}/>

<InfoContainer styles={['tabs']} className={'IdentityPage__ListContainer'}>
<Tabs onChange={(index) => setActiveTab(index)} index={activeTab}>
<Tabs onChange={setActiveTab} index={activeTab}>
<TabList>
<Tab>Transactions {identity.data?.totalTxs !== undefined
? <span className={`Tabs__TabItemsCount ${identity.data?.totalTxs === 0 ? 'Tabs__TabItemsCount--Empty' : ''}`}>
Expand Down

0 comments on commit bd6ac8a

Please sign in to comment.