Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/common/table-container-with-header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export function TableContainerWithHeader({ title, actions, children, className =
<h3 className="font-monospace text-xs uppercase text-secondary">{title}</h3>
{actions && <div className="flex items-center gap-2">{actions}</div>}
</div>
<div className="overflow-x-auto">{children}</div>
<div className="overflow-x-auto pb-4">{children}</div>
</div>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export function CollateralView({ allocations, totalAllocation, vaultAssetSymbol,
<span className="text-sm whitespace-nowrap">{item.collateralSymbol}</span>
</div>
</TableCell>
<TableCell className="p-3 rounded-r align-middle">
<TableCell className="p-3 rounded-r align-middle text-sm">
<AllocationCell
amount={allocatedAmount}
symbol={vaultAssetSymbol}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export function MarketView({ allocations, totalAllocation, vaultAssetSymbol, vau
{/* Market Info Column */}
<TableCell className="p-3 rounded-l">
<MarketIdentity
showId
market={market}
chainId={chainId}
focus={MarketIdentityFocus.Collateral}
Expand All @@ -78,7 +79,7 @@ export function MarketView({ allocations, totalAllocation, vaultAssetSymbol, vau
<TableCell className="p-3 text-right text-xs text-secondary whitespace-nowrap">{liquidity}</TableCell>

{/* Allocation */}
<TableCell className="p-3 rounded-r align-middle">
<TableCell className="p-3 rounded-r align-middle text-sm">
<AllocationCell
amount={allocatedAmount}
symbol={vaultAssetSymbol}
Expand Down
76 changes: 63 additions & 13 deletions src/features/autovault/vault-list-view.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
'use client';

import { useState, useEffect, useMemo } from 'react';
import { FaPlus } from 'react-icons/fa';
import { GoPlusCircle } from 'react-icons/go';
import { FiShield, FiZap, FiSettings } from 'react-icons/fi';
import { ChevronDownIcon } from '@radix-ui/react-icons';
import { useRouter } from 'next/navigation';
import { useAppKit } from '@reown/appkit/react';
import { useConnection } from 'wagmi';
import { Button } from '@/components/ui/button';
import { Avatar } from '@/components/Avatar/Avatar';
import { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem } from '@/components/ui/dropdown-menu';
import Header from '@/components/layout/header/Header';
import { fetchUserVaultV2AddressesAllNetworks } from '@/data-sources/subgraph/v2-vaults';
import { getDeployedVaults } from '@/utils/vault-storage';
Expand Down Expand Up @@ -133,14 +136,18 @@ export default function AutovaultListContent() {
return combined;
}, [vaultAddresses, address]);

const handleManageVault = () => {
if (mergedVaultAddresses.length > 0) {
const handleManageVault = (vaultAddress?: string, networkId?: number) => {
if (vaultAddress && networkId) {
router.push(`/autovault/${networkId}/${vaultAddress}`);
} else if (mergedVaultAddresses.length > 0) {
const firstVault = mergedVaultAddresses[0];
router.push(`/autovault/${firstVault.networkId}/${firstVault.address}`);
}
};

const hasVaults = mergedVaultAddresses.length > 0;
const hasSingleVault = mergedVaultAddresses.length === 1;
const hasMultipleVaults = mergedVaultAddresses.length > 1;

return (
<div className="flex w-full flex-col justify-between font-zen">
Expand Down Expand Up @@ -177,21 +184,64 @@ export default function AutovaultListContent() {
{/* Actions for users with existing vaults */}
{isConnected && hasVaults && (
<div className="flex items-center justify-center gap-3 pt-4">
<Button
variant="primary"
size="lg"
className="font-zen px-8"
onClick={handleManageVault}
>
Manage Vault
</Button>
{/* Single vault - show avatar with address */}
{hasSingleVault && (
<Button
variant="primary"
size="lg"
className="font-zen px-6"
onClick={() => handleManageVault()}
>
<Avatar
address={mergedVaultAddresses[0].address as `0x${string}`}
size={20}
/>
<span className="ml-2">Manage {mergedVaultAddresses[0].address.slice(0, 6)}</span>
</Button>
)}

{/* Multiple vaults - show dropdown */}
{hasMultipleVaults && (
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button
variant="primary"
size="lg"
className="font-zen px-6"
>
<Avatar
address={mergedVaultAddresses[0].address as `0x${string}`}
size={20}
/>
<span className="ml-2">Manage {mergedVaultAddresses[0].address.slice(0, 6)}</span>
<ChevronDownIcon className="ml-2 h-4 w-4" />
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="center">
{mergedVaultAddresses.map((vault) => (
<DropdownMenuItem
key={`${vault.networkId}-${vault.address}`}
onClick={() => handleManageVault(vault.address, vault.networkId)}
className="cursor-pointer"
>
<Avatar
address={vault.address as `0x${string}`}
size={16}
/>
<span className="ml-2">{vault.address.slice(0, 6)}</span>
</DropdownMenuItem>
))}
</DropdownMenuContent>
</DropdownMenu>
)}

<Button
variant="default"
size="lg"
className="font-zen px-8"
onClick={handleCreateVault}
>
<FaPlus
<GoPlusCircle
size={16}
className="mr-2"
/>
Expand All @@ -210,7 +260,7 @@ export default function AutovaultListContent() {
className="font-zen px-8"
onClick={handleCreateVault}
>
<FaPlus
<GoPlusCircle
size={16}
className="mr-2"
/>
Expand Down
Loading