MyCrypto/common/components/LogOutPrompt.tsx
James Prado 816ce3180f Translation Updates (#1323)
* Update account view routing

* Temporarily add unicode character to translated strings for testing

* Temporarily select add unicode to all untranslated strings

* Format changes

* Add all english translations for /account & /generate

* Add the rest of the english translations

* Add a few more missing translations

* Update en translations

* Get selectedLanguage from localstorage instead of redux sttate

* Update snapshots

* Add missing translation keys & Update translate functs & change variable prefix

* translate all markdown strings & remove old translation strings

* Update snapshot

* Add a few more translation strs

* Move raw strings being translated into json

* All translation keys are now Uppercase

* Fix up the last few translations

* Update snapshot

* Uppercase de translation strings

* Bring back shapeshift logo on swap

* Fix contracts tab translations

* Fix a few more translations

* Fix translations

* remove debugging stuff

* Update snapshots

* Use react.fragment as markdown root renderer

* Seperate markdown translations into their own function

* Clean up translation functions

* Clean up translation functions

* Update snapshot

* Fix some broken translation strings

* Add prettier ignore file
2018-03-21 22:50:25 -05:00

89 lines
2.3 KiB
TypeScript

import React from 'react';
import { connect } from 'react-redux';
import { withRouter, RouteComponentProps } from 'react-router-dom';
import Modal, { IButton } from 'components/ui/Modal';
import { AppState } from 'reducers';
import { resetWallet, TResetWallet } from 'actions/wallet';
import translate, { translateRaw } from 'translations';
interface Props extends RouteComponentProps<{}> {
// State
wallet: AppState['wallet']['inst'];
// Actions
resetWallet: TResetWallet;
}
interface State {
nextLocation: RouteComponentProps<{}>['location'] | null;
openModal: boolean;
}
class LogOutPromptClass extends React.Component<Props, State> {
constructor(props: Props) {
super(props);
this.state = {
nextLocation: null,
openModal: false
};
this.props.history.block(nextLocation => {
if (this.props.wallet && nextLocation.pathname !== this.props.location.pathname) {
const isSubTab =
nextLocation.pathname.split('/')[1] === this.props.location.pathname.split('/')[1];
if (!isSubTab) {
this.setState({
openModal: true,
nextLocation
});
return false;
}
}
});
}
public render() {
const buttons: IButton[] = [
{ text: translate('ACTION_7'), type: 'primary', onClick: this.onConfirm },
{ text: translate('ACTION_2'), type: 'default', onClick: this.onCancel }
];
return (
<Modal
title={translateRaw('WALLET_LOGOUT_MODAL_TITLE')}
isOpen={this.state.openModal}
handleClose={this.onCancel}
buttons={buttons}
>
<p>{translate('WALLET_LOGOUT_MODAL_DESC')}</p>
</Modal>
);
}
private onCancel = () => {
this.setState({ nextLocation: null, openModal: false });
};
private onConfirm = () => {
const { nextLocation: next } = this.state;
this.props.resetWallet();
this.setState(
{
openModal: false,
nextLocation: null
},
() => {
if (next) {
this.props.history.push(`${next.pathname}${next.search}${next.hash}`);
}
}
);
};
}
function mapStateToProps(state: AppState) {
return { wallet: state.wallet.inst };
}
export default connect(mapStateToProps, {
resetWallet
})(withRouter<Props>(LogOutPromptClass));