Clean up clode

This commit is contained in:
Paulo Gustavo Veiga 2021-02-14 23:41:14 -08:00
parent 0e8c75d32c
commit 616396fe6a
11 changed files with 21 additions and 33 deletions

View File

@ -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);
};

View File

@ -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)

View File

@ -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)
}
);

View File

@ -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();

View File

@ -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>();

View File

@ -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 => {

View File

@ -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);
};

View File

@ -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';

View File

@ -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');

View File

@ -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);
};

View File

@ -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);
};