This file contains hidden or 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
| const rules = [ | |
| { | |
| contractAddress: 353463, | |
| min: 2, | |
| max: '', | |
| specialTokenIDs: '', | |
| discordRoleId: 234 | |
| }, | |
| { | |
| contractAddress: 3534464663, |
This file contains hidden or 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
| function findEligibleRolesByOwnedTokens(rules, ownedTokensByContract) { | |
| const eligibleRoleIds = [] | |
| for (rule of rules) { | |
| if (isRuleSatisfied(rule, ownedTokensByContract[rule.contractAddress])) { | |
| eligibleRoleIds.push(rule.discordRoleId) | |
| } | |
| } | |
| return eligibleRoleIds |
This file contains hidden or 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
| //Create Context | |
| import React from 'react'; | |
| const CartContext = React.createContext(); | |
| export default CartContext; | |
| //App.js | |
| import CartContext from './context/CartContext'; | |
| //pass state and functions | |
| <CartContext.Provider value={{card, addToCard}}> |
This file contains hidden or 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
| type CallbackFunction = () => void; | |
| function useInterval(callback: CallbackFunction, delay: number) { | |
| const savedCallback = useRef<CallbackFunction>() | |
| useEffect(() => { | |
| savedCallback.current = callback; | |
| }, [callback]); | |
| useEffect(() => { |
This file contains hidden or 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
| // https://stackoverflow.com/questions/48048957/react-long-press-event | |
| import { useState, useEffect } from 'react'; | |
| export default function LongPress (callback = () => {}, ms = 300) { | |
| const [startLongPress, setStartLongPress] = useState(false) | |
| useEffect(() => { | |
| let timerId; |
This file contains hidden or 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 React, { useState, useContext } from 'react'; | |
| import { AuthContext } from '../auth/AuthContext'; | |
| function LoginPage(props) { | |
| const isAuth = useContext(AuthContext); | |
| //bla bla | |
| const handleSubmit = async (event) => { | |
| //bla bla | |
This file contains hidden or 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
| //index.js | |
| import React from 'react'; | |
| import ReactDOM from 'react-dom'; | |
| import './index.css'; | |
| import App from './App'; | |
| import * as serviceWorker from './serviceWorker'; | |
| import { AuthProvider } from './views/auth/AuthContext'; | |
| ReactDOM.render( | |
| <AuthProvider> |
This file contains hidden or 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
| //index.js | |
| import React from 'react'; | |
| import ReactDOM from 'react-dom'; | |
| import './index.css'; | |
| import App from './App'; | |
| import * as serviceWorker from './serviceWorker'; | |
| import { AuthProvider } from './views/auth/AuthContext'; | |
| ReactDOM.render( | |
| <AuthProvider> |
This file contains hidden or 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
| //App.js | |
| import React from 'react'; | |
| import { BrowserRouter, Route, Switch } from 'react-router-dom'; | |
| import { Dashboard } from './views/dashboard'; | |
| import Login from './views/login/Login'; | |
| import { ProtectedRoute } from './views/routes/ProtectedRoute'; | |
| import * as ROUTES from './views/constants/route'; | |
| import 'antd/dist/antd.css'; | |
| function App() { |
NewerOlder

