Skip to content

Commit

Permalink
feat(spinner): add pending actions to state (anoma#117)
Browse files Browse the repository at this point in the history
* feat(spinner): add pending actions to state

* tests(notifications): tests for reducers and regexp

* feat: pass notify to account creation function
  • Loading branch information
mateuszjasiuk authored Oct 14, 2022
1 parent 33588bf commit 54a5ed4
Show file tree
Hide file tree
Showing 10 changed files with 491 additions and 75 deletions.
24 changes: 13 additions & 11 deletions apps/namada-interface/src/App/Token/TokenSend/TokenSendForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { AccountsState } from "slices/accounts";
import {
clearEvents,
submitTransferTransaction,
actionTypes,
TransfersState,
TransferType,
} from "slices/transfers";
Expand Down Expand Up @@ -36,6 +37,7 @@ import { Icon, IconName } from "components/Icon";
import { useNavigate } from "react-router-dom";
import { TopLevelRoute } from "App/types";
import { ColorMode, DesignConfiguration } from "utils/theme";
import { NotificationsState } from "slices/notifications";

enum ComponentColor {
GasButtonBorder,
Expand Down Expand Up @@ -156,8 +158,15 @@ const TokenSendForm = ({
);
const balancesForChain = balancesState[chainId] || {};

const { isTransferSubmitting, transferError, events } =
useAppSelector<TransfersState>((state) => state.transfers);
const isTransferSubmitting = useAppSelector<boolean>((state) =>
state.notifications.pendingActions.includes(
actionTypes.SUBMIT_TRANSFER_ACTION_TYPE
)
);

const { transferError } = useAppSelector<TransfersState>(
(state) => state.transfers
);

const transparentAndShieldedAccounts = {
...derivedAccounts,
Expand Down Expand Up @@ -269,6 +278,7 @@ const TokenSendForm = ({
amount,
token: tokenType,
feeAmount: gasFee,
notify: true
})
);
}
Expand Down Expand Up @@ -423,22 +433,14 @@ const TokenSendForm = ({

<StatusContainer>
{transferError && <StatusMessage>{transferError}</StatusMessage>}
{isTransferSubmitting && (
<StatusMessage>Submitting transfer</StatusMessage>
)}
{events && (
<>
<StatusMessage>Transfer successful!</StatusMessage>
<StatusMessage>Gas used: {events.gas}</StatusMessage>
</>
)}
</StatusContainer>

<ButtonsContainer>
<BackButton onClick={() => navigate(TopLevelRoute.Wallet)}>
<Icon iconName={IconName.ChevronLeft} />
</BackButton>
<Button
loading={isTransferSubmitting}
variant={ButtonVariant.Contained}
disabled={isFormInvalid}
onClick={handleOnSendClick}
Expand Down
2 changes: 1 addition & 1 deletion apps/namada-interface/src/slices/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ export { default as transfersReducer } from "./transfers";
export { default as channelsReducer } from "./channels";
export { default as settingsReducer } from "./settings";
export { default as coinsReducer } from "./coins";
export { default as notificationsReducer } from "./notifications";
export { notificationsReducer } from "./notifications";
export { stakingAndGovernanceReducers } from "./StakingAndGovernance";
58 changes: 0 additions & 58 deletions apps/namada-interface/src/slices/notifications.ts

This file was deleted.

4 changes: 4 additions & 0 deletions apps/namada-interface/src/slices/notifications/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export { default as notificationsReducer } from "./slice";
export { actions } from "./slice";
export * from "./reducers";
export * from "./types";
Loading

0 comments on commit 54a5ed4

Please sign in to comment.