forked from burrowfdn/burrow-cash
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'add-margin-trading' into add-marginTrading-interface
- Loading branch information
Showing
12 changed files
with
862 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import React from "react"; | ||
import { createRoot } from "react-dom/client"; | ||
import ModalWithCountdown from "./ModalWithCountdown"; | ||
|
||
interface ShowPositionResultParams { | ||
title?: string; | ||
type?: "Long" | "Short"; | ||
price?: string; | ||
transactionHashes?: string; | ||
positionSize?: { | ||
amount: string; | ||
symbol: string; | ||
usdValue: string; | ||
}; | ||
} | ||
|
||
let container: HTMLDivElement | null = null; | ||
let root: ReturnType<typeof createRoot> | null = null; | ||
|
||
export const showPositionResult = (params: ShowPositionResultParams) => { | ||
if (params.transactionHashes) { | ||
const shownTxs = localStorage.getItem("shownTransactions") || "[]"; | ||
const shownTxArray = JSON.parse(shownTxs); | ||
|
||
if (shownTxArray.includes(params.transactionHashes)) { | ||
return; | ||
} | ||
|
||
shownTxArray.push(params.transactionHashes); | ||
if (shownTxArray.length > 100) { | ||
shownTxArray.shift(); | ||
} | ||
localStorage.setItem("shownTransactions", JSON.stringify(shownTxArray)); | ||
} | ||
|
||
if (!container) { | ||
container = document.createElement("div"); | ||
container.id = "position-result-container"; | ||
document.body.appendChild(container); | ||
root = createRoot(container); | ||
} | ||
|
||
const handleClose = () => { | ||
if (root) { | ||
root.unmount(); | ||
} | ||
if (container) { | ||
container.remove(); | ||
container = null; | ||
root = null; | ||
} | ||
}; | ||
|
||
root?.render(<ModalWithCountdown show onClose={handleClose} {...params} />); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.