mirror of
https://bitbucket.org/wisemapping/wisemapping-frontend.git
synced 2024-11-10 17:33:24 +01:00
Clean up clode
This commit is contained in:
parent
0e8c75d32c
commit
616396fe6a
@ -20,7 +20,7 @@ export type CreateProps = {
|
||||
}
|
||||
|
||||
const defaultModel: CreateModel = { title: '', description: '' };
|
||||
const CreateDialog = (props: CreateProps) => {
|
||||
const CreateDialog = ({onClose}: CreateProps) => {
|
||||
const client: Client = useSelector(activeInstance);
|
||||
const [model, setModel] = React.useState<CreateModel>(defaultModel);
|
||||
const [error, setError] = React.useState<ErrorInfo>();
|
||||
@ -40,7 +40,7 @@ const CreateDialog = (props: CreateProps) => {
|
||||
);
|
||||
|
||||
const handleOnClose = (): void => {
|
||||
props.onClose();
|
||||
onClose();
|
||||
setModel(defaultModel);
|
||||
setError(undefined);
|
||||
};
|
||||
|
@ -9,12 +9,11 @@ import { SimpleDialogProps, handleOnMutationSuccess } from "..";
|
||||
import BaseDialog from "../base-dialog";
|
||||
|
||||
|
||||
const DeleteDialog = (props: SimpleDialogProps) => {
|
||||
const DeleteDialog = ({ mapId, onClose } : SimpleDialogProps) => {
|
||||
const intl = useIntl();
|
||||
const { mapId, onClose } = props;
|
||||
|
||||
const client: Client = useSelector(activeInstance);
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
const mutation = useMutation((id: number) => client.deleteMap(id),
|
||||
{
|
||||
onSuccess: () => handleOnMutationSuccess(onClose, queryClient)
|
||||
|
@ -13,15 +13,14 @@ export type DeleteMultiselectDialogProps = {
|
||||
onClose: () => void
|
||||
}
|
||||
|
||||
const DeleteMultiselectDialog = (props: DeleteMultiselectDialogProps) => {
|
||||
const { onClose, mapsId } = props;
|
||||
const DeleteMultiselectDialog = ({ onClose, mapsId }: DeleteMultiselectDialogProps) => {
|
||||
const intl = useIntl();
|
||||
const client: Client = useSelector(activeInstance);
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
const mutation = useMutation((ids: number[]) => client.deleteMaps(ids),
|
||||
{
|
||||
onSuccess: () => handleOnMutationSuccess(props.onClose, queryClient)
|
||||
onSuccess: () => handleOnMutationSuccess(onClose, queryClient)
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -17,11 +17,10 @@ export type DuplicateModel = {
|
||||
}
|
||||
|
||||
const defaultModel: DuplicateModel = { title: '', description: '', id: -1 };
|
||||
const DuplicateDialog = (props: SimpleDialogProps) => {
|
||||
const DuplicateDialog = ({ mapId, onClose }: SimpleDialogProps) => {
|
||||
const service: Client = useSelector(activeInstance);
|
||||
const [model, setModel] = React.useState<DuplicateModel>(defaultModel);
|
||||
const [error, setError] = React.useState<ErrorInfo>();
|
||||
const { mapId, onClose } = props;
|
||||
|
||||
const intl = useIntl();
|
||||
|
||||
|
@ -16,9 +16,8 @@ type ExportDialogProps = {
|
||||
onClose: () => void,
|
||||
}
|
||||
|
||||
const ExportDialog = (props: ExportDialogProps) => {
|
||||
const ExportDialog = ({ mapId, onClose, enableImgExport, svgXml }: ExportDialogProps) => {
|
||||
const intl = useIntl();
|
||||
const { mapId, onClose, enableImgExport, svgXml } = props;
|
||||
const [submit, setSubmit] = React.useState<boolean>(false);
|
||||
const [formExportRef, setExportFormRef] = React.useState<any>();
|
||||
const [formTransformtRef, setTransformFormRef] = React.useState<any>();
|
||||
|
@ -10,9 +10,8 @@ import { Link, Paper, Table, TableBody, TableCell, TableContainer, TableHead, Ta
|
||||
import moment from "moment";
|
||||
|
||||
|
||||
const HistoryDialog = (props: SimpleDialogProps) => {
|
||||
const HistoryDialog = ({ mapId, onClose }: SimpleDialogProps) => {
|
||||
const intl = useIntl();
|
||||
const mapId = props.mapId;
|
||||
|
||||
const client: Client = useSelector(activeInstance);
|
||||
const { isLoading, error, data } = useQuery<unknown, ErrorInfo, ChangeHistory[]>('history', () => {
|
||||
@ -21,7 +20,7 @@ const HistoryDialog = (props: SimpleDialogProps) => {
|
||||
const changeHistory: ChangeHistory[] = data ? data : [];
|
||||
|
||||
const handleOnClose = (): void => {
|
||||
props.onClose();
|
||||
onClose();
|
||||
};
|
||||
|
||||
const handleOnClick = (event, vid): void => {
|
||||
|
@ -5,7 +5,7 @@ import { useSelector } from 'react-redux';
|
||||
import { Button, FormControl } from '@material-ui/core';
|
||||
|
||||
|
||||
import Client, { BasicMapInfo, ErrorInfo } from '../../../../classes/client';
|
||||
import Client, { ErrorInfo } from '../../../../classes/client';
|
||||
import { activeInstance } from '../../../../redux/clientSlice';
|
||||
import Input from '../../../form/input';
|
||||
import BaseDialog from '../base-dialog';
|
||||
@ -22,7 +22,7 @@ export type CreateProps = {
|
||||
}
|
||||
|
||||
const defaultModel: ImportModel = { title: '' };
|
||||
const ImportDialog = (props: CreateProps) => {
|
||||
const ImportDialog = ({onClose}: CreateProps) => {
|
||||
const client: Client = useSelector(activeInstance);
|
||||
const [model, setModel] = React.useState<ImportModel>(defaultModel);
|
||||
const [error, setError] = React.useState<ErrorInfo>();
|
||||
@ -42,7 +42,7 @@ const ImportDialog = (props: CreateProps) => {
|
||||
);
|
||||
|
||||
const handleOnClose = (): void => {
|
||||
props.onClose();
|
||||
onClose();
|
||||
setModel(defaultModel);
|
||||
setError(undefined);
|
||||
};
|
||||
|
@ -2,11 +2,7 @@ import React from 'react';
|
||||
import RenameDialog from './rename-dialog';
|
||||
import DeleteDialog from './delete-dialog';
|
||||
import { ActionType } from '../action-chooser';
|
||||
import { AccountInfo, ErrorInfo, MapInfo } from '../../../classes/client';
|
||||
import Client from '../../../classes/client';
|
||||
import { useSelector } from 'react-redux';
|
||||
import { QueryClient, useQuery } from 'react-query';
|
||||
import { activeInstance } from '../../../redux/clientSlice';
|
||||
import { QueryClient } from 'react-query';
|
||||
import DuplicateDialog from './duplicate-dialog';
|
||||
import CreateDialog from './create-dialog';
|
||||
import HistoryDialog from './history-dialog';
|
||||
|
@ -10,8 +10,7 @@ import { useStyles } from './style';
|
||||
import moment from 'moment';
|
||||
import { fetchMapById } from '../../../../redux/clientSlice';
|
||||
|
||||
const InfoDialog = (props: SimpleDialogProps) => {
|
||||
const { mapId, onClose } = props;
|
||||
const InfoDialog = ({ mapId, onClose }: SimpleDialogProps) => {
|
||||
const { map } = fetchMapById(mapId);
|
||||
const [error, setError] = React.useState<ErrorInfo>();
|
||||
const [] = React.useState('1');
|
||||
|
@ -13,8 +13,7 @@ import { handleOnMutationSuccess, SimpleDialogProps } from '..';
|
||||
import { useStyles } from './style';
|
||||
|
||||
|
||||
const PublishDialog = (props: SimpleDialogProps) => {
|
||||
const { mapId, onClose } = props;
|
||||
const PublishDialog = ({ mapId, onClose }: SimpleDialogProps) => {
|
||||
const { map } = fetchMapById(mapId);
|
||||
|
||||
const client: Client = useSelector(activeInstance);
|
||||
@ -40,7 +39,7 @@ const PublishDialog = (props: SimpleDialogProps) => {
|
||||
);
|
||||
|
||||
const handleOnClose = (): void => {
|
||||
props.onClose();
|
||||
onClose();
|
||||
setError(undefined);
|
||||
};
|
||||
|
||||
|
@ -4,7 +4,7 @@ import { useMutation, useQueryClient } from "react-query";
|
||||
import { useSelector } from "react-redux";
|
||||
import Client, { BasicMapInfo, ErrorInfo } from "../../../../classes/client";
|
||||
import { activeInstance, fetchMapById } from '../../../../redux/clientSlice';
|
||||
import { SimpleDialogProps, handleOnMutationSuccess } from "..";
|
||||
import { SimpleDialogProps, handleOnMutationSuccess } from "..";
|
||||
import Input from "../../../form/input";
|
||||
import { FormControl } from "@material-ui/core";
|
||||
import BaseDialog from "../base-dialog";
|
||||
@ -16,11 +16,10 @@ export type RenameModel = {
|
||||
}
|
||||
|
||||
const defaultModel: RenameModel = { title: '', description: '', id: -1 };
|
||||
const RenameDialog = (props: SimpleDialogProps) => {
|
||||
const RenameDialog = ({ mapId, onClose }: SimpleDialogProps) => {
|
||||
const service: Client = useSelector(activeInstance);
|
||||
const [model, setModel] = React.useState<RenameModel>(defaultModel);
|
||||
const [error, setError] = React.useState<ErrorInfo>();
|
||||
const { mapId } = props;
|
||||
|
||||
const intl = useIntl();
|
||||
const queryClient = useQueryClient();
|
||||
@ -31,7 +30,7 @@ const RenameDialog = (props: SimpleDialogProps) => {
|
||||
},
|
||||
{
|
||||
onSuccess: () => {
|
||||
handleOnMutationSuccess(props.onClose, queryClient);
|
||||
handleOnMutationSuccess(onClose, queryClient);
|
||||
},
|
||||
onError: (error) => {
|
||||
setError(error);
|
||||
@ -40,7 +39,7 @@ const RenameDialog = (props: SimpleDialogProps) => {
|
||||
);
|
||||
|
||||
const handleOnClose = (): void => {
|
||||
props.onClose();
|
||||
onClose();
|
||||
setModel(defaultModel);
|
||||
setError(undefined);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user