@@ -176,14 +240,47 @@ export function Permissions() {
-
- Permissions
-
-
+ {!isLoading && providers.length === 0 ? (
+
+
+ To be able to grant or revoke access to applications, you need to
+ have at least one identifier.
+
+
+
+ ) : (
+ <>
+
+ Permissions
+
+
+ Note: The process of revoking or granting access to
+ applications may take some time.
+
+
+ >
+ )}
);
}
diff --git a/src/services/api/index.ts b/src/services/api/index.ts
index 8147533..2802abf 100644
--- a/src/services/api/index.ts
+++ b/src/services/api/index.ts
@@ -1,4 +1,6 @@
import axios from 'axios';
+import { useNavigate } from 'react-router-dom';
+import useSnackbarStore from '../../store/useSnackbarStore';
export const baseURL = import.meta.env.VITE_API_BASE_URL;
@@ -35,5 +37,32 @@ apiInstance.interceptors.request.use(
}
);
+apiInstance.interceptors.response.use(
+ (response) => response,
+ (error) => {
+ const navigate = useNavigate();
+ const { showSnackbar } = useSnackbarStore();
+ console.log(error.response, 'test');
+
+ if (error.response?.status === 400) {
+ showSnackbar('Bad Request', {
+ severity: 'error',
+ });
+ }
+
+ if (error.response?.status === 401) {
+ // Show the snackbar message
+ showSnackbar('Session expired. Please log in again.', {
+ severity: 'warning',
+ });
+
+ // Redirect the user to the login page
+ navigate('/auth/login');
+ }
+
+ return Promise.reject(error);
+ }
+);
+
export default apiInstance;
export { apiInstance as api };
diff --git a/src/store/useSnackbarStore.ts b/src/store/useSnackbarStore.ts
new file mode 100644
index 0000000..5fd469b
--- /dev/null
+++ b/src/store/useSnackbarStore.ts
@@ -0,0 +1,38 @@
+import { SnackbarOrigin } from '@mui/material';
+import { create } from 'zustand';
+
+interface SnackbarState {
+ message: string;
+ open: boolean;
+ options?: SnackbarOptions;
+ showSnackbar: (message: string, options?: SnackbarOptions) => void;
+ closeSnackbar: () => void;
+}
+
+interface SnackbarOptions {
+ severity?: 'success' | 'error' | 'warning' | 'info';
+ duration?: number;
+ position?: SnackbarOrigin;
+}
+
+const useSnackbarStore = create