Chore: Migrate REST API - usersAutoComplete to Typescript (#3845)
This commit is contained in:
parent
9652692af5
commit
261b380818
|
@ -20,10 +20,6 @@ const styles = StyleSheet.create({
|
||||||
padding: 16
|
padding: 16
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
interface IUser {
|
|
||||||
username: string;
|
|
||||||
_id: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface IParsedData {
|
interface IParsedData {
|
||||||
label: string;
|
label: string;
|
||||||
|
@ -47,7 +43,7 @@ const ForwardLivechatView = ({ navigation, route, theme }: IBaseScreen<ChatsStac
|
||||||
try {
|
try {
|
||||||
const result = await RocketChat.getDepartments({ count: COUNT_DEPARTMENT, text, offset });
|
const result = await RocketChat.getDepartments({ count: COUNT_DEPARTMENT, text, offset });
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
const parsedDepartments: IParsedData[] = result.departments.map(department => ({
|
const parsedDepartments = result.departments.map(department => ({
|
||||||
label: department.name,
|
label: department.name,
|
||||||
value: department._id
|
value: department._id
|
||||||
}));
|
}));
|
||||||
|
@ -71,7 +67,7 @@ const ForwardLivechatView = ({ navigation, route, theme }: IBaseScreen<ChatsStac
|
||||||
term
|
term
|
||||||
});
|
});
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
const parsedUsers = result.items.map((user: IUser) => ({ label: user.username, value: user._id }));
|
const parsedUsers = result.items.map(user => ({ label: user.username, value: user._id }));
|
||||||
if (!term) {
|
if (!term) {
|
||||||
setUsers(parsedUsers);
|
setUsers(parsedUsers);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue