-
Notifications
You must be signed in to change notification settings - Fork 19
Wallet page #76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Wallet page #76
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
5ae1b12
fix: fix dark theme in wallet-sheet
Michaelkingsdev bd3fca4
feat(wallet): add full wallet page with balance, assets, activity, an…
Michaelkingsdev 80c36e4
Merge branch 'main' of https://github.com/Michaelkingsdev/bounties in…
Michaelkingsdev caf4338
fix: fix coderabbit corrections
Michaelkingsdev 64044f9
fix: fix coderabbit correction
Michaelkingsdev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| import type { Metadata } from "next"; | ||
|
|
||
| export const metadata: Metadata = { | ||
| title: "Wallet | Bounties", | ||
| description: "Manage your abstracted wallet, view assets, track earnings, and off-ramp funds directly to your bank account.", | ||
| }; | ||
|
|
||
| export default function WalletLayout({ | ||
| children, | ||
| }: { | ||
| children: React.ReactNode; | ||
| }) { | ||
| return <>{children}</>; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| "use client"; | ||
|
|
||
| import { WalletOverview } from "@/components/wallet/wallet-overview"; | ||
| import { BalanceCard } from "@/components/wallet/balance-card"; | ||
| import { AssetsList } from "@/components/wallet/assets-list"; | ||
| import { TransactionHistory } from "@/components/wallet/transaction-history"; | ||
| import { WithdrawalSection } from "@/components/wallet/withdrawal-section"; | ||
| import { SecuritySection } from "@/components/wallet/security-section"; | ||
| import { mockWalletWithAssets } from "@/lib/mock-wallet"; | ||
Michaelkingsdev marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"; | ||
|
|
||
| export default function WalletPage() { | ||
| return ( | ||
| <div className="container mx-auto max-w-6xl px-4 py-8 space-y-8"> | ||
| <div className="flex flex-col gap-2"> | ||
| <h1 className="text-3xl font-bold tracking-tight">Wallet</h1> | ||
| <p className="text-muted-foreground"> | ||
| Manage your earnings, assets, and withdrawals. | ||
| </p> | ||
| </div> | ||
|
|
||
| <div className="grid gap-8 lg:grid-cols-3"> | ||
| <div className="lg:col-span-2 space-y-8"> | ||
| <BalanceCard walletInfo={mockWalletWithAssets} /> | ||
|
|
||
| <Tabs defaultValue="assets" className="w-full"> | ||
| <TabsList className="mb-4"> | ||
| <TabsTrigger value="assets">Assets</TabsTrigger> | ||
| <TabsTrigger value="activity">Activity</TabsTrigger> | ||
| <TabsTrigger value="withdraw">Withdraw</TabsTrigger> | ||
| <TabsTrigger value="security">Security</TabsTrigger> | ||
| </TabsList> | ||
|
|
||
| <TabsContent value="assets" className="space-y-4"> | ||
| <AssetsList assets={mockWalletWithAssets.assets} /> | ||
| </TabsContent> | ||
|
|
||
| <TabsContent value="activity" className="space-y-4"> | ||
| <TransactionHistory activity={mockWalletWithAssets.recentActivity} /> | ||
| </TabsContent> | ||
|
|
||
| <TabsContent value="withdraw" className="space-y-4"> | ||
| <WithdrawalSection walletInfo={mockWalletWithAssets} /> | ||
| </TabsContent> | ||
|
|
||
| <TabsContent value="security" className="space-y-4"> | ||
| <SecuritySection walletInfo={mockWalletWithAssets} /> | ||
| </TabsContent> | ||
| </Tabs> | ||
| </div> | ||
|
|
||
| <div className="space-y-8"> | ||
| <WalletOverview walletInfo={mockWalletWithAssets} /> | ||
|
|
||
| <div className="rounded-xl border border-border bg-card p-6"> | ||
| <h3 className="font-semibold mb-4">Quick Links</h3> | ||
| <div className="grid gap-3"> | ||
| {/* TODO: Implement these routes */} | ||
| <span className="text-sm text-muted-foreground cursor-not-allowed">How it works?</span> | ||
| <span className="text-sm text-muted-foreground cursor-not-allowed">Fee Schedule</span> | ||
| <span className="text-sm text-muted-foreground cursor-not-allowed">Support Center</span> | ||
| </div> | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| </div> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| ); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,156 @@ | ||
| "use client"; | ||
|
|
||
| import { useState } from "react"; | ||
| import { WalletAsset } from "@/types/wallet"; | ||
| import { Input } from "@/components/ui/input"; | ||
| import { Search, ArrowUpDown, Filter } from "lucide-react"; | ||
| import { Button } from "@/components/ui/button"; | ||
|
|
||
| interface AssetsListProps { | ||
| assets: WalletAsset[]; | ||
| } | ||
|
|
||
| export function AssetsList({ assets }: AssetsListProps) { | ||
| const [search, setSearch] = useState(""); | ||
| const [hideSmallBalances, setHideSmallBalances] = useState(false); | ||
| const [sortConfig, setSortConfig] = useState<{ | ||
| key: 'tokenSymbol' | 'amount' | 'usdValue'; | ||
| direction: 'asc' | 'desc'; | ||
| }>({ key: 'usdValue', direction: 'desc' }); | ||
|
|
||
| const handleSort = (key: 'tokenSymbol' | 'amount' | 'usdValue') => { | ||
| setSortConfig(prev => ({ | ||
| key, | ||
| direction: prev.key === key && prev.direction === 'desc' ? 'asc' : 'desc' | ||
| })); | ||
| }; | ||
|
|
||
| const filteredAndSortedAssets = [...assets] | ||
| .filter(asset => { | ||
| const matchesSearch = asset.tokenName.toLowerCase().includes(search.toLowerCase()) || | ||
| asset.tokenSymbol.toLowerCase().includes(search.toLowerCase()); | ||
| const passesFilter = !hideSmallBalances || asset.usdValue >= 1; | ||
| return matchesSearch && passesFilter; | ||
| }) | ||
| .sort((a, b) => { | ||
| const aValue = a[sortConfig.key]; | ||
| const bValue = b[sortConfig.key]; | ||
|
|
||
| if (typeof aValue === 'string' && typeof bValue === 'string') { | ||
| return sortConfig.direction === 'asc' | ||
| ? aValue.localeCompare(bValue) | ||
| : bValue.localeCompare(aValue); | ||
| } | ||
|
|
||
| if (typeof aValue === 'number' && typeof bValue === 'number') { | ||
| return sortConfig.direction === 'asc' | ||
| ? aValue - bValue | ||
| : bValue - aValue; | ||
| } | ||
|
|
||
| return 0; | ||
| }); | ||
|
|
||
| const totalUsd = assets.reduce((acc, c) => acc + c.usdValue, 0); | ||
|
|
||
| const formatCurrency = (amount: number) => { | ||
| return new Intl.NumberFormat("en-US", { | ||
| style: "currency", | ||
| currency: "USD", | ||
| }).format(amount); | ||
| }; | ||
|
|
||
| return ( | ||
| <div className="space-y-4"> | ||
| <div className="flex flex-col sm:flex-row gap-4 items-center justify-between"> | ||
| <div className="relative w-full sm:max-w-xs"> | ||
| <Search className="absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground" /> | ||
| <Input | ||
| placeholder="Search assets..." | ||
| className="pl-9 bg-muted/50" | ||
| value={search} | ||
| onChange={(e) => setSearch(e.target.value)} | ||
| /> | ||
| </div> | ||
| <div className="flex items-center gap-2 w-full sm:w-auto"> | ||
| <Button | ||
| variant="outline" | ||
| size="sm" | ||
| className="flex-1 sm:flex-none" | ||
| onClick={() => handleSort('tokenSymbol')} | ||
| title="Sort by Symbol" | ||
| > | ||
| <ArrowUpDown className="mr-2 h-4 w-4" /> | ||
| Sort Symbol | ||
| </Button> | ||
| <Button | ||
| variant={hideSmallBalances ? "default" : "outline"} | ||
| size="sm" | ||
| className="flex-1 sm:flex-none" | ||
| onClick={() => setHideSmallBalances(!hideSmallBalances)} | ||
| title={hideSmallBalances ? "Showing only >$1" : "Filter small balances"} | ||
| > | ||
| <Filter className="mr-2 h-4 w-4" /> | ||
| {hideSmallBalances ? "Filtering" : "Filter"} | ||
| </Button> | ||
| </div> | ||
| </div> | ||
|
|
||
| <div className="rounded-xl border border-border overflow-hidden"> | ||
| <div className="overflow-x-auto"> | ||
| <table className="w-full text-sm"> | ||
| <thead className="bg-muted/50 border-b border-border"> | ||
| <tr> | ||
| <th className="text-left py-3 px-4 font-medium text-muted-foreground uppercase tracking-wider text-[10px]">Asset</th> | ||
| <th className="text-right py-3 px-4 font-medium text-muted-foreground uppercase tracking-wider text-[10px]">Balance</th> | ||
| <th className="text-right py-3 px-4 font-medium text-muted-foreground uppercase tracking-wider text-[10px]">Price</th> | ||
| <th className="text-right py-3 px-4 font-medium text-muted-foreground uppercase tracking-wider text-[10px]">Value</th> | ||
| <th className="text-right py-3 px-4 font-medium text-muted-foreground uppercase tracking-wider text-[10px] hidden md:table-cell">Portfolio %</th> | ||
| </tr> | ||
| </thead> | ||
| <tbody className="divide-y divide-border"> | ||
| {filteredAndSortedAssets.length === 0 ? ( | ||
| <tr> | ||
| <td colSpan={5} className="py-12 text-center text-muted-foreground"> | ||
| No assets found matching your search. | ||
| </td> | ||
| </tr> | ||
| ) : ( | ||
| filteredAndSortedAssets.map((asset) => ( | ||
| <tr key={asset.id} className="hover:bg-muted/30 transition-colors cursor-pointer group"> | ||
| <td className="py-4 px-4"> | ||
| <div className="flex items-center gap-3"> | ||
| <div className="flex h-10 w-10 items-center justify-center rounded-full bg-primary/10 text-xs font-bold text-primary-foreground dark:text-primary"> | ||
| {asset.tokenSymbol} | ||
| </div> | ||
| <div> | ||
| <div className="font-semibold">{asset.tokenSymbol}</div> | ||
| <div className="text-xs text-muted-foreground">{asset.tokenName}</div> | ||
| </div> | ||
| </div> | ||
| </td> | ||
| <td className="py-4 px-4 text-right"> | ||
| <div className="font-medium">{asset.amount.toLocaleString()}</div> | ||
| <div className="text-xs text-muted-foreground">{asset.tokenSymbol}</div> | ||
| </td> | ||
| <td className="py-4 px-4 text-right"> | ||
| {formatCurrency(asset.amount ? asset.usdValue / asset.amount : 0)} | ||
| </td> | ||
| <td className="py-4 px-4 text-right"> | ||
| <div className="font-medium">{formatCurrency(asset.usdValue)}</div> | ||
| </td> | ||
| <td className="py-4 px-4 text-right hidden md:table-cell"> | ||
| <div className="text-xs font-medium"> | ||
| {(totalUsd ? (asset.usdValue / totalUsd) * 100 : 0).toFixed(1)}% | ||
| </div> | ||
| </td> | ||
| </tr> | ||
| )) | ||
| )} | ||
| </tbody> | ||
| </table> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| ); | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.