@@ -7,13 +7,13 @@ import FormProvider from '@components/Form/FormProvider';
7
7
import InputWrapper from '@components/Form/InputWrapper' ;
8
8
import type { FormInputErrors } from '@components/Form/types' ;
9
9
import HeaderWithBackButton from '@components/HeaderWithBackButton' ;
10
+ import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription' ;
10
11
import MultipleAvatars from '@components/MultipleAvatars' ;
11
12
import PressableWithoutFeedback from '@components/Pressable/PressableWithoutFeedback' ;
12
13
import type { AnimatedTextInputRef } from '@components/RNTextInput' ;
13
14
import ScreenWrapper from '@components/ScreenWrapper' ;
14
15
import Text from '@components/Text' ;
15
16
import TextInput from '@components/TextInput' ;
16
- import ValuePicker from '@components/ValuePicker' ;
17
17
import type { WithCurrentUserPersonalDetailsProps } from '@components/withCurrentUserPersonalDetails' ;
18
18
import withCurrentUserPersonalDetails from '@components/withCurrentUserPersonalDetails' ;
19
19
import useAutoFocusInput from '@hooks/useAutoFocusInput' ;
@@ -41,6 +41,8 @@ import isLoadingOnyxValue from '@src/types/utils/isLoadingOnyxValue';
41
41
import AccessOrNotFoundWrapper from './AccessOrNotFoundWrapper' ;
42
42
import withPolicyAndFullscreenLoading from './withPolicyAndFullscreenLoading' ;
43
43
import type { WithPolicyAndFullscreenLoadingProps } from './withPolicyAndFullscreenLoading' ;
44
+ import WorkspaceMemberDetailsRoleSelectionModal from './WorkspaceMemberRoleSelectionModal' ;
45
+ import type { ListItemType } from './WorkspaceMemberRoleSelectionModal' ;
44
46
45
47
type WorkspaceInviteMessagePageProps = WithPolicyAndFullscreenLoadingProps &
46
48
WithCurrentUserPersonalDetailsProps &
@@ -62,11 +64,17 @@ function WorkspaceInviteMessagePage({policy, route, currentUserPersonalDetails}:
62
64
const [ allPersonalDetails ] = useOnyx ( ONYXKEYS . PERSONAL_DETAILS_LIST ) ;
63
65
const isOnyxLoading = isLoadingOnyxValue ( workspaceInviteMessageDraftResult , invitedEmailsToAccountIDsDraftResult , formDataResult ) ;
64
66
67
+ const [ isRoleSelectionModalVisible , setIsRoleSelectionModalVisible ] = useState ( false ) ;
68
+
65
69
const welcomeNoteSubject = useMemo (
66
70
( ) => `# ${ currentUserPersonalDetails ?. displayName ?? '' } invited you to ${ policy ?. name ?? 'a workspace' } ` ,
67
71
[ policy ?. name , currentUserPersonalDetails ?. displayName ] ,
68
72
) ;
69
73
74
+ const openRoleSelectionModal = useCallback ( ( ) => {
75
+ setIsRoleSelectionModalVisible ( true ) ;
76
+ } , [ ] ) ;
77
+
70
78
const getDefaultWelcomeNote = useCallback ( ( ) => {
71
79
return (
72
80
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
@@ -124,22 +132,37 @@ function WorkspaceInviteMessagePage({policy, route, currentUserPersonalDetails}:
124
132
125
133
const policyName = policy ?. name ;
126
134
127
- const roleItems = useMemo ( ( ) => {
128
- return Object . values ( CONST . POLICY . ROLE ) . map ( ( roleValue ) => {
129
- let label = '' ;
130
- if ( roleValue === CONST . POLICY . ROLE . USER ) {
131
- label = translate ( 'common.member' ) ;
132
- } else if ( roleValue === CONST . POLICY . ROLE . ADMIN ) {
133
- label = translate ( 'common.admin' ) ;
134
- } else {
135
- label = translate ( 'common.auditor' ) ;
136
- }
137
- return {
138
- label,
139
- value : roleValue ,
140
- } ;
141
- } ) ;
142
- } , [ translate ] ) ;
135
+ const roleItems : ListItemType [ ] = useMemo (
136
+ ( ) => [
137
+ {
138
+ value : CONST . POLICY . ROLE . ADMIN ,
139
+ text : translate ( 'common.admin' ) ,
140
+ alternateText : translate ( 'workspace.common.adminAlternateText' ) ,
141
+ isSelected : role === CONST . POLICY . ROLE . ADMIN ,
142
+ keyForList : CONST . POLICY . ROLE . ADMIN ,
143
+ } ,
144
+ {
145
+ value : CONST . POLICY . ROLE . AUDITOR ,
146
+ text : translate ( 'common.auditor' ) ,
147
+ alternateText : translate ( 'workspace.common.auditorAlternateText' ) ,
148
+ isSelected : role === CONST . POLICY . ROLE . AUDITOR ,
149
+ keyForList : CONST . POLICY . ROLE . AUDITOR ,
150
+ } ,
151
+ {
152
+ value : CONST . POLICY . ROLE . USER ,
153
+ text : translate ( 'common.member' ) ,
154
+ alternateText : translate ( 'workspace.common.memberAlternateText' ) ,
155
+ isSelected : role === CONST . POLICY . ROLE . USER ,
156
+ keyForList : CONST . POLICY . ROLE . USER ,
157
+ } ,
158
+ ] ,
159
+ [ role , translate ] ,
160
+ ) ;
161
+
162
+ const changeRole = useCallback ( ( { value} : ListItemType ) => {
163
+ setIsRoleSelectionModalVisible ( false ) ;
164
+ setRole ( value ) ;
165
+ } , [ ] ) ;
143
166
144
167
return (
145
168
< AccessOrNotFoundWrapper
@@ -197,13 +220,17 @@ function WorkspaceInviteMessagePage({policy, route, currentUserPersonalDetails}:
197
220
</ View >
198
221
< View style = { [ styles . mb3 ] } >
199
222
< View style = { [ styles . mhn5 , styles . mb3 ] } >
200
- < InputWrapper
201
- inputID = { INPUT_IDS . ROLE }
202
- InputComponent = { ValuePicker }
203
- label = { translate ( 'common.role' ) }
223
+ < MenuItemWithTopDescription
224
+ title = { translate ( `workspace.common.roleName` , { role} ) }
225
+ description = { translate ( 'common.role' ) }
226
+ shouldShowRightIcon
227
+ onPress = { openRoleSelectionModal }
228
+ />
229
+ < WorkspaceMemberDetailsRoleSelectionModal
230
+ isVisible = { isRoleSelectionModalVisible }
204
231
items = { roleItems }
205
- value = { role }
206
- onValueChange = { ( value ) => setRole ( value as typeof role ) }
232
+ onRoleChange = { changeRole }
233
+ onClose = { ( ) => setIsRoleSelectionModalVisible ( false ) }
207
234
/>
208
235
</ View >
209
236
< InputWrapper
0 commit comments