Skip to content

Commit a2b1fa5

Browse files
Agarwalchetanahmed-n-abdeltwab
authored andcommitted
refactor(user-info): remove any usage and enforce strict typing in UserInfoActions (#38859)
1 parent 224dde3 commit a2b1fa5

3 files changed

Lines changed: 6 additions & 5 deletions

File tree

apps/meteor/client/views/room/contextualBar/UserInfo/UserInfoActions.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { useTranslation } from 'react-i18next';
88

99
import { UserInfoAction } from '../../../../components/UserInfo';
1010
import { useMemberExists } from '../../../hooks/useMemberExists';
11+
import type { UserInfoAction as UserInfoActionType } from '../../hooks/useUserInfoActions';
1112
import { useUserInfoActions } from '../../hooks/useUserInfoActions';
1213

1314
type UserInfoActionsProps = {
@@ -58,10 +59,9 @@ const UserInfoActions = ({ user, rid, isInvited, backToList }: UserInfoActionsPr
5859
);
5960
}, [menuOptions, t]);
6061

61-
// TODO: sanitize Action type to avoid any
6262
const actions = useMemo(() => {
63-
const mapAction = ([key, { content, title, icon, onClick }]: any): ReactElement => (
64-
<UserInfoAction key={key} title={title} label={content} onClick={onClick} icon={icon} />
63+
const mapAction = ([key, action]: [string, UserInfoActionType]): ReactElement => (
64+
<UserInfoAction key={key} title={action.title} label={action.content} onClick={action.onClick} icon={action.icon ?? 'kebab'} />
6565
);
6666

6767
return [...actionsDefinition.map(mapAction), menu].filter(Boolean);
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
export { useUserInfoActions } from './useUserInfoActions';
2+
export type { UserInfoAction, UserMenuAction } from './useUserInfoActions';

apps/meteor/client/views/room/hooks/useUserInfoActions/useUserInfoActions.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ type UserInfoActionWithContent = {
4444

4545
export type UserInfoAction = UserInfoActionWithContent | UserInfoActionWithOnlyIcon;
4646

47-
type UserMenuAction = {
47+
export type UserMenuAction = {
4848
id: string;
4949
title: string;
5050
items: GenericMenuItemProps[];
@@ -66,7 +66,7 @@ export const useUserInfoActions = ({
6666
size = 2,
6767
isMember,
6868
isInvited,
69-
}: UserInfoActionsParams): { actions: [string, UserInfoAction][]; menuActions: any | undefined } => {
69+
}: UserInfoActionsParams): { actions: [string, UserInfoAction][]; menuActions: UserMenuAction | undefined } => {
7070
const addUser = useAddUserAction(user, rid, reload);
7171
const blockUser = useBlockUserAction(user, rid);
7272
const changeLeader = useChangeLeaderAction(user, rid);

0 commit comments

Comments
 (0)