Skip to content

Commit

Permalink
save handler
Browse files Browse the repository at this point in the history
  • Loading branch information
zbycz committed Oct 14, 2024
1 parent 1470fc9 commit a489b83
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/components/FeaturePanel/EditDialog/useGetHandleSave.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ import { createNoteText } from './createNoteText';
import { t } from '../../../services/intl';
import { addOsmFeature, editOsmFeature } from '../../../services/osmApiAuth';
import { insertOsmNote } from '../../../services/osmApi';
import { useSnackbar } from '../../utils/SnackbarContext';

export const useGetHandleSave = () => {
const { showToast } = useSnackbar();
const { loggedIn, handleLogout } = useOsmAuthContext();
const { feature, isUndelete } = useEditDialogFeature();
const {
Expand All @@ -27,8 +29,7 @@ export const useGetHandleSave = () => {
isUndelete,
);
if (noteText == null) {
// TODO we need better check that this ... formik?
alert(t('editdialog.changes_needed')); // eslint-disable-line no-alert
showToast(t('editdialog.changes_needed'), 'warning');
return;
}

Expand All @@ -41,7 +42,7 @@ export const useGetHandleSave = () => {

promise.then(setSuccessInfo, (err) => {
if (err?.status === 401) {
alert(t('editdialog.osm_session_expired')); // eslint-disable-line no-alert
showToast(t('editdialog.osm_session_expired'), 'error');
handleLogout();
} else {
console.error(err); // eslint-disable-line no-console
Expand Down

0 comments on commit a489b83

Please sign in to comment.