Skip to content

Commit

Permalink
Whitelist loader (#374)
Browse files Browse the repository at this point in the history
* Added pair address to dropdown option

* added loading indicator

* fixed naming

* using existing ellipsify function
  • Loading branch information
HannuProd authored Feb 21, 2022
1 parent 04f0e9d commit 724f084
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { Formik } from "formik";
import { Form } from "formik-antd";
import { useSdk } from "service";
import { getFormItemName, isValidAddress } from "utils/forms";
import { ellipsifyAddress } from "utils/ui";
import * as Yup from "yup";

import { TokensPerPair } from "../..";
Expand All @@ -24,6 +25,7 @@ export interface FormWhiteilstPairValues {
interface FormWhitelistPairProps extends FormWhiteilstPairValues {
readonly tokensPerPairs: readonly TokensPerPair[];
readonly pairAddress: string;
readonly isLoadingPairs: boolean;
readonly setPairAddress: React.Dispatch<React.SetStateAction<string>>;
readonly goBack: () => void;
readonly handleSubmit: (values: FormWhiteilstPairValues) => void;
Expand All @@ -36,6 +38,7 @@ export default function FormWhitelistPair({
comment,
goBack,
handleSubmit,
isLoadingPairs,
}: FormWhitelistPairProps): JSX.Element {
const {
sdkState: { config },
Expand All @@ -61,6 +64,7 @@ export default function FormWhitelistPair({
<Stack gap="s1">
<StyledSelect
suffixIcon={<DownArrow />}
loading={isLoadingPairs}
size="large"
value={
isValidAddress(pairAddress, config.addressPrefix) ? pairAddress : "Select pair to whitelist"
Expand All @@ -69,7 +73,7 @@ export default function FormWhitelistPair({
>
{tokensPerPairs.map((pair) => (
<Option key={pair.pairAddress} value={pair.pairAddress}>
{`${pair.tokenA.name}${pair.tokenB.name}`}
{`${pair.tokenA.name}${pair.tokenB.name} ${ellipsifyAddress(pair.pairAddress)}`}
</Option>
))}
</StyledSelect>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export default function ProposalWhitelistPair({

const [pairAddress, setPairAddress] = useState("");
const [comment, setComment] = useState("");
const [isLoadingPairs, setLoadingPairs] = useState(false);

const [tokensPerPairs, setTokensPerPairs] = useState<readonly TokensPerPair[]>([]);

Expand All @@ -75,7 +76,7 @@ export default function ProposalWhitelistPair({
useEffect(() => {
(async function getPairs() {
if (!client || !signingClient) return;

setLoadingPairs(true);
const pairs = await getPairsEager(client, config.factoryAddress);

const tokensPerPairs: readonly TokensPerPair[] = await Promise.all(
Expand All @@ -93,6 +94,7 @@ export default function ProposalWhitelistPair({
);

setTokensPerPairs(tokensPerPairsWithDso);
setLoadingPairs(false);
})();
}, [client, config.factoryAddress, dsoAddress, getPairToken, signingClient]);

Expand Down Expand Up @@ -141,6 +143,7 @@ export default function ProposalWhitelistPair({
tokensPerPairs={tokensPerPairs}
pairAddress={pairAddress}
setPairAddress={setPairAddress}
isLoadingPairs={isLoadingPairs}
comment={comment}
goBack={() => setProposalStep(undefined)}
handleSubmit={submitWhitelistPair}
Expand Down

0 comments on commit 724f084

Please sign in to comment.