Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions app/definitions/ILivechatEditView.ts
Original file line number Diff line number Diff line change
@@ -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 };
}
3 changes: 2 additions & 1 deletion app/lib/rocketchat/services/restApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);

Expand Down
41 changes: 3 additions & 38 deletions app/views/LivechatEditView.tsx
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -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';

Expand All @@ -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;
Expand Down