mirror of
https://github.com/muerwre/orchidmap-front.git
synced 2025-04-25 11:06:40 +07:00
moved components to TypeScript
This commit is contained in:
parent
85b8860862
commit
0a01c91271
54 changed files with 2771 additions and 5134 deletions
76
src/components/panels/EditorDialog.tsx
Normal file
76
src/components/panels/EditorDialog.tsx
Normal file
|
@ -0,0 +1,76 @@
|
|||
import * as React from 'react';
|
||||
import { IModes, MODES } from '$constants/modes';
|
||||
|
||||
import { RouterDialog } from '$components/dialogs/RouterDialog';
|
||||
import { StickersDialog } from '$components/dialogs/StickersDialog';
|
||||
import { TrashDialog } from '$components/dialogs/TrashDialog';
|
||||
import { LogoDialog } from '$components/dialogs/LogoDialog';
|
||||
import { SaveDialog } from '$components/dialogs/SaveDialog';
|
||||
import { CancelDialog } from '$components/dialogs/CancelDialog';
|
||||
|
||||
import { bindActionCreators } from 'redux';
|
||||
import { connect } from 'react-redux';
|
||||
|
||||
import {
|
||||
setMode,
|
||||
setLogo,
|
||||
routerCancel,
|
||||
routerSubmit,
|
||||
setActiveSticker,
|
||||
clearStickers,
|
||||
clearPoly,
|
||||
clearAll,
|
||||
clearCancel,
|
||||
stopEditing,
|
||||
setEditing,
|
||||
sendSaveRequest,
|
||||
changeProvider,
|
||||
} from '$redux/user/actions';
|
||||
import { ProviderDialog } from '$components/dialogs/ProviderDialog';
|
||||
import { ShotPrefetchDialog } from '$components/dialogs/ShotPrefetchDialog';
|
||||
import { IRootState } from "$redux/user/reducer";
|
||||
|
||||
interface Props extends IRootState {
|
||||
width: number,
|
||||
}
|
||||
|
||||
const DIALOG_CONTENTS: { [x: string]: any } = {
|
||||
[MODES.ROUTER]: RouterDialog,
|
||||
[MODES.STICKERS_SELECT]: StickersDialog,
|
||||
[MODES.TRASH]: TrashDialog,
|
||||
[MODES.LOGO]: LogoDialog,
|
||||
[MODES.SAVE]: SaveDialog,
|
||||
[MODES.CONFIRM_CANCEL]: CancelDialog,
|
||||
[MODES.PROVIDER]: ProviderDialog,
|
||||
[MODES.SHOT_PREFETCH]: ShotPrefetchDialog,
|
||||
};
|
||||
|
||||
export const Component = (props: Props) => (
|
||||
props.mode && DIALOG_CONTENTS[props.mode]
|
||||
? React.createElement(DIALOG_CONTENTS[props.mode], { ...props })
|
||||
: null
|
||||
);
|
||||
|
||||
const mapStateToProps = ({ user }) => ({ ...user });
|
||||
|
||||
const mapDispatchToProps = dispatch => bindActionCreators({
|
||||
routerCancel,
|
||||
routerSubmit,
|
||||
setLogo,
|
||||
setActiveSticker,
|
||||
clearStickers,
|
||||
clearPoly,
|
||||
clearAll,
|
||||
clearCancel,
|
||||
stopEditing,
|
||||
setEditing,
|
||||
setMode,
|
||||
sendSaveRequest,
|
||||
changeProvider,
|
||||
}, dispatch);
|
||||
|
||||
export const EditorDialog = connect(
|
||||
mapStateToProps,
|
||||
mapDispatchToProps
|
||||
)(Component);
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue