Browse Source

FIX | Prevent further group chat creation if no user is selected (#22)

BANK-1152: Mobile. Створення групового чату. Додаток дозволяє перейти до наступного екрану, не обравши жодного учасника.
Reviewed-on: #22
Co-authored-by: Oksana Stepanenko <oksana.stepanenko@jetup.team>
Co-committed-by: Oksana Stepanenko <oksana.stepanenko@jetup.team>
pull/23/head
Oksana Stepanenko 9 months ago committed by Vitalik Yatsenko
parent
commit
6aaf8b0671
  1. 15
      src/modules/chats/screens/chats.screen.tsx
  2. 8
      src/modules/users/screens/select-user-list.screen.tsx

15
src/modules/chats/screens/chats.screen.tsx

@ -1,6 +1,7 @@ @@ -1,6 +1,7 @@
import React, { FC } from 'react'
import {
IRouteParams,
IShortUser,
PrimaryHeader,
RouteKey,
ScreenLayout,
@ -10,12 +11,23 @@ import { HeaderRightBtn } from '../atoms' @@ -10,12 +11,23 @@ import { HeaderRightBtn } from '../atoms'
import { SmartChatsList } from '../smart-components'
import { useSelector } from 'react-redux'
import { selectId } from '@/store/account'
import _ from 'lodash'
interface IProps extends IRouteParams {}
export const ChatsScreen: FC<IProps> = ({ navigation }) => {
const accountId = useSelector(selectId)
const checkSelectedUsersAndContinue = (selectedUsers: IShortUser[]) => {
if (_.isEmpty(selectedUsers))
appEvents.emit('openInfoModal', {
title: 'Виберіть учасників.',
message: 'Хоча б один користувач повинен бути вибраний',
onPressOk: () => {},
})
else navigation.navigate(RouteKey.CreateGroup)
}
const createChat = () => {
appEvents.emit('openActionSheet', {
items: [
@ -30,8 +42,7 @@ export const ChatsScreen: FC<IProps> = ({ navigation }) => { @@ -30,8 +42,7 @@ export const ChatsScreen: FC<IProps> = ({ navigation }) => {
title: 'Нова група',
isLoading: false,
footerBtnTitle: 'Далі',
onSubmit: () =>
navigation.navigate(RouteKey.CreateGroup),
onSubmit: checkSelectedUsersAndContinue,
useChatBtnColors: true,
excludeIds: [accountId],
resetOnGoBack: true,

8
src/modules/users/screens/select-user-list.screen.tsx

@ -3,6 +3,7 @@ import { @@ -3,6 +3,7 @@ import {
$size,
FooterWithBtn,
IRouteParams,
IShortUser,
ScreenLayout,
useTheme,
} from '@/shared'
@ -27,7 +28,7 @@ interface IProps extends IRouteParams { @@ -27,7 +28,7 @@ interface IProps extends IRouteParams {
title: string
isLoading: boolean
footerBtnTitle: string
onSubmit: () => void
onSubmit: (users?: IShortUser[]) => void
useChatBtnColors?: boolean
disableIds?: number[]
excludeIds?: number[]
@ -89,7 +90,10 @@ export const SelectUserList: FC<IProps> = ({ @@ -89,7 +90,10 @@ export const SelectUserList: FC<IProps> = ({
}}
// eslint-disable-next-line react/no-unstable-nested-components
footer={() => (
<FooterWithBtn btnTitle={footerBtnTitle} onPress={onSubmit} />
<FooterWithBtn
btnTitle={footerBtnTitle}
onPress={() => onSubmit(selectedUsers)}
/>
)}
horizontalPadding={0}>
{selectedUsers.length ? renderSelectedUserRow : null}

Loading…
Cancel
Save