diff --git a/src/components/Views/ContactEdit.jsx b/src/components/Views/ContactEdit.jsx index 7f151d56..e60bd70a 100644 --- a/src/components/Views/ContactEdit.jsx +++ b/src/components/Views/ContactEdit.jsx @@ -18,7 +18,7 @@ const useStyles = makeStyles({ } }) -const ContactEdit = () => { +const ContactEdit = ({ onClose }) => { const { fileId } = useParams() const navigate = useNavigate() const client = useClient() @@ -32,8 +32,12 @@ const ContactEdit = () => { ]) const [isBusy, setIsBusy] = useState(false) - const onClose = () => { - navigate('..') + const _onClose = () => { + if (onClose) { + onClose() + } else { + navigate('..') + } } const onConfirm = async contactSelected => { @@ -71,12 +75,16 @@ const ContactEdit = () => { severity: 'success', variant: 'filled' }) - onClose() + _onClose() } const isLoading = currentEditInformation.isLoading || isLoadingContacts if (!isLoading && !currentEditInformation.file) { - return + if (onClose) { + onClose() + } else { + return + } } return isLoading ? ( @@ -88,7 +96,7 @@ const ContactEdit = () => { contacts={contacts} currentEditInformation={currentEditInformation} onConfirm={onConfirm} - onClose={onClose} + onClose={_onClose} isBusy={isBusy} /> ) diff --git a/src/components/Views/InformationEdit.jsx b/src/components/Views/InformationEdit.jsx index e430fcd9..6c31bb11 100644 --- a/src/components/Views/InformationEdit.jsx +++ b/src/components/Views/InformationEdit.jsx @@ -24,7 +24,7 @@ import { useAlert } from 'cozy-ui/transpiled/react/providers/Alert' import useBreakpoints from 'cozy-ui/transpiled/react/providers/Breakpoints' import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n' -const InformationEdit = () => { +const InformationEdit = ({ onClose }) => { const { fileId } = useParams() const client = useClient() const { t } = useI18n() @@ -59,8 +59,12 @@ const InformationEdit = () => { ? scannerT(`items.${currentEditInformations.paperDef.label}`) : '' - const onClose = () => { - navigate('..') + const _onClose = () => { + if (onClose) { + onClose() + } else { + navigate('..') + } } const onConfirm = async () => { @@ -93,14 +97,18 @@ const InformationEdit = () => { variant: 'filled' }) - navigate('..') + _onClose() } if ( !currentEditInformations.isLoading && !isInformationEditPermitted(currentEditInformations) ) { - return + if (onClose) { + onClose() + } else { + return + } } const fallbackIcon = @@ -115,7 +123,7 @@ const InformationEdit = () => { return (