Skip to content

Commit fef2a3a

Browse files
committed
converted tutorial.tsx and added reducer to RTK slices
1 parent e47f9d4 commit fef2a3a

File tree

3 files changed

+21
-8
lines changed

3 files changed

+21
-8
lines changed

src/app/RTKslices.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,11 @@ export const mainSlice = createSlice({
367367
tabs[currentTab].currParent = savedSnapshot.currParent;
368368
tabs[currentTab].currBranch = savedSnapshot.Branch;
369369
tabs[currentTab].seriesSavedStatus = false;
370+
},
371+
tutorialSaveSeriesToggle: (state, action) => {
372+
const { tabs, currentTab } = state;
373+
tabs[currentTab] = { ...tabs[currentTab], seriesSavedStatus: action.payload }
374+
370375
}
371376
},
372377
})
@@ -391,7 +396,8 @@ export const {
391396
moveBackward,
392397
resetSlider,
393398
toggleMode,
394-
importSnapshots
399+
importSnapshots,
400+
tutorialSaveSeriesToggle
395401
} = mainSlice.actions
396402

397403

src/app/components/Tutorial.tsx

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@
55
import * as React from 'react';
66
import { Component } from 'react';
77
import 'intro.js/introjs.css';
8-
import { tutorialSaveSeriesToggle, setCurrentTabInApp } from '../actions/actions';
8+
// import { tutorialSaveSeriesToggle, setCurrentTabInApp } from '../actions/actions';
99
import { TutorialProps, TutorialState, StepsObj } from '../FrontendTypes';
1010
import { Button } from '@mui/material';
1111
import HelpOutlineIcon from '@mui/icons-material/HelpOutline';
1212
const { Steps } = require('intro.js-react'); //Must be required in. This enables compatibility with TS. If imported in, throws ts error of not rendering steps as a class component correctly. The package 'intro.js-react' is small React wrapper around Intro.js. The wrapper provides support for both steps and hints. https://introjs.com/docs/
13-
13+
import { setCurrentTabInApp, tutorialSaveSeriesToggle } from '../RTKslices'
14+
import { useDispatch, useSelector } from 'react-redux';
1415
/*
1516
This is the tutorial displayed when the "How to use" button is clicked
1617
This needs to be a class component to be compatible with updateStepElement from intro.js
@@ -35,10 +36,13 @@ export default class Tutorial extends Component<TutorialProps, TutorialState> {
3536
public refs: any;
3637

3738
render(): JSX.Element {
38-
const {
39-
currentTabInApp, // 'currentTabInApp' from 'ButtonsContainer' after useStoreContext()
40-
dispatch // 'dispatch' from 'ButtonsContainer' after useStoreContext()
41-
} = this.props;
39+
// const {
40+
// currentTabInApp, // 'currentTabInApp' from 'ButtonsContainer' after useStoreContext()
41+
// dispatch // 'dispatch' from 'ButtonsContainer' after useStoreContext()
42+
// } = this.props;
43+
44+
const dispatch = useDispatch();
45+
const currentTabInApp = useSelector((state: any) => state.main.currentTabInApp);
4246

4347
// This updates the steps so that they can target dynamically rendered elements
4448
const onChangeHandler = (currentStepIndex: number) => { // takes in the current step and updates the tab[currentTab]'s seriesSavedStatus based on conditions and updates the element associated with the step.

src/app/containers/ButtonsContainer.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,10 @@ function ButtonsContainer(): JSX.Element {
7878
Upload
7979
</Button>
8080
{/* The component below renders a button for the tutorial walkthrough of Reactime */}
81-
<Tutorial dispatch={dispatch} currentTabInApp={currentTabInApp} />
81+
<Tutorial
82+
//commented out so we can use useDispatch in Tutorial.tsx
83+
// dispatch={dispatch}
84+
currentTabInApp={currentTabInApp} />
8285
</div>
8386
);
8487
}

0 commit comments

Comments
 (0)