Skip to content

Commit 86bbc5d

Browse files
authored
Merge pull request #1 from brianjshan/num-components
Num components
2 parents 4895a59 + 663efee commit 86bbc5d

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

app/src/components/left/ComponentPanel.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ const ComponentPanel = (): JSX.Element => {
3030
setErrorMsg('Component name cannot be blank.');
3131
} else if (type === 'dupe') {
3232
setErrorMsg('Component name already exists.');
33+
} else if (type === 'letters') {
34+
setErrorMsg('Component name must start with a letter.');
3335
}
3436
};
3537

@@ -45,6 +47,7 @@ const ComponentPanel = (): JSX.Element => {
4547
// check if name of new component is the same as an existing component
4648
const checkNameDupe = (inputName: String) => {
4749
let checkList = state.components.slice();
50+
4851
// checks to see if inputted comp name already exists
4952
let dupe = false;
5053
checkList.forEach(comp => {
@@ -79,7 +82,16 @@ const ComponentPanel = (): JSX.Element => {
7982
};
8083

8184
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() === '') {
8395
triggerError('empty');
8496
return;
8597
} else if (checkNameDupe(compName)) {

app/src/containers/RightContainer.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,10 @@ import Button from '@material-ui/core/Button';
1010
import { stateContext } from '../context/context';
1111
import HTMLTypes from '../context/HTMLTypes';
1212

13-
1413
import ProjectManager from '../components/right/ProjectManager';
1514

1615
// need to pass in props to use the useHistory feature of react router
1716
const RightContainer = (props): JSX.Element => {
18-
1917
const classes = useStyles();
2018
const [state, dispatch] = useContext(stateContext);
2119
const [displayMode, setDisplayMode] = useState('');
@@ -420,8 +418,7 @@ const useStyles = makeStyles({
420418
marginBottom: '0',
421419
marginTop: '10px'
422420
}
423-
},
424-
421+
}
425422
});
426423

427424
export default RightContainer;

app/src/interfaces/Interfaces.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { DragObjectWithType } from 'react-dnd';
22

33
export interface State {
4-
name: String;
5-
isLoggedIn: Boolean;
4+
name: string;
5+
isLoggedIn: boolean;
66
components: Component[];
77
rootComponents: number[];
88
projectType: string;

0 commit comments

Comments
 (0)