Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SendEth: add localstorage #19

Open
wants to merge 1 commit into
base: scholarship-buidlguidl
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/react-app/src/components/EtherInput.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ import React, { useEffect, useState } from "react";

export default function EtherInput(props) {
const [mode, setMode] = useState(props.price ? "USD" : "ETH");
const [display, setDisplay] = useState();
const [value, setValue] = useState();
const [display, setDisplay] = useState(props.value);
const [value, setValue] = useState(props.value);

const currentValue = typeof props.value !== "undefined" ? props.value : value;

Expand Down
26 changes: 22 additions & 4 deletions packages/react-app/src/components/MultiSig/SendEth.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useContractReader } from "eth-hooks";
import { ethers } from "ethers";
import React, { useState } from "react";
import React, { useState, useEffect } from "react";
import { Link } from "react-router-dom";
import { Button, Typography, Card, Tooltip } from "antd";
import { SendOutlined, SearchOutlined } from "@ant-design/icons";
Expand All @@ -21,7 +21,8 @@ function SendEth({
readContracts,
contractName,
}) {
// const [to, setTo] = useLocalStorage("to", undefined);
const [to, setTo] = useLocalStorage("to", undefined, 60000);
const [amt, setAmt] = useLocalStorage("amt", 0, 60000);
const [toAddress, setToAddress] = useState(undefined);
const [amount, setAmount] = useState(0);

Expand Down Expand Up @@ -64,6 +65,11 @@ function SendEth({
}
};

useEffect(() => {
if (amt) setAmount(amt);
if (to) setToAddress(to);
}, []);

return (
<div>
<div className="m-2 p-1 flex justify-center items-center border-2 rounded-lg">
Expand All @@ -73,11 +79,23 @@ function SendEth({
ensProvider={mainnetProvider}
placeholder={"Recepient address"}
value={toAddress}
onChange={setToAddress}
onChange={e => {
setToAddress(e);
setTo(e);
}}
/>
</div>
<div className="p-2">
<EtherInput price={price} mode="USD" value={amount} onChange={setAmount} provider={localProvider} />
<EtherInput
price={price}
mode="USD"
value={amt ? amt : amount}
onChange={e => {
setAmount(e);
setAmt(e);
}}
provider={localProvider}
/>
</div>

<Tooltip title="Send eth">
Expand Down