feat: introduce inline error messages in SamlConfiguration and RoleMappings forms

This commit is contained in:
kasia.oczkowska
2024-12-13 11:12:04 +00:00
parent 819f122106
commit e784215e3c
7 changed files with 314 additions and 174 deletions

View File

@@ -1,6 +1,5 @@
import { useMutation, useQueryClient } from '@tanstack/react-query';
import api from 'helpers/api';
import { enqueueSnackbar } from 'notistack';
export default function useAdminCreateSamlAuthProvider() {
const queryClient = useQueryClient();
@@ -16,20 +15,6 @@ export default function useAdminCreateSamlAuthProvider() {
queryKey: ['admin', 'samlAuthProviders'],
});
},
onError: (error) => {
const errors = Object.entries(
error.response.data.errors || [['', 'Failed while saving!']],
);
for (const error of errors) {
enqueueSnackbar(`${error[0] ? error[0] + ': ' : ''} ${error[1]}`, {
variant: 'error',
SnackbarProps: {
'data-test': 'snackbar-create-saml-auth-provider-error',
},
});
}
},
});
return query;