Skip to content

Commit b72bf66

Browse files
authored
Merge pull request #17 from oslabs-beta/RachTeoTSCleanup
25 Files Optimized for TS
2 parents 9269d76 + 4cc401f commit b72bf66

30 files changed

+150
-145
lines changed

app/src/components/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { saveProject } from '../helperFunctions/projectGetSaveDel';
88
import Cookies from 'js-cookie';
99
//redux toolkit addition
1010
import { useSelector, useDispatch } from 'react-redux';
11-
import { setInitialState, toggleLoggedIn, configToggle } from '../redux/reducers/slice/appStateSlice';
11+
import { setInitialState, toggleLoggedIn} from '../redux/reducers/slice/appStateSlice';
1212

1313
import { RootState } from '../redux/store';
1414

app/src/components/ContextAPIManager/AssignTab/AssignContainer.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import DoubleArrowIcon from '@mui/icons-material/DoubleArrow';
1010
import { addComponentToContext } from '../../../redux/reducers/slice/contextReducer';
1111
import { useSelector, useDispatch, useStore } from 'react-redux';
1212
import { deleteElement } from '../../../redux/reducers/slice/appStateSlice';
13+
import { RootState } from '../../../redux/store';
1314

1415
const AssignContainer = () => {
1516
const dispatch = useDispatch();
@@ -18,7 +19,7 @@ const AssignContainer = () => {
1819
const [contextInput, setContextInput] = React.useState(null);
1920
const [componentInput, setComponentInput] = React.useState(null);
2021
const [componentTable, setComponentTable] = useState([]);
21-
const { state, contextParam } = useSelector((store) => ({
22+
const { state, contextParam } = useSelector((store:RootState) => ({
2223
state: store.appState,
2324
contextParam: store.contextSlice
2425
}));

app/src/components/ContextAPIManager/AssignTab/components/ComponentDropDrown.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import Autocomplete, { createFilterOptions } from '@mui/material/Autocomplete';
44
import Box from '@mui/material/Box';
55

66
import { useSelector } from 'react-redux';
7-
import { Store } from 'redux';
7+
import { RootState } from '../../../../redux/store';
88

99
const filter = createFilterOptions();
1010

@@ -16,7 +16,7 @@ const ComponentDropDown = ({
1616
}) => {
1717
const { allContext } = contextStore;
1818
// const [componentList] = useContext(StateContext);
19-
const {state, isDarkMode} = useSelector(store =>({
19+
const {state, isDarkMode} = useSelector((store:RootState) =>({
2020
state: store.appState,
2121
isDarkMode: store.darkMode.isDarkMode
2222
} ))

app/src/components/ContextAPIManager/AssignTab/components/ContextDropDown.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import React, { Fragment, useState, useEffect } from 'react';
22
import TextField from '@mui/material/TextField';
33
import Autocomplete, { createFilterOptions } from '@mui/material/Autocomplete';
4-
import Button from '@mui/material/Button';
54
import Box from '@mui/material/Box';
6-
import { Typography } from '@mui/material';
75
import { useSelector } from 'react-redux';
6+
import { RootState } from '../../../../redux/store';
87

98
const filter = createFilterOptions();
109

@@ -16,7 +15,7 @@ const ContextDropDown = ({
1615
}) => {
1716
const { allContext } = contextStore;
1817

19-
const isDarkMode = useSelector(store => store.darkMode.isDarkMode)
18+
const isDarkMode = useSelector((store:RootState) => store.darkMode.isDarkMode)
2019
const color = isDarkMode ? "white":"black"
2120
const onChange = (event, newValue) => {
2221
if (typeof newValue === 'string') {

app/src/components/ContextAPIManager/ContextManager.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
2-
31
import React, { useContext } from 'react';
42
import { makeStyles } from '@mui/styles';
53
import Box from '@mui/material/Box';
@@ -12,6 +10,7 @@ import CreateContainer from './CreateTab/CreateContainer';
1210
import AssignContainer from './AssignTab/AssignContainer';
1311
import DisplayContainer from './DisplayTab/DisplayContainer';
1412
import { useSelector } from 'react-redux'
13+
import { RootState } from '../../redux/store';
1514

1615

1716
const useStyles = makeStyles({
@@ -22,7 +21,7 @@ const useStyles = makeStyles({
2221
});
2322

2423
const ContextManager = (props): JSX.Element => {
25-
const { isDarkMode, style } = useSelector((store) => ({
24+
const { isDarkMode, style } = useSelector((store:RootState) => ({
2625
isDarkMode: store.darkMode.isDarkMode,
2726
style: store.styleSlice
2827
}));
@@ -40,7 +39,7 @@ const ContextManager = (props): JSX.Element => {
4039
<React.Fragment>
4140
<div className={classes.contextContainer} style={style.style}>
4241
<Box sx={{ width: '100%', typography: 'body1' }}>
43-
<TabContext value={value} sx={{color:color}}>
42+
<TabContext value={value}>
4443
<Box sx={{ borderBottom: 1, borderColor: 'divider' }}>
4544
<TabList onChange={handleChange} centered={true} sx={{color:color}}>
4645
<Tab style={ { color: color }}label="Create/Edit" value="1" />

app/src/components/ContextAPIManager/CreateTab/CreateContainer.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@ import AddDataForm from './components/AddDataForm';
77
import AddContextForm from './components/AddContextForm';
88
// import * as actions from '../../../redux/actions/actions';
99
import { Typography } from '@mui/material';
10-
import StateContext from '../../../context/context';
1110
import { addContext, deleteContext, addContextValues } from '../../../redux/reducers/slice/contextReducer';
1211
import { useSelector, useDispatch } from 'react-redux';
1312
import { deleteElement } from '../../../redux/reducers/slice/appStateSlice';
13+
import { RootState } from '../../../redux/store';
1414

1515
const CreateContainer = () => {
1616
const defaultTableData = [{ key: 'Enter Key', value: 'Enter value' }];
17-
const state = useSelector(store => store.contextSlice);
17+
const state = useSelector((store:RootState) => store.contextSlice);
1818

19-
const store = useStore();
19+
// const store = useStore();
2020
// const [state, setState] = useState([]);
2121
const [tableState, setTableState] = React.useState(defaultTableData);
2222
const [contextInput, setContextInput] = React.useState(null);

app/src/components/ContextAPIManager/CreateTab/components/AddContextForm.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import Button from '@mui/material/Button';
55
import Box from '@mui/material/Box';
66
import { Typography } from '@mui/material';
77
import { useSelector } from 'react-redux';
8+
import { RootState } from '../../../../redux/store';
89

910
const filter = createFilterOptions();
1011

@@ -19,7 +20,7 @@ const AddContextForm = ({
1920
const { allContext } = contextStore;
2021
const [btnDisabled, setBtnDisabled] = useState(false);
2122
// const [state, dispatch] = useContext(StateContext);
22-
const { state, isDarkMode } = useSelector(store => ({
23+
const { state, isDarkMode } = useSelector((store:RootState) => ({
2324
isDarkMode: store.darkMode.isDarkMode,
2425
state: store.appState
2526
}))

app/src/components/ContextAPIManager/CreateTab/components/AddDataForm.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@ import Button from '@mui/material/Button';
44
import Box from '@mui/material/Box';
55
import { Typography } from '@mui/material';
66
import {useSelector} from 'react-redux'
7+
import { RootState } from '../../../../redux/store';
78

89
const AddDataForm = ({ handleClickInputData, contextInput }) => {
910
//const [contextInput, setContextInput] = React.useState(null);
1011
const defaultInputData = {inputKey: '', inputValue: ''};
1112
const [dataContext, setDataContext] = React.useState(defaultInputData);
12-
const {isDarkMode} = useSelector(store=> store.darkMode.isDarkMode)
13+
const { isDarkMode } = useSelector((store:RootState)=> store.darkMode)
1314
const saveData = () => {
1415
setDataContext(defaultInputData);
1516
handleClickInputData(contextInput, dataContext)

app/src/components/ContextAPIManager/CreateTab/components/DataTable.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import TableRow from '@mui/material/TableRow';
77
import Paper from '@mui/material/Paper';
88
import { styled } from '@mui/material/styles';
99
import TableCell, { tableCellClasses } from '@mui/material/TableCell';
10-
import TableFooter from '@mui/material/TableFooter';
1110

1211
const StyledTableCell = styled(TableCell)(({ theme }) => ({
1312
[`&.${tableCellClasses.head}`]: {

app/src/components/ContextAPIManager/DisplayTab/DisplayContainer.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
import React, { useEffect, useState } from 'react';
2-
import { useStore } from 'react-redux';
1+
import React, { useEffect, useState} from 'react';
2+
import { useStore, useSelector } from 'react-redux';
33
import { Chart } from 'react-google-charts';
44
import Grid from '@mui/material/Grid';
5+
import { RootState } from '../../../redux/store';
56

67
const DisplayContainer = () => {
7-
const store = useStore();
8-
const { allContext } = store.getState().contextSlice;
8+
const allContext = useSelector((store:RootState) => store.contextSlice);
9+
// const { allContext } = store.getState().contextSlice;
910
const [contextData, setContextData] = useState([]);
1011

1112
//build data for Google charts, tree rendering

app/src/components/bottom/BottomTabs.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,15 @@ import Tree from '../../tree/TreeChart';
1313
import FormControl from '@mui/material/FormControl';
1414
import MenuItem from '@mui/material/MenuItem';
1515
import Select from '@mui/material/Select';
16-
import Arrow from '../main/Arrow';
16+
import arrow from '../main/Arrow';
1717
import { useDispatch, useSelector } from 'react-redux';
1818
import { changeProjectType } from '../../redux/reducers/slice/appStateSlice';
19+
import { RootState } from '../../redux/store';
1920

2021
const BottomTabs = (props): JSX.Element => {
2122
// state that controls which tab the user is on
2223
const dispatch = useDispatch();
23-
const { state, contextParam, style } = useSelector((store) => ({
24+
const { state, contextParam, style } = useSelector((store: RootState) => ({
2425
state: store.appState,
2526
contextParam: store.contextSlice,
2627
style: store.styleSlice,
@@ -47,7 +48,7 @@ const BottomTabs = (props): JSX.Element => {
4748
};
4849

4950
// Render's the highliting arrow feature that draws an arrow from the Canvas to the DemoRender
50-
Arrow.renderArrow(state.canvasFocus?.childId);
51+
arrow.renderArrow(state.canvasFocus?.childId);
5152

5253
return (
5354
<div

app/src/components/bottom/CodePreview.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { fetchPlugin } from '../../plugins/fetch-plugin';
1515
import * as esbuild from 'esbuild-wasm';
1616
import {codePreviewSave, codePreviewInput} from "../../redux/reducers/slice/codePreviewSlice";
1717
import { useDispatch, useSelector } from 'react-redux';
18+
import { RootState } from '../../redux/store';
1819

1920
const CodePreview: React.FC<{
2021
theme: string | null;
@@ -36,13 +37,13 @@ const CodePreview: React.FC<{
3637
const wrapper = useRef();
3738
const dimensions = useResizeObserver(wrapper);
3839
const { height } = dimensions || 0;
39-
const state = useSelector(store => store.appState)
40+
const state = useSelector((store:RootState) => store.appState)
4041
const [, setDivHeight] = useState(0);
4142
let currentComponent = state.components.find(
4243
(elem: Component) => elem.id === state.canvasFocus.componentId
4344
);
4445

45-
const [input, setInput] = useState();
46+
const [input, setInput] = useState('');
4647

4748
useEffect(() => {
4849
startService();

app/src/components/bottom/CreationPanel.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@ import React from 'react';
22
import ComponentPanel from '../right/ComponentPanel'
33
import HTMLPanel from '../left/HTMLPanel'
44
import { useSelector } from 'react-redux';
5+
import { RootState } from '../../redux/store';
56

67
// Creation panel holds all of the creation functionality of the application. ComponentPanel, HTMLPanel, and StatePropsPanel are all hanged here.
78
// This allows users to create all aspects of this application in one place.
89
const CreationPanel = (props): JSX.Element => {
9-
const style = useSelector((store) => store.styleSlice);
10+
const style = useSelector((store: RootState) => store.styleSlice);
1011
return (
1112
<div className="creation-panel" style={style.style}>
1213
<ComponentPanel isThemeLight={props.isThemeLight}/>

app/src/components/bottom/TableStateProps.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ import makeStyles from '@mui/styles/makeStyles';
1010
import { StatePropsPanelProps } from '../../interfaces/Interfaces';
1111
import { useDispatch, useSelector } from 'react-redux';
1212
import { deleteState } from '../../redux/reducers/slice/appStateSlice';
13+
import { RootState } from '../../redux/store';
1314

1415
const TableStateProps = props => {
15-
const { state, contextParam } = useSelector((store) => ({
16+
const { state, contextParam } = useSelector((store: RootState) => ({
1617
state: store.appState,
1718
contextParam: store.contextSlice,
1819
}));

app/src/components/bottom/UseStateModal.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ function UseStateModal({ updateAttributeWithState, attributeToChange, childId })
3434
setStatePropsId(-1);
3535
setOpen(false);
3636
}}
37-
deleteHandler={() => func()}
3837
isThemeLight={true}
3938
/>
4039
</div>

app/src/components/form/Selector.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
import React from 'react';
32
import FormControl from '@mui/material/FormControl';
43
import Select from '@mui/material/Select';

app/src/components/left/DragDropPanel.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { useContext } from 'react';
22
import Grid from '@mui/material/Grid';
33
import HTMLItem from './HTMLItem';
4-
4+
import { RootState } from '../../redux/store';
55
import { useSelector, useDispatch } from 'react-redux';
66
import { deleteElement } from '../../redux/reducers/slice/appStateSlice';
77

@@ -19,9 +19,9 @@ Hook state:
1919
*/
2020
// Extracted the drag and drop functionality from HTMLPanel to make a modular component that can hang wherever the future designers may choose.
2121
const DragDropPanel = (props): JSX.Element => {
22-
const isDarkMode = useSelector(store => store.darkMode.isDarkMode);
22+
const isDarkMode = useSelector((store:RootState) => store.darkMode.isDarkMode);
2323
const dispatch = useDispatch();
24-
const { state, contextParam } = useSelector((store) => ({
24+
const { state, contextParam } = useSelector((store:RootState) => ({
2525
state: store.appState,
2626
contextParam: store.contextSlice,
2727
}));

app/src/components/left/HTMLItem.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import ListItem from '@mui/material/ListItem';
88
import ListItemText from '@mui/material/ListItemText';
99
import createModal from '../right/createModal';
1010
import { useSelector } from 'react-redux';
11+
import { RootState } from '../../redux/store';
1112

1213
const useStyles = makeStyles({
1314
HTMLPanelItem: {
@@ -45,7 +46,7 @@ const HTMLItem : React.FC<{
4546

4647
const classes = useStyles();
4748
const [modal, setModal] = useState(null);
48-
const isDarkMode = useSelector(store => store.darkMode.isDarkMode);
49+
const isDarkMode = useSelector((store:RootState) => store.darkMode.isDarkMode);
4950
const [{ isDragging }, drag] = useDrag({
5051
item: {
5152
type: ItemTypes.INSTANCE,

app/src/components/left/HTMLPanel.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
// TextField,
99
} from '@mui/material';
1010
import TextField from '@mui/material/TextField';
11+
import { RootState } from '../../redux/store';
1112

1213
/*
1314
DESCRIPTION: This is the bottom half of the left panel, starting from the 'HTML
@@ -28,8 +29,8 @@ const HTMLPanel = (props): JSX.Element => {
2829
const [name, setName] = useState('');
2930
const [errorMsg, setErrorMsg] = useState('');
3031
const [errorStatus, setErrorStatus] = useState(false);
31-
const isDarkMode = useSelector((store) => store.darkMode.isDarkMode);
32-
const state = useSelector((store) => store.appState);
32+
const isDarkMode = useSelector((store:RootState) => store.darkMode.isDarkMode);
33+
const state = useSelector((store:RootState) => store.appState);
3334
const dispatch = useDispatch();
3435
let startingID = 0;
3536
state.HTMLTypes.forEach((element) => {
@@ -166,7 +167,7 @@ const HTMLPanel = (props): JSX.Element => {
166167
? classes.lightThemeFontColor
167168
: classes.darkThemeFontColor
168169
}
169-
value="New HTML Tag"
170+
//value="New HTML Tag"
170171
>
171172
New HTML Tag:{' '}
172173
</h4>

app/src/components/login/FBPassWord.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useState} from 'react';
1+
import React, { useState, MouseEvent} from 'react';
22
import { LoginInt } from '../../interfaces/Interfaces';
33
import {
44
Link as RouteLink,

app/src/components/login/SignIn.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import {
2727
} from '../../../../app/src/public/styles/theme';
2828
import Brightness3Icon from '@mui/icons-material/Brightness3';
2929
import Brightness5Icon from '@mui/icons-material/Brightness5';
30+
import { RootState } from '../../redux/store';
3031

3132
import config from '../../../../config.js';
3233
const { API_BASE_URL } = config;
@@ -79,7 +80,7 @@ const SignIn: React.FC<LoginInt & RouteComponentProps> = (props) => {
7980
const [username, setUsername] = useState('');
8081
const [password, setPassword] = useState('');
8182

82-
const isDarkMode = useSelector((store) => store.darkMode.isDarkMode);
83+
const isDarkMode = useSelector((store:RootState) => store.darkMode.isDarkMode);
8384

8485
const [invalidUserMsg, setInvalidUserMsg] = useState('');
8586
const [invalidPassMsg, setInvalidPassMsg] = useState('');

app/src/components/login/SignUp.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ import Typography from '@mui/material/Typography';
1616
import makeStyles from '@mui/styles/makeStyles';
1717
import Container from '@mui/material/Container';
1818
import AssignmentIcon from '@mui/icons-material/Assignment';
19-
2019
import { toggleDarkMode } from '../../redux/reducers/slice/darkModeSlice';
2120
import { useSelector, useDispatch } from 'react-redux';
2221
import { ThemeProvider, Theme, StyledEngineProvider } from '@mui/material/styles';
2322
import { SigninDark, SigninLight } from '../../../../app/src/public/styles/theme';
23+
import { RootState } from '../../redux/store';
2424

2525
declare module '@mui/styles/defaultTheme' {
2626
// eslint-disable-next-line @typescript-eslint/no-empty-interface
@@ -77,7 +77,7 @@ const SignUp: React.FC<LoginInt & RouteComponentProps> = props => {
7777
const [invalidUsername, setInvalidUsername] = useState(false);
7878
const [invalidPassword, setInvalidPassword] = useState(false);
7979
const [invalidVerifyPassword, setInvalidVerifyPassword] = useState(false);
80-
const isDarkMode = useSelector(store => store.darkMode.isDarkMode);
80+
const isDarkMode = useSelector((store:RootState) => store.darkMode.isDarkMode);
8181

8282
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
8383
let inputVal = e.target.value;

0 commit comments

Comments
 (0)