2021-06-15 20:13:42 +00:00
|
|
|
import React, { useEffect } from 'react';
|
2021-11-25 14:25:11 +00:00
|
|
|
import { StackNavigationOptions, StackNavigationProp } from '@react-navigation/stack';
|
|
|
|
import { RouteProp } from '@react-navigation/native';
|
2021-06-15 20:13:42 +00:00
|
|
|
import { connect } from 'react-redux';
|
2021-12-24 13:12:49 +00:00
|
|
|
import { CompositeNavigationProp } from '@react-navigation/core';
|
2021-06-15 20:13:42 +00:00
|
|
|
|
|
|
|
import * as List from '../containers/List';
|
|
|
|
import StatusBar from '../containers/StatusBar';
|
|
|
|
import * as HeaderButton from '../containers/HeaderButton';
|
|
|
|
import SafeAreaView from '../containers/SafeAreaView';
|
|
|
|
import I18n from '../i18n';
|
2021-12-24 13:12:49 +00:00
|
|
|
import { ChatsStackParamList, DrawerParamList, NewMessageStackParamList } from '../stacks/types';
|
2021-11-25 14:25:11 +00:00
|
|
|
|
|
|
|
interface IAddChannelTeamView {
|
2021-12-24 13:12:49 +00:00
|
|
|
navigation: CompositeNavigationProp<
|
|
|
|
StackNavigationProp<ChatsStackParamList, 'AddChannelTeamView'>,
|
|
|
|
CompositeNavigationProp<StackNavigationProp<NewMessageStackParamList>, StackNavigationProp<DrawerParamList>>
|
|
|
|
>;
|
|
|
|
route: RouteProp<ChatsStackParamList, 'AddChannelTeamView'>;
|
2021-11-25 14:25:11 +00:00
|
|
|
isMasterDetail: boolean;
|
|
|
|
}
|
|
|
|
|
2021-12-24 13:12:49 +00:00
|
|
|
const setHeader = ({
|
|
|
|
navigation,
|
|
|
|
isMasterDetail
|
|
|
|
}: {
|
|
|
|
navigation: StackNavigationProp<ChatsStackParamList, 'AddChannelTeamView'>;
|
|
|
|
isMasterDetail: boolean;
|
|
|
|
}) => {
|
2021-11-25 14:25:11 +00:00
|
|
|
const options: StackNavigationOptions = {
|
2021-06-15 20:13:42 +00:00
|
|
|
headerTitle: I18n.t('Add_Channel_to_Team')
|
|
|
|
};
|
|
|
|
|
|
|
|
if (isMasterDetail) {
|
|
|
|
options.headerLeft = () => <HeaderButton.CloseModal navigation={navigation} />;
|
|
|
|
}
|
|
|
|
|
|
|
|
navigation.setOptions(options);
|
|
|
|
};
|
|
|
|
|
2021-11-25 14:25:11 +00:00
|
|
|
const AddChannelTeamView = ({ navigation, route, isMasterDetail }: IAddChannelTeamView) => {
|
2021-06-15 20:13:42 +00:00
|
|
|
const { teamId, teamChannels } = route.params;
|
|
|
|
|
|
|
|
useEffect(() => {
|
2021-12-24 13:12:49 +00:00
|
|
|
setHeader({ navigation, isMasterDetail });
|
2021-06-15 20:13:42 +00:00
|
|
|
}, []);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<SafeAreaView testID='add-channel-team-view'>
|
|
|
|
<StatusBar />
|
|
|
|
<List.Container>
|
|
|
|
<List.Separator />
|
|
|
|
<List.Item
|
|
|
|
title='Create_New'
|
2021-10-01 18:12:19 +00:00
|
|
|
onPress={() =>
|
|
|
|
isMasterDetail
|
|
|
|
? navigation.navigate('SelectedUsersViewCreateChannel', {
|
|
|
|
nextAction: () => navigation.navigate('CreateChannelView', { teamId })
|
|
|
|
})
|
|
|
|
: navigation.navigate('SelectedUsersView', {
|
|
|
|
nextAction: () =>
|
|
|
|
navigation.navigate('ChatsStackNavigator', { screen: 'CreateChannelView', params: { teamId } })
|
|
|
|
})
|
2021-06-15 20:13:42 +00:00
|
|
|
}
|
|
|
|
testID='add-channel-team-view-create-channel'
|
|
|
|
left={() => <List.Icon name='team' />}
|
|
|
|
right={() => <List.Icon name='chevron-right' />}
|
|
|
|
/>
|
|
|
|
<List.Separator />
|
|
|
|
<List.Item
|
|
|
|
title='Add_Existing'
|
|
|
|
onPress={() => navigation.navigate('AddExistingChannelView', { teamId, teamChannels })}
|
|
|
|
testID='add-channel-team-view-add-existing'
|
|
|
|
left={() => <List.Icon name='channel-public' />}
|
|
|
|
right={() => <List.Icon name='chevron-right' />}
|
|
|
|
/>
|
|
|
|
<List.Separator />
|
|
|
|
</List.Container>
|
|
|
|
</SafeAreaView>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2021-11-25 14:25:11 +00:00
|
|
|
const mapStateToProps = (state: any) => ({
|
2021-06-15 20:13:42 +00:00
|
|
|
isMasterDetail: state.app.isMasterDetail
|
|
|
|
});
|
|
|
|
|
|
|
|
export default connect(mapStateToProps)(AddChannelTeamView);
|