From 28f84f6d94405a081a4cf731551442440377c139 Mon Sep 17 00:00:00 2001 From: Reinaldo Neto Date: Tue, 5 Oct 2021 17:46:02 -0300 Subject: [PATCH 1/3] Chore: Migrate InviteUsersView to ts --- app/containers/TextInput.tsx | 31 +++++++------ .../InviteUsersView/{index.js => index.tsx} | 45 +++++++++++-------- .../InviteUsersView/{styles.js => styles.ts} | 0 3 files changed, 42 insertions(+), 34 deletions(-) rename app/views/InviteUsersView/{index.js => index.tsx} (80%) rename app/views/InviteUsersView/{styles.js => styles.ts} (100%) diff --git a/app/containers/TextInput.tsx b/app/containers/TextInput.tsx index f9c2236a8e9..28534f01dbd 100644 --- a/app/containers/TextInput.tsx +++ b/app/containers/TextInput.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { StyleSheet, Text, View } from 'react-native'; +import { StyleSheet, Text, TextInputProps, View } from 'react-native'; import Touchable from 'react-native-platform-touchable'; import sharedStyles from '../views/Styles'; @@ -50,23 +50,22 @@ const styles = StyleSheet.create({ } }); -interface IRCTextInputProps { +interface IRCTextInputProps extends TextInputProps { label: string; - error: { + error?: { error: any; reason: any; }; - loading: boolean; - secureTextEntry: boolean; - containerStyle: any; - inputStyle: object; - inputRef: any; - testID: string; - iconLeft: string; - iconRight: string; - placeholder: string; - left: JSX.Element; - onIconRightPress(): void; + loading?: boolean; + secureTextEntry?: boolean; + containerStyle?: any; + inputStyle?: object; + inputRef?: any; + testID?: string; + iconLeft?: string; + iconRight?: string; + left?: JSX.Element; + onIconRightPress?(): void; theme: string; } @@ -152,7 +151,7 @@ export default class RCTextInput extends React.PureComponent + style={[styles.label, { color: themes[theme].titleText }, error?.error && { color: dangerColor }]}> {label} ) : null} @@ -168,7 +167,7 @@ export default class RCTextInput extends React.PureComponent ({ +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; + rid: string; +} +class InviteUsersView extends React.Component { + static navigationOptions: StackNavigationOptions = { title: I18n.t('Invite_users') - }); - - static propTypes = { - navigation: PropTypes.object, - route: PropTypes.object, - theme: PropTypes.string, - timeDateFormat: PropTypes.string, - invite: PropTypes.object, - createInviteLink: PropTypes.func, - clearInviteLink: PropTypes.func }; + rid: string; - 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 From f9d7d5dbdd418a04870ce4be3358c312de1309dc Mon Sep 17 00:00:00 2001 From: Reinaldo Neto Date: Wed, 6 Oct 2021 10:48:49 -0300 Subject: [PATCH 2/3] minor tweaks --- app/containers/TextInput.tsx | 1 - app/views/InviteUsersView/index.tsx | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/app/containers/TextInput.tsx b/app/containers/TextInput.tsx index 28534f01dbd..897e4b9539b 100644 --- a/app/containers/TextInput.tsx +++ b/app/containers/TextInput.tsx @@ -57,7 +57,6 @@ interface IRCTextInputProps extends TextInputProps { reason: any; }; loading?: boolean; - secureTextEntry?: boolean; containerStyle?: any; inputStyle?: object; inputRef?: any; diff --git a/app/views/InviteUsersView/index.tsx b/app/views/InviteUsersView/index.tsx index 716a7121ffa..cfcd3fa11e0 100644 --- a/app/views/InviteUsersView/index.tsx +++ b/app/views/InviteUsersView/index.tsx @@ -35,13 +35,13 @@ interface IInviteUsersView { }; createInviteLink(rid: string): void; clearInviteLink(): void; - rid: string; } class InviteUsersView extends React.Component { + private rid: string; + static navigationOptions: StackNavigationOptions = { title: I18n.t('Invite_users') }; - rid: string; constructor(props: IInviteUsersView) { super(props); From f72389ef238049b46baa7ebb991961df5f8843ca Mon Sep 17 00:00:00 2001 From: Reinaldo Neto Date: Fri, 8 Oct 2021 21:01:10 -0300 Subject: [PATCH 3/3] minor tweak --- app/containers/TextInput.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/containers/TextInput.tsx b/app/containers/TextInput.tsx index 897e4b9539b..42f31b5ab02 100644 --- a/app/containers/TextInput.tsx +++ b/app/containers/TextInput.tsx @@ -51,7 +51,7 @@ const styles = StyleSheet.create({ }); interface IRCTextInputProps extends TextInputProps { - label: string; + label?: string; error?: { error: any; reason: any;