import { View } from 'react-native';
import { useStyles } from './styles';
import { ElementID, PageID } from '../../../../../enums';
import FormLabel from '../../../../../elements/FormLabel';
import { useNavigation } from '@react-navigation/native';
import { useBehaviour } from '../../../../../providers/BehaviourProvider';
import { MemberChip } from '../../../../../components/MemberChip/MemberChip';
import CommunityAddMemberButton from '../../../../../elements/CommunityAddMemberButton';
function Members({
  value,
  goBack,
  onChange
}) {
  const {
    styles
  } = useStyles();
  const {
    AmityCommunitySetupPageBehavior
  } = useBehaviour();
  const navigation = useNavigation();
  const onAddedAction = users => {
    goBack();
    onChange(users);
  };
  return /*#__PURE__*/React.createElement(View, {
    style: styles.container
  }, /*#__PURE__*/React.createElement(FormLabel, {
    pageId: PageID.community_setup_page,
    elementId: ElementID.community_add_member_title
  }), /*#__PURE__*/React.createElement(View, {
    style: styles.memberContainer
  }, /*#__PURE__*/React.createElement(CommunityAddMemberButton, {
    pageId: PageID.community_setup_page,
    onPress: () => {
      if (AmityCommunitySetupPageBehavior.goToAddMemberPage) {
        return AmityCommunitySetupPageBehavior.goToAddMemberPage({
          users: value,
          onAddedAction
        });
      }
      navigation.navigate('CommunityAddMember', {
        users: value,
        onAddedAction
      });
    }
  }), value.length > 0 && value.map(member => /*#__PURE__*/React.createElement(View, {
    style: styles.selectedMemberContainer,
    key: member.userId
  }, /*#__PURE__*/React.createElement(MemberChip, {
    member: member,
    onPress: deletedMember => {
      onChange(value.filter(m => m.userId !== deletedMember.userId));
    }
  })))));
}
export default Members;
//# sourceMappingURL=index.js.map