|
1 | 1 | import { push } from "connected-react-router";
|
| 2 | +import * as actionTypes from "./actionTypes"; |
2 | 3 | import { createDemoWithWalkthroughPath } from "../../utils/paths";
|
3 | 4 | import { DemoSlug, CategorySlug } from "../../models/slugs";
|
| 5 | +import { DemoThunkAction } from "."; |
| 6 | +import { DemoThunkDispatch } from ".."; |
4 | 7 |
|
5 |
| -export const goToMainPage = () => push("/"); |
| 8 | +interface WentToMainPage { |
| 9 | + type: actionTypes.NAVIGATION_WENT_TO_MAIN_PAGE; |
| 10 | +} |
| 11 | + |
| 12 | +interface WentToDemoPage { |
| 13 | + type: actionTypes.NAVIGATION_WENT_TO_DEMO_PAGE; |
| 14 | + category: string; |
| 15 | + demo: string; |
| 16 | +} |
| 17 | + |
| 18 | +export type NavigationAction = WentToMainPage | WentToDemoPage; |
6 | 19 |
|
7 |
| -export function goToDemoPage(category: string, demo: string) { |
8 |
| - const url = createDemoWithWalkthroughPath({ |
9 |
| - category: category as CategorySlug, |
10 |
| - demo: demo as DemoSlug |
11 |
| - }); |
| 20 | +const wentToMainPage = (): WentToMainPage => ({ |
| 21 | + type: "NAVIGATION_WENT_TO_MAIN_PAGE" |
| 22 | +}); |
| 23 | + |
| 24 | +const wentToDemoPage = (category: CategorySlug, demo: DemoSlug): WentToDemoPage => ({ |
| 25 | + type: "NAVIGATION_WENT_TO_DEMO_PAGE", |
| 26 | + category, |
| 27 | + demo |
| 28 | +}); |
| 29 | + |
| 30 | +export function goToMainPage(): DemoThunkAction { |
| 31 | + return (dispatch: DemoThunkDispatch) => { |
| 32 | + dispatch(push("/")); |
| 33 | + dispatch(wentToMainPage()); |
| 34 | + }; |
| 35 | +} |
12 | 36 |
|
13 |
| - return push(url); |
| 37 | +export function goToDemoPage(category: CategorySlug, demo: DemoSlug): DemoThunkAction { |
| 38 | + return (dispatch: DemoThunkDispatch) => { |
| 39 | + const url = createDemoWithWalkthroughPath({ |
| 40 | + category, |
| 41 | + demo |
| 42 | + }); |
| 43 | + |
| 44 | + dispatch(push(url)); |
| 45 | + dispatch(wentToDemoPage(category, demo)); |
| 46 | + }; |
14 | 47 | }
|
15 | 48 |
|
16 | 49 | export function goToDemoAssetPage(url: string) {
|
|
0 commit comments