verdnatura-chat/app/views/InviteUsersEditView/index.tsx

55 lines
1.8 KiB
TypeScript
Raw Normal View History

import { StackNavigationProp } from '@react-navigation/stack';
import React, { useLayoutEffect } from 'react';
import { View } from 'react-native';
import { useDispatch } from 'react-redux';
import { RouteProp, useNavigation, useRoute } from '@react-navigation/native';
2020-01-28 13:22:35 +00:00
import { inviteLinksCreate } from '../../actions/inviteLinks';
2020-01-28 13:22:35 +00:00
import Button from '../../containers/Button';
import * as List from '../../containers/List';
import SafeAreaView from '../../containers/SafeAreaView';
2020-01-28 13:22:35 +00:00
import StatusBar from '../../containers/StatusBar';
import I18n from '../../i18n';
import { ChatsStackParamList } from '../../stacks/types';
import { events, logEvent } from '../../lib/methods/helpers/log';
import styles from './styles';
import Picker from './Picker';
2020-01-28 13:22:35 +00:00
const InviteUsersEditView = () => {
const navigation = useNavigation<StackNavigationProp<ChatsStackParamList, 'InviteUsersEditView'>>();
const { rid } = useRoute<RouteProp<ChatsStackParamList, 'InviteUsersEditView'>>().params;
const dispatch = useDispatch();
2020-01-28 13:22:35 +00:00
useLayoutEffect(() => {
navigation.setOptions({
title: I18n.t('Invite_users')
});
}, [navigation]);
2020-01-28 13:22:35 +00:00
const createInviteLink = () => {
logEvent(events.IU_EDIT_CREATE_LINK);
dispatch(inviteLinksCreate(rid));
2020-01-28 13:22:35 +00:00
navigation.pop();
};
2020-01-28 13:22:35 +00:00
return (
<SafeAreaView>
<List.Container>
<StatusBar />
<List.Section>
<List.Separator />
<List.Item title='Expiration_Days' right={() => <Picker param={'days'} first={'Never'} />} />
<List.Separator />
<List.Item title='Max_number_of_uses' right={() => <Picker param='maxUses' first='No_limit' />} />
<List.Separator />
</List.Section>
<View style={styles.innerContainer}>
<Button title={I18n.t('Generate_New_Link')} type='primary' onPress={createInviteLink} />
</View>
</List.Container>
</SafeAreaView>
);
};
2020-01-28 13:22:35 +00:00
export default InviteUsersEditView;