Chore: Evaluate AddChannelTeamView - TypeScript (#4170)
This commit is contained in:
parent
f5051e189d
commit
1a52c7dc57
|
@ -1,7 +1,7 @@
|
||||||
import React, { useEffect } from 'react';
|
import React, { useEffect } from 'react';
|
||||||
import { StackNavigationOptions, StackNavigationProp } from '@react-navigation/stack';
|
import { StackNavigationOptions, StackNavigationProp } from '@react-navigation/stack';
|
||||||
import { RouteProp } from '@react-navigation/native';
|
import { RouteProp, useNavigation, useRoute } from '@react-navigation/native';
|
||||||
import { connect } from 'react-redux';
|
import { useSelector } from 'react-redux';
|
||||||
import { CompositeNavigationProp } from '@react-navigation/core';
|
import { CompositeNavigationProp } from '@react-navigation/core';
|
||||||
|
|
||||||
import * as List from '../containers/List';
|
import * as List from '../containers/List';
|
||||||
|
@ -10,15 +10,14 @@ import * as HeaderButton from '../containers/HeaderButton';
|
||||||
import SafeAreaView from '../containers/SafeAreaView';
|
import SafeAreaView from '../containers/SafeAreaView';
|
||||||
import I18n from '../i18n';
|
import I18n from '../i18n';
|
||||||
import { ChatsStackParamList, DrawerParamList, NewMessageStackParamList } from '../stacks/types';
|
import { ChatsStackParamList, DrawerParamList, NewMessageStackParamList } from '../stacks/types';
|
||||||
|
import { IApplicationState } from '../definitions';
|
||||||
|
|
||||||
interface IAddChannelTeamView {
|
type TRoute = RouteProp<ChatsStackParamList, 'AddChannelTeamView'>;
|
||||||
navigation: CompositeNavigationProp<
|
|
||||||
StackNavigationProp<ChatsStackParamList, 'AddChannelTeamView'>,
|
type TNavigation = CompositeNavigationProp<
|
||||||
CompositeNavigationProp<StackNavigationProp<NewMessageStackParamList>, StackNavigationProp<DrawerParamList>>
|
StackNavigationProp<ChatsStackParamList, 'AddChannelTeamView'>,
|
||||||
>;
|
CompositeNavigationProp<StackNavigationProp<NewMessageStackParamList>, StackNavigationProp<DrawerParamList>>
|
||||||
route: RouteProp<ChatsStackParamList, 'AddChannelTeamView'>;
|
>;
|
||||||
isMasterDetail: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
const setHeader = ({
|
const setHeader = ({
|
||||||
navigation,
|
navigation,
|
||||||
|
@ -38,12 +37,14 @@ const setHeader = ({
|
||||||
navigation.setOptions(options);
|
navigation.setOptions(options);
|
||||||
};
|
};
|
||||||
|
|
||||||
const AddChannelTeamView = ({ navigation, route, isMasterDetail }: IAddChannelTeamView) => {
|
const AddChannelTeamView = () => {
|
||||||
const { teamId, teamChannels } = route.params;
|
const navigation = useNavigation<TNavigation>();
|
||||||
|
const isMasterDetail = useSelector((state: IApplicationState) => state.app.isMasterDetail);
|
||||||
|
const { teamChannels, teamId } = useRoute<TRoute>().params;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setHeader({ navigation, isMasterDetail });
|
setHeader({ navigation, isMasterDetail });
|
||||||
}, []);
|
}, [isMasterDetail, navigation]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SafeAreaView testID='add-channel-team-view'>
|
<SafeAreaView testID='add-channel-team-view'>
|
||||||
|
@ -80,8 +81,4 @@ const AddChannelTeamView = ({ navigation, route, isMasterDetail }: IAddChannelTe
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const mapStateToProps = (state: any) => ({
|
export default AddChannelTeamView;
|
||||||
isMasterDetail: state.app.isMasterDetail
|
|
||||||
});
|
|
||||||
|
|
||||||
export default connect(mapStateToProps)(AddChannelTeamView);
|
|
||||||
|
|
Loading…
Reference in New Issue