From acb76df6bbb910027a0d4ce53868e3bad87f4f0d Mon Sep 17 00:00:00 2001 From: Reinaldo Neto Date: Thu, 11 Nov 2021 21:44:11 -0300 Subject: [PATCH 01/13] Chore: Migrate LivechatEditView to Typescript --- app/containers/UIKit/MultiSelect/index.tsx | 4 +- app/definition/ITagsOmnichannel.ts | 5 + app/definition/IVisitor.ts | 24 ++++ ...vechatEditView.js => LivechatEditView.tsx} | 133 ++++++++++++------ 4 files changed, 121 insertions(+), 45 deletions(-) create mode 100644 app/definition/ITagsOmnichannel.ts create mode 100644 app/definition/IVisitor.ts rename app/views/{LivechatEditView.js => LivechatEditView.tsx} (72%) diff --git a/app/containers/UIKit/MultiSelect/index.tsx b/app/containers/UIKit/MultiSelect/index.tsx index d50dede31c7..c560fea277e 100644 --- a/app/containers/UIKit/MultiSelect/index.tsx +++ b/app/containers/UIKit/MultiSelect/index.tsx @@ -22,8 +22,8 @@ interface IMultiSelect { context?: number; loading?: boolean; multiselect?: boolean; - onSearch: Function; - onClose: Function; + onSearch?: Function; + onClose?: Function; inputStyle: object; value?: any[]; disabled?: boolean | object; diff --git a/app/definition/ITagsOmnichannel.ts b/app/definition/ITagsOmnichannel.ts new file mode 100644 index 00000000000..d0bb2c9b5f0 --- /dev/null +++ b/app/definition/ITagsOmnichannel.ts @@ -0,0 +1,5 @@ +export interface ITagsOmnichannel { + _id: string; + name: string; + departments: string[]; +} diff --git a/app/definition/IVisitor.ts b/app/definition/IVisitor.ts new file mode 100644 index 00000000000..19a53d690f0 --- /dev/null +++ b/app/definition/IVisitor.ts @@ -0,0 +1,24 @@ +export interface IVisitor { + _id?: string; + token: string; + username: string; + updatedAt?: Date; + name: string; + department?: string; + phone?: Array; + visitorEmails?: Array; + customFields?: { + [key: string]: any; + }; + livechatData?: { + [key: string]: any; + }; +} + +export interface IVisitorEmail { + address: string; +} + +export interface IVisitorPhone { + phoneNumber: string; +} diff --git a/app/views/LivechatEditView.js b/app/views/LivechatEditView.tsx similarity index 72% rename from app/views/LivechatEditView.js rename to app/views/LivechatEditView.tsx index 8a610864748..f9b726a13b6 100644 --- a/app/views/LivechatEditView.js +++ b/app/views/LivechatEditView.tsx @@ -1,5 +1,6 @@ import React, { useEffect, useState } from 'react'; -import PropTypes from 'prop-types'; +import { StackNavigationProp } from '@react-navigation/stack'; +import { RouteProp } from '@react-navigation/native'; import { ScrollView, StyleSheet, Text } from 'react-native'; import { connect } from 'react-redux'; import { BLOCK_CONTEXT } from '@rocket.chat/ui-kit'; @@ -10,7 +11,6 @@ import TextInput from '../containers/TextInput'; import KeyboardView from '../presentation/KeyboardView'; import RocketChat from '../lib/rocketchat'; import I18n from '../i18n'; - import { LISTENER } from '../containers/Toast'; import EventEmitter from '../utils/events'; import scrollPersistTaps from '../utils/scrollPersistTaps'; @@ -18,6 +18,8 @@ import { getUserSelector } from '../selectors/login'; import Button from '../containers/Button'; import SafeAreaView from '../containers/SafeAreaView'; import { MultiSelect } from '../containers/UIKit/MultiSelect'; +import { IVisitor } from '../definition/IVisitor'; +import { ITagsOmnichannel } from '../definition/ITagsOmnichannel'; import sharedStyles from './Styles'; const styles = StyleSheet.create({ @@ -39,20 +41,74 @@ const styles = StyleSheet.create({ } }); -const Title = ({ title, theme }) => +interface ITitle { + title: string; + theme: string; +} + +interface IField { + _id: string; + visibility: string; + scope: string; +} + +interface IInputs { + name: string; + email: string; + phone: string; + topic: string; + tags: string[]; +} + +type TParams = IVisitor & IInputs; + +interface IInputsRefs { + name: unknown; + phone: unknown; + topic: unknown; + [index: string]: unknown; +} + +interface ICustomFields { + visitor?: { [key: string]: string }; + livechat?: { [key: string]: string }; +} +interface ILivechatEditViewProps { + user: any; + navigation: StackNavigationProp; + route: RouteProp< + { + LivechatEditView: { + // TODO: refactor when migrate room + room: any; + // TODO: refactor when migrate user + roomUser: IVisitor; + }; + }, + 'LivechatEditView' + >; + theme: string; + editOmnichannelContact: string[]; + editLivechatRoomCustomfields: string[]; +} + +const Title = ({ title, theme }: ITitle) => title ? {title} : null; -Title.propTypes = { - title: PropTypes.string, - theme: PropTypes.string -}; -const LivechatEditView = ({ user, navigation, route, theme, editOmnichannelContact, editLivechatRoomCustomfields }) => { - const [customFields, setCustomFields] = useState({}); - const [availableUserTags, setAvailableUserTags] = useState([]); +const LivechatEditView = ({ + user, + navigation, + route, + theme, + editOmnichannelContact, + editLivechatRoomCustomfields +}: ILivechatEditViewProps) => { + const [customFields, setCustomFields] = useState({} as ICustomFields); + const [availableUserTags, setAvailableUserTags] = useState([]); const [permissions, setPermissions] = useState([]); - const params = {}; - const inputs = {}; + const params: Partial = {}; + const inputs: Partial = {}; const livechat = route.params?.room ?? {}; const visitor = route.params?.roomUser ?? {}; @@ -61,14 +117,14 @@ const LivechatEditView = ({ user, navigation, route, theme, editOmnichannelConta const result = await RocketChat.getCustomFields(); if (result.success && result.customFields?.length) { const visitorCustomFields = result.customFields - .filter(field => field.visibility !== 'hidden' && field.scope === 'visitor') - .map(field => ({ [field._id]: (visitor.livechatData && visitor.livechatData[field._id]) || '' })) - .reduce((ret, field) => ({ ...field, ...ret })); + .filter((field: IField) => field.visibility !== 'hidden' && field.scope === 'visitor') + .map((field: IField) => ({ [field._id]: (visitor.livechatData && visitor.livechatData[field._id]) || '' })) + .reduce((ret: IField, field: IField) => ({ ...field, ...ret })); const livechatCustomFields = result.customFields - .filter(field => field.visibility !== 'hidden' && field.scope === 'room') - .map(field => ({ [field._id]: (livechat.livechatData && livechat.livechatData[field._id]) || '' })) - .reduce((ret, field) => ({ ...field, ...ret })); + .filter((field: IField) => field.visibility !== 'hidden' && field.scope === 'room') + .map((field: IField) => ({ [field._id]: (livechat.livechatData && livechat.livechatData[field._id]) || '' })) + .reduce((ret: IField, field: IField) => ({ ...field, ...ret })); return setCustomFields({ visitor: visitorCustomFields, livechat: livechatCustomFields }); } @@ -83,8 +139,8 @@ const LivechatEditView = ({ user, navigation, route, theme, editOmnichannelConta setTags(uniqueArray); }, [availableUserTags]); - const getTagsList = async agentDepartments => { - const tags = await RocketChat.getTagsList(); + const getTagsList = async (agentDepartments: string[]) => { + const tags: ITagsOmnichannel[] = await RocketChat.getTagsList(); const isAdmin = ['admin', 'livechat-manager'].find(role => user.roles.includes(role)); const availableTags = tags .filter(({ departments }) => isAdmin || departments.length === 0 || departments.some(i => agentDepartments.indexOf(i) > -1)) @@ -95,16 +151,16 @@ const LivechatEditView = ({ user, navigation, route, theme, editOmnichannelConta const getAgentDepartments = async () => { const result = await RocketChat.getAgentDepartments(visitor?._id); if (result.success) { - const agentDepartments = result.departments.map(dept => dept.departmentId); + const agentDepartments = result.departments.map((dept: { departmentId: string }) => dept.departmentId); getTagsList(agentDepartments); } }; const submit = async () => { - const userData = { _id: visitor?._id }; + const userData: Partial = { _id: visitor?._id }; const { rid, sms } = livechat; - const roomData = { _id: rid }; + const roomData: Partial = { _id: rid }; if (params.name) { userData.name = params.name; @@ -149,7 +205,7 @@ const LivechatEditView = ({ user, navigation, route, theme, editOmnichannelConta } }; - const onChangeText = (key, text) => { + const onChangeText = (key: string, text: string) => { params[key] = text; }; @@ -159,6 +215,9 @@ const LivechatEditView = ({ user, navigation, route, theme, editOmnichannelConta }; useEffect(() => { + navigation.setOptions({ + title: I18n.t('Edit') + }); getAgentDepartments(); getCustomFields(); getPermissions(); @@ -177,7 +236,7 @@ const LivechatEditView = ({ user, navigation, route, theme, editOmnichannelConta defaultValue={visitor?.name} onChangeText={text => onChangeText('name', text)} onSubmitEditing={() => { - inputs.name.focus(); + inputs?.name?.focus(); }} theme={theme} editable={!!permissions[0]} @@ -190,7 +249,7 @@ const LivechatEditView = ({ user, navigation, route, theme, editOmnichannelConta defaultValue={visitor?.visitorEmails && visitor?.visitorEmails[0]?.address} onChangeText={text => onChangeText('email', text)} onSubmitEditing={() => { - inputs.phone.focus(); + inputs?.phone.focus(); }} theme={theme} editable={!!permissions[0]} @@ -208,7 +267,7 @@ const LivechatEditView = ({ user, navigation, route, theme, editOmnichannelConta const key = keys[0]; inputs[key].focus(); } else { - inputs.topic.focus(); + inputs?.topic.focus(); } }} theme={theme} @@ -226,7 +285,7 @@ const LivechatEditView = ({ user, navigation, route, theme, editOmnichannelConta if (array.length - 1 > index) { return inputs[array[index + 1][0]].focus(); } - inputs.topic.focus(); + inputs?.topic.focus(); }} theme={theme} editable={!!permissions[0]} @@ -240,15 +299,14 @@ const LivechatEditView = ({ user, navigation, route, theme, editOmnichannelConta }} defaultValue={livechat?.topic} onChangeText={text => onChangeText('topic', text)} - onSubmitEditing={() => inputs.tags.focus()} theme={theme} editable={!!permissions[1]} /> {I18n.t('Tags')} ({ text: { text: tag }, value: tag }))} - onChange={({ value }) => { + options={tagParam.map((tag: string) => ({ text: { text: tag }, value: tag }))} + onChange={({ value }: { value: string[] }) => { setTagParamSelected([...value]); }} placeholder={{ text: I18n.t('Tags') }} @@ -285,19 +343,8 @@ const LivechatEditView = ({ user, navigation, route, theme, editOmnichannelConta ); }; -LivechatEditView.propTypes = { - user: PropTypes.object, - navigation: PropTypes.object, - route: PropTypes.object, - theme: PropTypes.string, - editOmnichannelContact: PropTypes.array, - editLivechatRoomCustomfields: PropTypes.array -}; -LivechatEditView.navigationOptions = { - title: I18n.t('Edit') -}; -const mapStateToProps = state => ({ +const mapStateToProps = (state: any) => ({ server: state.server.server, user: getUserSelector(state), editOmnichannelContact: state.permissions['edit-omnichannel-contact'], From 40ff437c895972700feb21a8c19eb5b87c3ec953 Mon Sep 17 00:00:00 2001 From: AlexAlexandre Date: Tue, 16 Nov 2021 18:28:12 -0300 Subject: [PATCH 02/13] refactor: minor tweak --- app/containers/TextInput.tsx | 4 ++-- app/definition/IVisitor.ts | 18 +++++++++--------- app/presentation/TextInput.tsx | 2 +- app/views/LivechatEditView.tsx | 23 ++++++++++++++--------- 4 files changed, 26 insertions(+), 21 deletions(-) diff --git a/app/containers/TextInput.tsx b/app/containers/TextInput.tsx index 28ae1c2f152..f70d138e836 100644 --- a/app/containers/TextInput.tsx +++ b/app/containers/TextInput.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { StyleProp, StyleSheet, Text, TextInputProps, TextStyle, View, ViewStyle } from 'react-native'; +import { StyleProp, StyleSheet, Text, TextInputProps, TextInput as RNTextInput, TextStyle, View, ViewStyle } from 'react-native'; import Touchable from 'react-native-platform-touchable'; import sharedStyles from '../views/Styles'; @@ -59,7 +59,7 @@ interface IRCTextInputProps extends TextInputProps { loading?: boolean; containerStyle?: StyleProp; inputStyle?: StyleProp; - inputRef?: React.Ref; + inputRef?: React.Ref; testID?: string; iconLeft?: string; iconRight?: string; diff --git a/app/definition/IVisitor.ts b/app/definition/IVisitor.ts index 19a53d690f0..ed770a6f659 100644 --- a/app/definition/IVisitor.ts +++ b/app/definition/IVisitor.ts @@ -1,3 +1,11 @@ +export interface IVisitorEmail { + address: string; +} + +export interface IVisitorPhone { + phoneNumber: string; +} + export interface IVisitor { _id?: string; token: string; @@ -10,15 +18,7 @@ export interface IVisitor { customFields?: { [key: string]: any; }; - livechatData?: { + livechatData: { [key: string]: any; }; } - -export interface IVisitorEmail { - address: string; -} - -export interface IVisitorPhone { - phoneNumber: string; -} diff --git a/app/presentation/TextInput.tsx b/app/presentation/TextInput.tsx index 028b811b534..d5aa8dba0d9 100644 --- a/app/presentation/TextInput.tsx +++ b/app/presentation/TextInput.tsx @@ -14,7 +14,7 @@ interface IThemedTextInput extends TextInputProps { theme: string; } -const ThemedTextInput = React.forwardRef(({ style, theme, ...props }: IThemedTextInput, ref: any) => ( +const ThemedTextInput = React.forwardRef(({ style, theme, ...props }: IThemedTextInput, ref: React.Ref) => ( ([]); const [permissions, setPermissions] = useState([]); - const params: Partial = {}; - const inputs: Partial = {}; + // const params: Partial = {}; + const params = {} as TParams; + const inputs = {} as IInputsRefs; + // const inputs = {} as ForwardedRef; const livechat = route.params?.room ?? {}; const visitor = route.params?.roomUser ?? {}; @@ -157,10 +160,10 @@ const LivechatEditView = ({ }; const submit = async () => { - const userData: Partial = { _id: visitor?._id }; + const userData = { _id: visitor?._id } as TParams; const { rid, sms } = livechat; - const roomData: Partial = { _id: rid }; + const roomData = { _id: rid } as TParams; if (params.name) { userData.name = params.name; @@ -193,6 +196,7 @@ const LivechatEditView = ({ }); if (sms) { + // @ts-ignore delete userData.phone; } @@ -236,7 +240,7 @@ const LivechatEditView = ({ defaultValue={visitor?.name} onChangeText={text => onChangeText('name', text)} onSubmitEditing={() => { - inputs?.name?.focus(); + inputs.name.focus(); }} theme={theme} editable={!!permissions[0]} @@ -328,6 +332,7 @@ const LivechatEditView = ({ onChangeText={text => onChangeText(key, text)} onSubmitEditing={() => { if (array.length - 1 > index) { + // @ts-ignore return inputs[array[index + 1]].focus(); } submit(); From 81d9794f59c3daa9ded0c2d5a39062be00b1252b Mon Sep 17 00:00:00 2001 From: AlexAlexandre Date: Wed, 17 Nov 2021 23:06:35 -0300 Subject: [PATCH 03/13] refactor: fix the interfaces for input --- app/views/LivechatEditView.tsx | 48 ++++++++++++---------------------- 1 file changed, 17 insertions(+), 31 deletions(-) diff --git a/app/views/LivechatEditView.tsx b/app/views/LivechatEditView.tsx index 8a372a9a453..73e65dddbd5 100644 --- a/app/views/LivechatEditView.tsx +++ b/app/views/LivechatEditView.tsx @@ -1,7 +1,7 @@ -import React, { ForwardedRef, Ref, RefAttributes, RefObject, useEffect, useState } from 'react'; +import React, { useEffect, useState } from 'react'; import { StackNavigationProp } from '@react-navigation/stack'; import { RouteProp } from '@react-navigation/native'; -import { ScrollView, StyleSheet, Text, TextInput as RNTextInput, TextInputProps } from 'react-native'; +import { ScrollView, StyleSheet, Text, TextInput as RNTextInput } from 'react-native'; import { connect } from 'react-redux'; import { BLOCK_CONTEXT } from '@rocket.chat/ui-kit'; @@ -53,10 +53,10 @@ interface IField { } interface IInputs { - [key: string]: string; + [key: string]: string | undefined; name: string; email: string; - phone: string; + phone?: string; topic: string; tags: string; } @@ -64,10 +64,10 @@ interface IInputs { type TParams = IVisitor & IInputs; interface IInputsRefs { - name: RNTextInput; - phone: unknown; - topic: unknown; - [index: string]: unknown; + name: RNTextInput | null; + phone: RNTextInput | null; + topic: RNTextInput | null; + [index: string]: RNTextInput | null; } interface ICustomFields { @@ -77,17 +77,7 @@ interface ICustomFields { interface ILivechatEditViewProps { user: any; navigation: StackNavigationProp; - route: RouteProp< - { - LivechatEditView: { - // TODO: refactor when migrate room - room: any; - // TODO: refactor when migrate user - roomUser: IVisitor; - }; - }, - 'LivechatEditView' - >; + route: RouteProp; theme: string; editOmnichannelContact: string[]; editLivechatRoomCustomfields: string[]; @@ -108,10 +98,8 @@ const LivechatEditView = ({ const [availableUserTags, setAvailableUserTags] = useState([]); const [permissions, setPermissions] = useState([]); - // const params: Partial = {}; const params = {} as TParams; const inputs = {} as IInputsRefs; - // const inputs = {} as ForwardedRef; const livechat = route.params?.room ?? {}; const visitor = route.params?.roomUser ?? {}; @@ -196,7 +184,6 @@ const LivechatEditView = ({ }); if (sms) { - // @ts-ignore delete userData.phone; } @@ -240,7 +227,7 @@ const LivechatEditView = ({ defaultValue={visitor?.name} onChangeText={text => onChangeText('name', text)} onSubmitEditing={() => { - inputs.name.focus(); + inputs.name?.focus(); }} theme={theme} editable={!!permissions[0]} @@ -253,7 +240,7 @@ const LivechatEditView = ({ defaultValue={visitor?.visitorEmails && visitor?.visitorEmails[0]?.address} onChangeText={text => onChangeText('email', text)} onSubmitEditing={() => { - inputs?.phone.focus(); + inputs.phone?.focus(); }} theme={theme} editable={!!permissions[0]} @@ -269,9 +256,9 @@ const LivechatEditView = ({ const keys = Object.keys(customFields?.visitor || {}); if (keys.length > 0) { const key = keys[0]; - inputs[key].focus(); + inputs[key]?.focus(); } else { - inputs?.topic.focus(); + inputs.topic?.focus(); } }} theme={theme} @@ -287,9 +274,9 @@ const LivechatEditView = ({ onChangeText={text => onChangeText(key, text)} onSubmitEditing={() => { if (array.length - 1 > index) { - return inputs[array[index + 1][0]].focus(); + return inputs[array[index + 1][0]]?.focus(); } - inputs?.topic.focus(); + inputs.topic?.focus(); }} theme={theme} editable={!!permissions[0]} @@ -322,7 +309,7 @@ const LivechatEditView = ({ inputStyle={styles.multiSelect} /> - {Object.entries(customFields?.livechat || {}).map(([key, value], index, array) => ( + {Object.entries(customFields?.livechat || {}).map(([key, value], index, array: any) => ( onChangeText(key, text)} onSubmitEditing={() => { if (array.length - 1 > index) { - // @ts-ignore - return inputs[array[index + 1]].focus(); + return inputs[array[index + 1]]?.focus(); } submit(); }} From abd9fbb0cf5caa4bdfe0d8649c790505a710537e Mon Sep 17 00:00:00 2001 From: AlexAlexandre Date: Wed, 17 Nov 2021 23:23:02 -0300 Subject: [PATCH 04/13] refactor: fix lint erros --- app/definition/{ITeam.js => ITeam.ts} | 0 app/views/E2EEnterYourPasswordView.tsx | 6 +++--- 2 files changed, 3 insertions(+), 3 deletions(-) rename app/definition/{ITeam.js => ITeam.ts} (100%) diff --git a/app/definition/ITeam.js b/app/definition/ITeam.ts similarity index 100% rename from app/definition/ITeam.js rename to app/definition/ITeam.ts diff --git a/app/views/E2EEnterYourPasswordView.tsx b/app/views/E2EEnterYourPasswordView.tsx index dd9cdfa8ae4..60bb46108f9 100644 --- a/app/views/E2EEnterYourPasswordView.tsx +++ b/app/views/E2EEnterYourPasswordView.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { ScrollView, StyleSheet, Text } from 'react-native'; +import { ScrollView, StyleSheet, Text, TextInput as RNTextInput } from 'react-native'; import { connect } from 'react-redux'; import { Dispatch } from 'redux'; import { StackNavigationOptions, StackNavigationProp } from '@react-navigation/stack'; @@ -40,7 +40,7 @@ interface IE2EEnterYourPasswordViewProps { } class E2EEnterYourPasswordView extends React.Component { - private passwordInput?: TextInput; + private passwordInput?: RNTextInput; static navigationOptions = ({ navigation }: Pick): StackNavigationOptions => ({ headerLeft: () => , @@ -79,7 +79,7 @@ class E2EEnterYourPasswordView extends React.Component { + inputRef={(e: RNTextInput) => { this.passwordInput = e; }} placeholder={I18n.t('Password')} From 7ca1fede1526f90461b7b71296dc97e5927fdfd1 Mon Sep 17 00:00:00 2001 From: Reinaldo Neto Date: Thu, 9 Dec 2021 16:16:31 -0300 Subject: [PATCH 05/13] minor tweak with new navigation types --- app/definition/ITeam.ts | 5 ----- app/definitions/IRoom.ts | 5 +++++ app/{definition => definitions}/ITagsOmnichannel.ts | 0 app/{definition => definitions}/IVisitor.ts | 4 ++-- app/views/LivechatEditView.tsx | 13 +++++++------ 5 files changed, 14 insertions(+), 13 deletions(-) delete mode 100644 app/definition/ITeam.ts rename app/{definition => definitions}/ITagsOmnichannel.ts (100%) rename app/{definition => definitions}/IVisitor.ts (82%) diff --git a/app/definition/ITeam.ts b/app/definition/ITeam.ts deleted file mode 100644 index 8cf8bddcea9..00000000000 --- a/app/definition/ITeam.ts +++ /dev/null @@ -1,5 +0,0 @@ -// https://github.com/RocketChat/Rocket.Chat/blob/develop/definition/ITeam.ts -exports.TEAM_TYPE = { - PUBLIC: 0, - PRIVATE: 1 -}; diff --git a/app/definitions/IRoom.ts b/app/definitions/IRoom.ts index 786c1d7c85b..d9def510de6 100644 --- a/app/definitions/IRoom.ts +++ b/app/definitions/IRoom.ts @@ -24,4 +24,9 @@ export interface IRoom extends IRocketChatRecord { autoTranslate?: boolean; observe?: Function; usedCannedResponse: string; + livechatData?: { + [key: string]: any; + }; + tags?: string[]; + sms?: string; } diff --git a/app/definition/ITagsOmnichannel.ts b/app/definitions/ITagsOmnichannel.ts similarity index 100% rename from app/definition/ITagsOmnichannel.ts rename to app/definitions/ITagsOmnichannel.ts diff --git a/app/definition/IVisitor.ts b/app/definitions/IVisitor.ts similarity index 82% rename from app/definition/IVisitor.ts rename to app/definitions/IVisitor.ts index ed770a6f659..6375135672f 100644 --- a/app/definition/IVisitor.ts +++ b/app/definitions/IVisitor.ts @@ -13,8 +13,8 @@ export interface IVisitor { updatedAt?: Date; name: string; department?: string; - phone?: Array; - visitorEmails?: Array; + phone?: IVisitorPhone[]; + visitorEmails?: IVisitorEmail[]; customFields?: { [key: string]: any; }; diff --git a/app/views/LivechatEditView.tsx b/app/views/LivechatEditView.tsx index 73e65dddbd5..33b7ad95d2e 100644 --- a/app/views/LivechatEditView.tsx +++ b/app/views/LivechatEditView.tsx @@ -18,8 +18,9 @@ import { getUserSelector } from '../selectors/login'; import Button from '../containers/Button'; import SafeAreaView from '../containers/SafeAreaView'; import { MultiSelect } from '../containers/UIKit/MultiSelect'; -import { IVisitor } from '../definition/IVisitor'; -import { ITagsOmnichannel } from '../definition/ITagsOmnichannel'; +import { IVisitor } from '../definitions/IVisitor'; +import { ITagsOmnichannel } from '../definitions/ITagsOmnichannel'; +import { ChatsStackParamList } from '../stacks/types'; import sharedStyles from './Styles'; const styles = StyleSheet.create({ @@ -53,12 +54,12 @@ interface IField { } interface IInputs { - [key: string]: string | undefined; + [key: string]: string | string[] | undefined; name: string; email: string; phone?: string; topic: string; - tags: string; + tag: string[]; } type TParams = IVisitor & IInputs; @@ -76,8 +77,8 @@ interface ICustomFields { } interface ILivechatEditViewProps { user: any; - navigation: StackNavigationProp; - route: RouteProp; + navigation: StackNavigationProp; + route: RouteProp; theme: string; editOmnichannelContact: string[]; editLivechatRoomCustomfields: string[]; From 77d3f6a3401987119228b1f336e53443f422d026 Mon Sep 17 00:00:00 2001 From: Reinaldo Neto Date: Fri, 24 Dec 2021 17:32:25 -0300 Subject: [PATCH 06/13] function --- app/containers/UIKit/MultiSelect/index.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/containers/UIKit/MultiSelect/index.tsx b/app/containers/UIKit/MultiSelect/index.tsx index c560fea277e..bedac3257f7 100644 --- a/app/containers/UIKit/MultiSelect/index.tsx +++ b/app/containers/UIKit/MultiSelect/index.tsx @@ -22,8 +22,8 @@ interface IMultiSelect { context?: number; loading?: boolean; multiselect?: boolean; - onSearch?: Function; - onClose?: Function; + onSearch?: () => void; + onClose?: () => void; inputStyle: object; value?: any[]; disabled?: boolean | object; From c7232d32851bd4d2dea7a991a86ae0130c15d028 Mon Sep 17 00:00:00 2001 From: Reinaldo Neto Date: Fri, 24 Dec 2021 17:38:31 -0300 Subject: [PATCH 07/13] iroom tweak --- app/definitions/IRoom.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/definitions/IRoom.ts b/app/definitions/IRoom.ts index d9def510de6..0dccd40cb36 100644 --- a/app/definitions/IRoom.ts +++ b/app/definitions/IRoom.ts @@ -25,7 +25,7 @@ export interface IRoom extends IRocketChatRecord { observe?: Function; usedCannedResponse: string; livechatData?: { - [key: string]: any; + [key: string]: string; }; tags?: string[]; sms?: string; From 5326604efb0800383924c09856e949011a5a235d Mon Sep 17 00:00:00 2001 From: Reinaldo Neto Date: Fri, 24 Dec 2021 17:40:59 -0300 Subject: [PATCH 08/13] livechateditview tweak --- app/views/LivechatEditView.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/views/LivechatEditView.tsx b/app/views/LivechatEditView.tsx index 33b7ad95d2e..3e5e7903ccc 100644 --- a/app/views/LivechatEditView.tsx +++ b/app/views/LivechatEditView.tsx @@ -65,10 +65,10 @@ interface IInputs { type TParams = IVisitor & IInputs; interface IInputsRefs { + [index: string]: RNTextInput | null; name: RNTextInput | null; phone: RNTextInput | null; topic: RNTextInput | null; - [index: string]: RNTextInput | null; } interface ICustomFields { @@ -76,6 +76,7 @@ interface ICustomFields { livechat?: { [key: string]: string }; } interface ILivechatEditViewProps { + // TODO: Refactor when migrate models user: any; navigation: StackNavigationProp; route: RouteProp; From 549eb2ca8cc1de2c1aab6f844821d65ab169507b Mon Sep 17 00:00:00 2001 From: Reinaldo Neto Date: Fri, 24 Dec 2021 17:57:55 -0300 Subject: [PATCH 09/13] TextInput tweak --- app/presentation/TextInput.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/presentation/TextInput.tsx b/app/presentation/TextInput.tsx index d5aa8dba0d9..7a50f8bd77e 100644 --- a/app/presentation/TextInput.tsx +++ b/app/presentation/TextInput.tsx @@ -14,7 +14,7 @@ interface IThemedTextInput extends TextInputProps { theme: string; } -const ThemedTextInput = React.forwardRef(({ style, theme, ...props }: IThemedTextInput, ref: React.Ref) => ( +const ThemedTextInput = React.forwardRef(({ style, theme, ...props }, ref) => ( Date: Tue, 11 Jan 2022 15:59:03 -0300 Subject: [PATCH 10/13] refactor: update new types and interfaces for use ISubscription --- app/definitions/ISubscription.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/app/definitions/ISubscription.ts b/app/definitions/ISubscription.ts index 5f561edfb59..287f26087be 100644 --- a/app/definitions/ISubscription.ts +++ b/app/definitions/ISubscription.ts @@ -79,6 +79,7 @@ export interface ISubscription { avatarETag?: string; teamId?: string; teamMain?: boolean; + sms?: boolean; // https://nozbe.github.io/WatermelonDB/Relation.html#relation-api messages: Relation; threads: Relation; From 1a0655cc9fa0f0f408276b2fa1bea5ebe60b7c77 Mon Sep 17 00:00:00 2001 From: Reinaldo Neto Date: Tue, 25 Jan 2022 14:16:35 -0300 Subject: [PATCH 11/13] refactor to default useState type --- app/views/LivechatEditView.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/LivechatEditView.tsx b/app/views/LivechatEditView.tsx index 36fcd3908e1..2cec40a52fa 100644 --- a/app/views/LivechatEditView.tsx +++ b/app/views/LivechatEditView.tsx @@ -102,7 +102,7 @@ const LivechatEditView = ({ editOmnichannelContact, editLivechatRoomCustomfields }: ILivechatEditViewProps) => { - const [customFields, setCustomFields] = useState({} as ICustomFields); + const [customFields, setCustomFields] = useState({}); const [availableUserTags, setAvailableUserTags] = useState([]); const [permissions, setPermissions] = useState([]); From 2db152c0cdd932ee418ae42ba627831192a58c60 Mon Sep 17 00:00:00 2001 From: Reinaldo Neto Date: Mon, 7 Feb 2022 11:45:00 -0300 Subject: [PATCH 12/13] change the component name in SearchBox --- app/containers/SearchBox.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/containers/SearchBox.tsx b/app/containers/SearchBox.tsx index 8adebc3ee24..d30923e8269 100644 --- a/app/containers/SearchBox.tsx +++ b/app/containers/SearchBox.tsx @@ -2,7 +2,7 @@ import React from 'react'; import { NativeSyntheticEvent, StyleSheet, - TextInput as TextInputComp, + TextInput as RNTextInput, Text, TextInputFocusEventData, TextInputProps, @@ -59,7 +59,7 @@ interface ISearchBox { hasCancel?: boolean; onCancelPress?: Function; theme?: string; - inputRef?: React.Ref; + inputRef?: React.Ref; testID?: string; onFocus?: (e: NativeSyntheticEvent) => void; } From 77e78fbf4fbc624ecf870ab3e3c6882a6704a350 Mon Sep 17 00:00:00 2001 From: Reinaldo Neto Date: Mon, 7 Feb 2022 11:59:30 -0300 Subject: [PATCH 13/13] changed state type --- app/views/LivechatEditView.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/LivechatEditView.tsx b/app/views/LivechatEditView.tsx index 2cec40a52fa..c77bc3999f3 100644 --- a/app/views/LivechatEditView.tsx +++ b/app/views/LivechatEditView.tsx @@ -20,7 +20,7 @@ import SafeAreaView from '../containers/SafeAreaView'; import { MultiSelect } from '../containers/UIKit/MultiSelect'; import { IVisitor } from '../definitions/IVisitor'; import { ITagsOmnichannel } from '../definitions/ITagsOmnichannel'; -import { ISubscription } from '../definitions'; +import { IApplicationState, ISubscription } from '../definitions'; import { ChatsStackParamList } from '../stacks/types'; import sharedStyles from './Styles'; @@ -345,7 +345,7 @@ const LivechatEditView = ({ ); }; -const mapStateToProps = (state: any) => ({ +const mapStateToProps = (state: IApplicationState) => ({ server: state.server.server, user: getUserSelector(state), editOmnichannelContact: state.permissions['edit-omnichannel-contact'],