feat(wallets): add isDefault field to wallet model and implement setDefaultWallet functionality
This commit is contained in:
@@ -5,6 +5,7 @@ import {
|
||||
ArrowUpDown,
|
||||
History,
|
||||
PencilLine,
|
||||
Star,
|
||||
} from "lucide-react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
@@ -14,6 +15,7 @@ import {
|
||||
TooltipTrigger,
|
||||
} from "@/components/ui/tooltip";
|
||||
import type { Wallet } from "@/lib/api";
|
||||
import { useSetDefaultWallet } from "@/lib/queries";
|
||||
import { DepositDialog } from "./DepositDialog";
|
||||
import { AdjustBalanceDialog } from "./AdjustBalanceDialog";
|
||||
import { TransferDialog } from "./TransferDialog";
|
||||
@@ -30,6 +32,7 @@ interface WalletCardProps {
|
||||
}
|
||||
|
||||
export function WalletCard({ wallet }: WalletCardProps) {
|
||||
const setDefaultWallet = useSetDefaultWallet();
|
||||
const [depositOpen, setDepositOpen] = useState(false);
|
||||
const [adjustOpen, setAdjustOpen] = useState(false);
|
||||
const [transferOpen, setTransferOpen] = useState(false);
|
||||
@@ -40,17 +43,48 @@ export function WalletCard({ wallet }: WalletCardProps) {
|
||||
<>
|
||||
<div className="rounded-lg border p-4 space-y-3">
|
||||
<div className="flex items-start justify-between">
|
||||
<div>
|
||||
<div className="flex items-center gap-2">
|
||||
<p className="font-medium">{wallet.name}</p>
|
||||
<p className="text-xs text-muted-foreground">{wallet.currency}</p>
|
||||
{wallet.isDefault && (
|
||||
<span className="rounded-full bg-primary/10 px-2 py-0.5 text-[10px] font-medium text-primary">
|
||||
Default
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
<div className="flex items-center gap-1">
|
||||
<TooltipProvider>
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setDefaultWallet.mutate(wallet.id)}
|
||||
className={`transition-colors cursor-pointer ${
|
||||
wallet.isDefault
|
||||
? "text-yellow-500 hover:text-yellow-600"
|
||||
: "text-muted-foreground hover:text-foreground"
|
||||
}`}
|
||||
>
|
||||
<Star
|
||||
className="size-4"
|
||||
fill={wallet.isDefault ? "currentColor" : "none"}
|
||||
/>
|
||||
</button>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent>
|
||||
{wallet.isDefault
|
||||
? "Billetera predeterminada"
|
||||
: "Marcar como predeterminada"}
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
</TooltipProvider>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setEditOpen(true)}
|
||||
className="text-muted-foreground hover:text-foreground transition-colors cursor-pointer"
|
||||
>
|
||||
<PencilLine className="size-4" />
|
||||
</button>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setEditOpen(true)}
|
||||
className="text-muted-foreground hover:text-foreground transition-colors cursor-pointer"
|
||||
>
|
||||
<PencilLine className="size-4" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<p className="text-2xl font-bold tabular-nums">
|
||||
|
||||
Reference in New Issue
Block a user