-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
96b4d66
commit ea3fd5f
Showing
7 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import wrapWithProvider from "./wrap-with-provider"; | ||
|
||
export const wrapRootElement = wrapWithProvider; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import wrapWithProvider from "./wrap-with-provider"; | ||
|
||
export const wrapRootElement = wrapWithProvider; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { SET_SCENARIO } from "./types"; | ||
import { ScenarioType } from "../types/scenario"; | ||
import { SetScenarioActionType } from "../types/actions"; | ||
|
||
export const setScenario = (scenario: ScenarioType): SetScenarioActionType => { | ||
return { | ||
type: SET_SCENARIO, | ||
payload: scenario, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { legacy_createStore as createStore, applyMiddleware } from "redux"; | ||
import thunk from "redux-thunk"; | ||
import { SET_SCENARIO } from "./types"; | ||
import { ScenarioType } from "../types/scenario"; | ||
import { ScenarioActionTypes } from "../types/actions"; | ||
|
||
const scenarioReducer = ( | ||
state = <ScenarioType>{}, | ||
action: ScenarioActionTypes, | ||
): ScenarioType => { | ||
switch (action.type) { | ||
case SET_SCENARIO: | ||
return { ...state, ...action.payload }; | ||
|
||
default: | ||
return state; | ||
} | ||
}; | ||
|
||
export default createStore(scenarioReducer, applyMiddleware(thunk)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export const SET_SCENARIO = "SET_SCENARIO"; | ||
export const MODIFY_SCENARIO_PROPERTY = "MODIFY_SCENARIO_PROPERTY"; | ||
export const MODIFY_MASS_PROPERTY = "MODIFY_MASS_PROPERTY"; | ||
export const ADD_MASS = "ADD_MASS"; | ||
export const DELETE_MASS = "DELETE_MASS"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { ScenarioType } from "./scenario"; | ||
|
||
export type SetScenarioActionType = { | ||
type: string; | ||
payload: ScenarioType; | ||
}; | ||
|
||
export type ScenarioActionTypes = SetScenarioActionType; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import React, { ReactElement, ReactNode } from "react"; | ||
import { Provider } from "react-redux"; | ||
import store from "./src/state"; | ||
|
||
type Props = { | ||
element: ReactNode; | ||
}; | ||
|
||
export default ({ element }: Props): ReactElement => ( | ||
<Provider store={store}>{element}</Provider> | ||
); |