Skip to content

Commit 66747ba

Browse files
authored
signing transactions and granting access should signal that buttons are working (#33)
1 parent b698736 commit 66747ba

File tree

3 files changed

+35
-15
lines changed

3 files changed

+35
-15
lines changed

src/popup/basics/index.tsx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,16 +135,26 @@ export const FormButton = styled(ButtonEl)`
135135
interface SubmitButtonProps {
136136
buttonCTA: string;
137137
isSubmitting: boolean;
138-
isValid: boolean;
138+
isValid?: boolean;
139+
size?: string;
140+
onClick?: () => void;
139141
}
140142

141143
export const FormSubmitButton = ({
142144
buttonCTA,
143145
isSubmitting,
144-
isValid,
146+
isValid = true,
147+
onClick,
148+
size,
145149
...props
146150
}: SubmitButtonProps) => (
147-
<FormButton type="submit" disabled={isSubmitting || !isValid} {...props}>
151+
<FormButton
152+
onClick={onClick}
153+
size={size}
154+
type="submit"
155+
disabled={isSubmitting || !isValid}
156+
{...props}
157+
>
148158
{isSubmitting ? "Loading..." : buttonCTA}
149159
</FormButton>
150160
);

src/popup/views/GrantAccess/index.tsx

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import React from "react";
1+
import React, { useState } from "react";
22
import styled from "styled-components";
33
import { useLocation } from "react-router-dom";
44

55
import { rejectAccess, grantAccess } from "api/internal";
66

77
import { COLOR_PALETTE, FONT_WEIGHT } from "popup/styles";
8-
import { Button } from "popup/basics";
8+
import { Button, FormSubmitButton } from "popup/basics";
99

1010
const GrantAccessEl = styled.div`
1111
padding: 2.25rem 2.5rem;
@@ -42,13 +42,15 @@ export const GrantAccess = () => {
4242
const decodedTab = atob(location.search.replace("?", ""));
4343
const tabToUnlock = decodedTab ? JSON.parse(decodedTab) : {};
4444
const { url, title } = tabToUnlock;
45+
const [isGranting, setIsGranting] = useState(false);
4546

46-
const rejectAndClose = async () => {
47-
await rejectAccess();
47+
const rejectAndClose = () => {
48+
rejectAccess();
4849
window.close();
4950
};
5051

5152
const grantAndClose = async () => {
53+
setIsGranting(true);
5254
await grantAccess(url);
5355
window.close();
5456
};
@@ -65,9 +67,12 @@ export const GrantAccess = () => {
6567
<RejectButton size="small" onClick={() => rejectAndClose()}>
6668
Reject
6769
</RejectButton>
68-
<Button size="small" onClick={() => grantAndClose()}>
69-
Connect
70-
</Button>
70+
<FormSubmitButton
71+
buttonCTA="Confirm"
72+
isSubmitting={isGranting}
73+
size="small"
74+
onClick={() => grantAndClose()}
75+
/>
7176
</ButtonContainerEl>
7277
</GrantAccessEl>
7378
);

src/popup/views/SignTransaction/index.tsx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from "react";
1+
import React, { useState } from "react";
22
import { useLocation } from "react-router-dom";
33
import { useSelector } from "react-redux";
44
import BigNumber from "bignumber.js";
@@ -12,7 +12,7 @@ import { truncatedPublicKey } from "helpers";
1212

1313
import { publicKeySelector } from "popup/ducks/authServices";
1414
import { COLOR_PALETTE, FONT_WEIGHT } from "popup/styles";
15-
import { Button, BackButton } from "popup/basics";
15+
import { Button, BackButton, FormSubmitButton } from "popup/basics";
1616

1717
const El = styled.div`
1818
padding: 2.25rem 2.5rem;
@@ -92,13 +92,15 @@ export const SignTransaction = () => {
9292

9393
const { _fee, _operations } = transaction;
9494
const publicKey = useSelector(publicKeySelector);
95+
const [isConfirming, setIsConfirming] = useState(false);
9596

9697
const rejectAndClose = async () => {
9798
await rejectAccess();
9899
window.close();
99100
};
100101

101102
const signAndClose = async () => {
103+
setIsConfirming(true);
102104
await signTransaction({ transaction });
103105
window.close();
104106
};
@@ -247,9 +249,12 @@ export const SignTransaction = () => {
247249
<RejectButton size="small" onClick={() => rejectAndClose()}>
248250
Reject
249251
</RejectButton>
250-
<Button size="small" onClick={() => signAndClose()}>
251-
Confirm
252-
</Button>
252+
<FormSubmitButton
253+
buttonCTA="Confirm"
254+
isSubmitting={isConfirming}
255+
size="small"
256+
onClick={() => signAndClose()}
257+
/>
253258
</ButtonContainerEl>
254259
</El>
255260
);

0 commit comments

Comments
 (0)