-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
270 additions
and
63 deletions.
There are no files selected for viewing
21 changes: 16 additions & 5 deletions
21
src/components/Modals/ENSMapAddressModal/ENSMapAddressModal.container.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,32 @@ | ||
import { connect } from 'react-redux' | ||
import { SET_ENS_ADDRESS_REQUEST, setENSAddressRequest } from 'modules/ens/actions' | ||
import { | ||
SET_ENS_ADDRESS_REQUEST, | ||
SET_ENS_RESOLVER_REQUEST, | ||
clearENSErrors, | ||
setENSAddressRequest, | ||
setENSResolverRequest | ||
} from 'modules/ens/actions' | ||
import { isLoadingType } from 'decentraland-dapps/dist/modules/loading/selectors' | ||
import { getError, getLoading, isWaitingTxSetAddress } from 'modules/ens/selectors' | ||
import { getENSBySubdomain, getError, getLoading, isWaitingTxSetAddress, isWaitingTxSetResolver } from 'modules/ens/selectors' | ||
import { RootState } from 'modules/common/types' | ||
import { MapDispatch, MapDispatchProps, OwnProps } from './ENSMapAddressModal.types' | ||
import EnsMapAddressModal from './ENSMapAddressModal' | ||
|
||
const mapState = (state: RootState) => { | ||
const mapState = (state: RootState, ownProps: OwnProps) => { | ||
const error = getError(state) | ||
return { | ||
isLoading: isLoadingType(getLoading(state), SET_ENS_ADDRESS_REQUEST) || isWaitingTxSetAddress(state), | ||
error: error ? error.message : null | ||
isLoadingSetResolver: isLoadingType(getLoading(state), SET_ENS_RESOLVER_REQUEST), | ||
isWaitingTxSetResolver: isWaitingTxSetResolver(state), | ||
error: error ? error.message : null, | ||
ens: getENSBySubdomain(state, ownProps.metadata.ens.subdomain) | ||
} | ||
} | ||
|
||
const mapDispatch = (dispatch: MapDispatch, ownProps: OwnProps): MapDispatchProps => ({ | ||
onSave: ((address: string) => dispatch(setENSAddressRequest(ownProps.metadata.ens, address))) as any | ||
onSave: ((address: string) => dispatch(setENSAddressRequest(ownProps.metadata.ens, address))) as any, | ||
onUnmount: () => dispatch(clearENSErrors()), | ||
onSetENSResolver: ens => dispatch(setENSResolverRequest(ens)) | ||
}) | ||
|
||
export default connect(mapState, mapDispatch)(EnsMapAddressModal) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 16 additions & 4 deletions
20
src/components/Modals/ENSMapAddressModal/ENSMapAddressModal.types.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,26 @@ | ||
import { ModalProps } from 'decentraland-ui' | ||
import { Dispatch } from 'redux' | ||
import { SetENSAddressRequestAction } from 'modules/ens/actions' | ||
import { | ||
ClearENSErrorsAction, | ||
SetENSAddressRequestAction, | ||
SetENSResolverRequestAction, | ||
clearENSErrors, | ||
setENSResolverRequest | ||
} from 'modules/ens/actions' | ||
import { ENS } from 'modules/ens/types' | ||
|
||
export type Props = ModalProps & { | ||
error: string | null | ||
isLoading: boolean | ||
isLoadingSetResolver: boolean | ||
isWaitingTxSetResolver: boolean | ||
ens: ENS | ||
onSave: (address: string) => void | ||
onUnmount: typeof clearENSErrors | ||
onSetENSResolver: typeof setENSResolverRequest | ||
} | ||
|
||
export type MapStateProps = Pick<Props, 'error' | 'isLoading'> | ||
export type MapDispatchProps = Pick<Props, 'onSave'> | ||
export type MapDispatch = Dispatch<SetENSAddressRequestAction> | ||
export type MapStateProps = Pick<Props, 'error' | 'isLoading' | 'isLoadingSetResolver' | 'isWaitingTxSetResolver' | 'ens'> | ||
export type MapDispatchProps = Pick<Props, 'onSave' | 'onUnmount' | 'onSetENSResolver'> | ||
export type MapDispatch = Dispatch<SetENSAddressRequestAction | ClearENSErrorsAction | SetENSResolverRequestAction> | ||
export type OwnProps = Omit<Props, keyof MapDispatchProps> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.