feat: add error snackbar when creating or updating saml auth provider
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
||||||
import api from 'helpers/api';
|
import api from 'helpers/api';
|
||||||
|
import { enqueueSnackbar } from 'notistack';
|
||||||
|
|
||||||
export default function useAdminCreateSamlAuthProvider() {
|
export default function useAdminCreateSamlAuthProvider() {
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
@@ -15,6 +16,20 @@ export default function useAdminCreateSamlAuthProvider() {
|
|||||||
queryKey: ['admin', 'samlAuthProviders'],
|
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;
|
return query;
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
||||||
import api from 'helpers/api';
|
import api from 'helpers/api';
|
||||||
|
import { enqueueSnackbar } from 'notistack';
|
||||||
|
|
||||||
export default function useAdminUpdateSamlAuthProvider(samlAuthProviderId) {
|
export default function useAdminUpdateSamlAuthProvider(samlAuthProviderId) {
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
@@ -18,6 +19,20 @@ export default function useAdminUpdateSamlAuthProvider(samlAuthProviderId) {
|
|||||||
queryKey: ['admin', 'samlAuthProviders'],
|
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-update-saml-auth-provider-error',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
return query;
|
return query;
|
||||||
|
@@ -65,7 +65,7 @@ function SamlConfiguration({ provider, providerLoading }) {
|
|||||||
'data-test': 'snackbar-save-saml-provider-success',
|
'data-test': 'snackbar-save-saml-provider-success',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch {
|
||||||
throw new Error('Failed while saving!');
|
throw new Error('Failed while saving!');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user