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
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { HyperdriveConfig } from "@delvtech/hyperdrive-appconfig";
import { Cog8ToothIcon } from "@heroicons/react/20/solid";
import { Link } from "@tanstack/react-router";
import { ReactElement, useRef, useState } from "react";
import { useClickAway } from "react-use";
import { MARKET_DETAILS_ROUTE } from "src/ui/markets/routes";

export function ManageShortButton({
hyperdrive,
assetId,
}: {
hyperdrive: HyperdriveConfig;
assetId: bigint;
}): ReactElement {
const [isOpen, setIsOpen] = useState(false);
const dropdownRef = useRef<HTMLDivElement>(null);
useClickAway(dropdownRef, () => setIsOpen(false));
return (
<div
className="relative flex w-full items-center font-inter"
ref={dropdownRef}
>
<button
onClick={() => setIsOpen(!isOpen)}
className="daisy-btn daisy-btn-ghost rounded-full bg-gray-600 hover:bg-gray-700"
>
<Cog8ToothIcon className="h-5" />
Manage
</button>
{isOpen && (
<ul className="absolute right-6 top-full z-50 mt-4 w-[300px] rounded-box border border-neutral-content/20 bg-neutral px-4 py-1">
<button
className="m-0 flex h-[52px] w-full flex-row items-center justify-start border-b-2 border-b-neutral-content/20 p-0 text-start hover:bg-neutral hover:text-neutral-content"
onClick={() => {
const modalId = `${assetId}`;
(
document.getElementById(modalId) as HTMLDialogElement
).showModal();
}}
>
Close Short
</button>
<Link
className="m-0 flex h-[52px] w-full flex-row items-center justify-start p-0 text-start hover:bg-neutral hover:text-neutral-content"
to={MARKET_DETAILS_ROUTE}
params={{
chainId: hyperdrive.chainId.toString(),
address: hyperdrive.address,
}}
search={{ position: "short" }}
>
Go to pool
</Link>
</ul>
)}
</div>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
HyperdriveConfig,
} from "@delvtech/hyperdrive-appconfig";
import { OpenShort } from "@delvtech/hyperdrive-viem";
import { Cog8ToothIcon } from "@heroicons/react/20/solid";
import { ChevronDownIcon, ChevronUpIcon } from "@heroicons/react/24/outline";
import { Link } from "@tanstack/react-router";
import {
Expand All @@ -28,6 +27,7 @@ import { MaturesOnCellTwo } from "src/ui/hyperdrive/MaturesOnCell/MaturesOnCell"
import { StatusCell } from "src/ui/hyperdrive/longs/OpenLongsTable/StatusCell";
import { CloseShortModalButton } from "src/ui/hyperdrive/shorts/CloseShortModalButton/CloseShortModalButton";
import { CurrentShortsValueCell } from "src/ui/hyperdrive/shorts/OpenShortsTable/CurrentShortsValueCell";
import { ManageShortButton } from "src/ui/hyperdrive/shorts/OpenShortsTable/ManageShortButton";
import { ShortRateAndSizeCell } from "src/ui/hyperdrive/shorts/OpenShortsTable/ShortRateAndSizeCell";
import { TotalOpenShortValue } from "src/ui/hyperdrive/shorts/OpenShortsTable/TotalOpenShortsValue";
import { usePortfolioShortsData } from "src/ui/portfolio/usePortfolioShortsData";
Expand Down Expand Up @@ -372,20 +372,10 @@ function getColumns({
id: "go-to-market",
cell: ({ row }) => {
return (
<div className="flex w-full items-center font-inter">
<button
className="daisy-btn daisy-btn-ghost rounded-full bg-gray-600 hover:bg-gray-700"
onClick={() => {
const modalId = `${row.original.assetId}`;
(
document.getElementById(modalId) as HTMLDialogElement
).showModal();
}}
>
<Cog8ToothIcon className="h-5" />
Manage
</button>
</div>
<ManageShortButton
hyperdrive={hyperdrive}
assetId={row.original.assetId}
/>
);
},
}),
Expand Down
Loading