From a85c4f96b98e0a8bcf0af9b01a051dae7e57d1c8 Mon Sep 17 00:00:00 2001 From: Farabi Date: Tue, 18 Feb 2025 18:41:12 +0800 Subject: [PATCH] fix: position page and account switcher --- .../AccountSwitcher/AccountSwitcher.tsx | 8 ++++---- src/components/ui/account-popover.tsx | 8 ++++---- src/screens/PositionsPage/PositionsPage.tsx | 18 +++++++++++++----- 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/src/components/AccountSwitcher/AccountSwitcher.tsx b/src/components/AccountSwitcher/AccountSwitcher.tsx index e2dc6be..a743881 100644 --- a/src/components/AccountSwitcher/AccountSwitcher.tsx +++ b/src/components/AccountSwitcher/AccountSwitcher.tsx @@ -4,12 +4,12 @@ import { useClientStore } from '@/stores/clientStore'; import { useAccount } from '@/hooks/useAccount'; import { AccountPopover, AccountPopoverContent, AccountPopoverTrigger } from '@/components/ui/account-popover'; import { AccountInfo } from './AccountInfo'; -import { useDeviceDetection } from '@/hooks/useDeviceDetection'; +import { useOrientationStore } from '@/stores/orientationStore'; export const AccountSwitcher: React.FC = () => { const { balance } = useClientStore(); const { accountType, selectedAccount } = useAccount(); - const { isDesktop } = useDeviceDetection(); + const { isLandscape } = useOrientationStore(); const [isOpen, setIsOpen] = useState(false); return ( @@ -18,7 +18,7 @@ export const AccountSwitcher: React.FC = () => { diff --git a/src/components/ui/account-popover.tsx b/src/components/ui/account-popover.tsx index 2709c48..7b95a8c 100644 --- a/src/components/ui/account-popover.tsx +++ b/src/components/ui/account-popover.tsx @@ -1,6 +1,6 @@ import * as Popover from "@radix-ui/react-popover" import { cn } from "@/lib/utils" -import { useDeviceDetection } from "@/hooks/useDeviceDetection" +import { useOrientationStore } from "@/stores/orientationStore" export const AccountPopover = Popover.Root export const AccountPopoverTrigger = Popover.Trigger @@ -11,12 +11,12 @@ export const AccountPopoverContent = ({ sideOffset = 4, ...props }: Popover.PopoverContentProps) => { - const { isDesktop } = useDeviceDetection() + const { isLandscape } = useOrientationStore() return ( <> - {!isDesktop && ( + {!isLandscape && (
@@ -26,7 +26,7 @@ export const AccountPopoverContent = ({ sideOffset={sideOffset} className={cn( "z-50 rounded-md border bg-white p-0 shadow-md outline-none", - isDesktop ? "w-80" : "w-[90vw]", + isLandscape ? "w-80" : "w-[90vw]", "data-[state=open]:animate-in data-[state=closed]:animate-out", "data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0", "data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95", diff --git a/src/screens/PositionsPage/PositionsPage.tsx b/src/screens/PositionsPage/PositionsPage.tsx index 9b2912f..552da2f 100644 --- a/src/screens/PositionsPage/PositionsPage.tsx +++ b/src/screens/PositionsPage/PositionsPage.tsx @@ -56,17 +56,25 @@ const PositionsPage: React.FC = () => { }, [swipedCard]); return ( -
+
{/* Tabs */} -
+
{/* Positions List */} -
+
{positions .filter((position) => (activeTab === "open" ? position.isOpen : !position.isOpen)) .map((position) => {