From 51b48325e88fe3f2dc8dd2a8bcf9dc14c08610e0 Mon Sep 17 00:00:00 2001 From: cryptooda Date: Mon, 3 Feb 2025 11:14:50 +0700 Subject: [PATCH] Update front --- src/Managing.WebApp/package.json | 15 +++++++------- .../src/components/mollecules/LogIn/LogIn.tsx | 5 ++++- src/Managing.WebApp/src/hooks/useCookie.ts | 2 +- .../src/pages/authPage/auth.tsx | 20 +++++++++++++++++++ src/Managing.WebApp/vite.config.ts | 4 ++-- 5 files changed, 35 insertions(+), 11 deletions(-) diff --git a/src/Managing.WebApp/package.json b/src/Managing.WebApp/package.json index e6e79de..a984ecc 100644 --- a/src/Managing.WebApp/package.json +++ b/src/Managing.WebApp/package.json @@ -20,11 +20,12 @@ "@microsoft/signalr": "^6.0.5", "@tanstack/react-query": "^5.36.1", "@wagmi/chains": "^0.2.9", - "@wagmi/connectors": "^4.3.2", - "@wagmi/core": "^2.9.0", + "@wagmi/connectors": "^5.7.3", + "@wagmi/core": "^2.16.3", "@walletconnect/universal-provider": "^2.8.6", + "axios": "^0.27.2", "classnames": "^2.3.1", - "connectkit": "^1.7.3", + "connectkit": "^1.8.2", "date-fns": "^2.30.0", "jotai": "^1.6.7", "latest-version": "^9.0.0", @@ -46,8 +47,8 @@ "react-toastify": "^9.0.1", "reactflow": "^11.8.3", "viem": "2.x", - "wagmi": "^2.8.7", - "web3": "^4.0.2", + "wagmi": "^2.14.9", + "web3": "^4.16.0", "zustand": "^4.4.1", "postcss": "^8.4.13", "autoprefixer": "^10.4.7", @@ -73,8 +74,8 @@ "prettier": "^2.6.1", "prettier-plugin-tailwind-css": "^1.5.0", "tailwindcss": "^3.0.23", - "typescript": "^5.0.4", - "vite": "^4.4.9", + "typescript": "^5.7.3", + "vite": "^6.0.11", "whatwg-fetch": "^3.6.2" }, "msw": { diff --git a/src/Managing.WebApp/src/components/mollecules/LogIn/LogIn.tsx b/src/Managing.WebApp/src/components/mollecules/LogIn/LogIn.tsx index ea62fa8..1614339 100644 --- a/src/Managing.WebApp/src/components/mollecules/LogIn/LogIn.tsx +++ b/src/Managing.WebApp/src/components/mollecules/LogIn/LogIn.tsx @@ -37,7 +37,10 @@ const LogIn = () => { }) .then((data) => { setCookie('token', data, 1) - location.reload() + console.log('token', data) + setTimeout(() => { + location.assign("/"); + }, 2000); }) .catch((err: any) => { t.update('error', 'Error : Some thing bad happen') diff --git a/src/Managing.WebApp/src/hooks/useCookie.ts b/src/Managing.WebApp/src/hooks/useCookie.ts index 759becb..43be74f 100644 --- a/src/Managing.WebApp/src/hooks/useCookie.ts +++ b/src/Managing.WebApp/src/hooks/useCookie.ts @@ -34,7 +34,7 @@ const useCookie = (): UseCookieReturn => { document.cookie = `${name}=''; expires=Thu, 01 Jan 2000 00:00:00 GMT; path=''` } - return { deleteCookie, getCookie, setCookie } + return { deleteCookie, getCookie, setCookie } as UseCookieReturn } export default useCookie diff --git a/src/Managing.WebApp/src/pages/authPage/auth.tsx b/src/Managing.WebApp/src/pages/authPage/auth.tsx index f8f4364..a824f93 100644 --- a/src/Managing.WebApp/src/pages/authPage/auth.tsx +++ b/src/Managing.WebApp/src/pages/authPage/auth.tsx @@ -3,11 +3,30 @@ import { useAccount } from 'wagmi' import LogIn from '../../components/mollecules/LogIn/LogIn' import useCookie from '../../hooks/useCookie' +import { useEffect, useState } from 'react' + export const Auth = ({ children }: any) => { const { getCookie, deleteCookie } = useCookie() const { isConnected } = useAccount() const token = getCookie('token') + console.log('token', token) + console.log('isConnected', isConnected) + + const [isLoading, setIsLoading] = useState(true); + + useEffect(() => { + const timeout = setTimeout(() => { + setIsLoading(false); + }, 2000); // Adjust the timeout duration as needed + + return () => clearTimeout(timeout); + }, []); + + if (isLoading) { + return
Loading...
; + } + if (!isConnected) { deleteCookie('token') return ( @@ -22,6 +41,7 @@ export const Auth = ({ children }: any) => { } } + const styles = { alignItems: 'center', display: 'flex', diff --git a/src/Managing.WebApp/vite.config.ts b/src/Managing.WebApp/vite.config.ts index 449a7b8..9559d6e 100644 --- a/src/Managing.WebApp/vite.config.ts +++ b/src/Managing.WebApp/vite.config.ts @@ -4,11 +4,11 @@ import { defineConfig } from 'vite' export default defineConfig({ build: { sourcemap: true, - target: 'es2020', + target: 'es2022', }, optimizeDeps: { esbuildOptions: { - target: 'es2020', + target: 'es2022', }, }, plugins: [react()],