Skip to content

Commit 9219b14

Browse files
authored
Merge pull request #17 from oslabs-beta/featurekelvin
fixed save series functionality within RTKstore and added necessary r…
2 parents d33e991 + ab400d9 commit 9219b14

File tree

4 files changed

+18
-3
lines changed

4 files changed

+18
-3
lines changed

src/app/RTKslices.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,12 @@ export const mainSlice = createSlice({
144144
if (!mode?.paused) {
145145
if (typeof action.payload === 'number') {
146146
state.currentTab = action.payload;
147+
return;
147148
} else if (typeof action.payload === 'object') {
148149
state.currentTab = action.payload.tabId;
149150
if (action.payload?.title)
150151
state.currentTitle = action.payload.title;
152+
return;
151153
};
152154
}
153155
console.log('setTab: state end', current(state));
@@ -382,7 +384,9 @@ export const mainSlice = createSlice({
382384
switch (action.payload) {
383385
case 'paused':
384386
actionText = 'setPause';
387+
break;
385388
default:
389+
break;
386390
}
387391
port.postMessage({
388392
action: actionText,
@@ -461,6 +465,8 @@ export const mainSlice = createSlice({
461465
const { newSeries, newSeriesName } = action.payload;
462466
if (!tabs[currentTab].seriesSavedStatus) {
463467
tabs[currentTab] = { ...tabs[currentTab], seriesSavedStatus: 'inputBoxOpen' };
468+
//testing return to fix save functionality
469+
return;
464470
}
465471
// Runs if series name input box is active.
466472
// Updates chrome local storage with the newly saved series. Console logging the seriesArray grabbed from local storage may be helpful.
@@ -472,6 +478,8 @@ export const mainSlice = createSlice({
472478
seriesArray.push(newSeries);
473479
localStorage.setItem('project', JSON.stringify(seriesArray));
474480
tabs[currentTab] = { ...tabs[currentTab], seriesSavedStatus: 'saved' };
481+
//testing return to fix save functionality instead of break
482+
return;
475483
}
476484
},
477485

src/app/components/App.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ function App(): JSX.Element {
2828
<ThemeProvider theme={theme}>
2929
<Router>
3030
{/* we wrap our application with the <Router> tag so that all components that are nested will have the react-router context */}
31-
<StoreContext.Provider value={useReducer(mainReducer, initialState)}>
31+
{/* <StoreContext.Provider value={useReducer(mainReducer, initialState)}> */}
3232
{/* we wrap our MainContainer with the provider so that we will be able to use the store context. We create our store by using useReducer and passing it into the value property */}
3333
<MainContainer />
34-
</StoreContext.Provider>
34+
{/* </StoreContext.Provider> */}
3535
</Router>
3636
</ThemeProvider>
3737
);

src/app/components/StateRoute/PerformanceVisx/BarGraph.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,18 @@ const BarGraph = (props: BarGraphProps): JSX.Element => {
113113
});
114114

115115
const saveSeriesClickHandler = () => { // function to save the currently selected series
116+
console.log('we are in save series click handler')
116117
if (tabs[currentTab].seriesSavedStatus === 'inputBoxOpen') {
118+
console.log('we are inside the conditional within saveSeriesClickHandler')
119+
console.log('this is the comparison.length', comparison.length)
117120
const actionNames = document.getElementsByClassName('actionname');
118121
for (let i = 0; i < actionNames.length; i += 1) {
119122
toStorage.data.barStack[i].name = actionNames[i].value;
120123
}
121-
dispatch(save(toStorage, seriesNameInput)); // saves the series under seriesName
124+
console.log('this is seriesnameINput', seriesNameInput);
125+
console.log('this is toStorage', toStorage);
126+
dispatch(save({ newSeries: toStorage, newSeriesName: seriesNameInput })); // saves the series under seriesName
127+
console.log('this is seriesName', seriesName);
122128
setSeriesNameInput(`Series ${comparison.length}`); // sends a reducer that saves the series/toStorage object the user wants to chrome local storage
123129
return;
124130
}

src/app/components/StateRoute/PerformanceVisx/PerformanceVisx.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ const traverse = (snapshot, data, snapshots, currTotalRender: currNum = 0): void
123123
const allStorage = (): Series[] => {
124124
let values = localStorage.getItem('project');
125125
const newValues: Series[] = values === null ? [] : JSON.parse(values);
126+
console.log('this is newValues', newValues);
126127
return newValues;
127128
};
128129

0 commit comments

Comments
 (0)