[FIX] Add users shouldn't have Skip option (#4828)
This commit is contained in:
parent
1abff18e75
commit
3cd1a5f0a6
|
@ -94,6 +94,7 @@ export type ChatsStackParamList = {
|
|||
showButton?: boolean;
|
||||
title?: string;
|
||||
buttonText?: string;
|
||||
showSkipText?: boolean;
|
||||
nextAction?(): void;
|
||||
};
|
||||
InviteUsersView: {
|
||||
|
|
|
@ -75,7 +75,8 @@ export default function ActionsSection({ rid, t, joined }: IActionsSection): Rea
|
|||
route: 'SelectedUsersView',
|
||||
params: {
|
||||
title: i18n.t('Add_users'),
|
||||
nextAction: addUser
|
||||
nextAction: addUser,
|
||||
showSkipText: false
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ const SelectedUsersView = () => {
|
|||
const [chats, setChats] = useState<ISelectedUser[]>([]);
|
||||
const [search, setSearch] = useState<TSearch[]>([]);
|
||||
|
||||
const { maxUsers, showButton, title, buttonText, nextAction } = useRoute<TRoute>().params;
|
||||
const { maxUsers, showButton, title, buttonText, showSkipText = true, nextAction } = useRoute<TRoute>().params;
|
||||
const navigation = useNavigation<TNavigation>();
|
||||
|
||||
const { colors } = useTheme();
|
||||
|
@ -58,20 +58,25 @@ const SelectedUsersView = () => {
|
|||
|
||||
const isGroupChat = () => maxUsers && maxUsers > 2;
|
||||
|
||||
const handleButtonTitle = (buttonTextHeader: string) => {
|
||||
if (users.length > 0) {
|
||||
return buttonTextHeader;
|
||||
}
|
||||
return showSkipText ? I18n.t('Skip') : '';
|
||||
};
|
||||
|
||||
useLayoutEffect(() => {
|
||||
const titleHeader = title ?? I18n.t('Select_Members');
|
||||
const buttonTextHeader = buttonText ?? I18n.t('Next');
|
||||
const nextActionHeader = nextAction ?? (() => {});
|
||||
const buttonTitle = handleButtonTitle(buttonTextHeader);
|
||||
const options = {
|
||||
title: titleHeader,
|
||||
headerRight: () =>
|
||||
(!maxUsers || showButton || (isGroupChat() && users.length > 1)) && (
|
||||
(!maxUsers || showButton || (isGroupChat() && users.length > 1)) &&
|
||||
!!buttonTitle && (
|
||||
<HeaderButton.Container>
|
||||
<HeaderButton.Item
|
||||
title={users.length > 0 ? buttonTextHeader : I18n.t('Skip')}
|
||||
onPress={nextActionHeader}
|
||||
testID='selected-users-view-submit'
|
||||
/>
|
||||
<HeaderButton.Item title={buttonTitle} onPress={nextActionHeader} testID='selected-users-view-submit' />
|
||||
</HeaderButton.Container>
|
||||
)
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue