diff --git a/resources/scripts/components/server/files/RenameFileModal.tsx b/resources/scripts/components/server/files/RenameFileModal.tsx index 8ecbc9d91..fb3c0620d 100644 --- a/resources/scripts/components/server/files/RenameFileModal.tsx +++ b/resources/scripts/components/server/files/RenameFileModal.tsx @@ -9,22 +9,23 @@ import tw from 'twin.macro'; import Button from '@/components/elements/Button'; import useServer from '@/plugins/useServer'; import useFileManagerSwr from '@/plugins/useFileManagerSwr'; -import withFlash, { WithFlashProps } from '@/hoc/withFlash'; +import useFlash from '@/plugins/useFlash'; interface FormikValues { name: string; } -type OwnProps = WithFlashProps & RequiredModalProps & { files: string[]; useMoveTerminology?: boolean }; +type OwnProps = RequiredModalProps & { files: string[]; useMoveTerminology?: boolean }; -const RenameFileModal = ({ flash, files, useMoveTerminology, ...props }: OwnProps) => { +const RenameFileModal = ({ files, useMoveTerminology, ...props }: OwnProps) => { const { uuid } = useServer(); const { mutate } = useFileManagerSwr(); + const { clearFlashes, clearAndAddHttpError } = useFlash(); const directory = ServerContext.useStoreState(state => state.files.directory); const setSelectedFiles = ServerContext.useStoreActions(actions => actions.files.setSelectedFiles); const submit = ({ name }: FormikValues, { setSubmitting }: FormikHelpers) => { - flash.clearFlashes('files'); + clearFlashes('files'); const len = name.split('/').length; if (files.length === 1) { @@ -50,7 +51,7 @@ const RenameFileModal = ({ flash, files, useMoveTerminology, ...props }: OwnProp .catch(error => { mutate(); setSubmitting(false); - flash.clearAndAddHttpError({ key: 'files', error }); + clearAndAddHttpError({ key: 'files', error }); }) .then(() => props.onDismissed()); }; @@ -96,4 +97,4 @@ const RenameFileModal = ({ flash, files, useMoveTerminology, ...props }: OwnProp ); }; -export default withFlash(RenameFileModal); +export default RenameFileModal; diff --git a/resources/scripts/hoc/withFlash.tsx b/resources/scripts/hoc/withFlash.tsx deleted file mode 100644 index 4a3f008f4..000000000 --- a/resources/scripts/hoc/withFlash.tsx +++ /dev/null @@ -1,23 +0,0 @@ -import React from 'react'; -import useFlash from '@/plugins/useFlash'; -import { Actions } from 'easy-peasy'; -import { ApplicationStore } from '@/state'; - -export interface WithFlashProps { - flash: Actions['flashes']; -} - -function withFlash (Component: React.ComponentType): React.ComponentType { - return (props: TOwnProps) => { - const { addError, addFlash, clearFlashes, clearAndAddHttpError } = useFlash(); - - return ( - - ); - }; -} - -export default withFlash;