diff --git a/packages/webapp/src/components/maps-page/action-dispatcher/create-dialog/index.tsx b/packages/webapp/src/components/maps-page/action-dispatcher/create-dialog/index.tsx index c2c9f325..680d4b41 100644 --- a/packages/webapp/src/components/maps-page/action-dispatcher/create-dialog/index.tsx +++ b/packages/webapp/src/components/maps-page/action-dispatcher/create-dialog/index.tsx @@ -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(defaultModel); const [error, setError] = React.useState(); @@ -40,7 +40,7 @@ const CreateDialog = (props: CreateProps) => { ); const handleOnClose = (): void => { - props.onClose(); + onClose(); setModel(defaultModel); setError(undefined); }; diff --git a/packages/webapp/src/components/maps-page/action-dispatcher/delete-dialog/index.tsx b/packages/webapp/src/components/maps-page/action-dispatcher/delete-dialog/index.tsx index b0ae513a..ab07baa1 100644 --- a/packages/webapp/src/components/maps-page/action-dispatcher/delete-dialog/index.tsx +++ b/packages/webapp/src/components/maps-page/action-dispatcher/delete-dialog/index.tsx @@ -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) diff --git a/packages/webapp/src/components/maps-page/action-dispatcher/delete-multiselect-dialog/index.tsx b/packages/webapp/src/components/maps-page/action-dispatcher/delete-multiselect-dialog/index.tsx index 0a9b37a8..382a1339 100644 --- a/packages/webapp/src/components/maps-page/action-dispatcher/delete-multiselect-dialog/index.tsx +++ b/packages/webapp/src/components/maps-page/action-dispatcher/delete-multiselect-dialog/index.tsx @@ -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) } ); diff --git a/packages/webapp/src/components/maps-page/action-dispatcher/duplicate-dialog/index.tsx b/packages/webapp/src/components/maps-page/action-dispatcher/duplicate-dialog/index.tsx index 19eac677..601ae74c 100644 --- a/packages/webapp/src/components/maps-page/action-dispatcher/duplicate-dialog/index.tsx +++ b/packages/webapp/src/components/maps-page/action-dispatcher/duplicate-dialog/index.tsx @@ -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(defaultModel); const [error, setError] = React.useState(); - const { mapId, onClose } = props; const intl = useIntl(); diff --git a/packages/webapp/src/components/maps-page/action-dispatcher/export-dialog/index.tsx b/packages/webapp/src/components/maps-page/action-dispatcher/export-dialog/index.tsx index f1ca18b4..a837398b 100644 --- a/packages/webapp/src/components/maps-page/action-dispatcher/export-dialog/index.tsx +++ b/packages/webapp/src/components/maps-page/action-dispatcher/export-dialog/index.tsx @@ -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(false); const [formExportRef, setExportFormRef] = React.useState(); const [formTransformtRef, setTransformFormRef] = React.useState(); diff --git a/packages/webapp/src/components/maps-page/action-dispatcher/history-dialog/index.tsx b/packages/webapp/src/components/maps-page/action-dispatcher/history-dialog/index.tsx index 695b3eca..1bc7f291 100644 --- a/packages/webapp/src/components/maps-page/action-dispatcher/history-dialog/index.tsx +++ b/packages/webapp/src/components/maps-page/action-dispatcher/history-dialog/index.tsx @@ -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('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 => { diff --git a/packages/webapp/src/components/maps-page/action-dispatcher/import-dialog/index.tsx b/packages/webapp/src/components/maps-page/action-dispatcher/import-dialog/index.tsx index 0fc25e6b..9e9371df 100644 --- a/packages/webapp/src/components/maps-page/action-dispatcher/import-dialog/index.tsx +++ b/packages/webapp/src/components/maps-page/action-dispatcher/import-dialog/index.tsx @@ -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(defaultModel); const [error, setError] = React.useState(); @@ -42,7 +42,7 @@ const ImportDialog = (props: CreateProps) => { ); const handleOnClose = (): void => { - props.onClose(); + onClose(); setModel(defaultModel); setError(undefined); }; diff --git a/packages/webapp/src/components/maps-page/action-dispatcher/index.tsx b/packages/webapp/src/components/maps-page/action-dispatcher/index.tsx index eb0b0856..ed8d50d6 100644 --- a/packages/webapp/src/components/maps-page/action-dispatcher/index.tsx +++ b/packages/webapp/src/components/maps-page/action-dispatcher/index.tsx @@ -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'; diff --git a/packages/webapp/src/components/maps-page/action-dispatcher/info-dialog/index.tsx b/packages/webapp/src/components/maps-page/action-dispatcher/info-dialog/index.tsx index 783f0a38..54b41061 100644 --- a/packages/webapp/src/components/maps-page/action-dispatcher/info-dialog/index.tsx +++ b/packages/webapp/src/components/maps-page/action-dispatcher/info-dialog/index.tsx @@ -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(); const [] = React.useState('1'); diff --git a/packages/webapp/src/components/maps-page/action-dispatcher/publish-dialog/index.tsx b/packages/webapp/src/components/maps-page/action-dispatcher/publish-dialog/index.tsx index 0daabf79..b93e48fe 100644 --- a/packages/webapp/src/components/maps-page/action-dispatcher/publish-dialog/index.tsx +++ b/packages/webapp/src/components/maps-page/action-dispatcher/publish-dialog/index.tsx @@ -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); }; diff --git a/packages/webapp/src/components/maps-page/action-dispatcher/rename-dialog/index.tsx b/packages/webapp/src/components/maps-page/action-dispatcher/rename-dialog/index.tsx index 7b3d1fb2..fce07d01 100644 --- a/packages/webapp/src/components/maps-page/action-dispatcher/rename-dialog/index.tsx +++ b/packages/webapp/src/components/maps-page/action-dispatcher/rename-dialog/index.tsx @@ -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(defaultModel); const [error, setError] = React.useState(); - 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); };