utils APIs
- calculateSlippageAmount
- calculateGasMargin
- getRouterContract
- getBscScanLink
- isAddress
- shortenAddress
- getEtherscanLink
- basisPointsToPercent
- getTokenAddress
- copyToClipboard
- deepMergeByKey
- decrypt
- encrypt
- emailErrorMsg
- reqErrorMsg
- debouncePromise
- callbackify
- isValidURL
- hasUserApiEditAccess
- loadThirdPartyScript
- getCurrentWindow
- hashVote
- toEthSignedMessageHash
- MAINNET_ID
- usePrevious
- bnum
- normalizeBalance
- isWalletScheme
- WalletSchemeProposalState
- VotingMachineProposalState
- calculateStakes
- formatBalance
- denormalizeBalance
- PendingAction
- isVoteNo
- isVoteYes
- parseSignedVoteMessage
- toPercentage
- verifySignedVote
- NETWORK_ASSET_SYMBOL
- ZERO_ADDRESS
- enumKeys
- DEFAULT_CHAIN_ID
- useInterval
- getBlockchainLink
- getERC20Token
- getDxVoteContract
- toAddressStub
- getNetworkById
- formatNumberValue
- encodeDxdVestingCreate
- encodeErc20Approval
- encodeErc20Transfer
- encodeRepMint
- TXEvents
- BigNumber
- ZERO_HASH
- ANY_ADDRESS
- ERC20_APPROVE_SIGNATURE
- ERC20_TRANSFER_SIGNATURE
- QUEUED_PRIORITY_THRESHOLD
- NETWORKS
- toCamelCaseString
- ALCHEMY_NETWORK_URLS
- DEFAULT_RPC_URLS
- appendEthAPIKey
- NETWORK_APIS
- INFURA_NETWORK_NAMES
- POKT_NETWORK_URLS
- constants
- session
- displayFromWei
- getBigNumber
- getSupplyCap
- getAllowance
- approve
- fromWei
- getFullDisplayBalance
- getLibrary
- maxAmountSpend
- addMaticToMetamask
- returnTokenFromKey
- isSupportedNetwork
- formatTokenAmount
- formatCompact
- formatNumber
- isTokensOnList
- getAPYWithFee
- getRewardRate
- getStakedAmountStakingInfo
- getTVLStaking
- getEarnedUSDLPFarm
- getEarnedUSDDualFarm
- formatAPY
- getUSDString
- formatMulDivTokenAmount
- getExactTokenAmount
- escapeRegExp
- currencyId
- getOneYearFee
- returnStakingInfo
- getAllTokensOnUniswap
- getAllPairsOnUniswap
- getSecondsOneDay
- getValueTokenDecimals
- getPartialTokenAmount
- confirmPriceImpactWithoutFee
- halfAmountSpend
- getTokenInfo
- getEthPrice
- getIntervalTokenData
- getTokenAPRSyrup
- getEarnedUSDSyrup
- getFormattedPrice
- getPriceColor
- getTopTokens
- shortenTx
- getContract
- isZero
- getChartData
- getChartDates
- getChartStartTime
- getLimitedData
- getTopPairs
- getGlobalData
- getBulkPairData
- formatDateFromTimeStamp
- getPairChartData
- getYAXISValuesAnalytics
- getPairTransactions
- getTokenChartData
- getTokenPairs2
- useLairDQUICKAPY
- getPageItemsToLoad
- returnFullWidthMobile
- returnDualStakingInfo
- getDaysCurrentYear
- getTokenPairs
- getBlockFromTimestamp
- getFarmLPToken
- getSyrupLPToken
- initTokenAmountFromCallResult
- returnSyrupInfo
- getCallStateResult
- notEmpty
- DEFAULT_TO_CHAIN_ID
- CHAINS
- UnsupportedChainIdError
- switchChain
- showMigrationBanner
- isValidAddress
- ChainId
- COLORS
- QUERIES
- onboard
- disableSendForm
- max
- parseUnits
- formatUnits
- ParsingError
- TOKENS_LIST
- Token
- blockLiquidity
- migrationPoolV2Warning
- formatEtherRaw
- numberFormatter
- estimateGasForAddEthLiquidity
- DEFAULT_ADD_LIQUIDITY_ETH_GAS_ESTIMATE
- UPDATE_GAS_INTERVAL_MS
- toWeiSafe
- addEtherscan
- receiveAmount
- getEstimatedDepositTime
- DEFAULT_FROM_CHAIN_ID
- formatEther
- PROVIDERS
- getRelayFees
- getLpFee
- isSupportedChainId
- getAddress
- getDepositBox
- TransactionError
- MAX_APPROVAL_AMOUNT
- optimismErc20Pairs
- bobaErc20Pairs
- tagAddress
- validateContractAndChain
- multicallTwoAddress
- IChainSelection
- CHAINS_SELECTION
- onboardBaseConfig
- getConfirmationDepositTime
- shortenAddressLong
- timeAgo
- textareaAutoResize
- initOAuthWindow
- parseURL
- scrollToBottom
- isUrl
- get_url_extension
- wait
- b64_to_utf8
- utf8_to_b64
- callDelayer
- useKeyboardDidShow
- capitalizedCase
- getCoinSymbol
- getCountryName
- getTransactionStatusColor
- useAlert
- scaleSpacing
- getActiveCase
- changeBodyTheme
- getPercentage
- metaGenerator
- useFetch
- visualize
- worldLegends
- dateFormat
- getPerDayStats
- API_BASEURL
- API_INDONESIA
- indonesiaLegends
- getActiveCaseID
- isWsAddress
- constructApiDescriptionObject
- encodeURI
- NOOP
- isLoggedIn
- getBalance
- getAccount
- isTokenOnList
- formatAddressShort
- requiresTypeSlug
- getNextOffchainPollEndingTime
- slugify
- slugifyPreserveDashes
- setupSwagger
- isBlindMode
- getExplorerLink
- isCountdown
- showVvsPrice
- getCookies
- iconFromMIME
- makeRangeArray
- exitIfMaintenance
- sanitizeHtmlString
- parseDate
- retryWrapper
- batchPromises
- arrayPartitions
- sleep
- checkKeyboardTrigger
- clampValue
- debounce
- normalize
- strToInt
- getFromLocalStorage
- saveToLocalStorage
- generateTagColors
- formatNumberWithCommas
- memoize
- calculateTotalInvestment
- throttle
- urlParametersState
- mmddyyyy2ddmmyyy
- sortStringDates
- gtag
- compactNumberFormatter
- getNumberSign
- getLastArrayElement
- fillArrayUntil
- capitalizeFirstLetter
- buildUrl
- XmlWrapper
- XmlTemplate
- setCookie
Other Related APIs
- react#ReactElement
- react-router-dom#useLocation
- react-router-dom#useHistory
- @material-ui/core#Button
- @material-ui/core#Typography
- @material-ui/core#IconButton
- @material-ui/core#Toolbar
- @material-ui/core#AppBar
- @material-ui/core#Grid
- @material-ui/core#MenuItem
- @material-ui/core#Menu
- @material-ui/core#Link
- utils#session
utils#constants TypeScript Examples
The following examples show how to use
utils#constants.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: index.tsx From ArCovidRos with GNU Affero General Public License v3.0 | 5 votes |
NoMatch = (): ReactElement => {
const location = useLocation();
const { isAuthorized, clearStorage } = session;
const { ROUTES } = constants;
const history = useHistory();
const handleLinkClick = (path: string): void => {
history.push(path);
};
return (
<div
style={{
height: "100vh",
display: "flex",
alignItems: "center",
justifyContent: "center",
}}
>
<div
style={{
padding: "150px 50px 150px 50px",
borderRadius: "10px",
boxShadow: "2px 2px 10px #666 ",
textAlign: "center",
}}
>
<Typography variant="h6">
La ruta <code>{location.pathname}</code> es inválida
</Typography>
<Button
style={{
color: "#00ff8b",
borderColor: "#00ff8b",
fontWeight: "bold",
}}
variant="outlined"
onClick={() => handleLinkClick(ROUTES.HOME)}
>
Volver al inicio
</Button>
</div>
</div>
);
}
Example #2
Source File: index.tsx From ArCovidRos with GNU Affero General Public License v3.0 | 4 votes |
export default function Header() {
const { isAuthorized, clearStorage } = session;
const { ROUTES } = constants;
const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null);
const history = useHistory();
const logOut = (): void => {
clearStorage();
history.push(ROUTES.LOGIN);
};
const handleLinkClick = (path: string): void => {
history.push(path);
};
const handleMenuClick = (event: React.MouseEvent<HTMLButtonElement>) => {
setAnchorEl(event.currentTarget);
};
const handleMenuClose = () => {
setAnchorEl(null);
};
return (
<div>
<AppBar style={{ background: "#00011A" }} position="static">
<Toolbar variant="regular">
<Grid container direction="row" alignItems="center">
<Grid style={{ margin: "0 15px" }}>
<img src={HackFunIcon} width="60px" />
</Grid>
<Grid xs={10}>
<Typography variant="h6">HackFun</Typography>
</Grid>
<Grid>
<IconButton edge="end" color="inherit" aria-label="github">
<a
style={{ color: "white" }}
href="https://github.com/Hackfun-Rosario/ArCovidRos"
>
<GitHubIcon />
</a>
</IconButton>
</Grid>
<Grid>
<IconButton
style={{ marginLeft: "15px" }}
edge="end"
color="inherit"
aria-label="menu"
onClick={handleMenuClick}
>
<MenuIcon />
</IconButton>
<Menu
id="simple-menu"
anchorEl={anchorEl}
keepMounted
open={Boolean(anchorEl)}
onClose={handleMenuClose}
>
<MenuItem onClick={handleMenuClose}>
<Link
style={{
marginRight: "10px",
textDecoration: "none",
color: "black",
}}
onClick={() => handleLinkClick(ROUTES.HOME)}
>
Inicio
</Link>
</MenuItem>
{isAuthorized() && (
<div>
<MenuItem onClick={handleMenuClose}>
<Link
style={{
marginRight: "10px",
textDecoration: "none",
color: "black",
}}
onClick={() => handleLinkClick(ROUTES.ABM_PROVINCE)}
>
Alta Provincia
</Link>
</MenuItem>
<MenuItem onClick={handleMenuClose}>
<Link
onClick={() => handleLinkClick(ROUTES.ABM_CITY)}
style={{ textDecoration: "none", color: "black" }}
>
Alta Ciudad
</Link>
</MenuItem>
<MenuItem onClick={logOut}>Logout</MenuItem>
</div>
)}
{!isAuthorized() && (
<MenuItem onClick={handleMenuClose}>
<Link
onClick={() => handleLinkClick(ROUTES.LOGIN)}
style={{ textDecoration: "none", color: "black" }}
>
Login
</Link>
</MenuItem>
)}
</Menu>
</Grid>
</Grid>
</Toolbar>
</AppBar>
</div>
);
}