Skip to content

Commit 6b3c427

Browse files
committed
reverts back to older version of ContextAPI files in order to regain functionality. this change loses some styling that was fixed previously
1 parent 9f93c22 commit 6b3c427

File tree

9 files changed

+95
-93
lines changed

9 files changed

+95
-93
lines changed

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

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import React, { Fragment, } from 'react';
1+
import React, { Fragment, useState, useEffect, useContext } from 'react';
22
import TextField from '@mui/material/TextField';
33
import Autocomplete, { createFilterOptions } from '@mui/material/Autocomplete';
44
import Box from '@mui/material/Box';
5+
import StateContext from '../../../../context/context';
56
import { useSelector } from 'react-redux';
67

78
const filter = createFilterOptions();
@@ -12,10 +13,9 @@ const ComponentDropDown = ({
1213
componentInput,
1314
setComponentInput
1415
}) => {
15-
const { state, isDarkMode } = useSelector((store) => ({
16-
state: store.appState,
17-
isDarkMode: store.darkMode.isDarkMode
18-
}));
16+
const { allContext } = contextStore;
17+
// const [componentList] = useContext(StateContext);
18+
const state = useSelector(store => store.appState)
1919

2020
const onChange = (event, newValue) => {
2121
if (typeof newValue === 'string') {
@@ -40,7 +40,7 @@ const ComponentDropDown = ({
4040
const filtered = filter(options, params);
4141
const { inputValue } = params;
4242
// Suggest the creation of a new contextInput
43-
const isExisting = options.some((option) => inputValue === option.name);
43+
const isExisting = options.some(option => inputValue === option.name);
4444
if (inputValue !== '' && !isExisting) {
4545
filtered.push({
4646
inputValue,
@@ -53,7 +53,7 @@ const ComponentDropDown = ({
5353
return filtered;
5454
};
5555

56-
const getOptionLabel = (option) => {
56+
const getOptionLabel = option => {
5757
// Value selected with enter, right from the input
5858
if (typeof option === 'string') {
5959
return option;
@@ -67,7 +67,6 @@ const ComponentDropDown = ({
6767
};
6868

6969
const renderOption = (props, option) => <li {...props}>{option.name}</li>;
70-
const color = isDarkMode ? 'lightgray' : 'black';
7170

7271
return (
7372
<Fragment>
@@ -85,20 +84,13 @@ const ComponentDropDown = ({
8584
renderOption={renderOption}
8685
sx={{ width: 425 }}
8786
freeSolo
88-
renderInput={(params) => (
89-
<TextField
90-
{...params}
91-
label="Select Component"
92-
helperText="Select a component for your selected context to consume"
93-
InputLabelProps={{ style: { color } }}
94-
FormHelperTextProps={{ style: { color } }}
95-
InputProps={{ style: { color } }}
96-
/>
87+
renderInput={params => (
88+
<TextField {...params} label="Select Component" helperText='Select a component for your selected context to consume' />
9789
)}
9890
/>
9991
</Box>
10092
</Fragment>
10193
);
10294
};
10395

104-
export default ComponentDropDown;
96+
export default ComponentDropDown;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,4 @@ export default function DataTable({ target }) {
4949
</Table>
5050
</TableContainer>
5151
);
52-
}
52+
}

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

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import React, { Fragment, } from 'react';
1+
import React, { Fragment, useState, useEffect } from 'react';
22
import TextField from '@mui/material/TextField';
33
import Autocomplete, { createFilterOptions } from '@mui/material/Autocomplete';
44
import Button from '@mui/material/Button';
55
import Box from '@mui/material/Box';
6-
import { useSelector } from 'react-redux';
6+
import { Typography } from '@mui/material';
77

88
const filter = createFilterOptions();
99

@@ -14,7 +14,6 @@ const ContextDropDown = ({
1414
setContextInput
1515
}) => {
1616
const { allContext } = contextStore;
17-
const isDarkMode = useSelector((store) => store.darkMode.isDarkMode);
1817

1918
const onChange = (event, newValue) => {
2019
if (typeof newValue === 'string') {
@@ -39,7 +38,7 @@ const ContextDropDown = ({
3938
const filtered = filter(options, params);
4039
const { inputValue } = params;
4140
// Suggest the creation of a new contextInput
42-
const isExisting = options.some((option) => inputValue === option.name);
41+
const isExisting = options.some(option => inputValue === option.name);
4342
if (inputValue !== '' && !isExisting) {
4443
filtered.push({
4544
inputValue,
@@ -52,7 +51,7 @@ const ContextDropDown = ({
5251
return filtered;
5352
};
5453

55-
const getOptionLabel = (option) => {
54+
const getOptionLabel = option => {
5655
// Value selected with enter, right from the input
5756
if (typeof option === 'string') {
5857
return option;
@@ -66,7 +65,6 @@ const ContextDropDown = ({
6665
};
6766

6867
const renderOption = (props, option) => <li {...props}>{option.name}</li>;
69-
const color = isDarkMode ? 'lightgray' : 'black';
7068

7169
return (
7270
<Fragment>
@@ -84,20 +82,13 @@ const ContextDropDown = ({
8482
renderOption={renderOption}
8583
sx={{ width: 425 }}
8684
freeSolo
87-
renderInput={(params) => (
88-
<TextField
89-
{...params}
90-
label="Select Context"
91-
helperText="Select a context you would like to assign"
92-
InputLabelProps={{ style: { color } }}
93-
FormHelperTextProps={{ style: { color } }}
94-
InputProps={{ style: { color } }}
95-
/>
85+
renderInput={params => (
86+
<TextField {...params} label="Select Context" helperText='Select a context you would like to assign'/>
9687
)}
9788
/>
9889
</Box>
9990
</Fragment>
10091
);
10192
};
10293

103-
export default ContextDropDown;
94+
export default ContextDropDown;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,4 @@ export default function ContextTable() {
6969
</Table>
7070
</TableContainer>
7171
);
72-
}
72+
}

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

Lines changed: 40 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,38 @@
1-
import React from 'react';
1+
import React, { useEffect, useState, useContext } from 'react';
2+
import { useStore } from 'react-redux';
23
import Divider from '@mui/material/Divider';
34
import Grid from '@mui/material/Grid';
45
import DataTable from './components/DataTable';
56
import AddDataForm from './components/AddDataForm';
67
import AddContextForm from './components/AddContextForm';
8+
// import * as actions from '../../../redux/actions/actions';
79
import { Typography } from '@mui/material';
8-
import {
9-
addContext,
10-
deleteContext,
11-
addContextValues
12-
} from '../../../redux/reducers/slice/contextReducer';
10+
import StateContext from '../../../context/context';
11+
import { addContext, deleteContext, addContextValues } from '../../../redux/reducers/slice/contextReducer';
1312
import { useSelector, useDispatch } from 'react-redux';
1413
import { deleteElement } from '../../../redux/reducers/slice/appStateSlice';
14+
1515
const CreateContainer = () => {
1616
const defaultTableData = [{ key: 'Enter Key', value: 'Enter value' }];
17-
const { state, isDarkMode } = useSelector((store) => ({
18-
state: store.appState,
19-
isDarkMode: store.darkMode.isDarkMode
20-
}));
17+
const state = useSelector(store => store.contextSlice);
2118

19+
const store = useStore();
20+
// const [state, setState] = useState([]);
2221
const [tableState, setTableState] = React.useState(defaultTableData);
2322
const [contextInput, setContextInput] = React.useState(null);
23+
// const [stateContext, dispatchContext] = useContext(StateContext);
2424
const dispatch = useDispatch();
2525

26+
//pulling data from redux store
27+
// useEffect(() => {
28+
29+
// setState(allContext)
30+
// // setState(store.getState().contextSlice);
31+
32+
// }, [allContext]);
33+
34+
35+
2636
//update data store when user adds a new context
2737
const handleClickSelectContext = () => {
2838
//prevent user from adding duplicate context
@@ -33,24 +43,34 @@ const CreateContainer = () => {
3343
}
3444
setContextInput('');
3545
dispatch(addContext(contextInput));
46+
47+
// setState(allContext);
3648
};
3749

3850
//update data store when user add new key-value pair to context
3951
const handleClickInputData = ({ name }, { inputKey, inputValue }) => {
40-
dispatch(addContextValues({ name, inputKey, inputValue }));
41-
52+
dispatch(
53+
addContextValues({ name, inputKey, inputValue })
54+
);
55+
// setState(allContext);
4256
};
4357

4458
//update data store when user deletes context
4559
const handleDeleteContextClick = () => {
4660
dispatch(deleteContext(contextInput));
4761
setContextInput('');
62+
// setState(allContext);
4863
setTableState(defaultTableData);
49-
dispatch(deleteElement({ id: 'FAKE_ID', contextParam: state }));
64+
65+
dispatch(deleteElement({id:'FAKE_ID', contextParam: state}))
66+
// dispatchContext({
67+
// type: 'DELETE ELEMENT',
68+
// payload: 'FAKE_ID'
69+
// });
5070
};
5171

5272
//re-render data table when there's new changes
53-
const renderTable = (targetContext) => {
73+
const renderTable = targetContext => {
5474
if (
5575
targetContext === null ||
5676
targetContext === undefined ||
@@ -62,9 +82,6 @@ const CreateContainer = () => {
6282
setTableState(targetContext.values);
6383
}
6484
};
65-
66-
const color = isDarkMode ? 'lightgray' : 'black';
67-
6885
return (
6986
<>
7087
<Grid container display="flex" justifyContent="space-evenly">
@@ -99,7 +116,11 @@ const CreateContainer = () => {
99116
</Grid>
100117
<Divider orientation="vertical" variant="middle" flexItem />
101118
<Grid item>
102-
<Typography style={{ color }} variant="h6" gutterBottom={true}>
119+
<Typography
120+
style={{ color: 'black' }}
121+
variant="h6"
122+
gutterBottom={true}
123+
>
103124
Context Data Table
104125
</Typography>
105126
<DataTable target={tableState} contextInput={contextInput} />
@@ -109,4 +130,4 @@ const CreateContainer = () => {
109130
);
110131
};
111132

112-
export default CreateContainer;
133+
export default CreateContainer;

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

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
import React, { Fragment, useState } from 'react';
1+
import React, { Fragment, useState, useEffect, useContext } from 'react';
22
import TextField from '@mui/material/TextField';
33
import Autocomplete, { createFilterOptions } from '@mui/material/Autocomplete';
44
import Button from '@mui/material/Button';
55
import Box from '@mui/material/Box';
66
import { Typography } from '@mui/material';
7+
import StateContext from '../../../../context/context';
78
import { useSelector } from 'react-redux';
89

910
const filter = createFilterOptions();
@@ -18,7 +19,8 @@ const AddContextForm = ({
1819
}) => {
1920
const { allContext } = contextStore;
2021
const [btnDisabled, setBtnDisabled] = useState(false);
21-
const isDarkMode = useSelector((state) => state.darkMode.isDarkMode);
22+
// const [state, dispatch] = useContext(StateContext);
23+
const state = useSelector(store => store.appState)
2224

2325
const handleClick = () => {
2426
if (contextInput === '' || contextInput === null) return;
@@ -48,7 +50,7 @@ const AddContextForm = ({
4850
const filtered = filter(options, params);
4951
const { inputValue } = params;
5052
// Suggest the creation of a new contextInput
51-
const isExisting = options.some((option) => inputValue === option.name);
53+
const isExisting = options.some(option => inputValue === option.name);
5254
if (inputValue !== '' && !isExisting) {
5355
filtered.push({
5456
inputValue,
@@ -61,7 +63,7 @@ const AddContextForm = ({
6163
return filtered;
6264
};
6365

64-
const getOptionLabel = (option) => {
66+
const getOptionLabel = option => {
6567
// Value selected with enter, right from the input
6668
if (typeof option === 'string') {
6769
return option;
@@ -75,14 +77,13 @@ const AddContextForm = ({
7577
};
7678

7779
const renderOption = (props, option) => <li {...props}>{option.name}</li>;
78-
const color = isDarkMode ? 'lightgray' : 'black';
7980

8081
return (
8182
<Fragment>
82-
<Typography style={{ color }} variant="h6" gutterBottom={true}>
83+
<Typography style={{ color: 'black' }} variant="h6" gutterBottom={true}>
8384
Context Input
8485
</Typography>
85-
<Box sx={{ display: 'flex', gap: 2, mb: 4, color }}>
86+
<Box sx={{ display: 'flex', gap: 2, mb: 4 }}>
8687
<Autocomplete
8788
id="autoCompleteContextField"
8889
value={contextInput}
@@ -96,14 +97,8 @@ const AddContextForm = ({
9697
renderOption={renderOption}
9798
sx={{ width: 425 }}
9899
freeSolo
99-
renderInput={(params) => (
100-
<TextField
101-
{...params}
102-
variant="outlined"
103-
label="Create/Select Context"
104-
InputLabelProps={{ style: { color } }}
105-
InputProps={{ style: { color } }}
106-
/>
100+
renderInput={params => (
101+
<TextField {...params} label="Create/Select Context" />
107102
)}
108103
/>
109104
<Button
@@ -126,4 +121,4 @@ const AddContextForm = ({
126121
);
127122
};
128123

129-
export default AddContextForm;
124+
export default AddContextForm;

0 commit comments

Comments
 (0)