Skip to content

Commit 52f4e8f

Browse files
Rakib AnsaryRakib Ansary
Rakib Ansary
authored and
Rakib Ansary
committed
feat(wallet-admin): add dashboard & payment listing
1 parent 56f2a72 commit 52f4e8f

File tree

134 files changed

+3936
-3
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

134 files changed

+3936
-3
lines changed

.circleci/config.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ workflows:
257257
branches:
258258
only:
259259
- dev
260-
- TSJR-314_skill-manager_landing-page
260+
- feat/wallet-admin
261261

262262
- deployQa:
263263
context: org-global

craco.config.js

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ module.exports = {
4444
'@talentSearch': resolve('src/apps/talent-search/src'),
4545
'@profiles': resolve('src/apps/profiles/src'),
4646
'@wallet': resolve('src/apps/wallet/src'),
47+
'@walletAdmin': resolve('src/apps/wallet-admin/src'),
4748

4849
'@platform': resolve('src/apps/platform/src'),
4950
// aliases used in SCSS files

src/apps/platform/src/platform.routes.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { accountsRoutes } from '~/apps/accounts'
1111
import { onboardingRoutes } from '~/apps/onboarding'
1212
import { adminRoutes } from '~/apps/admin'
1313
import { walletRoutes } from '~/apps/wallet'
14+
import { walletAdminRoutes } from '~/apps/wallet-admin'
1415

1516
const Home: LazyLoadedComponent = lazyLoad(
1617
() => import('./routes/home'),
@@ -38,6 +39,7 @@ export const platformRoutes: Array<PlatformRoute> = [
3839
...talentSearchRoutes,
3940
...profilesRoutes,
4041
...walletRoutes,
42+
...walletAdminRoutes,
4143
...accountsRoutes,
4244
...adminRoutes,
4345
...homeRoutes,

src/apps/wallet-admin/.prettierrc

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"semi": false,
3+
"trailingComma": "all",
4+
"jsxSingleQuote": true,
5+
"jsxBracketSameLine": true,
6+
"printWidth": 120
7+
}

src/apps/wallet-admin/README.md

Whitespace-only changes.

src/apps/wallet-admin/index.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './src'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { FC, useContext } from 'react'
2+
import { Outlet, Routes } from 'react-router-dom'
3+
4+
import { routerContext, RouterContextData } from '~/libs/core'
5+
6+
import { toolTitle } from './wallet-admin.routes'
7+
import { WalletSwr } from './lib'
8+
9+
const AccountsApp: FC<{}> = () => {
10+
const { getChildRoutes }: RouterContextData = useContext(routerContext)
11+
12+
return (
13+
<WalletSwr>
14+
<Outlet />
15+
<Routes>{getChildRoutes(toolTitle)}</Routes>
16+
</WalletSwr>
17+
)
18+
}
19+
20+
export default AccountsApp
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { FC, useContext } from 'react'
2+
3+
import { profileContext, ProfileContextData } from '~/libs/core'
4+
import { LoadingSpinner } from '~/libs/ui'
5+
6+
import { WalletAdminLayout } from './page-layout'
7+
8+
const AccountSettingsPage: FC<{}> = () => {
9+
const { profile, initialized }: ProfileContextData = useContext(profileContext)
10+
11+
return (
12+
<>
13+
<LoadingSpinner hide={initialized} />
14+
{initialized && profile && <WalletAdminLayout profile={profile} />}
15+
</>
16+
)
17+
}
18+
19+
export default AccountSettingsPage
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default as WalletHomePage } from './WalletAdminHomePage'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
@import '@libs/ui/styles/includes';
2+
3+
.contentLayoutOuter {
4+
margin: $sp-8 auto !important;
5+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { FC } from 'react'
2+
3+
import { UserProfile } from '~/libs/core'
4+
import { ContentLayout } from '~/libs/ui'
5+
6+
import { WalletAdminTabs } from '../tabs'
7+
8+
import styles from './WalletAdminLayout.module.scss'
9+
10+
interface WalletHomeLayoutProps {
11+
profile: UserProfile
12+
}
13+
14+
const WalletAdminLayout: FC<WalletHomeLayoutProps> = (props: WalletHomeLayoutProps) => (
15+
<ContentLayout outerClass={styles.contentLayoutOuter}>
16+
<WalletAdminTabs profile={props.profile} />
17+
</ContentLayout>
18+
)
19+
20+
export default WalletAdminLayout
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default as WalletAdminLayout } from './WalletAdminLayout'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
@import '@libs/ui/styles/includes';
2+
3+
.container {
4+
form {
5+
@include ltelg {
6+
:global(.input-el) {
7+
margin-bottom: $sp-4;
8+
}
9+
}
10+
}
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import { Dispatch, FC, SetStateAction, useEffect, useMemo, useState } from 'react'
2+
import { useLocation } from 'react-router-dom'
3+
4+
import { UserProfile } from '~/libs/core'
5+
import { PageTitle, TabsNavbar, TabsNavItem } from '~/libs/ui'
6+
7+
import { getHashFromTabId, getTabIdFromHash, WalletAdminTabsConfig, WalletAdminTabViews } from './config'
8+
import { PaymentsTab } from './payments'
9+
import { HomeTab } from './home'
10+
import styles from './WalletAdminTabs.module.scss'
11+
12+
interface WalletHomeProps {
13+
profile: UserProfile
14+
}
15+
16+
const WalletAdminTabs: FC<WalletHomeProps> = (props: WalletHomeProps) => {
17+
const { hash }: { hash: string } = useLocation()
18+
19+
const activeTabHash: string = useMemo<string>(() => getTabIdFromHash(hash), [hash])
20+
21+
const [activeTab, setActiveTab]: [string, Dispatch<SetStateAction<string>>] = useState<string>(activeTabHash)
22+
23+
useEffect(() => {
24+
setActiveTab(activeTabHash)
25+
}, [activeTabHash])
26+
27+
function handleTabChange(tabId: string): void {
28+
setActiveTab(tabId)
29+
window.location.hash = getHashFromTabId(tabId)
30+
}
31+
32+
return (
33+
<div className={styles.container}>
34+
<TabsNavbar defaultActive={activeTab} onChange={handleTabChange} tabs={WalletAdminTabsConfig} />
35+
36+
<PageTitle>
37+
{[
38+
WalletAdminTabsConfig.find((tab: TabsNavItem) => tab.id === activeTab)?.title,
39+
'Wallet',
40+
'Topcoder',
41+
].join(' | ')}
42+
</PageTitle>
43+
44+
{activeTab === WalletAdminTabViews.home && <HomeTab profile={props.profile} />}
45+
46+
{activeTab === WalletAdminTabViews.payments && <PaymentsTab profile={props.profile} />}
47+
</div>
48+
)
49+
}
50+
51+
export default WalletAdminTabs
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './wallet-tabs-config'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import { TabsNavItem } from '~/libs/ui'
2+
3+
export enum WalletAdminTabViews {
4+
home = '0',
5+
payments = '1',
6+
// taxforms = '2',
7+
// withdrawalmethods = '3',
8+
}
9+
10+
export const WalletAdminTabsConfig: TabsNavItem[] = [
11+
{
12+
id: WalletAdminTabViews.home,
13+
title: 'Dashboard',
14+
},
15+
{
16+
id: WalletAdminTabViews.payments,
17+
title: 'Payments',
18+
},
19+
// {
20+
// id: WalletAdminTabViews.withdrawalmethods,
21+
// title: 'Withdrawal Methods',
22+
// },
23+
// {
24+
// id: WalletAdminTabViews.taxforms,
25+
// title: 'Tax Forms',
26+
// },
27+
]
28+
29+
export function getHashFromTabId(tabId: string): string {
30+
switch (tabId) {
31+
case WalletAdminTabViews.home:
32+
return '#home'
33+
case WalletAdminTabViews.payments:
34+
return '#payments'
35+
// case WalletAdminTabViews.taxforms:
36+
// return '#tax-forms'
37+
// case WalletAdminTabViews.withdrawalmethods:
38+
// return '#withdrawal-methods'
39+
default:
40+
return '#home'
41+
}
42+
}
43+
44+
export function getTabIdFromHash(hash: string): string {
45+
switch (hash) {
46+
case '#winnings':
47+
return WalletAdminTabViews.payments
48+
// case '#tax-forms':
49+
// return WalletAdminTabViews.taxforms
50+
// case '#withdrawal-methods':
51+
// return WalletAdminTabViews.withdrawalmethods
52+
default:
53+
return WalletAdminTabViews.home
54+
}
55+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
@import '@libs/ui/styles/includes';
2+
3+
.container {
4+
background-color: $black-5;
5+
padding: 100px 32px;
6+
margin: $sp-8 0;
7+
border-radius: 8px;
8+
display: flex;
9+
flex-direction: column;
10+
gap: 50px;
11+
box-sizing: border-box;
12+
}
13+
14+
.banner {
15+
display: flex;
16+
justify-content: center;
17+
align-items: center;
18+
flex-wrap: wrap;
19+
& > * {
20+
flex: 1 1 auto;
21+
display: flex;
22+
justify-content: center;
23+
align-items: center;
24+
}
25+
}
26+
27+
@media (max-width: 768px) {
28+
.banner {
29+
flex-direction: column;
30+
}
31+
}
32+
33+
.info-row-container {
34+
display: flex;
35+
flex-direction: column;
36+
gap: 20px;
37+
padding-left: 50px;
38+
padding-right: 50px;
39+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/* eslint-disable react/jsx-wrap-multilines */
2+
import { FC, useEffect, useState } from 'react'
3+
4+
import { UserProfile } from '~/libs/core'
5+
import { IconOutline, LinkButton, LoadingCircles } from '~/libs/ui'
6+
7+
import { Balance, WalletDetails } from '../../../lib/models/WalletDetails'
8+
import { getWalletDetails } from '../../../lib/services/wallet'
9+
import { InfoRow } from '../../../lib'
10+
import { BannerImage, BannerText } from '../../../lib/assets/home'
11+
import Chip from '../../../lib/components/chip/Chip'
12+
13+
import styles from './Home.module.scss'
14+
15+
interface HomeTabProps {
16+
profile: UserProfile
17+
}
18+
19+
const HomeTab: FC<HomeTabProps> = () => (
20+
<div className={styles.container}>
21+
<div className={styles.banner}>
22+
<BannerText />
23+
<BannerImage />
24+
</div>
25+
</div>
26+
)
27+
28+
export default HomeTab
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default as HomeTab } from './HomeTab'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default as WalletAdminTabs } from './WalletAdminTabs'

0 commit comments

Comments
 (0)