Update front

This commit is contained in:
2025-02-03 11:14:50 +07:00
parent 47e5b2f29c
commit 51b48325e8
5 changed files with 35 additions and 11 deletions

View File

@@ -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": {

View File

@@ -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')

View File

@@ -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

View File

@@ -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 <div>Loading...</div>;
}
if (!isConnected) {
deleteCookie('token')
return (
@@ -22,6 +41,7 @@ export const Auth = ({ children }: any) => {
}
}
const styles = {
alignItems: 'center',
display: 'flex',

View File

@@ -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()],