Skip to content

Commit dcfb38b

Browse files
committed
finished tab 1
Co-authored-by: Sal Saluga [email protected] Co-authored-by: Ken Bains [email protected] Co-authored-by: Bianca Picasso [email protected]
1 parent 1b0da98 commit dcfb38b

File tree

2 files changed

+27
-27
lines changed

2 files changed

+27
-27
lines changed

app/src/components/ContextAPIManager/CreatorComponent/CreatorForm.tsx

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,6 @@ import { Typography } from '@mui/material';
2121

2222
const filter = createFilterOptions();
2323

24-
// const contextArr = [
25-
// {
26-
// name: 'theme',
27-
// contextInputs: [
28-
// { key: 'dark', contextInput: 'black' },
29-
// { key: 'light', contextInput: 'white' }
30-
// ]
31-
// },
32-
33-
// {
34-
// name: 'mood',
35-
// contextInputs: [
36-
// { key: 'happy', contextInput: 'rainbow' },
37-
// { key: 'sad', contextInput: 'blue' }
38-
// ]
39-
// }
40-
// ];
41-
4224
//START - Table styling
4325
const StyledTableCell = styled(TableCell)(({ theme }) => ({
4426
[`&.${tableCellClasses.head}`]: {
@@ -69,12 +51,24 @@ const CreatorForm = ({
6951
//array storing all contexts
7052
const { allContext } = contextStore;
7153

54+
//a state to keep track of data in table
55+
const [tableState, setTableState] = React.useState([
56+
{
57+
key: 'Enter key',
58+
value: 'Enter value'
59+
}
60+
]);
61+
7262
const [contextInput, setContextInput] = React.useState(null);
7363
const [dataContext, setDataContext] = React.useState({
7464
inputKey: '',
7565
inputValue: ''
7666
});
7767

68+
const renderTable = targetContext => {
69+
setTableState(targetContext.values);
70+
};
71+
7872
const handleChange = e => {
7973
setDataContext(prevDataContext => {
8074
return {
@@ -113,7 +107,7 @@ const CreatorForm = ({
113107
});
114108
} else {
115109
setContextInput(newValue);
116-
console.log('selected from drop down', contextInput)
110+
renderTable(newValue);
117111
}
118112
}}
119113
filterOptions={(options, params) => {
@@ -122,8 +116,8 @@ const CreatorForm = ({
122116
const { inputValue } = params;
123117
// Suggest the creation of a new contextInput
124118
const isExisting = options.some(
125-
option => inputValue === option.name
126-
// console.log(inputValue)
119+
option => inputValue === option.name
120+
// console.log(inputValue)
127121
);
128122
if (inputValue !== '' && !isExisting) {
129123
filtered.push({
@@ -156,6 +150,11 @@ const CreatorForm = ({
156150
freeSolo
157151
renderInput={params => (
158152
<TextField {...params} label="Create/Select Context" />
153+
// <TextField
154+
// {...params}
155+
// label="Free solo with text demo"
156+
// onKeyUp={() => console.log(params.inputProps.value)}
157+
// />
159158
)}
160159
/>
161160
<Button variant="contained" onClick={handleClick}>
@@ -193,7 +192,7 @@ const CreatorForm = ({
193192
</Button>
194193
</Box>
195194

196-
{/* <ContextTable target={contextArr[0].contextInputs}/> */}
195+
<ContextTable target={tableState} />
197196
</Fragment>
198197
);
199198
};

app/src/redux/reducers/slice/contextReducer.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,23 +31,24 @@ const contextReducer = (state = initialState, action) => {
3131
...state,
3232
allContext: [...state.allContext, newContext]
3333
};
34-
34+
3535
case types.ADD_CONTEXT_VALUES:
3636
// console.log('payload is', action.payload);
3737

3838
const newAllContext = [...state.allContext];
3939

4040
for (let i = 0; i < newAllContext.length; i += 1) {
4141
if (newAllContext[i].name === action.payload.name) {
42-
newAllContext[i].values.push({ key : action.payload.inputKey , value : action.payload.inputValue})
43-
}
42+
newAllContext[i].values.push({
43+
key: action.payload.inputKey,
44+
value: action.payload.inputValue
45+
});
46+
}
4447
}
4548

4649
return {
4750
...state,
4851
allContext: newAllContext
49-
50-
5152
};
5253
default: {
5354
return state;

0 commit comments

Comments
 (0)