Chore: evaluate `LegalView` (#4097)

* chore: evaluate LegalView

* remove: `options` from `LegalView` on OutsideStack

* remove: `mapStateToProps` in favor of `useSelector`
This commit is contained in:
Gerzon Z 2022-05-10 17:19:57 -04:00 committed by GitHub
parent 9320d1e05e
commit c9fd7973f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 43 additions and 45 deletions

View File

@ -28,7 +28,7 @@ const _OutsideStack = () => {
<Outside.Screen name='ForgotPasswordView' component={ForgotPasswordView} options={ForgotPasswordView.navigationOptions} /> <Outside.Screen name='ForgotPasswordView' component={ForgotPasswordView} options={ForgotPasswordView.navigationOptions} />
<Outside.Screen name='SendEmailConfirmationView' component={SendEmailConfirmationView} /> <Outside.Screen name='SendEmailConfirmationView' component={SendEmailConfirmationView} />
<Outside.Screen name='RegisterView' component={RegisterView} options={RegisterView.navigationOptions} /> <Outside.Screen name='RegisterView' component={RegisterView} options={RegisterView.navigationOptions} />
<Outside.Screen name='LegalView' component={LegalView} options={LegalView.navigationOptions} /> <Outside.Screen name='LegalView' component={LegalView} />
</Outside.Navigator> </Outside.Navigator>
); );
}; };

View File

@ -1,33 +1,36 @@
import React from 'react'; import React, { useEffect } from 'react';
import { connect } from 'react-redux'; import { useSelector } from 'react-redux';
import { StackNavigationOptions } from '@react-navigation/stack';
import I18n from '../i18n'; import I18n from '../i18n';
import StatusBar from '../containers/StatusBar'; import StatusBar from '../containers/StatusBar';
import openLink from '../utils/openLink'; import openLink from '../utils/openLink';
import { TSupportedThemes, withTheme } from '../theme'; import { useTheme } from '../theme';
import SafeAreaView from '../containers/SafeAreaView'; import SafeAreaView from '../containers/SafeAreaView';
import * as List from '../containers/List'; import * as List from '../containers/List';
import { OutsideParamList } from '../stacks/types';
import { IBaseScreen, IApplicationState } from '../definitions';
interface ILegalView { interface ILegalViewProps extends IBaseScreen<OutsideParamList, 'LegalView'> {
server: string; server: string;
theme: TSupportedThemes;
} }
class LegalView extends React.Component<ILegalView, any> { const LegalView = ({ navigation }: ILegalViewProps): React.ReactElement => {
static navigationOptions = (): StackNavigationOptions => ({ const server = useSelector((state: IApplicationState) => state.server.server);
const { theme } = useTheme();
useEffect(() => {
navigation.setOptions({
title: I18n.t('Legal') title: I18n.t('Legal')
}); });
}, []);
onPressItem = ({ route }: { route: string }) => { const onPressItem = ({ route }: { route: string }) => {
const { server, theme } = this.props;
if (!server) { if (!server) {
return; return;
} }
openLink(`${server}/${route}`, theme); openLink(`${server}/${route}`, theme);
}; };
render() {
return ( return (
<SafeAreaView testID='legal-view'> <SafeAreaView testID='legal-view'>
<StatusBar /> <StatusBar />
@ -36,14 +39,14 @@ class LegalView extends React.Component<ILegalView, any> {
<List.Separator /> <List.Separator />
<List.Item <List.Item
title='Terms_of_Service' title='Terms_of_Service'
onPress={() => this.onPressItem({ route: 'terms-of-service' })} onPress={() => onPressItem({ route: 'terms-of-service' })}
testID='legal-terms-button' testID='legal-terms-button'
showActionIndicator showActionIndicator
/> />
<List.Separator /> <List.Separator />
<List.Item <List.Item
title='Privacy_Policy' title='Privacy_Policy'
onPress={() => this.onPressItem({ route: 'privacy-policy' })} onPress={() => onPressItem({ route: 'privacy-policy' })}
testID='legal-privacy-button' testID='legal-privacy-button'
showActionIndicator showActionIndicator
/> />
@ -52,11 +55,6 @@ class LegalView extends React.Component<ILegalView, any> {
</List.Container> </List.Container>
</SafeAreaView> </SafeAreaView>
); );
} };
}
const mapStateToProps = (state: any) => ({ export default LegalView;
server: state.server.server
});
export default connect(mapStateToProps)(withTheme(LegalView));