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