Skip to content

Commit

Permalink
fix: Use difference functions for back and close dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
yanguoyu committed Sep 25, 2023
1 parent 44ee6df commit a783599
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ const SUDTMigrateToExistAccountDialog = ({
isMainnet,
walletID,
isLightClient,
onCancel,
onCloseDialog,
onBack,
onSuccess,
}: {
cell: SpecialAssetCell
Expand All @@ -26,7 +27,8 @@ const SUDTMigrateToExistAccountDialog = ({
isMainnet: boolean
walletID: string
isLightClient: boolean
onCancel: () => void
onCloseDialog: () => void
onBack: () => void
onSuccess: (text: string) => void
}) => {
const [t] = useTranslation()
Expand Down Expand Up @@ -56,7 +58,7 @@ const SUDTMigrateToExistAccountDialog = ({
outPoint: cell.outPoint,
acpAddress: address,
}).then(res => {
onCancel()
onCloseDialog()
if (isSuccessResponse(res)) {
if (res.result) {
dispatch({
Expand Down Expand Up @@ -87,14 +89,14 @@ const SUDTMigrateToExistAccountDialog = ({
})
}
})
}, [cell.outPoint, address, t, onCancel, dispatch, walletID])
}, [cell.outPoint, address, t, onCloseDialog, dispatch, walletID])

return (
<Dialog
className={styles.container}
show
title={t('migrate-sudt.transfer-to-exist-account.title')}
onCancel={onCancel}
onCancel={onBack}
cancelText={t('migrate-sudt.back')}
confirmText={t('migrate-sudt.next')}
onConfirm={onSubmit}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,16 @@ const SUDTMigrateToNewAccountDialog = ({
tokenInfo: findTokenInfo,
sUDTAccounts,
walletID,
onCancel,
onCloseDialog,
onBack,
onSuccess,
}: {
cell: SpecialAssetCell
tokenInfo?: Controller.GetTokenInfoList.TokenInfo
sUDTAccounts: State.SUDTAccount[]
walletID: string
onCancel: () => void
onCloseDialog: () => void
onBack: () => void
onSuccess: (text: string) => void
}) => {
const [t] = useTranslation()
Expand All @@ -51,7 +53,7 @@ const SUDTMigrateToNewAccountDialog = ({
generateSudtMigrateAcpTx({
outPoint: cell.outPoint,
}).then(res => {
onCancel()
onCloseDialog()
if (isSuccessResponse(res)) {
if (res.result) {
dispatch({
Expand Down Expand Up @@ -91,7 +93,7 @@ const SUDTMigrateToNewAccountDialog = ({
})
}
})
}, [cell, t, onCancel, walletID, tokenInfo, dispatch, sudtAmount])
}, [cell, t, onCloseDialog, walletID, tokenInfo, dispatch, sudtAmount])

const renderList = fields.map(field => {
return field.key === 'balance' ? (
Expand Down Expand Up @@ -123,7 +125,7 @@ const SUDTMigrateToNewAccountDialog = ({
className={styles.container}
show
title={t('migrate-sudt.turn-into-new-account.title')}
onCancel={onCancel}
onCancel={onBack}
cancelText={t('migrate-sudt.cancel')}
confirmText={t('migrate-sudt.confirm')}
onConfirm={onSubmit}
Expand Down
12 changes: 10 additions & 2 deletions packages/neuron-ui/src/components/SpecialAssetList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,12 @@ const SpecialAssetList = () => {
)

const onCloseDialog = useCallback(() => {
setIsExistAccountDialogOpen(false)
setIsNewAccountDialogOpen(false)
setIsMigrateDialogOpen(false)
}, [setIsNewAccountDialogOpen, setIsExistAccountDialogOpen, setIsMigrateDialogOpen])

const onBack = useCallback(() => {
setIsExistAccountDialogOpen(false)
setIsNewAccountDialogOpen(false)
setIsMigrateDialogOpen(true)
Expand Down Expand Up @@ -522,7 +528,8 @@ const SpecialAssetList = () => {
sUDTAccounts={sUDTAccounts}
walletID={id}
tokenInfo={migrateTokenInfo}
onCancel={onCloseDialog}
onCloseDialog={onCloseDialog}
onBack={onBack}
onSuccess={handleActionSuccess}
/>
) : null}
Expand All @@ -534,7 +541,8 @@ const SpecialAssetList = () => {
sUDTAccounts={sUDTAccounts}
isMainnet={isMainnet}
walletID={id}
onCancel={onCloseDialog}
onCloseDialog={onCloseDialog}
onBack={onBack}
isLightClient={isLightClient}
onSuccess={handleActionSuccess}
/>
Expand Down

0 comments on commit a783599

Please sign in to comment.