mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 04:46:40 +07:00
fixed typescript errors
This commit is contained in:
parent
41e4190096
commit
94cc515589
11 changed files with 70 additions and 40 deletions
|
@ -1,14 +1,9 @@
|
|||
import React, { FC } from 'react';
|
||||
import { EditorUploadButton } from '~/components/editors/EditorUploadButton';
|
||||
import { INode } from '~/redux/types';
|
||||
import { UPLOAD_TYPES } from '~/redux/uploads/constants';
|
||||
import { IEditorComponentProps } from '~/redux/node/types';
|
||||
|
||||
interface IProps {
|
||||
data: INode;
|
||||
setData: (val: INode) => void;
|
||||
temp: string[];
|
||||
setTemp: (val: string[]) => void;
|
||||
}
|
||||
type IProps = IEditorComponentProps & {};
|
||||
|
||||
const EditorAudioUploadButton: FC<IProps> = ({ data, setData, temp, setTemp }) => (
|
||||
<EditorUploadButton
|
||||
|
|
9
src/components/editors/EditorFiller/index.tsx
Normal file
9
src/components/editors/EditorFiller/index.tsx
Normal file
|
@ -0,0 +1,9 @@
|
|||
import React, { FC } from 'react';
|
||||
import { Filler } from '~/components/containers/Filler';
|
||||
import { IEditorComponentProps } from '~/redux/node/types';
|
||||
|
||||
type IProps = IEditorComponentProps & {};
|
||||
|
||||
const EditorFiller: FC<IProps> = () => <Filler />;
|
||||
|
||||
export { EditorFiller };
|
|
@ -2,13 +2,9 @@ import React, { FC } from 'react';
|
|||
import { EditorUploadButton } from '~/components/editors/EditorUploadButton';
|
||||
import { INode } from '~/redux/types';
|
||||
import { UPLOAD_TYPES } from '~/redux/uploads/constants';
|
||||
import { IEditorComponentProps } from '~/redux/node/types';
|
||||
|
||||
interface IProps {
|
||||
data: INode;
|
||||
setData: (val: INode) => void;
|
||||
temp: string[];
|
||||
setTemp: (val: string[]) => void;
|
||||
}
|
||||
type IProps = IEditorComponentProps & {};
|
||||
|
||||
const EditorImageUploadButton: FC<IProps> = ({ data, setData, temp, setTemp }) => (
|
||||
<EditorUploadButton
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import React, { FC, useState, useCallback, useEffect } from 'react';
|
||||
import { INode, IFileWithUUID } from '~/redux/types';
|
||||
import React, { FC, useCallback, useEffect, useState } from 'react';
|
||||
import { IFileWithUUID } from '~/redux/types';
|
||||
import uuid from 'uuid4';
|
||||
import * as styles from './styles.scss';
|
||||
import { UPLOAD_SUBJECTS, UPLOAD_TARGETS, UPLOAD_TYPES } from '~/redux/uploads/constants';
|
||||
|
@ -10,6 +10,7 @@ import { selectUploads } from '~/redux/uploads/selectors';
|
|||
import { getURL } from '~/utils/dom';
|
||||
import { Icon } from '~/components/input/Icon';
|
||||
import { PRESETS } from '~/constants/urls';
|
||||
import { IEditorComponentProps } from '~/redux/node/types';
|
||||
|
||||
const mapStateToProps = state => {
|
||||
const { statuses, files } = selectUploads(state);
|
||||
|
@ -22,12 +23,8 @@ const mapDispatchToProps = {
|
|||
};
|
||||
|
||||
type IProps = ReturnType<typeof mapStateToProps> &
|
||||
typeof mapDispatchToProps & {
|
||||
data: INode;
|
||||
setData: (data: INode) => void;
|
||||
temp: string[];
|
||||
setTemp: (val: string[]) => void;
|
||||
};
|
||||
typeof mapDispatchToProps &
|
||||
IEditorComponentProps & {};
|
||||
|
||||
const EditorUploadCoverButtonUnconnected: FC<IProps> = ({
|
||||
data,
|
||||
|
|
|
@ -11,13 +11,17 @@ import { RestoreRequestDialog } from '~/containers/dialogs/RestoreRequestDialog'
|
|||
import { RestorePasswordDialog } from '~/containers/dialogs/RestorePasswordDialog';
|
||||
import { DIALOGS } from '~/redux/modal/constants';
|
||||
import { PhotoSwipe } from '~/containers/dialogs/PhotoSwipe';
|
||||
import { LoginSocialRegisterDialog } from '~/containers/dialogs/LoginSocialRegisterDialog';
|
||||
import { IDialogProps } from '~/redux/types';
|
||||
import { FC } from 'react';
|
||||
|
||||
export const DIALOG_CONTENT = {
|
||||
export const DIALOG_CONTENT: Record<string, FC<IDialogProps>> = {
|
||||
[DIALOGS.EDITOR_IMAGE]: EditorDialogImage,
|
||||
[DIALOGS.EDITOR_TEXT]: EditorDialogText,
|
||||
[DIALOGS.EDITOR_VIDEO]: EditorDialogVideo,
|
||||
[DIALOGS.EDITOR_AUDIO]: EditorDialogAudio,
|
||||
[DIALOGS.LOGIN]: LoginDialog,
|
||||
[DIALOGS.LOGIN_SOCIAL_REGISTER]: LoginSocialRegisterDialog,
|
||||
[DIALOGS.LOADING]: LoadingDialog,
|
||||
[DIALOGS.TEST]: TestDialog,
|
||||
[DIALOGS.PROFILE]: ProfileDialog,
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import React, { FC, useState, useCallback, FormEvent, useEffect, createElement } from 'react';
|
||||
import React, { createElement, FC, FormEvent, useCallback, useEffect, useState } from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
import { ScrollDialog } from '../ScrollDialog';
|
||||
import { IDialogProps } from '~/redux/modal/constants';
|
||||
import { useCloseOnEscape } from '~/utils/hooks';
|
||||
import { Group } from '~/components/containers/Group';
|
||||
|
@ -13,9 +12,10 @@ import { EditorPanel } from '~/components/editors/EditorPanel';
|
|||
import * as NODE_ACTIONS from '~/redux/node/actions';
|
||||
import { selectUploads } from '~/redux/uploads/selectors';
|
||||
import { ERROR_LITERAL } from '~/constants/errors';
|
||||
import { NODE_EDITORS, EMPTY_NODE } from '~/redux/node/constants';
|
||||
import { EMPTY_NODE, NODE_EDITORS } from '~/redux/node/constants';
|
||||
import { BetterScrollDialog } from '../BetterScrollDialog';
|
||||
import { CoverBackdrop } from '~/components/containers/CoverBackdrop';
|
||||
import { IEditorComponentProps } from '~/redux/node/types';
|
||||
|
||||
const mapStateToProps = state => {
|
||||
const { editor, errors } = selectNode(state);
|
||||
|
@ -32,7 +32,7 @@ const mapDispatchToProps = {
|
|||
type IProps = IDialogProps &
|
||||
ReturnType<typeof mapStateToProps> &
|
||||
typeof mapDispatchToProps & {
|
||||
type: typeof NODE_EDITORS[keyof typeof NODE_EDITORS];
|
||||
type: keyof typeof NODE_EDITORS;
|
||||
};
|
||||
|
||||
const EditorDialogUnconnected: FC<IProps> = ({
|
||||
|
@ -64,7 +64,8 @@ const EditorDialogUnconnected: FC<IProps> = ({
|
|||
);
|
||||
|
||||
useEffect(() => {
|
||||
if (!NODE_EDITORS[type] && onRequestClose) onRequestClose();
|
||||
if (!Object.prototype.hasOwnProperty.call(NODE_EDITORS, type) && onRequestClose)
|
||||
onRequestClose();
|
||||
}, [type]);
|
||||
|
||||
useEffect(() => {
|
||||
|
@ -88,7 +89,7 @@ const EditorDialogUnconnected: FC<IProps> = ({
|
|||
|
||||
const error = errors && Object.values(errors)[0];
|
||||
|
||||
if (!NODE_EDITORS[type]) return null;
|
||||
if (!Object.prototype.hasOwnProperty.call(NODE_EDITORS, type)) return null;
|
||||
|
||||
return (
|
||||
<form onSubmit={onSubmit} className={styles.form}>
|
||||
|
@ -105,16 +106,13 @@ const EditorDialogUnconnected: FC<IProps> = ({
|
|||
setData,
|
||||
temp,
|
||||
setTemp,
|
||||
})}
|
||||
} as IEditorComponentProps)}
|
||||
</div>
|
||||
</BetterScrollDialog>
|
||||
</form>
|
||||
);
|
||||
};
|
||||
|
||||
const EditorDialog = connect(
|
||||
mapStateToProps,
|
||||
mapDispatchToProps
|
||||
)(EditorDialogUnconnected);
|
||||
const EditorDialog = connect(mapStateToProps, mapDispatchToProps)(EditorDialogUnconnected);
|
||||
|
||||
export { EditorDialog };
|
||||
|
|
20
src/containers/dialogs/LoginSocialRegisterDialog/index.tsx
Normal file
20
src/containers/dialogs/LoginSocialRegisterDialog/index.tsx
Normal file
|
@ -0,0 +1,20 @@
|
|||
import React, { FC } from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
import { IDialogProps } from '~/redux/modal/constants';
|
||||
import { BetterScrollDialog } from '~/containers/dialogs/BetterScrollDialog';
|
||||
|
||||
const mapStateToProps = () => ({});
|
||||
const mapDispatchToProps = {};
|
||||
|
||||
type Props = ReturnType<typeof mapStateToProps> & typeof mapDispatchToProps & IDialogProps & {};
|
||||
|
||||
const LoginSocialRegisterDialogUnconnected: FC<Props> = ({ onRequestClose }) => (
|
||||
<BetterScrollDialog onClose={onRequestClose}>NEEDS REGISTER!</BetterScrollDialog>
|
||||
);
|
||||
|
||||
const LoginSocialRegisterDialog = connect(
|
||||
mapStateToProps,
|
||||
mapDispatchToProps
|
||||
)(LoginSocialRegisterDialogUnconnected);
|
||||
|
||||
export { LoginSocialRegisterDialog };
|
|
@ -20,7 +20,7 @@ interface IProps {
|
|||
}
|
||||
|
||||
const TAB_HEADERS = {
|
||||
messages: <MessageForm is_sending_message={false} />,
|
||||
messages: <MessageForm />,
|
||||
};
|
||||
|
||||
const ProfileInfo: FC<IProps> = ({ user, tab, is_loading, is_own, setTab }) => (
|
||||
|
|
|
@ -6,6 +6,7 @@ export const DIALOGS = {
|
|||
EDITOR_VIDEO: 'EDITOR_VIDEO',
|
||||
EDITOR_AUDIO: 'EDITOR_AUDIO',
|
||||
LOGIN: 'LOGIN',
|
||||
LOGIN_SOCIAL_REGISTER: 'LOGIN_REGISTER',
|
||||
LOADING: 'LOADING',
|
||||
PROFILE: 'PROFILE',
|
||||
RESTORE_REQUEST: 'RESTORE_REQUEST',
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { FC } from 'react';
|
||||
import { FC, ReactElement } from 'react';
|
||||
import { INode, ValueOf, IComment } from '../types';
|
||||
import { NodeImageSlideBlock } from '~/components/node/NodeImageSlideBlock';
|
||||
import { NodeTextBlock } from '~/components/node/NodeTextBlock';
|
||||
|
@ -14,6 +14,8 @@ import { EditorAudioUploadButton } from '~/components/editors/EditorAudioUploadB
|
|||
import { EditorUploadCoverButton } from '~/components/editors/EditorUploadCoverButton';
|
||||
import { Filler } from '~/components/containers/Filler';
|
||||
import { modalShowPhotoswipe } from '../modal/actions';
|
||||
import { IEditorComponentProps } from '~/redux/node/types';
|
||||
import { EditorFiller } from '~/components/editors/EditorFiller';
|
||||
|
||||
const prefix = 'NODE.';
|
||||
export const NODE_ACTIONS = {
|
||||
|
@ -117,14 +119,14 @@ export const NODE_EDITORS = {
|
|||
[NODE_TYPES.AUDIO]: AudioEditor,
|
||||
};
|
||||
|
||||
export const NODE_PANEL_COMPONENTS = {
|
||||
[NODE_TYPES.TEXT]: [Filler, EditorUploadCoverButton],
|
||||
[NODE_TYPES.VIDEO]: [Filler, EditorUploadCoverButton],
|
||||
[NODE_TYPES.IMAGE]: [EditorImageUploadButton, Filler, EditorUploadCoverButton],
|
||||
export const NODE_PANEL_COMPONENTS: Record<string, FC<IEditorComponentProps>[]> = {
|
||||
[NODE_TYPES.TEXT]: [EditorFiller, EditorUploadCoverButton],
|
||||
[NODE_TYPES.VIDEO]: [EditorFiller, EditorUploadCoverButton],
|
||||
[NODE_TYPES.IMAGE]: [EditorImageUploadButton, EditorFiller, EditorUploadCoverButton],
|
||||
[NODE_TYPES.AUDIO]: [
|
||||
EditorAudioUploadButton,
|
||||
EditorImageUploadButton,
|
||||
Filler,
|
||||
EditorFiller,
|
||||
EditorUploadCoverButton,
|
||||
],
|
||||
};
|
||||
|
|
8
src/redux/node/types.ts
Normal file
8
src/redux/node/types.ts
Normal file
|
@ -0,0 +1,8 @@
|
|||
import { INode } from '~/redux/types';
|
||||
|
||||
export interface IEditorComponentProps {
|
||||
data: INode;
|
||||
setData: (data: INode) => void;
|
||||
temp: string[];
|
||||
setTemp: (val: string[]) => void;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue