diff --git a/package.json b/package.json index d0c7b2dd9..1e0daea8e 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,6 @@ "@testing-library/react-hooks": "^8.0.1", "@testing-library/user-event": "^14.5.1", "@tippyjs/react": "^4.2.6", - "@types/axios-cancel": "^0.2.2", "@types/body-scroll-lock": "^3.1.0", "@types/file-saver": "^2.0.5", "@types/lodash": "^4.14.199", @@ -125,7 +124,6 @@ "@testing-library/jest-dom": "^6.1.3", "@types/string-hash": "^1.1.1", "assert": "^2.1.0", - "axios-cancel": "^0.2.2", "body-scroll-lock": "4.0.0-beta.0", "browser-fs-access": "^0.35.0", "chart.js": "^4.4.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c30843aa7..61e845c9c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -32,9 +32,6 @@ dependencies: assert: specifier: ^2.1.0 version: 2.1.0 - axios-cancel: - specifier: ^0.2.2 - version: 0.2.2 body-scroll-lock: specifier: 4.0.0-beta.0 version: 4.0.0-beta.0 @@ -166,9 +163,6 @@ devDependencies: '@tippyjs/react': specifier: ^4.2.6 version: 4.2.6(react-dom@18.2.0)(react@18.2.0) - '@types/axios-cancel': - specifier: ^0.2.2 - version: 0.2.2 '@types/body-scroll-lock': specifier: ^3.1.0 version: 3.1.0 @@ -4978,14 +4972,6 @@ packages: resolution: {integrity: sha512-XTIieEY+gvJ39ChLcB4If5zHtPxt3Syj5rgZR+e1ctpmK8NjPf0zFqsz4JpLJT0xla9GFDKjy8Cpu331nrmE1Q==} dev: true - /@types/axios-cancel@0.2.2: - resolution: {integrity: sha512-zuSzeBdYgfkyztlURbgDvFZtO9L7r0b8x+uUQJNR8Pa7PbZAirK+2aYBXOe/JamVrvOTw5/E6kOAZytNhw5XQw==} - dependencies: - axios: 0.15.2 - transitivePeerDependencies: - - supports-color - dev: true - /@types/babel__core@7.20.1: resolution: {integrity: sha512-aACu/U/omhdk15O4Nfb+fHgH/z3QsfQzpnvRZhYhThms83ZnAOZz7zZAWO7mn2yyNQaA4xTO8GLK3uqFU4bYYw==} dependencies: @@ -5031,7 +5017,7 @@ packages: resolution: {integrity: sha512-oyl4jvAfTGX9Bt6Or4H9ni1Z447/tQuxnZsytsCaExKlmJiU8sFgnIBRzJUpKwB5eWn9HuBYlUlVA74q/yN0eQ==} dependencies: '@types/connect': 3.4.36 - '@types/node': 18.17.19 + '@types/node': 18.18.3 dev: true /@types/body-scroll-lock@3.1.0: @@ -5061,7 +5047,7 @@ packages: /@types/connect@3.4.36: resolution: {integrity: sha512-P63Zd/JUGq+PdrM1lv0Wv5SBYeA2+CORvbrXbngriYY0jzLUWfQMQQxOhjONEz/wlHOAxOdY7CY65rgQdTjq2w==} dependencies: - '@types/node': 18.17.19 + '@types/node': 18.18.3 dev: true /@types/cookie@0.4.1: @@ -5071,7 +5057,7 @@ packages: /@types/cross-spawn@6.0.3: resolution: {integrity: sha512-BDAkU7WHHRHnvBf5z89lcvACsvkz/n7Tv+HyD/uW76O29HoH1Tk/W6iQrepaZVbisvlEek4ygwT8IW7ow9XLAA==} dependencies: - '@types/node': 18.17.19 + '@types/node': 18.18.3 dev: true /@types/debug@4.1.8: @@ -5136,7 +5122,7 @@ packages: /@types/express-serve-static-core@4.17.37: resolution: {integrity: sha512-ZohaCYTgGFcOP7u6aJOhY9uIZQgZ2vxC2yWoArY+FeDXlqeH66ZVBjgvg+RLVAS/DWNq4Ap9ZXu1+SUQiiWYMg==} dependencies: - '@types/node': 18.17.19 + '@types/node': 18.18.3 '@types/qs': 6.9.8 '@types/range-parser': 1.2.5 '@types/send': 0.17.2 @@ -5180,7 +5166,7 @@ packages: resolution: {integrity: sha512-MxObHvNl4A69ofaTRU8DFqvgzzv8s9yRtaPPm5gud9HDNvpB3GPQFvNuTWAI59B9huVGV5jXYJwbCsmBsOGYWA==} dependencies: '@types/jsonfile': 6.1.2 - '@types/node': 18.17.19 + '@types/node': 18.18.3 dev: true /@types/glob@7.2.0: @@ -5242,7 +5228,7 @@ packages: /@types/jsonfile@6.1.2: resolution: {integrity: sha512-8t92P+oeW4d/CRQfJaSqEwXujrhH4OEeHRjGU3v1Q8mUS8GPF3yiX26sw4svv6faL2HfBtGTe2xWIoVgN3dy9w==} dependencies: - '@types/node': 18.17.19 + '@types/node': 18.18.3 dev: true /@types/lodash@4.14.199: @@ -5293,7 +5279,7 @@ packages: /@types/node-fetch@2.6.6: resolution: {integrity: sha512-95X8guJYhfqiuVVhRFxVQcf4hW/2bCuoPwDasMf/531STFoNoWTT7YDnWdXHEZKqAGUigmpG31r2FE70LwnzJw==} dependencies: - '@types/node': 18.17.19 + '@types/node': 18.18.3 form-data: 4.0.0 dev: true @@ -5384,7 +5370,7 @@ packages: resolution: {integrity: sha512-aAG6yRf6r0wQ29bkS+x97BIs64ZLxeE/ARwyS6wrldMm3C1MdKwCcnnEwMC1slI8wuxJOpiUH9MioC0A0i+GJw==} dependencies: '@types/mime': 1.3.3 - '@types/node': 18.17.19 + '@types/node': 18.18.3 dev: true /@types/serve-static@1.15.2: @@ -5399,7 +5385,7 @@ packages: dependencies: '@types/http-errors': 2.0.2 '@types/mime': 3.0.2 - '@types/node': 18.17.19 + '@types/node': 18.18.3 dev: true /@types/set-cookie-parser@2.4.3: @@ -6229,19 +6215,6 @@ packages: resolution: {integrity: sha512-DMD0KiN46eipeziST1LPP/STfDU0sufISXmjSgvVsoU2tqxctQeASejWcfNtxYKqETM1UxQ8sp2OrSBWpHY6sw==} engines: {node: '>= 0.4'} - /axios-cancel@0.2.2: - resolution: {integrity: sha512-YOArJ6aaK1c2W0uuxDSxTQbdNUwOpSNZeWM7u3K79tzfdzNicM5UzQ61zn1OolECU9fAd4A7fNV8hqnddK4Mdg==} - dev: false - - /axios@0.15.2: - resolution: {integrity: sha512-RCFd+A1fO/DVvW7NvbMN7qjADYnRMQAl/sEOARHPV7g+vxye4W3WOKQ5eVC2iuFB9H9Il6v9cSVRB0sqfFPUHw==} - deprecated: Critical security vulnerability fixed in v0.21.1. For more information, see https://github.com/axios/axios/pull/3410 - dependencies: - follow-redirects: 0.0.7 - transitivePeerDependencies: - - supports-color - dev: true - /axios@1.5.0: resolution: {integrity: sha512-D4DdjDo5CY50Qms0qGQTTw6Q44jl7zRwY7bthds06pUGfChBCTcQs+N743eFWGEd6pRTMd6A+I87aWyFV5wiZQ==} dependencies: @@ -8301,15 +8274,6 @@ packages: engines: {node: '>=0.4.0'} dev: true - /follow-redirects@0.0.7: - resolution: {integrity: sha512-RxpX808lAA4IZ2cNqzRedcsPfVuo2AJEL8mmGvGeN0KGLJWZf5fidmUkcB0DWUCrmLD+GAQ0J2WOBORw8BS/Uw==} - dependencies: - debug: 2.6.9 - stream-consume: 0.1.1 - transitivePeerDependencies: - - supports-color - dev: true - /follow-redirects@1.15.2: resolution: {integrity: sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==} engines: {node: '>=4.0'} @@ -11762,10 +11726,6 @@ packages: - utf-8-validate dev: true - /stream-consume@0.1.1: - resolution: {integrity: sha512-tNa3hzgkjEP7XbCkbRXe1jpg+ievoa0O4SCFlMOYEscGSS4JJsckGL8swUyAa/ApGU3Ae4t6Honor4HhL+tRyg==} - dev: true - /stream-shift@1.0.1: resolution: {integrity: sha512-AiisoFqQ0vbGcZgQPY1cdP2I76glaVA/RauYR4G4thNFgkTqr90yXTo4LYX60Jl+sIlPNHHdGSwo01AvbKUSVQ==} dev: true diff --git a/resources/js/app.tsx b/resources/js/app.tsx index 04e97537b..f88d160c2 100644 --- a/resources/js/app.tsx +++ b/resources/js/app.tsx @@ -6,7 +6,6 @@ import "../css/app.css"; import { createInertiaApp } from "@inertiajs/react"; import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; import axios, { type AxiosError } from "axios"; -import axiosCancel from "axios-cancel"; import { ArcElement, CategoryScale, @@ -20,7 +19,6 @@ import { Tooltip, } from "chart.js"; import { resolvePageComponent } from "laravel-vite-plugin/inertia-helpers"; -import get from "lodash/get"; import { createRoot } from "react-dom/client"; import { I18nextProvider } from "react-i18next"; import DarkModeContextProvider from "./Contexts/DarkModeContex"; @@ -34,16 +32,24 @@ import { i18n } from "@/I18n"; // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access (window as any).CookieConsent = CookieConsent; -// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-explicit-any -axiosCancel(axios as any); +const abortController = new AbortController(); +const { signal } = abortController; + +axios.interceptors.request.use((config) => { + config.signal = signal; + return config; +}); axios.interceptors.response.use( (response) => response, async (error: AxiosError) => { - const status = get(error, "response.status"); + const { status } = error.response ?? {}; if (status === 419) { - await axios.get(route("refresh-csrf-token")); + abortController.abort(); + await axios.get(route("refresh-csrf-token"), { + signal, + }); if (error.response != null) { return await axios(error.response.config);