Skip to content

Commit

Permalink
review
Browse files Browse the repository at this point in the history
  • Loading branch information
ggazzo committed May 20, 2022
1 parent 5cfce1b commit 716754b
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 21 deletions.
11 changes: 5 additions & 6 deletions apps/meteor/client/views/omnichannel/agents/AgentEdit.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { IUser } from '@rocket.chat/core-typings';
import type { ILivechatAgent, ILivechatDepartment, ILivechatDepartmentAgents } from '@rocket.chat/core-typings';
import { Field, TextInput, Button, Margins, Box, MultiSelect, Icon, Select } from '@rocket.chat/fuselage';
import { useMutableCallback } from '@rocket.chat/fuselage-hooks';
import { useToastMessageDispatch, useRoute, useSetting, useMethod, useTranslation } from '@rocket.chat/ui-contexts';
Expand All @@ -15,14 +15,13 @@ import { formsSubscription } from '../additionalForms';
// Department

type dataType = {
status: string;
user: IUser;
user: Pick<ILivechatAgent, '_id' | 'username' | 'name' | 'status' | 'statusLivechat' | 'emails' | 'livechat'>;
};

type AgentEditProps = {
data: dataType;
userDepartments: { departments: Array<{ departmentId: string }> };
availableDepartments: { departments: Array<{ _id: string; name?: string }> };
userDepartments: { departments: Pick<ILivechatDepartmentAgents, 'departmentId'>[] };
availableDepartments: { departments: Pick<ILivechatDepartment, '_id' | 'name'>[] };
uid: string;
reset: () => void;
};
Expand All @@ -44,7 +43,7 @@ const AgentEdit: FC<AgentEditProps> = ({ data, userDepartments, availableDepartm
[availableDepartments],
);
const initialDepartmentValue = useMemo(
() => (userDepartments?.departments ? userDepartments.departments.map(({ departmentId }) => departmentId) : []),
() => (userDepartments.departments ? userDepartments.departments.map(({ departmentId }) => departmentId) : []),
[userDepartments],
);
const eeForms = useSubscription(formsSubscription);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,19 @@ const AgentEditWithData: FC<AgentEditWithDataProps> = ({ uid, reload }) => {
error: availableDepartmentsError,
} = useEndpointData('livechat/department');

if ([state, availableDepartmentsState, userDepartmentsState].includes(AsyncStatePhase.LOADING)) {
if (
[state, availableDepartmentsState, userDepartmentsState].includes(AsyncStatePhase.LOADING) ||
!userDepartments ||
!availableDepartments
) {
return <FormSkeleton />;
}

if (error || userDepartmentsError || availableDepartmentsError || !data || !data.user) {
return <Box mbs='x16'>{t('User_not_found')}</Box>;
}

return (
<AgentEdit uid={uid} data={data.user} userDepartments={userDepartments} availableDepartments={availableDepartments} reset={reload} />
);
return <AgentEdit uid={uid} data={data} userDepartments={userDepartments} availableDepartments={availableDepartments} reset={reload} />;
};

export default AgentEditWithData;
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import React, { FC } from 'react';
type AgentInfoActionProps = {
icon: IconProps['name'];
label?: string;
title?: string;
};

const AgentInfoAction: FC<AgentInfoActionProps> = ({ icon, label, ...props }) => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ const AgentsRoute: FC = () => {
if (!context) {
return <></>;
}
const handleVerticalBarCloseButtonClick = () => {
const handleVerticalBarCloseButtonClick = (): void => {
agentsRoute.push({});
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@ const RemoveManagerButton = ({ _id, reload }: { _id: string; reload: () => void
const dispatchToastMessage = useToastMessageDispatch();

const handleRemoveClick = useMutableCallback(async () => {
const result = await deleteAction();
if (result?.success === true) {
reload();
}
await deleteAction();
reload();
});
const handleDelete = useMutableCallback((e) => {
e.stopPropagation();
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/lib/getUserEmailAddress.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { IUser } from '@rocket.chat/core-typings';

export const getUserEmailAddress = (user: IUser): string | undefined =>
export const getUserEmailAddress = (user: Pick<IUser, 'emails'>): string | undefined =>
Array.isArray(user.emails) ? user.emails.find(({ address }) => !!address)?.address : undefined;
8 changes: 4 additions & 4 deletions packages/rest-typings/src/v1/omnichannel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,13 @@ export type OmnichannelEndpoints = {
}>;
};

'livechat/users/manger/:_id': {
'livechat/users/manager/:_id': {
GET: (
params: PaginatedRequest<{
text: string;
}>,
) => { user: ILivechatAgent };
DELETE: () => { success: boolean };
DELETE: () => void;
};

'livechat/users/manager': {
Expand All @@ -163,7 +163,7 @@ export type OmnichannelEndpoints = {
params: PaginatedRequest<{
text: string;
}>,
) => { user: ILivechatAgent };
) => { user: Pick<ILivechatAgent, '_id' | 'username' | 'name' | 'status' | 'statusLivechat' | 'emails' | 'livechat'> };
DELETE: () => { success: boolean };
};

Expand Down Expand Up @@ -225,7 +225,7 @@ export type OmnichannelEndpoints = {
};
};
'livechat/agents/:uid/departments': {
GET: (params: { enableDepartmentsOnly: 'true' | 'false' | '0' | '1' }) => { departments: ILivechatDepartment[] };
GET: (params: { enableDepartmentsOnly: 'true' | 'false' | '0' | '1' }) => { departments: ILivechatDepartmentAgents[] };
};

'canned-responses': {
Expand Down
2 changes: 1 addition & 1 deletion packages/ui-contexts/src/ServerContext/methods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export interface ServerMethods {
'getRoomById': (rid: IRoom['_id']) => IRoom;
'getReadReceipts': GetReadReceiptsMethod;
'checkRegistrationSecretURL': (hash: string) => boolean;
'livechat:changeLivechatStatus': (params: { status: string; agentId: string }) => unknown;
'livechat:changeLivechatStatus': (params?: void | { status?: string; agentId?: string }) => unknown;
'livechat:saveAgentInfo': (_id: string, agentData: unknown, agentDepartments: unknown) => unknown;
'autoTranslate.getProviderUiMetadata': () => Record<string, { name: string; displayName: string }>;
'autoTranslate.getSupportedLanguages': (language: string) => ISupportedLanguage[];
Expand Down

0 comments on commit 716754b

Please sign in to comment.