forked from cerc-io/laconic-wallet
Add spinner to Yes button in ApproveTransaction
page (#122)
* Add spinner to Yes button * Fix indentation * Modify variable names * Set isRequestAccepted to false
This commit is contained in:
parent
9fa39c48ee
commit
40ccc4c333
@ -56,6 +56,7 @@ const ApproveTransaction = ({ route }: ApproveTransactionProps) => {
|
|||||||
const [fees, setFees] = useState<string>();
|
const [fees, setFees] = useState<string>();
|
||||||
const [txError, setTxError] = useState<string>();
|
const [txError, setTxError] = useState<string>();
|
||||||
const [isTxErrorDialogOpen, setIsTxErrorDialogOpen] = useState(false);
|
const [isTxErrorDialogOpen, setIsTxErrorDialogOpen] = useState(false);
|
||||||
|
const [isRequestAccepted, setIsRequestAccepted] = useState(false);
|
||||||
|
|
||||||
const navigation =
|
const navigation =
|
||||||
useNavigation<NativeStackNavigationProp<StackParamsList>>();
|
useNavigation<NativeStackNavigationProp<StackParamsList>>();
|
||||||
@ -169,6 +170,7 @@ const ApproveTransaction = ({ route }: ApproveTransactionProps) => {
|
|||||||
|
|
||||||
const acceptRequestHandler = async () => {
|
const acceptRequestHandler = async () => {
|
||||||
try {
|
try {
|
||||||
|
setIsRequestAccepted(true);
|
||||||
if (!account) {
|
if (!account) {
|
||||||
throw new Error('account not found');
|
throw new Error('account not found');
|
||||||
}
|
}
|
||||||
@ -205,6 +207,7 @@ const ApproveTransaction = ({ route }: ApproveTransactionProps) => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
await web3wallet!.respondSessionRequest({ topic, response });
|
await web3wallet!.respondSessionRequest({ topic, response });
|
||||||
|
setIsRequestAccepted(false);
|
||||||
navigation.navigate('Laconic');
|
navigation.navigate('Laconic');
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
setTxError(error.message);
|
setTxError(error.message);
|
||||||
@ -266,7 +269,11 @@ const ApproveTransaction = ({ route }: ApproveTransactionProps) => {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<View style={styles.buttonContainer}>
|
<View style={styles.buttonContainer}>
|
||||||
<Button mode="contained" onPress={acceptRequestHandler}>
|
<Button
|
||||||
|
mode="contained"
|
||||||
|
onPress={acceptRequestHandler}
|
||||||
|
loading={isRequestAccepted}
|
||||||
|
disabled={isRequestAccepted}>
|
||||||
Yes
|
Yes
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
|
Loading…
Reference in New Issue
Block a user