implement reset transaction state

This commit is contained in:
muzam
2022-01-11 20:20:39 +05:30
parent 7354474c70
commit a9676288ea
2 changed files with 11 additions and 2 deletions

View File

@@ -1,4 +1,4 @@
import { useEffect, useState } from "react";
import { useEffect } from "react";
import "../styles/globals.css";
import type { AppProps } from "next/app";
import Head from "next/head";

View File

@@ -117,6 +117,15 @@ const Transaction = () => {
txIsDisabled,
]);
const resetState = useCallback(() => {
setSelectedAccount(null);
setSelectedDestAccount(null);
setSelectedTransaction(null);
setTxFields({});
setTxIsDisabled(false);
setTxIsLoading(false);
}, []);
const usualFields = ["TransactionType", "Amount", "Account", "Destination"];
const otherFields = Object.keys(txFields).filter(k => !usualFields.includes(k)) as OtherFields;
return (
@@ -229,7 +238,7 @@ const Transaction = () => {
>
<Button outline>VIEW AS JSON</Button>
<Flex row>
<Button outline css={{ mr: "$3" }}>
<Button onClick={resetState} outline css={{ mr: "$3" }}>
RESET
</Button>
<Button