2021-04-07 14:49:37 -07:00
|
|
|
import { useState } from 'react'
|
2021-04-05 07:32:11 -07:00
|
|
|
import FloatingElement from './FloatingElement'
|
2021-04-05 14:38:59 -07:00
|
|
|
import OpenOrdersTable from './OpenOrdersTable'
|
2021-04-07 14:49:37 -07:00
|
|
|
import BalancesTable from './BalancesTable'
|
|
|
|
import FeeDiscountsTable from './FeeDiscountsTable'
|
|
|
|
import TradeHistoryTable from './TradeHistoryTable'
|
2021-04-05 14:38:59 -07:00
|
|
|
|
|
|
|
const TABS = ['Open Orders', 'Balances', 'Fee Discounts', 'Trade History']
|
|
|
|
|
|
|
|
const UserInfoTabs = ({ activeTab, setActiveTab }) => {
|
|
|
|
const handleTabChange = (tabName) => {
|
|
|
|
setActiveTab(tabName)
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div>
|
2021-04-12 09:49:02 -07:00
|
|
|
<div className={`sm:hidden`}>
|
|
|
|
<label htmlFor="tabs" className={`sr-only`}>
|
2021-04-05 14:38:59 -07:00
|
|
|
Select a tab
|
|
|
|
</label>
|
|
|
|
<select
|
|
|
|
id="tabs"
|
|
|
|
name="tabs"
|
2021-04-16 04:50:56 -07:00
|
|
|
className={`block w-full pl-3 pr-10 py-2 bg-th-bkg-2 border border-th-fgd-4 focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm rounded-md`}
|
2021-04-05 14:38:59 -07:00
|
|
|
onChange={(e) => handleTabChange(e.target.value)}
|
|
|
|
>
|
|
|
|
{TABS.map((tabName) => (
|
|
|
|
<option key={tabName} value={tabName}>
|
|
|
|
{tabName}
|
|
|
|
</option>
|
|
|
|
))}
|
|
|
|
</select>
|
|
|
|
</div>
|
2021-04-12 09:49:02 -07:00
|
|
|
<div className={`hidden sm:block`}>
|
|
|
|
<div className={`border-b border-th-fgd-4`}>
|
|
|
|
<nav className={`-mb-px flex space-x-8`} aria-label="Tabs">
|
2021-04-05 14:38:59 -07:00
|
|
|
{TABS.map((tabName) => (
|
|
|
|
<a
|
|
|
|
key={tabName}
|
|
|
|
onClick={() => handleTabChange(tabName)}
|
2021-04-19 06:45:59 -07:00
|
|
|
className={`whitespace-nowrap py-4 px-1 border-b-2 font-semibold cursor-pointer transition-all duration-500
|
2021-04-12 09:49:02 -07:00
|
|
|
${
|
|
|
|
activeTab === tabName
|
2021-04-16 04:50:56 -07:00
|
|
|
? `border-th-primary text-th-primary`
|
2021-04-16 07:08:33 -07:00
|
|
|
: `border-transparent text-th-fgd-4 hover:text-th-primary`
|
2021-04-12 09:49:02 -07:00
|
|
|
}
|
|
|
|
`}
|
2021-04-05 14:38:59 -07:00
|
|
|
>
|
|
|
|
{tabName}
|
|
|
|
{/* TODO: add indicator for number in tab */}
|
|
|
|
{/* <!-- Current: "bg-indigo-100 text-indigo-600", Default: "bg-gray-100 text-gray-900" -->
|
|
|
|
<span
|
2021-04-12 09:49:02 -07:00
|
|
|
className={`bg-gray-100 text-gray-900 hidden ml-2 py-0.5 px-2.5 rounded-full text-xs font-medium md:inline-block`}
|
2021-04-05 14:38:59 -07:00
|
|
|
>
|
|
|
|
52
|
|
|
|
</span> */}
|
|
|
|
</a>
|
|
|
|
))}
|
|
|
|
</nav>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
2021-04-05 07:32:11 -07:00
|
|
|
|
2021-04-07 14:49:37 -07:00
|
|
|
const TabContent = ({ activeTab }) => {
|
|
|
|
switch (activeTab) {
|
|
|
|
case 'Orders':
|
|
|
|
return <OpenOrdersTable />
|
|
|
|
case 'Balances':
|
|
|
|
return <BalancesTable />
|
|
|
|
case 'Fee Discounts':
|
|
|
|
return <FeeDiscountsTable />
|
|
|
|
case 'Trade History':
|
|
|
|
return <TradeHistoryTable />
|
|
|
|
default:
|
|
|
|
return <OpenOrdersTable />
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-05 07:32:11 -07:00
|
|
|
const UserInfo = () => {
|
2021-04-05 14:38:59 -07:00
|
|
|
const [activeTab, setActiveTab] = useState(TABS[0])
|
2021-04-05 07:32:11 -07:00
|
|
|
|
|
|
|
return (
|
|
|
|
<FloatingElement>
|
2021-04-05 14:38:59 -07:00
|
|
|
<UserInfoTabs activeTab={activeTab} setActiveTab={setActiveTab} />
|
2021-04-07 14:49:37 -07:00
|
|
|
<TabContent activeTab={activeTab} />
|
2021-04-05 07:32:11 -07:00
|
|
|
</FloatingElement>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export default UserInfo
|