diff --git a/.husky/pre-commit b/.husky/pre-commit index 3e48a61..b1d2126 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -2,3 +2,4 @@ . "$(dirname -- "$0")/_/husky.sh" yarn eslint . --fix +yarn type-check diff --git a/package.json b/package.json index 13b43a9..c4d6cf4 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,10 @@ "scripts": { "start": "NODE_OPTIONS=\"--max-old-space-size=1024\" craco start", "build": "craco build", + "build:check": "tsc --noEmit && craco build", + "type-check": "tsc --noEmit", + "type-check:strict": "tsc --noEmit --strict --noImplicitAny --noImplicitReturns --noImplicitThis --noUnusedLocals --noUnusedParameters", + "pre-commit": "npm run type-check", "test": "craco test --env=node --transformIgnorePatterns \"node_modules/(?!@frontend)/\"", "test:cart": "vitest ./src/utils/calcCart", "eject": "craco eject", diff --git a/src/utils/hooks/useReauthorization.ts b/src/utils/hooks/useReauthorization.ts index 63abc2e..a06bd70 100644 --- a/src/utils/hooks/useReauthorization.ts +++ b/src/utils/hooks/useReauthorization.ts @@ -6,29 +6,30 @@ import { clearTickets } from '@root/stores/tickets'; import { clearUserData, useUserStore } from '@root/stores/user'; import { useEffect } from 'react'; import { useLocation } from 'react-router-dom'; + export const useReauthorization = () => { const userId = useUserStore(store => store.userId) - const { search } = useLocation(); useEffect(() => { // Этот эффект сработает при каждом изменении query-параметров const params = new URLSearchParams(search); - const URLuserId = params.get('userId'); + const URLuserId = params.get('userid'); const URLtoken = params.get('sec'); if (URLuserId !== userId && URLtoken) { - if (getAuthToken()) { + // Если есть токен в URL, устанавливаем его + // Очищаем данные только если токен действительно изменился + if (getAuthToken() !== URLtoken) { clearAuthToken(); clearUserData(); clearCustomTariffs(); clearTickets(); - setNotEnoughMoneyAmount(0) - logout(); + setNotEnoughMoneyAmount(0); + // Не вызываем logout() чтобы избежать перенаправления } - setAuthToken(URLtoken);//перелогиниваемся + setAuthToken(URLtoken); } }, [search]); - }; \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index 172b4c8..9ad679b 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -16,7 +16,14 @@ "resolveJsonModule": true, "isolatedModules": true, "noEmit": true, - "jsx": "react-jsx" + "jsx": "react-jsx", + "noImplicitAny": true, + "noImplicitReturns": true, + "noImplicitThis": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "exactOptionalPropertyTypes": true, + "noPropertyAccessFromIndexSignature": true }, "include": ["src", "**/*.ts"] }