Skip to content

Commit

Permalink
remove loading button
Browse files Browse the repository at this point in the history
  • Loading branch information
kingsleydon committed Jan 14, 2025
1 parent 56e0ce2 commit 986fa74
Show file tree
Hide file tree
Showing 30 changed files with 115 additions and 368 deletions.
6 changes: 3 additions & 3 deletions apps/app/components/AssetTransfer.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import usePolkadotApi from '@/hooks/usePolkadotApi'
import useSignAndSend from '@/hooks/useSignAndSend'
import {barlow} from '@/lib/theme'
import {LoadingButton} from '@mui/lab'
import {
Alert,
Button,
DialogActions,
DialogContent,
DialogTitle,
Expand Down Expand Up @@ -111,14 +111,14 @@ const AssetTransfer: FC<{asset: Asset; onClose: () => void}> = ({
</Alert>
</DialogContent>
<DialogActions>
<LoadingButton
<Button
variant="text"
loading={loading}
disabled={!isValid}
onClick={transfer}
>
Submit
</LoadingButton>
</Button>
</DialogActions>
</>
)
Expand Down
5 changes: 2 additions & 3 deletions apps/app/components/BasePool/ClaimDelegation.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import usePolkadotApi from '@/hooks/usePolkadotApi'
import useSignAndSend from '@/hooks/useSignAndSend'
import {LoadingButton} from '@mui/lab'
import {
Button,
DialogActions,
Expand Down Expand Up @@ -109,14 +108,14 @@ const ClaimDelegation: FC<{
/>
</DialogContent>
<DialogActions>
<LoadingButton
<Button
variant="text"
onClick={claimReward}
disabled={!addressValid}
loading={loading}
>
Submit
</LoadingButton>
</Button>
</DialogActions>
</>
)
Expand Down
5 changes: 2 additions & 3 deletions apps/app/components/BasePool/ClaimReward.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import usePolkadotApi from '@/hooks/usePolkadotApi'
import useSignAndSend from '@/hooks/useSignAndSend'
import {LoadingButton} from '@mui/lab'
import {
Button,
DialogActions,
Expand Down Expand Up @@ -115,14 +114,14 @@ const ClaimReward: FC<{
/>
</DialogContent>
<DialogActions>
<LoadingButton
<Button
variant="text"
onClick={claimReward}
disabled={!addressValid}
loading={loading}
>
Submit
</LoadingButton>
</Button>
</DialogActions>
</>
)
Expand Down
9 changes: 5 additions & 4 deletions apps/app/components/BasePool/CreateButton.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import usePolkadotApi from '@/hooks/usePolkadotApi'
import useSignAndSend from '@/hooks/useSignAndSend'
import type {BasePoolKind} from '@/lib/subsquidQuery'
import type {LoadingButtonProps} from '@mui/lab'
import type {ButtonProps} from '@mui/material'
import type {FC} from 'react'
import PromiseButton from '../PromiseButton'

const CreateButton: FC<
{kind: BasePoolKind} & Omit<LoadingButtonProps, 'onClick'>
> = ({kind, ...props}) => {
const CreateButton: FC<{kind: BasePoolKind} & Omit<ButtonProps, 'onClick'>> = ({
kind,
...props
}) => {
const api = usePolkadotApi()
const signAndSend = useSignAndSend()
const onClick = async (): Promise<void> => {
Expand Down
7 changes: 3 additions & 4 deletions apps/app/components/BasePool/DelegateInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ import useSignAndSend from '@/hooks/useSignAndSend'
import {aprToApy} from '@/lib/apr'
import type {BasePoolCommonFragment} from '@/lib/subsquidQuery'
import {barlow} from '@/lib/theme'
import {LoadingButton} from '@mui/lab'
import {Skeleton, Stack, type SxProps, TextField} from '@mui/material'
import {Button, Skeleton, Stack, type SxProps, TextField} from '@mui/material'
import {getDecimalPattern, toCurrency, toPercentage} from '@phala/lib'
import {polkadotAccountAtom} from '@phala/store'
import Decimal from 'decimal.js'
Expand Down Expand Up @@ -125,7 +124,7 @@ const DelegateInput: FC<{basePool: BasePoolCommonFragment; sx?: SxProps}> = ({
}
}}
/>
<LoadingButton
<Button
onClick={() => {
delegate()
}}
Expand All @@ -135,7 +134,7 @@ const DelegateInput: FC<{basePool: BasePoolCommonFragment; sx?: SxProps}> = ({
variant="contained"
>
Delegate
</LoadingButton>
</Button>
</Stack>
<Property
size="small"
Expand Down
14 changes: 7 additions & 7 deletions apps/app/components/BasePool/OwnerSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import usePoolIntro, {type PoolIntro} from '@/hooks/usePoolIntro'
import useSignAndSend from '@/hooks/useSignAndSend'
import type {BasePoolCommonFragment} from '@/lib/subsquidQuery'
import {barlow} from '@/lib/theme'
import {LoadingButton} from '@mui/lab'
import {
Button,
DialogContent,
DialogTitle,
Grid2 as Grid,
Expand Down Expand Up @@ -140,15 +140,15 @@ const OwnerSettings: FC<{
}
}}
/>
<LoadingButton
<Button
onClick={setCommission}
disabled={!commissionValid}
loading={commissionLoading}
color={color}
variant="contained"
>
Save
</LoadingButton>
</Button>
</Stack>

{!isVault && (
Expand All @@ -175,15 +175,15 @@ const OwnerSettings: FC<{
}
}}
/>
<LoadingButton
<Button
onClick={setCapacity}
disabled={capacityString === ''}
loading={capacityLoading}
color={color}
variant="contained"
>
Save
</LoadingButton>
</Button>
</Stack>
)}
</Stack>
Expand Down Expand Up @@ -298,7 +298,7 @@ const OwnerSettings: FC<{
</Grid>

<Stack direction="row" justifyContent="flex-end">
<LoadingButton
<Button
disabled={!introLoaded}
onClick={() => {
void saveIntro()
Expand All @@ -308,7 +308,7 @@ const OwnerSettings: FC<{
variant="contained"
>
Save Intro
</LoadingButton>
</Button>
</Stack>
</DialogContent>
</>
Expand Down
6 changes: 3 additions & 3 deletions apps/app/components/BasePool/Whitelist/AddWhitelist.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import usePolkadotApi from '@/hooks/usePolkadotApi'
import useSignAndSend from '@/hooks/useSignAndSend'
import {LoadingButton} from '@mui/lab'
import {
Button,
DialogActions,
DialogContent,
DialogTitle,
Expand Down Expand Up @@ -53,14 +53,14 @@ const AddWhitelist: FC<{
/>
</DialogContent>
<DialogActions>
<LoadingButton
<Button
disabled={!isValid}
loading={loading}
variant="text"
onClick={onClick}
>
Submit
</LoadingButton>
</Button>
</DialogActions>
</>
)
Expand Down
6 changes: 3 additions & 3 deletions apps/app/components/BasePool/Worker/AddWorker.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import usePolkadotApi from '@/hooks/usePolkadotApi'
import useSignAndSend from '@/hooks/useSignAndSend'
import {LoadingButton} from '@mui/lab'
import {
Button,
DialogActions,
DialogContent,
DialogTitle,
Expand Down Expand Up @@ -56,14 +56,14 @@ const AddWorker: FC<{
/>
</DialogContent>
<DialogActions>
<LoadingButton
<Button
loading={loading}
variant="text"
onClick={onClick}
disabled={!isValid}
>
Submit
</LoadingButton>
</Button>
</DialogActions>
</>
)
Expand Down
6 changes: 3 additions & 3 deletions apps/app/components/BasePool/Worker/ChangeStake.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import usePolkadotApi from '@/hooks/usePolkadotApi'
import useSignAndSend from '@/hooks/useSignAndSend'
import {type GlobalStateQuery, useGlobalStateQuery} from '@/lib/subsquidQuery'
import {barlow} from '@/lib/theme'
import {LoadingButton} from '@mui/lab'
import {
Button,
DialogActions,
DialogContent,
DialogTitle,
Expand Down Expand Up @@ -155,14 +155,14 @@ const ChangeStake: FC<{
</Stack>
</DialogContent>
<DialogActions>
<LoadingButton
<Button
loading={loading}
variant="text"
onClick={onClick}
disabled={amountString === ''}
>
Submit
</LoadingButton>
</Button>
</DialogActions>
</>
)
Expand Down
5 changes: 2 additions & 3 deletions apps/app/components/ClaimKhalaAssets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {useSharePrice} from '@/hooks/staking'
import {useAutoSwitchChain} from '@/hooks/useAutoSwitchChain'
import {walletDialogOpenAtom} from '@/store/ui'
import {CheckCircleOutline, ContentCopy} from '@mui/icons-material'
import {LoadingButton} from '@mui/lab'
import {
Box,
Button,
Expand Down Expand Up @@ -374,15 +373,15 @@ const ClaimKhalaAssets = () => {

<Box component="form" onSubmit={handleSubmit}>
<SwitchChainButton>
<LoadingButton
<Button
variant="contained"
disabled={!ethAddress || !isClaimable}
fullWidth
type="submit"
loading={isLoading}
>
Claim
</LoadingButton>
</Button>
</SwitchChainButton>
</Box>
</>
Expand Down
5 changes: 2 additions & 3 deletions apps/app/components/Delegation/Withdraw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import usePolkadotApi from '@/hooks/usePolkadotApi'
import useSignAndSend from '@/hooks/useSignAndSend'
import type {DelegationCommonFragment} from '@/lib/subsquidQuery'
import {barlow} from '@/lib/theme'
import {LoadingButton} from '@mui/lab'
import {
Alert,
AlertTitle,
Expand Down Expand Up @@ -132,14 +131,14 @@ const Withdraw: FC<{
</DialogContent>

<DialogActions>
<LoadingButton
<Button
loading={loading}
variant="text"
onClick={onClick}
disabled={!isValid}
>
Submit
</LoadingButton>
</Button>
</DialogActions>
</>
)
Expand Down
10 changes: 5 additions & 5 deletions apps/app/components/PromiseButton.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import {LoadingButton, type LoadingButtonProps} from '@mui/lab'
import {Button, type ButtonProps} from '@mui/material'
import {type FC, useState} from 'react'

const PromiseButton: FC<
Omit<LoadingButtonProps, 'onClick'> & {
Omit<ButtonProps, 'onClick'> & {
onClick?: (
...args: Parameters<Exclude<LoadingButtonProps['onClick'], undefined>>
...args: Parameters<Exclude<ButtonProps['onClick'], undefined>>
) => Promise<unknown>
}
> = ({onClick, ...props}) => {
const [loading, setLoading] = useState(false)

const handleClick: LoadingButtonProps['onClick'] = (e) => {
const handleClick: ButtonProps['onClick'] = (e) => {
if (onClick != null) {
setLoading(true)
void onClick(e).finally(() => {
Expand All @@ -19,7 +19,7 @@ const PromiseButton: FC<
}
}

return <LoadingButton {...props} loading={loading} onClick={handleClick} />
return <Button {...props} loading={loading} onClick={handleClick} />
}

export default PromiseButton
5 changes: 2 additions & 3 deletions apps/app/components/Staking/Stake.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import {
} from '@/hooks/staking'
import {barlow} from '@/lib/theme'
import {OpenInNew, Unarchive} from '@mui/icons-material'
import {LoadingButton} from '@mui/lab'
import {
Box,
Button,
Expand Down Expand Up @@ -439,7 +438,7 @@ const Stake = () => {
</Paper>

<SwitchChainButton>
<LoadingButton
<Button
fullWidth
sx={{mt: 2}}
type="submit"
Expand All @@ -464,7 +463,7 @@ const Stake = () => {
(needApprove ? 'Approve and Stake' : 'Stake')}
{buttonErrorMessage == null && isUnstake && 'Unstake'}
{buttonErrorMessage != null && buttonErrorMessage}
</LoadingButton>
</Button>
</SwitchChainButton>
</Stack>
</Box>
Expand Down
Loading

0 comments on commit 986fa74

Please sign in to comment.