Skip to content

Commit

Permalink
Merge pull request #19 from moonshotcollective/commit-swap
Browse files Browse the repository at this point in the history
add redirect button in swaplist
  • Loading branch information
farque65 authored Oct 22, 2021
2 parents a91b334 + 647df56 commit 4fc22da
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
5 changes: 3 additions & 2 deletions packages/react-app/src/components/SwapItem.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React, { useEffect, useState } from "react";
import { useThemeSwitcher } from "react-css-theme-switcher";
import { Typography } from "antd";
import { Typography, Button } from "antd";
import { NETWORK } from "../constants";

export default function SwapItem({ hash, localProvider, chainId, ...props }) {
export default function SwapItem({ onClick, hash, localProvider, chainId, ...props }) {
const { currentTheme } = useThemeSwitcher();
const [loading, updateLoading] = useState(true);
const [txData, updateTxData] = useState({});
Expand Down Expand Up @@ -47,6 +47,7 @@ export default function SwapItem({ hash, localProvider, chainId, ...props }) {
{hash}
</a>
</Typography.Text>
<Button onClick={onClick}>Commit Swap</Button>
</div>
{loading ? <div style={{ fontStyle: "italic", color: "#efefef" }}>Loading...</div> : <button></button>}
</div>
Expand Down
19 changes: 18 additions & 1 deletion packages/react-app/src/views/SwapList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { SyncOutlined, SettingOutlined, ArrowDownOutlined } from "@ant-design/ic
import { utils, BigNumber } from "ethers";
import { Button, Divider, Input, List, Row, Col, Tabs, Card, Form, Checkbox } from "antd";
import { Address, Balance, SwapItem, AddressInput } from "../components";
import { useParams, useHistory } from "react-router-dom";
import { Router } from "@uniswap/sdk";

export default function SwapList({
purpose,
Expand All @@ -17,18 +19,25 @@ export default function SwapList({
writeContracts,
chainId,
}) {
const history = useHistory();
const { id } = useParams();
const [activeSwaps, setActiveSwaps] = useState([]);
const [swapIds, setSwapIds] = useState([]);

const getActiveSwaps = async () => {
let swaps = null;
let temp = [];
let tempIds = [];
if (readContracts?.MoonSwap) {
swaps = await readContracts.MoonSwap.getActiveSwaps();

swaps.forEach(swap => {
temp.push(utils.keccak256(swap));
tempIds.push(swap.toNumber());
});
console.log("viewswap ", swaps, temp);
setActiveSwaps(temp);
setSwapIds(tempIds);
}
};

Expand All @@ -50,7 +59,15 @@ export default function SwapList({
width: "80%",
}}
>
<SwapItem hash={item} localProvider={localProvider} chainId={chainId} fontSize={14} />
<SwapItem
onClick={() => {
history.push(`/swap/${swapIds[index]}`);
}}
hash={item}
localProvider={localProvider}
chainId={chainId}
fontSize={14}
/>
</div>
</List.Item>
)}
Expand Down

0 comments on commit 4fc22da

Please sign in to comment.