From 7728997e3e3e714d3149769c7e44aaa7c7ca7e81 Mon Sep 17 00:00:00 2001 From: Reinaldo Neto <47038980+reinaldonetof@users.noreply.github.com> Date: Wed, 20 Oct 2021 14:49:48 -0300 Subject: [PATCH] Chore: Migrate InviteUsersView to Typescript (#3426) * Chore: Migrate InviteUsersView to ts * minor tweaks * minor tweak Co-authored-by: AlexAlexandre --- .../InviteUsersView/{index.js => index.tsx} | 45 +++++++++++-------- .../InviteUsersView/{styles.js => styles.ts} | 0 2 files changed, 27 insertions(+), 18 deletions(-) rename app/views/InviteUsersView/{index.js => index.tsx} (80%) rename app/views/InviteUsersView/{styles.js => styles.ts} (100%) diff --git a/app/views/InviteUsersView/index.js b/app/views/InviteUsersView/index.tsx similarity index 80% rename from app/views/InviteUsersView/index.js rename to app/views/InviteUsersView/index.tsx index 2fe18f39a..cfcd3fa11 100644 --- a/app/views/InviteUsersView/index.js +++ b/app/views/InviteUsersView/index.tsx @@ -1,8 +1,10 @@ import React from 'react'; -import PropTypes from 'prop-types'; import { ScrollView, Share, View } from 'react-native'; import moment from 'moment'; import { connect } from 'react-redux'; +import { StackNavigationProp, StackNavigationOptions } from '@react-navigation/stack'; +import { RouteProp } from '@react-navigation/core'; +import { Dispatch } from 'redux'; import { inviteLinksClear as inviteLinksClearAction, @@ -20,22 +22,28 @@ import SafeAreaView from '../../containers/SafeAreaView'; import { events, logEvent } from '../../utils/log'; import styles from './styles'; -class InviteUsersView extends React.Component { - static navigationOptions = () => ({ - title: I18n.t('Invite_users') - }); +interface IInviteUsersView { + navigation: StackNavigationProp; + route: RouteProp; + theme: string; + timeDateFormat: string; + invite: { + url: string; + expires: number; + maxUses: number; + uses: number; + }; + createInviteLink(rid: string): void; + clearInviteLink(): void; +} +class InviteUsersView extends React.Component { + private rid: string; - static propTypes = { - navigation: PropTypes.object, - route: PropTypes.object, - theme: PropTypes.string, - timeDateFormat: PropTypes.string, - invite: PropTypes.object, - createInviteLink: PropTypes.func, - clearInviteLink: PropTypes.func + static navigationOptions: StackNavigationOptions = { + title: I18n.t('Invite_users') }; - constructor(props) { + constructor(props: IInviteUsersView) { super(props); this.rid = props.route.params?.rid; } @@ -97,6 +105,7 @@ class InviteUsersView extends React.Component { renderExpiration = () => { const { theme } = this.props; const expirationMessage = this.linkExpirationText(); + // @ts-ignore return ; }; @@ -104,10 +113,10 @@ class InviteUsersView extends React.Component { const { theme, invite } = this.props; return ( + {/* @ts-ignore*/} @@ -123,15 +132,15 @@ class InviteUsersView extends React.Component { } } -const mapStateToProps = state => ({ +const mapStateToProps = (state: any) => ({ timeDateFormat: state.settings.Message_TimeAndDateFormat, days: state.inviteLinks.days, maxUses: state.inviteLinks.maxUses, invite: state.inviteLinks.invite }); -const mapDispatchToProps = dispatch => ({ - createInviteLink: rid => dispatch(inviteLinksCreateAction(rid)), +const mapDispatchToProps = (dispatch: Dispatch) => ({ + createInviteLink: (rid: string) => dispatch(inviteLinksCreateAction(rid)), clearInviteLink: () => dispatch(inviteLinksClearAction()) }); diff --git a/app/views/InviteUsersView/styles.js b/app/views/InviteUsersView/styles.ts similarity index 100% rename from app/views/InviteUsersView/styles.js rename to app/views/InviteUsersView/styles.ts