From 30da4ae96520bf0bdeb68888f1e97a888fc79226 Mon Sep 17 00:00:00 2001
From: Mohammad Torkashvand <mohammad.torkashvand@geant.org>
Date: Fri, 30 Aug 2024 09:38:40 +0200
Subject: [PATCH] update gui

---
 .prettierignore               |  7 +++++++
 Changelog.md                  |  6 ++++++
 hooks/useAxiosInterceptor.tsx | 24 ------------------------
 hooks/useFetchInterceptor.tsx | 27 ---------------------------
 next.config.js                | 26 +++++++++++++-------------
 package.json                  |  7 ++++---
 tsconfig.json                 | 30 +++++++++++++++---------------
 types/types.ts                | 10 +++++++---
 8 files changed, 52 insertions(+), 85 deletions(-)
 create mode 100644 .prettierignore
 delete mode 100644 hooks/useAxiosInterceptor.tsx
 delete mode 100644 hooks/useFetchInterceptor.tsx

diff --git a/.prettierignore b/.prettierignore
new file mode 100644
index 0000000..23a76b9
--- /dev/null
+++ b/.prettierignore
@@ -0,0 +1,7 @@
+# Add files here to ignore them from prettier formatting
+
+/coverage
+/mkdocs
+
+.next
+node_modules
diff --git a/Changelog.md b/Changelog.md
index d5b14d9..639e1e7 100644
--- a/Changelog.md
+++ b/Changelog.md
@@ -3,20 +3,26 @@
 All notable changes to this project will be documented in this file.
 
 ## [2.4] - 2024-08-06
+
 - Redesigned maps to utilize the leafletmap package, replacing graph maps with real-world maps for enhanced accuracy and user experience.
 
 ## [2.3] - 2024-06-18
+
 - Extended the timeout for authentication on GAP
 
 ## [2.2] - 2024-06-04
+
 - Add a new page that shows the IP trunks in the network.
 
 ## [2.1] - 2024-05-24
+
 - Fix a bug that prevented operators from viewing workflows.
 
 ## [2.0] - 2024-05-23
+
 - Update GUI to version 2.
 - Rework project structure to be compatible with new UI library.
 
 ## [0.2] - 2023-12-04
+
 - initial skeleton
diff --git a/hooks/useAxiosInterceptor.tsx b/hooks/useAxiosInterceptor.tsx
deleted file mode 100644
index 712db2e..0000000
--- a/hooks/useAxiosInterceptor.tsx
+++ /dev/null
@@ -1,24 +0,0 @@
-import { useEffect } from 'react';
-import axios from 'axios';
-import { signOut } from 'next-auth/react';
-
-const useAxiosInterceptor = () => {
-  useEffect(() => {
-    const responseInterceptor = axios.interceptors.response.use(
-      response => response,
-      error => {
-        if (error.response && error.response.status === 401) {
-          const currentUrl = window.location.href;
-          signOut({ callbackUrl: `/api/auth/signin?error=SessionRequired&callbackUrl=${encodeURIComponent(currentUrl)}` });
-        }
-        return Promise.reject(error);
-      }
-    );
-
-    return () => {
-      axios.interceptors.response.eject(responseInterceptor);
-    };
-  }, []);
-};
-
-export default useAxiosInterceptor;
diff --git a/hooks/useFetchInterceptor.tsx b/hooks/useFetchInterceptor.tsx
deleted file mode 100644
index 84b4e44..0000000
--- a/hooks/useFetchInterceptor.tsx
+++ /dev/null
@@ -1,27 +0,0 @@
-import { useEffect } from 'react';
-import { signOut } from 'next-auth/react';
-
-const useFetchInterceptor = () => {
-  useEffect(() => {
-    const handleResponse = (response: Response) => {
-      if (response.status === 401) {
-        const currentUrl = window.location.href;
-        signOut({ callbackUrl: `/api/auth/signin?error=SessionRequired&callbackUrl=${encodeURIComponent(currentUrl)}` });
-      }
-      return response;
-    };
-
-    const originalFetch = global.fetch.bind(global);
-
-    global.fetch = async (input: RequestInfo | URL, init?: RequestInit) => {
-      const response = await originalFetch(input, init);
-      return handleResponse(response);
-    };
-
-    return () => {
-      global.fetch = originalFetch;
-    };
-  }, []);
-};
-
-export default useFetchInterceptor;
diff --git a/next.config.js b/next.config.js
index 2b3496d..4d36c5b 100644
--- a/next.config.js
+++ b/next.config.js
@@ -1,15 +1,15 @@
 module.exports = {
-    reactStrictMode: false,
-    output: 'standalone',
-    i18n: {
-        // These are all the locales you want to support in
-        // your application
-        locales: ['en-GB', 'nl-NL'],
-        defaultLocale: 'en-GB',
-    },
-    transpilePackages: ['@orchestrator-ui/orchestrator-ui-components'],
-    publicRuntimeConfig: {
-        OPA_PUBLIC_BUNDLE_URL: process.env.OPA_PUBLIC_BUNDLE_URL,
-        OAUTH2_CLIENT_ID: process.env.OAUTH2_CLIENT_ID,
-    },
+  reactStrictMode: false,
+  output: 'standalone',
+  i18n: {
+    // These are all the locales you want to support in
+    // your application
+    locales: ['en-GB', 'nl-NL'],
+    defaultLocale: 'en-GB',
+  },
+  transpilePackages: ['@orchestrator-ui/orchestrator-ui-components'],
+  publicRuntimeConfig: {
+    OPA_PUBLIC_BUNDLE_URL: process.env.OPA_PUBLIC_BUNDLE_URL,
+    OAUTH2_CLIENT_ID: process.env.OAUTH2_CLIENT_ID,
+  },
 };
diff --git a/package.json b/package.json
index 3aaf5e4..0c1107d 100644
--- a/package.json
+++ b/package.json
@@ -9,11 +9,12 @@
     "build": "next build",
     "start": "next start",
     "lint": "next lint",
-    "prettier": "prettier --write \"{components,configuration,contexts,pages,translations,public}/**/*.{js,jsx,ts,tsx,json,css,scss,md}\"",
+    "prettier": "prettier -c \"{**/*,*}.{ts,tsx,json,js,md}\"",
+    "prettier-fix": "prettier --write \"{**/*,*}.{ts,tsx,json,js,md}\"",
     "prettier:check": "prettier --check \"{components,configuration,contexts,pages,translations,public}/**/*.{js,jsx,ts,tsx,json,css,scss,md}\"",
     "prepare": "husky"
   },
-    "dependencies": {
+  "dependencies": {
     "@elastic/datemath": "^5.0.3",
     "@elastic/eui": "^95.1.0",
     "@elfalem/leaflet-curve": "^0.9.2",
@@ -74,5 +75,5 @@
     "react-no-ssr": {
       "react": "^18.3.1"
     }
-    }
+  }
 }
diff --git a/tsconfig.json b/tsconfig.json
index 41a4218..fe0f4f8 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -1,18 +1,18 @@
 {
-    "extends": "@orchestrator-ui/tsconfig/nextjs.json",
-    "compilerOptions": {
-        "baseUrl": ".",
-        "paths": {
-            "@/*": ["./*"]
-        },
-        "plugins": [
-            {
-                "name": "next"
-            }
-        ],
-        "strictNullChecks": true,
-        "jsx": "preserve"
+  "extends": "@orchestrator-ui/tsconfig/nextjs.json",
+  "compilerOptions": {
+    "baseUrl": ".",
+    "paths": {
+      "@/*": ["./*"]
     },
-    "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
-    "exclude": ["node_modules"]
+    "plugins": [
+      {
+        "name": "next"
+      }
+    ],
+    "strictNullChecks": true,
+    "jsx": "preserve"
+  },
+  "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
+  "exclude": ["node_modules"]
 }
diff --git a/types/types.ts b/types/types.ts
index b8988f9..dfb150f 100644
--- a/types/types.ts
+++ b/types/types.ts
@@ -15,7 +15,7 @@ export interface IptrunkSideNode {
     site_latitude: number;
     site_longitude: number;
   };
-  owner_subscription_id: string
+  owner_subscription_id: string;
 }
 
 export interface Iptrunk {
@@ -25,10 +25,14 @@ export interface Iptrunk {
   iptrunk_type: string;
   iptrunk_ipv4_network: string;
   iptrunk_ipv6_network: string;
-  geant_s_sid: string,
+  geant_s_sid: string;
   iptrunk_sides: Array<{ iptrunk_side_node: IptrunkSideNode }>;
 }
 
 export interface NetworkTopologyData {
-  iptrunks: Array<{ iptrunk: Iptrunk; insync: boolean; subscription_id: string }>;
+  iptrunks: Array<{
+    iptrunk: Iptrunk;
+    insync: boolean;
+    subscription_id: string;
+  }>;
 }
-- 
GitLab