aboutsummaryrefslogtreecommitdiffstats
path: root/packages/website/ts/utils/documentation_container.ts
blob: 54e8a2c1ab9259056791ac9ce798789e883e39d6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { DocsInfo, DocsInfoConfig } from '@0x/react-docs';
import { Dispatch } from 'redux';
import { DocPageProps } from 'ts/pages/documentation/doc_page';
import { Dispatcher } from 'ts/redux/dispatcher';
import { State } from 'ts/redux/reducer';
import { ScreenWidths } from 'ts/types';
import { Translate } from 'ts/utils/translate';

export interface ConnectedState {
    docsVersion: string;
    availableDocVersions: string[];
    docsInfo: DocsInfo;
    translate: Translate;
    screenWidth: ScreenWidths;
}

export interface ConnectedDispatch {
    dispatcher: Dispatcher;
}

export const mapDispatchToProps = (dispatch: Dispatch<State>): ConnectedDispatch => ({
    dispatcher: new Dispatcher(dispatch),
});

export const getMapStateToProps = (docsInfoConfig: DocsInfoConfig) => {
    const docsInfo = new DocsInfo(docsInfoConfig);
    const mapStateToProps = (state: State, _ownProps: DocPageProps): ConnectedState => ({
        docsVersion: state.docsVersion,
        availableDocVersions: state.availableDocVersions,
        translate: state.translate,
        docsInfo,
        screenWidth: state.screenWidth,
    });
    return mapStateToProps;
};