From 5a68d294b6aec6adfef2ea566b24941039b5dbab Mon Sep 17 00:00:00 2001 From: AlexisG Date: Mon, 18 Nov 2024 11:30:59 +0100 Subject: [PATCH] feat: Add success message when confirming editing --- src/components/ModelSteps/widgets/SubmitButton.jsx | 6 ++++++ src/components/Views/ContactEdit.jsx | 9 +++++++++ src/components/Views/InformationEdit.jsx | 7 +++++++ 3 files changed, 22 insertions(+) diff --git a/src/components/ModelSteps/widgets/SubmitButton.jsx b/src/components/ModelSteps/widgets/SubmitButton.jsx index 43215414..154bb56d 100644 --- a/src/components/ModelSteps/widgets/SubmitButton.jsx +++ b/src/components/ModelSteps/widgets/SubmitButton.jsx @@ -109,6 +109,12 @@ const SubmitButton = ({ onSubmit, disabled, formData }) => { }) } + showAlert({ + message: t('common.saveFile.success'), + severity: 'success', + variant: 'filled' + }) + return onSubmit() } diff --git a/src/components/Views/ContactEdit.jsx b/src/components/Views/ContactEdit.jsx index 4a53b771..7f151d56 100644 --- a/src/components/Views/ContactEdit.jsx +++ b/src/components/Views/ContactEdit.jsx @@ -8,6 +8,8 @@ import { updateReferencedContact } from 'src/components/ModelSteps/Edit/helpers' import { useClient } from 'cozy-client' import Backdrop from 'cozy-ui/transpiled/react/Backdrop' import Spinner from 'cozy-ui/transpiled/react/Spinner' +import { useAlert } from 'cozy-ui/transpiled/react/providers/Alert' +import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n' import { makeStyles } from 'cozy-ui/transpiled/react/styles' const useStyles = makeStyles({ @@ -21,6 +23,8 @@ const ContactEdit = () => { const navigate = useNavigate() const client = useClient() const classes = useStyles() + const { t } = useI18n() + const { showAlert } = useAlert() const currentEditInformation = useCurrentEditInformations(fileId, 'contact') const { isLoadingContacts, contacts } = useReferencedContact([ @@ -62,6 +66,11 @@ const ContactEdit = () => { currentFile: currentEditInformation.file, contactIdsSelected }) + showAlert({ + message: t('common.saveFile.success'), + severity: 'success', + variant: 'filled' + }) onClose() } const isLoading = currentEditInformation.isLoading || isLoadingContacts diff --git a/src/components/Views/InformationEdit.jsx b/src/components/Views/InformationEdit.jsx index 4ffb62ce..e430fcd9 100644 --- a/src/components/Views/InformationEdit.jsx +++ b/src/components/Views/InformationEdit.jsx @@ -20,6 +20,7 @@ import { isIOS } from 'cozy-device-helper' import Button from 'cozy-ui/transpiled/react/Buttons' import { FixedDialog } from 'cozy-ui/transpiled/react/CozyDialogs' import Spinner from 'cozy-ui/transpiled/react/Spinner' +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' @@ -30,6 +31,7 @@ const InformationEdit = () => { const { isMobile } = useBreakpoints() const scannerT = useScannerI18n() const navigate = useNavigate() + const { showAlert } = useAlert() const [value, setValue] = useState({}) const [validInput, setValidInput] = useState({}) @@ -85,6 +87,11 @@ const InformationEdit = () => { .collection(FILES_DOCTYPE) .updateMetadataAttribute(fileId, newMetadata) } + showAlert({ + message: t('common.saveFile.success'), + severity: 'success', + variant: 'filled' + }) navigate('..') }