Chore: Migrate REST API - editLivechat to Typescript (#3878)

This commit is contained in:
Reinaldo Neto 2022-03-14 10:23:20 -03:00 committed by GitHub
parent 58c9e98e49
commit cfb10ada60
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 45 additions and 39 deletions

View File

@ -0,0 +1,40 @@
import { TextInput } from 'react-native';
import { ILivechatVisitor } from './ILivechatVisitor';
import { ISubscription } from './ISubscription';
export interface ITitle {
title: string;
theme: string;
}
export interface IInputs {
livechatData: {
[key: string]: any;
};
name: string;
email: string;
phone?: string;
topic: string;
tag: string[];
[key: string]: any;
}
export type TParams = ILivechatVisitor & IInputs;
export interface ILivechat extends ISubscription {
// Param dynamic depends on server
sms?: string;
}
export interface IInputsRefs {
[index: string]: TextInput | null;
name: TextInput | null;
phone: TextInput | null;
topic: TextInput | null;
}
export interface ICustomFields {
visitor?: { [key: string]: string };
livechat?: { [key: string]: string };
}

View File

@ -4,6 +4,7 @@ import roomTypeToApiType, { RoomTypes } from '../methods/roomTypeToApiType';
import { SubscriptionType, INotificationPreferences, IRoomNotifications } from '../../../definitions';
import { ISpotlight } from '../../../definitions/ISpotlight';
import { IAvatarSuggestion, IParams } from '../../../definitions/IProfileViewInterfaces';
import { TParams } from '../../../definitions/ILivechatEditView';
export const createChannel = ({
name,
@ -337,7 +338,7 @@ export const closeLivechat = (rid: string, comment: string) =>
// RC 0.29.0
sdk.methodCallWrapper('livechat:closeRoom', rid, comment, { clientAction: true });
export const editLivechat = (userData: any, roomData: any) =>
export const editLivechat = (userData: TParams, roomData: TParams): Promise<{ error?: string }> =>
// RC 0.55.0
sdk.methodCallWrapper('livechat:saveInfo', userData, roomData);

View File

@ -1,7 +1,7 @@
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 } from 'react-native';
import { ScrollView, StyleSheet, Text } from 'react-native';
import { connect } from 'react-redux';
import { BLOCK_CONTEXT } from '@rocket.chat/ui-kit';
@ -18,8 +18,8 @@ import { getUserSelector } from '../selectors/login';
import Button from '../containers/Button';
import SafeAreaView from '../containers/SafeAreaView';
import { MultiSelect } from '../containers/UIKit/MultiSelect';
import { ILivechatVisitor } from '../definitions/ILivechatVisitor';
import { IApplicationState, ISubscription } from '../definitions';
import { ICustomFields, IInputsRefs, TParams, ITitle, ILivechat } from '../definitions/ILivechatEditView';
import { IApplicationState } from '../definitions';
import { ChatsStackParamList } from '../stacks/types';
import sharedStyles from './Styles';
@ -42,41 +42,6 @@ const styles = StyleSheet.create({
}
});
interface ITitle {
title: string;
theme: string;
}
interface IInputs {
livechatData: {
[key: string]: any;
};
name: string;
email: string;
phone?: string;
topic: string;
tag: string[];
[key: string]: any;
}
type TParams = ILivechatVisitor & IInputs;
interface ILivechat extends ISubscription {
// Param dynamic depends on server
sms?: string;
}
interface IInputsRefs {
[index: string]: RNTextInput | null;
name: RNTextInput | null;
phone: RNTextInput | null;
topic: RNTextInput | null;
}
interface ICustomFields {
visitor?: { [key: string]: string };
livechat?: { [key: string]: string };
}
interface ILivechatEditViewProps {
// TODO: Refactor when migrate models
user: any;