import React from 'react'
import { useAuthUser } from '~/src/contexts/AuthUser'
import { useInterceptor } from './useInterceptor'
/**
* Setup axios interceptors to work with auth
*/
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
export function mergeRefs<T>(...refs: Ref<T>[]) { | |
return (value: T) => { | |
refs.forEach((ref) => { | |
if (typeof ref === 'function') { | |
ref(value) | |
} else if (ref.current) { | |
ref.current = value | |
} | |
}) | |
} |
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, { useMemo } from 'react' | |
import ReactDOM from 'react-dom' | |
import styled from 'styled-components' | |
import { usePopper } from 'react-popper' | |
import type { Placement, Offsets } from '@popperjs/core' | |
import { useStateRef, useUpdateEffect, useDocumentListener, useOutsideClick } from '~/src/hooks' | |
import { theme } from '~/src/theme' | |
interface Props { |
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 merge = (left: number[], right: number[]): number[] => { | |
let result = [] | |
let lindex = 0 | |
let rindex = 0 | |
while (lindex < left.length && rindex < right.length) { | |
if (left[lindex] < right[rindex]) { | |
result.push(left[lindex]) | |
lindex++ | |
} else { |
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
// You can manually select this by: | |
// Console -> Find Modal -> Right Click -> Store as Global Variable | |
const modal = document.querySelector('#mount_0_0_5Q > div > div:nth-child(1) > div > div:nth-child(7) > div > div > div.rq0escxv.l9j0dhe7.du4w35lb > div > div.iqfcb0g7.tojvnm2t.a6sixzi8.k5wvi7nf.q3lfd5jv.pk4s997a.bipmatt0.cebpdrjk.qowsmv63.owwhemhu.dp1hu0rb.dhp61c6y.l9j0dhe7.iyyx5f41.a8s20v7p > div > div > div > div.rdhft8ur.a31nu0t8.r8a9u66l.ni8dbmo4.stjgntxs.k4urcfbm > div.f71di6ws.cxgpxx05.rz4wbd8a.sj5x9vvc.a8nywdso > div > div.j83agx80.cbu4d94t.buofh1pr.l9j0dhe7') | |
modal.querySelectorAll('.hu5pjgll.m6k467ps').forEach(element => { | |
var evt = new Event('click', { bubbles: true }) | |
element.dispatchEvent(evt) | |
}) |
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 dupes = (arr, key) => { | |
const map = {} | |
const result = [] | |
arr.forEach((obj) => { | |
const value = obj[key] | |
if (map[value]) result.push(obj) | |
map[value] = 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
import React, { memo, MouseEvent, RefObject, useEffect, useMemo } from 'react' | |
import { useRef } from 'react' | |
//#region utils | |
/** | |
* We need a notion of reactivity. React is not reactive. | |
*/ | |
interface Signal<A> { | |
(handler: (a: A) => void): () => void | |
} | |
function newSignal<A>(): [signal: Signal<A>, next: (value: A) => void] { |
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 generateUnique(length) { | |
const generated = [] | |
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789' | |
for (let i = 0; i < length; i++) { | |
let character = '' | |
do { | |
character = characters[random(characters.length)] | |
} while (generated.includes(character)) |
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
var integers = [] | |
// Generate 10 integers | |
for (var i = 0; i < 10; i++) { | |
var number | |
do { | |
// Keep generating a random number if it's already in the array twice. | |
number = random(5) | |
} while(getCountInList(number) >= 2) |
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
/** | |
* Get the prior status of the list based on the order of the provided statuses. | |
* | |
* @example | |
* getPriorStatus([{ status: 'active' }, { status: 'pending' }, { status: 'approved' }], ['approved', 'active', 'declined', 'pending']) | |
* @returns | |
* approved | |
*/ | |
const getPriorStatus = (data, statuses) => { | |
for (let i = 0; i < statuses.length; i++) { |