Skip to content

Commit

Permalink
Extract type
Browse files Browse the repository at this point in the history
  • Loading branch information
mattupham committed Sep 12, 2024
1 parent c635062 commit 14ee05b
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions packages/web/components/table/asset-balances.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { useLocalStorage } from "react-use";

import { AssetCell } from "~/components/table/cells/asset";
import { SpriteIconId } from "~/config";
import { MultiLanguageT } from "~/hooks";
import {
Breakpoint,
useFeatureFlags,
Expand Down Expand Up @@ -58,6 +59,8 @@ type SortKey = NonNullable<
RouterInputs["edge"]["assets"]["getUserBridgeAssets"]["sort"]
>["keyPath"];

type Action = "deposit" | "withdraw" | "trade" | "earn";

const DUST_THRESHOLD = new Dec(0.01);

export const AssetBalancesTable: FunctionComponent<{
Expand Down Expand Up @@ -234,7 +237,6 @@ export const AssetBalancesTable: FunctionComponent<{

const table = useReactTable({
data: filteredAssetsData,
// @ts-expect-error
columns: collapsedColumns,
manualSorting: true,
manualFiltering: true,
Expand Down Expand Up @@ -490,10 +492,7 @@ const PriceCell: AssetCellComponent = ({ currentPrice, priceChange24h }) => (
</div>
);

const getActionOptions = (
t: (key: string) => string,
showConvertButton: boolean
) => {
const getActionOptions = (t: MultiLanguageT, showConvertButton: boolean) => {
return [
...(showConvertButton
? [
Expand All @@ -503,7 +502,7 @@ const getActionOptions = (
: []),
{ key: "trade", label: t("portfolio.trade") },
{ key: "earn", label: t("portfolio.earn") },
];
] as Array<{ key: Action; label: string }>;
};

const handleSelectAction = (
Expand Down Expand Up @@ -639,8 +638,11 @@ export const AssetActionsCell: AssetCellComponent<{
};

const AssetActionsDropdown: FunctionComponent<{
actionOptions: { key: string; label: string }[];
onSelectAction: (key: string) => void;
actionOptions: {
key: Action;
label: string;
}[];
onSelectAction: (key: Action) => void;
}> = ({ actionOptions, onSelectAction }) => {
return (
<Popover className="relative shrink-0">
Expand Down Expand Up @@ -686,7 +688,7 @@ const AssetActionsDropdown: FunctionComponent<{
);
};

const getIconId = (key: string): SpriteIconId => {
const getIconId = (key: Action): SpriteIconId => {
switch (key) {
case "deposit":
return "deposit";
Expand All @@ -696,7 +698,5 @@ const getIconId = (key: string): SpriteIconId => {
return "arrows-swap";
case "earn":
return "chart-up";
default:
return "dots-three-vertical"; // fallback icon
}
};

0 comments on commit 14ee05b

Please sign in to comment.