Skip to content

Commit

Permalink
Merge pull request #2436 from zeitgeistpm/loading-btn
Browse files Browse the repository at this point in the history
Add loading state to tx buttons
  • Loading branch information
robhyrk authored Jun 14, 2024
2 parents 70ba274 + 550304a commit 1373aac
Show file tree
Hide file tree
Showing 15 changed files with 28 additions and 3 deletions.
1 change: 1 addition & 0 deletions components/court/DelegateButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ const DelegateButton = ({ address }: { address: string }) => {
</span>
</div>
<FormTransactionButton
loading={isLoading}
className="w-full max-w-[250px]"
disabled={formState.isValid === false || isLoading}
>
Expand Down
1 change: 1 addition & 0 deletions components/court/JoinCourtAsJurorButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ const JoinCourtAsJurorButton = ({ className }: { className?: string }) => {
</div>

<FormTransactionButton
loading={isLoading}
className="w-full max-w-[250px]"
disabled={formState.isValid === false || isLoading}
>
Expand Down
1 change: 1 addition & 0 deletions components/court/ManageDelegationsForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ const ManageDelegationsForm = (props: ManageDelegationsFormProps) => {
</div>

<FormTransactionButton
loading={isLoading}
className="w-full max-w-[250px]"
disabled={
formState.isValid === false ||
Expand Down
1 change: 1 addition & 0 deletions components/liquidity/ExitPoolFormAmm2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ const ExitPoolForm = ({
{...register("poolSharesPercentage", { min: 0, value: "0" })}
/>
<FormTransactionButton
loading={isLoading}
disabled={formState.isValid === false || isLoading}
>
Exit Pool
Expand Down
1 change: 1 addition & 0 deletions components/liquidity/JoinPoolFormAmm2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ const JoinPoolForm = ({
</div>

<FormTransactionButton
loading={isLoading}
disabled={
formState.isValid === false ||
isLoading ||
Expand Down
6 changes: 5 additions & 1 deletion components/markets/BuyFullSetForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,11 @@ const BuyFullSetForm = ({
</p>
</div>
</div>
<TransactionButton onClick={handleSignTransaction} disabled={disabled}>
<TransactionButton
onClick={handleSignTransaction}
disabled={disabled}
loading={isLoading}
>
Confirm Buy
{fee && (
<span className="block text-xs font-normal">
Expand Down
6 changes: 5 additions & 1 deletion components/markets/SellFullSetForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,11 @@ const SellFullSetForm = ({
</p>
</div>
</div>
<TransactionButton onClick={handleSignTransaction} disabled={disabled}>
<TransactionButton
onClick={handleSignTransaction}
disabled={disabled}
loading={isLoading}
>
Confirm Sell
{fee && (
<span className="block text-xs font-normal">
Expand Down
1 change: 1 addition & 0 deletions components/portfolio/DepositButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ const DepositModal = ({
</span>
</div>
<FormTransactionButton
loading={isLoading}
className="w-full max-w-[250px]"
disabled={formState.isValid === false || isLoading}
disableFeeCheck={true}
Expand Down
5 changes: 4 additions & 1 deletion components/portfolio/TransferButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,10 @@ const TransferModal = ({
: ""}
</span>
</div>
<FormTransactionButton disabled={!isValid || txIsLoading}>
<FormTransactionButton
loading={txIsLoading}
disabled={!isValid || txIsLoading}
>
Transfer
</FormTransactionButton>
</form>
Expand Down
1 change: 1 addition & 0 deletions components/portfolio/WithdrawButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ const WithdrawModal = ({
<span className="ml-1 text-black">{chain?.withdrawFee}</span>
</div>
<FormTransactionButton
loading={isLoading}
className="w-full max-w-[250px]"
disabled={formState.isValid === false || isLoading}
>
Expand Down
1 change: 1 addition & 0 deletions components/settings/AccountSettingsForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ const AcccountSettingsForm: React.FC<AcccountSettingsFormProps> = ({
</div>

<FormTransactionButton
loading={isUpdating}
disabled={!isDirty || !isValid || isUpdating || isClearing}
>
Set Identity
Expand Down
1 change: 1 addition & 0 deletions components/trade-form/BuyForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ const BuyForm = ({
className="w-full max-w-[250px]"
disabled={formState.isValid === false || isLoading}
disableFeeCheck={true}
loading={isLoading}
>
<div>
<div className="center h-[20px] font-normal">Buy</div>
Expand Down
1 change: 1 addition & 0 deletions components/trade-form/SellForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ const SellForm = ({
className="w-full max-w-[250px]"
disabled={formState.isValid === false || isLoading}
disableFeeCheck={true}
loading={isLoading}
>
<div>
<div className="center h-[20px] font-normal">Sell</div>
Expand Down
3 changes: 3 additions & 0 deletions components/ui/FormTransactionButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ interface TransactionButtonProps {
dataTest?: string;
disableFeeCheck?: boolean;
type?: "button" | "submit" | "reset";
loading: boolean | undefined;
}

const FormTransactionButton: FC<PropsWithChildren<TransactionButtonProps>> = ({
Expand All @@ -16,6 +17,7 @@ const FormTransactionButton: FC<PropsWithChildren<TransactionButtonProps>> = ({
disableFeeCheck = false,
type = "submit",
children,
loading = undefined,
}) => {
return (
<TransactionButton
Expand All @@ -24,6 +26,7 @@ const FormTransactionButton: FC<PropsWithChildren<TransactionButtonProps>> = ({
className={className}
dataTest={dataTest}
disableFeeCheck={disableFeeCheck}
loading={loading}
>
{children}
</TransactionButton>
Expand Down
1 change: 1 addition & 0 deletions pages/deposit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ const DotDeposit = ({ address }: { address: string }) => {
)}
</div>
<FormTransactionButton
loading={isLoading}
className="w-full rounded-none !bg-white !text-black disabled:bg-white disabled:text-white"
disabled={isValid === false || isLoading}
disableFeeCheck={true}
Expand Down

0 comments on commit 1373aac

Please sign in to comment.