Chore: Migrate InviteUsersView to Typescript (#3426)
* Chore: Migrate InviteUsersView to ts * minor tweaks * minor tweak Co-authored-by: AlexAlexandre <alexalexandrejr@gmail.com>
This commit is contained in:
parent
9922fdd7e5
commit
7728997e3e
|
@ -1,8 +1,10 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
import { ScrollView, Share, View } from 'react-native';
|
import { ScrollView, Share, View } from 'react-native';
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
|
import { StackNavigationProp, StackNavigationOptions } from '@react-navigation/stack';
|
||||||
|
import { RouteProp } from '@react-navigation/core';
|
||||||
|
import { Dispatch } from 'redux';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
inviteLinksClear as inviteLinksClearAction,
|
inviteLinksClear as inviteLinksClearAction,
|
||||||
|
@ -20,22 +22,28 @@ import SafeAreaView from '../../containers/SafeAreaView';
|
||||||
import { events, logEvent } from '../../utils/log';
|
import { events, logEvent } from '../../utils/log';
|
||||||
import styles from './styles';
|
import styles from './styles';
|
||||||
|
|
||||||
class InviteUsersView extends React.Component {
|
interface IInviteUsersView {
|
||||||
static navigationOptions = () => ({
|
navigation: StackNavigationProp<any, 'InviteUsersView'>;
|
||||||
title: I18n.t('Invite_users')
|
route: RouteProp<any, 'InviteUsersView'>;
|
||||||
});
|
theme: string;
|
||||||
|
timeDateFormat: string;
|
||||||
|
invite: {
|
||||||
|
url: string;
|
||||||
|
expires: number;
|
||||||
|
maxUses: number;
|
||||||
|
uses: number;
|
||||||
|
};
|
||||||
|
createInviteLink(rid: string): void;
|
||||||
|
clearInviteLink(): void;
|
||||||
|
}
|
||||||
|
class InviteUsersView extends React.Component<IInviteUsersView, any> {
|
||||||
|
private rid: string;
|
||||||
|
|
||||||
static propTypes = {
|
static navigationOptions: StackNavigationOptions = {
|
||||||
navigation: PropTypes.object,
|
title: I18n.t('Invite_users')
|
||||||
route: PropTypes.object,
|
|
||||||
theme: PropTypes.string,
|
|
||||||
timeDateFormat: PropTypes.string,
|
|
||||||
invite: PropTypes.object,
|
|
||||||
createInviteLink: PropTypes.func,
|
|
||||||
clearInviteLink: PropTypes.func
|
|
||||||
};
|
};
|
||||||
|
|
||||||
constructor(props) {
|
constructor(props: IInviteUsersView) {
|
||||||
super(props);
|
super(props);
|
||||||
this.rid = props.route.params?.rid;
|
this.rid = props.route.params?.rid;
|
||||||
}
|
}
|
||||||
|
@ -97,6 +105,7 @@ class InviteUsersView extends React.Component {
|
||||||
renderExpiration = () => {
|
renderExpiration = () => {
|
||||||
const { theme } = this.props;
|
const { theme } = this.props;
|
||||||
const expirationMessage = this.linkExpirationText();
|
const expirationMessage = this.linkExpirationText();
|
||||||
|
// @ts-ignore
|
||||||
return <Markdown msg={expirationMessage} username='' baseUrl='' theme={theme} />;
|
return <Markdown msg={expirationMessage} username='' baseUrl='' theme={theme} />;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -104,10 +113,10 @@ class InviteUsersView extends React.Component {
|
||||||
const { theme, invite } = this.props;
|
const { theme, invite } = this.props;
|
||||||
return (
|
return (
|
||||||
<SafeAreaView style={{ backgroundColor: themes[theme].backgroundColor }}>
|
<SafeAreaView style={{ backgroundColor: themes[theme].backgroundColor }}>
|
||||||
|
{/* @ts-ignore*/}
|
||||||
<ScrollView
|
<ScrollView
|
||||||
{...scrollPersistTaps}
|
{...scrollPersistTaps}
|
||||||
style={{ backgroundColor: themes[theme].auxiliaryBackground }}
|
style={{ backgroundColor: themes[theme].auxiliaryBackground }}
|
||||||
contentContainerStyle={styles.contentContainer}
|
|
||||||
showsVerticalScrollIndicator={false}>
|
showsVerticalScrollIndicator={false}>
|
||||||
<StatusBar />
|
<StatusBar />
|
||||||
<View style={styles.innerContainer}>
|
<View style={styles.innerContainer}>
|
||||||
|
@ -123,15 +132,15 @@ class InviteUsersView extends React.Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const mapStateToProps = state => ({
|
const mapStateToProps = (state: any) => ({
|
||||||
timeDateFormat: state.settings.Message_TimeAndDateFormat,
|
timeDateFormat: state.settings.Message_TimeAndDateFormat,
|
||||||
days: state.inviteLinks.days,
|
days: state.inviteLinks.days,
|
||||||
maxUses: state.inviteLinks.maxUses,
|
maxUses: state.inviteLinks.maxUses,
|
||||||
invite: state.inviteLinks.invite
|
invite: state.inviteLinks.invite
|
||||||
});
|
});
|
||||||
|
|
||||||
const mapDispatchToProps = dispatch => ({
|
const mapDispatchToProps = (dispatch: Dispatch) => ({
|
||||||
createInviteLink: rid => dispatch(inviteLinksCreateAction(rid)),
|
createInviteLink: (rid: string) => dispatch(inviteLinksCreateAction(rid)),
|
||||||
clearInviteLink: () => dispatch(inviteLinksClearAction())
|
clearInviteLink: () => dispatch(inviteLinksClearAction())
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue