1- import React from 'react' ;
2- import Icon from '@components/Icon' ;
3- // eslint-disable-next-line no-restricted-imports
4- import * as Expensicons from '@components/Icon/Expensicons' ;
1+ import React , { useMemo } from 'react' ;
52import type { OfflineWithFeedbackProps } from '@components/OfflineWithFeedback' ;
63import OfflineWithFeedback from '@components/OfflineWithFeedback' ;
74import type { PopoverMenuItem } from '@components/PopoverMenu' ;
85import { PressableWithoutFeedback } from '@components/Pressable' ;
96import { useMemoizedLazyExpensifyIcons } from '@hooks/useLazyAsset' ;
107import useLocalize from '@hooks/useLocalize' ;
11- import useTheme from '@hooks/useTheme' ;
128import useThemeStyles from '@hooks/useThemeStyles' ;
139import Navigation from '@libs/Navigation/Navigation' ;
1410import CONST from '@src/CONST' ;
@@ -44,27 +40,29 @@ type DomainItem = {
4440} & Pick < OfflineWithFeedbackProps , 'pendingAction' > ;
4541
4642function DomainMenuItem ( { item, index} : DomainMenuItemProps ) {
47- const icons = useMemoizedLazyExpensifyIcons ( [ 'NewWindow ' ] as const ) ;
43+ const icons = useMemoizedLazyExpensifyIcons ( [ 'Globe ' ] as const ) ;
4844 const styles = useThemeStyles ( ) ;
4945 const { translate} = useLocalize ( ) ;
50- const { isAdmin, isValidated} = item ;
51- const theme = useTheme ( ) ;
46+ const { isAdmin, isValidated, action} = item ;
5247
53- const threeDotsMenuItems : PopoverMenuItem [ ] | undefined =
54- ! isValidated && isAdmin
55- ? [
56- {
57- icon : Expensicons . Globe ,
58- text : translate ( 'domain.goToDomain' ) ,
59- onSelected : item . action ,
60- } ,
61- {
62- icon : Expensicons . Globe ,
63- text : translate ( 'domain.verifyDomain.title' ) ,
64- onSelected : ( ) => Navigation . navigate ( ROUTES . WORKSPACES_VERIFY_DOMAIN . getRoute ( item . accountID ) ) ,
65- } ,
66- ]
67- : undefined ;
48+ const threeDotsMenuItems : PopoverMenuItem [ ] | undefined = useMemo (
49+ ( ) =>
50+ isAdmin
51+ ? [
52+ {
53+ icon : icons . Globe ,
54+ text : translate ( 'domain.goToDomain' ) ,
55+ onSelected : action ,
56+ } ,
57+ ! isValidated && {
58+ icon : icons . Globe ,
59+ text : translate ( 'domain.verifyDomain.title' ) ,
60+ onSelected : ( ) => Navigation . navigate ( ROUTES . WORKSPACES_VERIFY_DOMAIN . getRoute ( item . accountID ) ) ,
61+ } ,
62+ ] . filter ( ( menuItem ) => ! ! menuItem )
63+ : undefined ,
64+ [ isAdmin , icons . Globe , translate , action , isValidated , item . accountID ] ,
65+ ) ;
6866
6967 return (
7068 < OfflineWithFeedback
@@ -76,7 +74,7 @@ function DomainMenuItem({item, index}: DomainMenuItemProps) {
7674 role = { CONST . ROLE . BUTTON }
7775 accessibilityLabel = "row"
7876 style = { styles . mh5 }
79- onPress = { item . action }
77+ onPress = { action }
8078 disabled = { ! isAdmin }
8179 >
8280 { ( { hovered} ) => (
@@ -85,23 +83,6 @@ function DomainMenuItem({item, index}: DomainMenuItemProps) {
8583 badgeText = { isAdmin && ! isValidated ? translate ( 'domain.notVerified' ) : undefined }
8684 isHovered = { hovered }
8785 menuItems = { threeDotsMenuItems }
88- rightIcon = {
89- isValidated ? (
90- < Icon
91- src = { icons . NewWindow }
92- fill = { hovered ? theme . iconHovered : theme . icon }
93- isButtonIcon
94- />
95- ) : (
96- < Icon
97- src = { Expensicons . ArrowRight }
98- fill = { theme . icon }
99- additionalStyles = { [ styles . alignSelfCenter , ! hovered && styles . opacitySemiTransparent ] }
100- isButtonIcon
101- medium
102- />
103- )
104- }
10586 />
10687 ) }
10788 </ PressableWithoutFeedback >
0 commit comments