Skip to content

Commit

Permalink
Fix navigation and stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Akim Mamedov committed Feb 27, 2024
1 parent cab1924 commit a0acb4d
Show file tree
Hide file tree
Showing 17 changed files with 225 additions and 226 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.idea
73 changes: 38 additions & 35 deletions web/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-redux": "^7.2.6",
"react-router-dom": "^6.0.2",
"react-router-dom": "^6.22.1",
"react-scripts": "5.0.1",
"react-toastify": "^8.1.0",
"redux": "^4.1.2",
Expand Down
95 changes: 95 additions & 0 deletions web/src/assets/metadata.json

Large diffs are not rendered by default.

34 changes: 2 additions & 32 deletions web/src/components/App/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import {
Navigate,
Route,
Routes,
useLocation,
useNavigate,
} from "react-router-dom";
import { useDispatch, useSelector } from "react-redux";
import { memo, useEffect, useState } from "react";
Expand Down Expand Up @@ -33,7 +31,6 @@ import {
ROUTE_WALLET,
} from "../../constants/routes";
import { catchError } from "../../utils";
import { setCurrentRoute } from "../../store/actions/routes";
import {
fetchCurrentAward,
fetchMerkleRoot,
Expand All @@ -45,22 +42,10 @@ function App() {
const { network, address } = useWeb3Connection();

const dispatch = useDispatch();
const navigate = useNavigate();
const { error } = useSelector((state) => state.error);
const [prevAddress, setPrevAddress] = useState(null);
const { username } = useSelector((state) => state.user);
const { currentRoute } = useSelector((state) => state.routes);
const location = useLocation();
const [locationPut, setLocationPut] = useState(false);
const [merkleRootFetched, setMerkleRootFetched] = useState(false);

useVh();
useEffect(() => {
if (currentRoute && !locationPut && currentRoute !== location.pathname) {
navigate(currentRoute);
setLocationPut(true);
}
}, [currentRoute]);

useEffect(() => {
console.log("nerwork: " + network.name);
Expand All @@ -73,23 +58,8 @@ function App() {
}, [network]);

useEffect(() => {
if (address) {
if (prevAddress && address !== prevAddress) {
dispatch(reduxCleanup());
navigate(ROUTE_INDEX);
dispatch(setCurrentRoute(ROUTE_INDEX));
} else if (!address && username) {
navigate(ROUTE_WALLET);
} else {
setPrevAddress(address);
}
}
}, [address, prevAddress]);

useEffect(() => {
window.scrollTo(0, 0);
dispatch(setCurrentRoute(location.pathname));
}, [location]);
dispatch(reduxCleanup());
}, [address]);

useEffect(() => {
if (error) {
Expand Down
1 change: 0 additions & 1 deletion web/src/components/ConnectWallet/ConnectWallet.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import Button from "../Button/Button";
import { useWeb3Connection } from "../../hooks/useWeb3Connection";
//import { getChainData } from '../../utils'

const ConnectWallet = () => {
const { connect, disconnect, address } = useWeb3Connection();
Expand Down
Loading

0 comments on commit a0acb4d

Please sign in to comment.