Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions src/components/Teams/CreateNewTeamPopup.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useSelector } from 'react-redux';
import { Button, Modal, ModalHeader, ModalBody, ModalFooter, Input, Alert } from 'reactstrap';
import { boxStyle, boxStyleDark } from '~/styles';
import '../Header/index.css';
const TEAM_NAME_MAX_LENGTH = 100;

export const CreateNewTeamPopup = React.memo(props => {
const darkMode = useSelector(state => state.theme.darkMode);
Expand All @@ -23,9 +24,12 @@ export const CreateNewTeamPopup = React.memo(props => {

const handleTeamNameChange = e => {
const teamName = e.target.value;
setNewName(teamName);
onValidation(true);
setTeamExists(allTeams.some(team => team.teamName.toLowerCase() === teamName.toLowerCase()));
// Only update if within character limit
if (teamName.length <= TEAM_NAME_MAX_LENGTH) {
setNewName(teamName);
onValidation(true);
setTeamExists(allTeams.some(team => team.teamName.toLowerCase() === teamName.toLowerCase()));
}
};

const handleSubmit = async () => {
Expand Down Expand Up @@ -60,9 +64,16 @@ export const CreateNewTeamPopup = React.memo(props => {
placeholder="Please enter a new team name"
value={newTeam}
onChange={handleTeamNameChange}
maxLength={TEAM_NAME_MAX_LENGTH}
className={darkMode ? 'bg-darkmode-liblack text-light border-0' : ''}
required
/>
<small
className={darkMode ? 'text-light' : 'text-muted'}
style={{ display: 'block', marginTop: '0.25rem' }}
>
{newTeam.length}/{TEAM_NAME_MAX_LENGTH} characters
</small>
{!isValidTeam && <Alert color="danger">Please enter a team name.</Alert>}
{teamExists && !props.isEdit && (
<Alert color="warning">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react';
import { Dropdown, Input } from 'reactstrap';
import './TeamsAndProjects.css';
import { useSelector } from 'react-redux';
const TEAM_NAME_MAX_LENGTH = 100;

// eslint-disable-next-line react/display-name
const AddTeamsAutoComplete = React.memo((props) => {
Expand Down Expand Up @@ -53,11 +54,18 @@ const AddTeamsAutoComplete = React.memo((props) => {
setSearchText(e.target.value);
setIsOpen(true);
}}
maxLength={TEAM_NAME_MAX_LENGTH}
className={darkMode ? 'bg-darkmode-liblack border-0 text-light' : ''}
placeholder="Search or select a team..."
aria-label="Add to Team"
/>

<small
className={darkMode ? 'text-light' : 'text-muted'}
style={{ display: 'block', marginTop: '0.25rem', fontSize: '0.875rem' }}
>
{searchText.length}/{TEAM_NAME_MAX_LENGTH} characters
</small>

{isOpen && (
<div
tabIndex="-1"
Expand Down
Loading