Skip to content

Commit

Permalink
feat: reset withdrawal form after withdraw success (#41)
Browse files Browse the repository at this point in the history
* feat: reset form

* fix: reset form only if success

* fix: update amount range bakcground color for iota theme

* feat: reset same to initial values

---------

Co-authored-by: Begoña Alvarez <[email protected]>
  • Loading branch information
evavirseda and begonaalvarezd authored May 6, 2024
1 parent 03b6a83 commit 08f625f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/components/inputs/amount-range.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
/******** Chrome, Safari, Opera and Edge Chromium styles ********/
/* slider track */
&::-webkit-slider-runnable-track {
background-color: #061928;
@apply bg-background-secondary;
border-radius: 0.5rem;
height: 8px;
}
Expand Down
18 changes: 16 additions & 2 deletions src/routes/sections/withdraw-section.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
import { getBech32AddressLengthFromChain, truncateText } from '$lib/common';
import { InputType } from '$lib/common/enums';
import { L2_NATIVE_GAS_TOKEN_DECIMALS } from '$lib/constants';
import { appConfiguration, nodeClient, selectedNetwork } from '$lib/evm-toolkit';
import {
appConfiguration,
nodeClient,
selectedNetwork,
} from '$lib/evm-toolkit';
import type { INativeToken } from '$lib/native-token';
import type { INFT } from '$lib/nft';
import { NotificationType, showNotification } from '$lib/notification';
Expand All @@ -31,7 +35,9 @@
$withdrawStateStore.availableBaseTokens /
10 ** L2_NATIVE_GAS_TOKEN_DECIMALS
).toFixed(2);
$: isValidAddress = formInput.receiverAddress.length === getBech32AddressLengthFromChain($selectedNetwork.chainRef);
$: isValidAddress =
formInput.receiverAddress.length ===
getBech32AddressLengthFromChain($selectedNetwork.chainRef);
$: canWithdraw =
$withdrawStateStore?.availableBaseTokens > 0 &&
formInput.baseTokensToSend > 0 &&
Expand Down Expand Up @@ -126,6 +132,7 @@
}
if (result.status) {
resetForm();
showNotification({
type: NotificationType.Success,
message: `Withdraw request sent. BlockIndex: ${result.blockNumber}`,
Expand Down Expand Up @@ -213,6 +220,13 @@
};
});
};
function resetForm(): void {
formInput.receiverAddress = '';
formInput.baseTokensToSend = storageDeposit;
formInput.nativeTokensToSend = {};
formInput.nftIDToSend = null;
}
</script>

<withdraw-component class="flex flex-col space-y-6 mt-6">
Expand Down
2 changes: 1 addition & 1 deletion src/themes/iota-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ html[data-theme="iota"] {
--action-hover: #108cffe6;
--action-disabled: #7587ab;
--background-primary: #fff;
--background-secondary: #f2f9ff;
--background-secondary: #fcfeff;
--background-tertiary: #e4ebfa;
--background-tertiary-hover: #e4ebfae6;
--color-error: #ff6755;
Expand Down

0 comments on commit 08f625f

Please sign in to comment.