File tree Expand file tree Collapse file tree 3 files changed +16
-7
lines changed Expand file tree Collapse file tree 3 files changed +16
-7
lines changed Original file line number Diff line number Diff line change @@ -30,6 +30,8 @@ const ComponentPanel = (): JSX.Element => {
30
30
setErrorMsg ( 'Component name cannot be blank.' ) ;
31
31
} else if ( type === 'dupe' ) {
32
32
setErrorMsg ( 'Component name already exists.' ) ;
33
+ } else if ( type === 'letters' ) {
34
+ setErrorMsg ( 'Component name must start with a letter.' ) ;
33
35
}
34
36
} ;
35
37
@@ -45,6 +47,7 @@ const ComponentPanel = (): JSX.Element => {
45
47
// check if name of new component is the same as an existing component
46
48
const checkNameDupe = ( inputName : String ) => {
47
49
let checkList = state . components . slice ( ) ;
50
+
48
51
// checks to see if inputted comp name already exists
49
52
let dupe = false ;
50
53
checkList . forEach ( comp => {
@@ -79,7 +82,16 @@ const ComponentPanel = (): JSX.Element => {
79
82
} ;
80
83
81
84
const handleNameSubmit = ( ) => {
82
- if ( compName . trim ( ) === '' ) {
85
+ let letters = / [ a - z ] / ;
86
+ if ( ! compName . charAt ( 0 ) . match ( letters ) ) {
87
+ triggerError ( 'letters' ) ;
88
+ return ;
89
+ // }
90
+ // let firstChar = compName.charAt(0);
91
+ // if (firstChar <= '9' && firstChar >= '0') {
92
+ // triggerError('number');
93
+ // return;
94
+ } else if ( compName . trim ( ) === '' ) {
83
95
triggerError ( 'empty' ) ;
84
96
return ;
85
97
} else if ( checkNameDupe ( compName ) ) {
Original file line number Diff line number Diff line change @@ -10,12 +10,10 @@ import Button from '@material-ui/core/Button';
10
10
import { stateContext } from '../context/context' ;
11
11
import HTMLTypes from '../context/HTMLTypes' ;
12
12
13
-
14
13
import ProjectManager from '../components/right/ProjectManager' ;
15
14
16
15
// need to pass in props to use the useHistory feature of react router
17
16
const RightContainer = ( props ) : JSX . Element => {
18
-
19
17
const classes = useStyles ( ) ;
20
18
const [ state , dispatch ] = useContext ( stateContext ) ;
21
19
const [ displayMode , setDisplayMode ] = useState ( '' ) ;
@@ -420,8 +418,7 @@ const useStyles = makeStyles({
420
418
marginBottom : '0' ,
421
419
marginTop : '10px'
422
420
}
423
- } ,
424
-
421
+ }
425
422
} ) ;
426
423
427
424
export default RightContainer ;
Original file line number Diff line number Diff line change 1
1
import { DragObjectWithType } from 'react-dnd' ;
2
2
3
3
export interface State {
4
- name : String ;
5
- isLoggedIn : Boolean ;
4
+ name : string ;
5
+ isLoggedIn : boolean ;
6
6
components : Component [ ] ;
7
7
rootComponents : number [ ] ;
8
8
projectType : string ;
You can’t perform that action at this time.
0 commit comments