This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { BrowserRouter, Route, Routes } from "react-router-dom"; | |
import { UserProvider } from "./contexts/user.context"; | |
import Home from "./pages/Home.page"; | |
import Login from "./pages/Login.page"; | |
import PrivateRoute from "./pages/PrivateRoute.page"; | |
import Signup from "./pages/Signup.page"; | |
function App() { | |
return ( | |
<BrowserRouter> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Button } from '@mui/material' | |
import { useContext } from 'react'; | |
import { UserContext } from '../contexts/user.context'; | |
export default function Home() { | |
const { logOutUser } = useContext(UserContext); | |
// This function is called when the user clicks the "Logout" button. | |
const logOut = async () => { | |
try { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Button, TextField } from "@mui/material"; | |
import { useContext, useState } from "react"; | |
import { Link, useLocation, useNavigate } from "react-router-dom"; | |
import { UserContext } from "../contexts/user.context"; | |
const Signup = () => { | |
const navigate = useNavigate(); | |
const location = useLocation(); | |
// As explained in the Login page. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Button, TextField } from "@mui/material"; | |
import { useContext, useEffect, useState } from "react"; | |
import { Link, useLocation, useNavigate } from "react-router-dom"; | |
import { UserContext } from "../contexts/user.context"; | |
const Login = () => { | |
const navigate = useNavigate(); | |
const location = useLocation(); | |
// We are consuming our user-management context to |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useContext } from "react"; | |
import { Navigate, Outlet, useLocation } from "react-router-dom"; | |
import { UserContext } from "../contexts/user.context"; | |
const PrivateRoute = (props) => { | |
// Fetching the user from the user context. | |
const { user } = useContext(UserContext); | |
const location = useLocation(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { createContext, useState } from "react"; | |
import { App, Credentials } from "realm-web"; | |
import { APP_ID } from "../realm/constants"; | |
// Creating a Realm App Instance | |
const app = new App(APP_ID); | |
// Creating a user context to manage and access all the user related functions | |
// across different component and pages. | |
export const UserContext = createContext(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: MIT | |
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/ERC20.sol) | |
pragma solidity ^0.8.0; | |
import "./IERC20.sol"; | |
import "./extensions/IERC20Metadata.sol"; | |
import "../../utils/Context.sol"; | |
/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: MIT | |
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/ERC20.sol) | |
pragma solidity ^0.8.0; | |
import "./IERC20.sol"; | |
import "./extensions/IERC20Metadata.sol"; | |
import "../../utils/Context.sol"; | |
/** |