Skip to content

Commit 4cc401f

Browse files
Rachel KucharskiMatteoDitersophia-bui
committed
25 files optimized for TS
Co-authored-by: Matteo <[email protected]> Co-authored-by: Sophia Bui <[email protected]>
1 parent de0767d commit 4cc401f

20 files changed

+45
-54
lines changed

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/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;

app/src/components/main/AddLink.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ import Select from '@mui/material/Select';
55
import { InputLabel } from '@mui/material';
66
import {useDispatch, useSelector} from 'react-redux';
77
import { updateAttributes } from '../../redux/reducers/slice/appStateSlice';
8+
import { RootState } from '../../redux/store';
89

910
function AddLink({ id, onClickHandler, linkDisplayed }) {
1011

11-
const { state, contextParam, isThemeLight } = useSelector((store) => ({
12+
const { state, contextParam, isThemeLight } = useSelector((store:RootState) => ({
1213
state: store.appState,
1314
contextParam: store.contextSlice,
1415
isThemeLight: store.styleSlice
@@ -34,7 +35,7 @@ function AddLink({ id, onClickHandler, linkDisplayed }) {
3435
const state = JSON.parse(JSON.stringify(element));
3536
state.childId = id;
3637
state.attributes.compLink = event.target.value;
37-
dispatch(updateAttributes(state, contextParam))
38+
dispatch(updateAttributes({attributes: state, contextParam: contextParam}))
3839
return true;
3940
}
4041
});
@@ -47,7 +48,7 @@ function AddLink({ id, onClickHandler, linkDisplayed }) {
4748

4849
return (
4950
<div style={{float: 'right'}}>
50-
<FormControl variant='outlined' focused='true' style={ {width: '100%'} }>
51+
<FormControl variant='outlined' focused={true} style={ {width: '100%'} }>
5152
<InputLabel id='page-select-label' style={ {color: isThemeLight? '#000' : '#fff'} }>Pages</InputLabel>
5253
<Select
5354
label='Pages'

app/src/components/main/AddRoute.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,19 @@ import { AddRoutes } from '../../interfaces/Interfaces'
22
import React from 'react';
33
import {useDispatch, useSelector} from 'react-redux'
44
import { addChild} from '../../redux/reducers/slice/appStateSlice';
5+
import { RootState } from '../../redux/store';
56

67
function AddRoute({
78
id
89
}: AddRoutes) {
910
const dispatch = useDispatch();
10-
const contextParam = useSelector(store => store.contextSlice)
11+
const contextParam = useSelector((store:RootState) => store.contextSlice)
1112
const handleClick = (id) => {
1213
dispatch(addChild({
1314
type: 'HTML Element',
1415
typeId: -1,
1516
childId: id, // this is the id of the parent to attach it to
16-
contextParam: store.contextSlice
17+
contextParam: contextParam
1718
}))
1819

1920
}

app/src/components/main/Canvas.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@ import renderChildren from '../../helperFunctions/renderChildren';
77
import Arrow from './Arrow';
88
import { useDispatch, useSelector } from 'react-redux';
99
import { changeFocus, addChild, snapShotAction } from '../../redux/reducers/slice/appStateSlice';
10+
import { RootState } from '../../redux/store';
1011

1112
function Canvas(props): JSX.Element {
1213

13-
const { state, contextParam,isDarkMode } = useSelector((store) => ({
14+
const { state, contextParam,isDarkMode } = useSelector((store:RootState) => ({
1415
state: store.appState,
1516
contextParam: store.contextSlice,
1617
isDarkMode: store.darkMode.isDarkMode
@@ -84,7 +85,7 @@ function Canvas(props): JSX.Element {
8485
break;
8586
} else {
8687
// if false
87-
setCopiedComp(child);
88+
// setCopiedComp(child);
8889
hasDiffParent = true;
8990
newChildName = child.name;
9091
i = components.length;

app/src/components/main/DeleteButton.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import React from 'react';
22
import { DeleteButtons } from '../../interfaces/Interfaces';
3-
43
import { useDispatch, useSelector } from 'react-redux';
54
import { deleteChild } from '../../redux/reducers/slice/appStateSlice';
5+
import { RootState } from '../../redux/store';
66

77
function DeleteButton({ id, name }: DeleteButtons) {
8-
const { state, contextParam } = useSelector((store) => ({
8+
const { state, contextParam } = useSelector((store:RootState) => ({
99
state: store.appState,
1010
contextParam: store.contextSlice,
1111
}));

app/src/components/main/DemoRender.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@ import { Component } from '../../interfaces/Interfaces';
66
import ReactDOMServer from 'react-dom/server';
77
import { useDispatch, useSelector } from 'react-redux';
88
import { changeFocus } from '../../redux/reducers/slice/appStateSlice';
9+
import { RootState } from '../../redux/store';
910

1011
// DemoRender is the full sandbox demo of our user's custom built React components. DemoRender references the design specifications stored in state to construct
1112
// real react components that utilize hot module reloading to depict the user's prototype application.
1213
const DemoRender = (): JSX.Element => {
13-
const state = useSelector(store => store.appState);
14+
const state = useSelector((store:RootState) => store.appState);
1415
const dispatch = useDispatch();
1516
let currentComponent = state.components.find(
1617
(elem: Component) => elem.id === state.canvasFocus.componentId
@@ -28,10 +29,6 @@ const DemoRender = (): JSX.Element => {
2829
const html = `
2930
<html>
3031
<head>
31-
<link
32-
rel="stylesheet"
33-
href="./fake.css"
34-
/>
3532
</head>
3633
<body>
3734
<div id="app">
@@ -74,7 +71,7 @@ const DemoRender = (): JSX.Element => {
7471

7572
// This function is the heart of DemoRender it will take the array of components stored in state and dynamically construct the desired React component for the live demo
7673
// Material UI is utilized to incorporate the apporpriate tags with specific configuration designs as necessitated by HTML standards.
77-
const componentBuilder = (array: object, key: number = 0) => {
74+
const componentBuilder = (array: any, key: number = 0) => {
7875
const componentsToRender = [];
7976
for (const element of array) {
8077
if (element.name !== 'separator') {

app/src/components/main/fake.css

Lines changed: 0 additions & 13 deletions
This file was deleted.

app/src/interfaces/Interfaces.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ export interface Action {
6161
}
6262

6363
export interface Payload {}
64+
6465
export interface Reduce {
6566
state: Context;
6667
action: Action;

0 commit comments

Comments
 (0)