Skip to content

Commit

Permalink
fix: added actioncomplete to lend borrow actionbox
Browse files Browse the repository at this point in the history
  • Loading branch information
k0beLeenders committed Sep 27, 2024
1 parent 7b42685 commit 5e34414
Showing 1 changed file with 47 additions and 10 deletions.
57 changes: 47 additions & 10 deletions apps/marginfi-v2-ui/src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import dynamic from "next/dynamic";
import { useRouter } from "next/router";

import { shortenAddress } from "@mrgnlabs/mrgn-common";
import { Desktop, Mobile } from "@mrgnlabs/mrgn-utils";
import { capture, Desktop, Mobile } from "@mrgnlabs/mrgn-utils";
import { ActionType } from "@mrgnlabs/marginfi-v2-ui-state";
import { ActionBox } from "@mrgnlabs/mrgn-ui";

Expand Down Expand Up @@ -33,7 +33,15 @@ const AssetsList = dynamic(async () => (await import("~/components/desktop/Asset
export default function HomePage() {
const router = useRouter();
const { walletContextState, walletAddress, isOverride, connected } = useWallet();
const [previousTxn, setIsWalletOpen] = useUiStore((state) => [state.previousTxn, state.setIsWalletOpen]);
const [previousTxn, setIsWalletOpen, setIsWalletAuthDialogOpen, setPreviousTxn, setIsActionComplete] = useUiStore(
(state) => [
state.previousTxn,
state.setIsWalletOpen,
state.setIsWalletAuthDialogOpen,
state.setPreviousTxn,
state.setIsActionComplete,
]
);
const [
marginfiClient,
isStoreInitialized,
Expand All @@ -51,6 +59,7 @@ export default function HomePage() {
state.accountSummary,
state.nativeSolBalance,
]);

const [actionMode, refreshState] = useActionBoxStore()((state) => [state.actionMode, state.refreshState]);
const [isStateReset, setIsStateReset] = React.useState(false);

Expand Down Expand Up @@ -108,11 +117,25 @@ export default function HomePage() {
selectedAccount,
banks: extendedBankInfos,
accountSummary: accountSummary,
onComplete: () => {},
connected: connected,
captureEvent: () => {},
onConnect: () => {},
walletContextState: walletContextState,
connected: connected,

onComplete: (previousTxn) => {
// TODO refactor previousTxn to be more like tradingui
if (previousTxn.txnType !== "LEND") return;
setIsActionComplete(true);

setPreviousTxn({
type: previousTxn.lendingOptions.type,
bank: previousTxn.lendingOptions.bank,
amount: previousTxn.lendingOptions.amount,
txn: previousTxn.txn,
});
},
captureEvent: (event, properties) => {
capture(event, properties);
},
onConnect: () => setIsWalletAuthDialogOpen(true),
}}
/>
</div>
Expand Down Expand Up @@ -141,11 +164,25 @@ export default function HomePage() {
selectedAccount,
banks: extendedBankInfos,
accountSummary: accountSummary,
onComplete: () => {},
connected: false,
captureEvent: () => {},
onConnect: () => {},
walletContextState: walletContextState,
connected: connected,

onComplete: (previousTxn) => {
// TODO refactor previousTxn to be more like tradingui
if (previousTxn.txnType !== "LEND") return;
setIsActionComplete(true);

setPreviousTxn({
type: previousTxn.lendingOptions.type,
bank: previousTxn.lendingOptions.bank,
amount: previousTxn.lendingOptions.amount,
txn: previousTxn.txn,
});
},
captureEvent: (event, properties) => {
capture(event, properties);
},
onConnect: () => setIsWalletAuthDialogOpen(true),
}}
/>
</div>
Expand Down

0 comments on commit 5e34414

Please sign in to comment.