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, { useCallback, useEffect, useRef } from "react"; | |
function usePolling(action, delay) { | |
const timeoutId = useRef(null); | |
const isComponentMounted = useRef(false); | |
const handlePolling = useCallback(() => { | |
action().then(() => { | |
if (isComponentMounted.current) { | |
timeoutId.current = setTimeout(handlePolling, delay); |
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
// Source: https://a-z-animals.com/animals/ | |
const allAnimals = { | |
Aardvark: true, | |
Aardwolf: true, | |
Abyssinian: true, | |
'Abyssinian Guinea Pig': true, | |
'Acadian Flycatcher': true, | |
'Achrioptera Manga': true, | |
'Ackie Monitor': true, | |
Addax: true, |
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 borderStyle = css` | |
border: solid 1px ${({ theme }) => theme.colors.neutral._40}; | |
`; | |
export const $TimelineCapsule = styled.div` | |
position: relative; | |
display: flex; | |
align-items: center; | |
justify-content: space-between; |
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 sortByPropertyName = ({ data, field = 'name' }) => | |
data.sort(function (a, b) { | |
var nameA = a[field].toUpperCase(); | |
var nameB = b[field].toUpperCase(); | |
if (nameA < nameB) return -1; | |
if (nameA > nameB) return 1; | |
return 0; | |
}); |
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
// Epochs | |
const epochs = [ | |
['year', 31536000], | |
['month', 2592000], | |
['day', 86400], | |
['hour', 3600], | |
['minute', 60], | |
['second', 1] | |
]; |
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 { AxiosResponse } from 'axios'; | |
import { logger } from 'firebase-functions'; | |
const retryPromise = ( | |
fn: () => Promise<AxiosResponse>, | |
retries = 2, | |
err: null | unknown = null | |
): Promise<AxiosResponse> => { | |
logger.log('Retries: ', retries); |
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 retry(fn, retries = 2, err = null) { | |
console.log("Retries: ", retries); | |
if (!retries) { | |
console.log("Done Retrying..."); | |
return Promise.reject(err); | |
} | |
return fn().catch((err) => { | |
console.log("Retrying..."); | |
return retry(fn, retries - 1, err.response); |
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 formatCount = (x) => x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ','); |
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 uploadFile = ({ | |
event, | |
onComplete | |
}: { | |
event: ChangeEvent<HTMLInputElement>; | |
onComplete: (file: File, base64File: string) => void; | |
}) => { | |
event.preventDefault(); | |
let base64File: string; |
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
// Tabs.jsx | |
import PropTypes from 'prop-types'; | |
import { useState } from 'react'; | |
import styles from './Tabs.module.css'; | |
export const Tabs = ({ tabHeaders, children, defaultTab }) => { | |
const [currentTab, setCurrentTab] = useState(defaultTab.toLowerCase()); | |
const handleTabSelect = (tabHeader) => { | |
setCurrentTab(tabHeader.toLowerCase()); |
NewerOlder