diff --git a/src/modules/dashboard/Dashboard.constants.ts b/src/modules/dashboard/Dashboard.constants.ts index 8e339bcd18..4a9342b255 100644 --- a/src/modules/dashboard/Dashboard.constants.ts +++ b/src/modules/dashboard/Dashboard.constants.ts @@ -1,14 +1,6 @@ -//Components import { PushAlpha, PushBot, PushDev } from 'blocks'; -//Types -import { ChatType, DashboardChannelTabsType, EnvKeys, SourceKeys } from './Dashboard.types'; - -export const dahboardChannelTabs: DashboardChannelTabsType = [ - { label: 'Trending Channels', value: 'trending' }, - { label: 'Hottest Channels', value: 'hottest' }, - { label: 'Subscribed', value: 'subscribed' }, -]; +import { ChatType, EnvKeys, SourceKeys } from './Dashboard.types'; export const recommendedChatList: ChatType[] = [ { diff --git a/src/modules/dashboard/Dashboard.types.ts b/src/modules/dashboard/Dashboard.types.ts index 4099eb234c..64b7a127e0 100644 --- a/src/modules/dashboard/Dashboard.types.ts +++ b/src/modules/dashboard/Dashboard.types.ts @@ -4,7 +4,7 @@ import { FC } from 'react'; export type ChannelTabs = 'subscribed' | 'trending' | 'hottest'; export type DashboardChannelTabType = { label: string; - value: ChannelTabs; + key: ChannelTabs; }; export type DashboardChannelTabsType = Array; export type TrendingChannelsType = { diff --git a/src/modules/dashboard/Dashboard.utils.ts b/src/modules/dashboard/Dashboard.utils.ts index 1d110a75cb..b826b48f69 100644 --- a/src/modules/dashboard/Dashboard.utils.ts +++ b/src/modules/dashboard/Dashboard.utils.ts @@ -1,6 +1,7 @@ import { TrendingChannelsResponse } from 'queries/types'; import { TrendingChannelsType } from './Dashboard.types'; + /** * @param weekData * @param currentData @@ -54,7 +55,7 @@ export const getTrendingChannelsData = ( subscriber: currentSubscriberData[key], name: channelDetails[key]?.name || '', icon: channelDetails[key]?.icon || '', - trend: trend + trend: trend, }); } diff --git a/src/modules/dashboard/components/ChannelTabsSection.tsx b/src/modules/dashboard/components/ChannelTabsSection.tsx index 24642021ed..4c9b46687e 100644 --- a/src/modules/dashboard/components/ChannelTabsSection.tsx +++ b/src/modules/dashboard/components/ChannelTabsSection.tsx @@ -1,16 +1,73 @@ import { useEffect, useState } from 'react'; -import { css } from 'styled-components'; -import { Box, Text } from 'blocks'; +import { Box, TabItem, Tabs } from 'blocks'; + import { useAccount } from 'hooks'; + import { ChannelTabs } from '../Dashboard.types'; + +import { HottestChannelsList } from './HottestChannelsList'; import { TrendingChannelsList } from './TrendingChannelsList'; import { SubscribedChannelsList } from './SubscribedChannelsList'; -import { dahboardChannelTabs } from '../Dashboard.constants'; -import { HottestChannelsList } from './HottestChannelsList'; const ChannelTabsSection = () => { - const [selectedChannelTab, setSelectedChannelTab] = useState(dahboardChannelTabs[0].value); + const dashboardChannelTabs: TabItem[] = [ + { + label: 'Trending Channels', + key: 'trending', + children: ( + + + + ), + }, + { + label: 'Hottest Channels', + key: 'hottest', + children: ( + + + + ), + }, + { + label: 'Subscribed', + key: 'subscribed', + children: ( + + + + ), + }, + ]; + const [selectedChannelTab, setSelectedChannelTab] = useState(dashboardChannelTabs[0].key as ChannelTabs); const { wallet } = useAccount(); const isWalletConnected = !!wallet?.accounts?.length; @@ -25,75 +82,25 @@ const ChannelTabsSection = () => { } }, [isWalletConnected]); + const getUpdatedDashboardTabs = (dashboardChannelTabs: TabItem[], isWalletConnected: boolean): TabItem[] => { + if (!isWalletConnected) return dashboardChannelTabs.filter((tabs) => tabs.key !== 'subscribed'); + + if (isWalletConnected) return dashboardChannelTabs.filter((tabs) => tabs.key !== 'hottest'); + return dashboardChannelTabs; + }; + return ( - - {/* TODO: Use Tabs component here */} - - {dahboardChannelTabs?.map((channelTab, index) => { - if (channelTab.value === 'subscribed' && !isWalletConnected) return null; - - if (channelTab.value === 'hottest' && isWalletConnected) return null; - - return ( - setSelectedChannelTab(channelTab.value)} - css={css` - background-color: var( - --${selectedChannelTab === channelTab.value ? 'components-button-tertiary-background-inverse' : 'surface-transparent'} - ); - `} - > - - {channelTab?.label} - - - ); - })} - - - - {selectedChannelTab === 'trending' && } - {selectedChannelTab === 'subscribed' && } - {selectedChannelTab === 'hottest' && } - + setSelectedChannelTab(activeKey as ChannelTabs)} + /> ); };