Browse Source

Merge #660

660: Move wallet info out of navbar into main screen r=bonomat a=bonomat

resolves #519
resolves #536

![image](https://user-images.githubusercontent.com/224613/142798202-f661ab9d-7812-4fdb-854d-123df2222528.png)


Co-authored-by: bonomat <philipp@hoenisch.at>
debug-collab-settlement
bors[bot] 3 years ago
committed by GitHub
parent
commit
2de980b12c
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 16
      taker-frontend/src/App.tsx
  2. 3
      taker-frontend/src/components/NavBar.tsx
  3. 18
      taker-frontend/src/components/Wallet.tsx

16
taker-frontend/src/App.tsx

@ -5,6 +5,7 @@ import {
AccordionItem, AccordionItem,
AccordionPanel, AccordionPanel,
Box, Box,
Center,
StackDivider, StackDivider,
useToast, useToast,
VStack, VStack,
@ -33,7 +34,7 @@ import {
StateGroupKey, StateGroupKey,
WalletInfo, WalletInfo,
} from "./components/Types"; } from "./components/Types";
import { Wallet } from "./components/Wallet"; import { Wallet, WalletInfoBar } from "./components/Wallet";
import useLatestEvent from "./Hooks"; import useLatestEvent from "./Hooks";
async function getMargin(payload: MarginRequestPayload): Promise<MarginResponse> { async function getMargin(payload: MarginRequestPayload): Promise<MarginResponse> {
@ -138,7 +139,11 @@ export const App = () => {
<Route path="/wallet" element={<Wallet walletInfo={walletInfo} />} /> <Route path="/wallet" element={<Wallet walletInfo={walletInfo} />} />
<Route <Route
path="/" path="/"
element={<VStack divider={<StackDivider borderColor="gray.500" />} spacing={4}> element={<>
<Center>
<WalletInfoBar walletInfo={walletInfo} />
</Center>
<VStack divider={<StackDivider borderColor="gray.500" />} spacing={4}>
<Trade <Trade
orderId={order?.id} orderId={order?.id}
quantity={format(effectiveQuantity)} quantity={format(effectiveQuantity)}
@ -184,12 +189,15 @@ export const App = () => {
</h2> </h2>
<AccordionPanel pb={4}> <AccordionPanel pb={4}>
<History <History
cfds={cfds.filter((cfd) => cfd.state.getGroup() === StateGroupKey.CLOSED)} cfds={cfds.filter((cfd) =>
cfd.state.getGroup() === StateGroupKey.CLOSED
)}
/> />
</AccordionPanel> </AccordionPanel>
</AccordionItem> </AccordionItem>
</Accordion> </Accordion>
</VStack>} </VStack>
</>}
/> />
</Routes> </Routes>
</Box> </Box>

3
taker-frontend/src/components/NavBar.tsx

@ -17,7 +17,6 @@ import { useNavigate } from "react-router-dom";
import logoBlack from "../images/logo_nav_bar_black.svg"; import logoBlack from "../images/logo_nav_bar_black.svg";
import logoWhite from "../images/logo_nav_bar_white.svg"; import logoWhite from "../images/logo_nav_bar_white.svg";
import { WalletInfo } from "./Types"; import { WalletInfo } from "./Types";
import { WalletNavBar } from "./Wallet";
interface NavProps { interface NavProps {
walletInfo: WalletInfo | null; walletInfo: WalletInfo | null;
@ -57,8 +56,6 @@ export default function Nav({ walletInfo }: NavProps) {
</MenuList> </MenuList>
</Menu> </Menu>
<WalletNavBar walletInfo={walletInfo} />
<Flex alignItems={"center"}> <Flex alignItems={"center"}>
<Stack direction={"row"} spacing={7}> <Stack direction={"row"} spacing={7}>
<Button onClick={toggleColorMode} bg={"transparent"}> <Button onClick={toggleColorMode} bg={"transparent"}>

18
taker-frontend/src/components/Wallet.tsx

@ -1,6 +1,7 @@
import { CheckIcon, CopyIcon } from "@chakra-ui/icons"; import { CheckIcon, CopyIcon, ExternalLinkIcon } from "@chakra-ui/icons";
import { Box, Center, Divider, HStack, IconButton, Skeleton, Text, useClipboard } from "@chakra-ui/react"; import { Box, Center, Divider, HStack, IconButton, Skeleton, Text, useClipboard } from "@chakra-ui/react";
import * as React from "react"; import * as React from "react";
import { useNavigate } from "react-router-dom";
import Timestamp from "./Timestamp"; import Timestamp from "./Timestamp";
import { WalletInfo } from "./Types"; import { WalletInfo } from "./Types";
@ -49,19 +50,28 @@ export default function Wallet(
); );
} }
const WalletNavBar = ({ const WalletInfoBar = ({
walletInfo, walletInfo,
}: WalletProps) => { }: WalletProps) => {
const { balance } = walletInfo || {}; const { balance } = walletInfo || {};
const navigate = useNavigate();
return ( return (
<HStack> <HStack>
<Text align={"left"} as="b">On-chain balance:</Text> <Text align={"left"} as="b">Wallet Balance:</Text>
<Skeleton isLoaded={balance != null}> <Skeleton isLoaded={balance != null}>
<HStack>
<Text>{balance} BTC</Text> <Text>{balance} BTC</Text>
<IconButton
bg={"transparent"}
aria-label="Go to wallet"
icon={<ExternalLinkIcon />}
onClick={() => navigate("/wallet")}
/>
</HStack>
</Skeleton> </Skeleton>
</HStack> </HStack>
); );
}; };
export { Wallet, WalletNavBar }; export { Wallet, WalletInfoBar };

Loading…
Cancel
Save