Skip to content

Commit 1b0da98

Browse files
Bianca PicassoBianca Picasso
authored andcommitted
context dropdown and key pair
Co-authored-by: Sal Saluga [email protected] Co-authored-by: Ken Bains [email protected] Co-authored-by: Huy Pham [email protected]
1 parent 5d9edde commit 1b0da98

File tree

4 files changed

+20
-6
lines changed

4 files changed

+20
-6
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const ContextCreator = () => {
1616
setIsReady(true);
1717
}, []);
1818

19+
1920
const dispatch = useDispatch();
2021

2122
const handleClickSelectContext = contextInput => {
@@ -34,6 +35,7 @@ const ContextCreator = () => {
3435
dispatch(
3536
actions.addContextValuesActionCreator({ name, inputKey, inputValue })
3637
);
38+
setState(store.getState().contextSlice);
3739
};
3840

3941
return (

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ const rows = [
4545
createData('Cupcake', 305, 3.7, 67, 4.3),
4646
createData('Gingerbread', 356, 16.0, 49, 3.9)
4747
];
48-
/* <Table style={{ width: 400, margin: 'auto' }}></Table> */
49-
// sx={{ width: '40%' }}
48+
5049
export default function ContextTable({target}) {
5150
return (
5251
<TableContainer component={Paper}>

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ const CreatorForm = ({
113113
});
114114
} else {
115115
setContextInput(newValue);
116+
console.log('selected from drop down', contextInput)
116117
}
117118
}}
118119
filterOptions={(options, params) => {
@@ -121,7 +122,8 @@ const CreatorForm = ({
121122
const { inputValue } = params;
122123
// Suggest the creation of a new contextInput
123124
const isExisting = options.some(
124-
option => inputValue === option.name
125+
option => inputValue === option.name
126+
// console.log(inputValue)
125127
);
126128
if (inputValue !== '' && !isExisting) {
127129
filtered.push({

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

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,23 @@ const contextReducer = (state = initialState, action) => {
3131
...state,
3232
allContext: [...state.allContext, newContext]
3333
};
34-
34+
3535
case types.ADD_CONTEXT_VALUES:
36-
console.log('payload is', action.payload);
36+
// console.log('payload is', action.payload);
37+
38+
const newAllContext = [...state.allContext];
39+
40+
for (let i = 0; i < newAllContext.length; i += 1) {
41+
if (newAllContext[i].name === action.payload.name) {
42+
newAllContext[i].values.push({ key : action.payload.inputKey , value : action.payload.inputValue})
43+
}
44+
}
3745

3846
return {
39-
...state
47+
...state,
48+
allContext: newAllContext
49+
50+
4051
};
4152
default: {
4253
return state;

0 commit comments

Comments
 (0)