Utilities for RealPay
npm install @hayitbek/realpay-utils``bash`
npm install realpay-utils`bash`
pnpm install realpay-utils`bash`
yarn add realpay-utils
#### useComponentVisible
`tsx
import { useComponentVisible } from '@hayitbek/realpay-utils'
const Component = () => {
const [isOpen, setIsOpen] = useState(false);
const {ref} = useComponentVisible({ setVisible: setIsOpen })
return
#### useCountDown
`tsx
import { useCountDown } from "@hayitbek/realpay-utils";const Component = () => {
const { timer, setTimer } = useCountDown(59);
return (
00:0${timer} : 00:${timer}}
)
}
`#### useDebounce
`tsx
import { useDebounce } from "@hayitbek/realpay-utils";const Component = () => {
const [value, setValue] = useState("");
const debouncedValue = useDebounce(value, 500);
return (
value={value}
onChange={(e) => setValue(e.target.value)}
/>
)
}
`#### useFocus
`tsx
import { useFocus } from "@hayitbek/realpay-utils";const Component = () => {
const ref = useRef(null);
const [isFocused, setIsFocused] = useState(false);
const {ref} = useFocus(ref,!isFocused)
return
}
`#### useInput
`tsx
import { useInput } from "@hayitbek/realpay-utils";const Component = () => {
const [value, setValue] = useState({
name: "",
});
const { handleChange, ref} = useInput(value)
return
}
`#### useRequestOnEnter
`tsx
import { useRequestOnEnter } from "@hayitbek/realpay-utils";const Component = () => {
const [isRequestEnabled, setIsRequestEnabled] = useState(false);
const [shouldFilter, setShouldFilter] = useState(false);
useRequestOnEnter(shouldFilter, setIsRequestEnabled);
}
`$3
#### classnames
`tsx
import {classnames} from "@hayitbek/realpay-utils"const Component = () => {
const [isBlue, setIsBlue] = useState(false);
return (
)
}
`#### formatDate
`tsx
import {formatDate} from "@hayitbek/realpay-utils"const Component = () => {
return
{formatDate("2024-07-17T09:59:26.249Z")}
}
`#### formatToAmount
`tsx
import {formatToAmount} from "@hayitbek/realpay-utils"const Component = () => {
return
{formatToAmount(1000000)}
}`#### getBaseUrl
`tsx
import {getBaseUrl} from "@hayitbek/realpay-utils"const baseUrl = getBaseUrl(import.meta.env,import.meta.env.MODE);
`#### memoize
`tsx
import {memoize} from "@hayitbek/realpay-utils"const memoizedFn = memoize(fn);
``