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 const useDebounce = (value, delay) => { | |
| const [debouncedValue, setDebouncedValue] = React.useState(value); | |
| React.useEffect(() => { | |
| const handler = setTimeout(() => { | |
| setDebouncedValue(value); | |
| }, delay); | |
| return () => { | |
| clearTimeout(handler); |
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 const breakpoints = { // adicionar outros breakpoints se estiver espeficificado no design | |
| '2xs': '360px', | |
| xs: '480px', | |
| sm: '640px', | |
| md: '768px', | |
| lg: '1024px', | |
| xl: '1280px', | |
| '2xl': '1536px', | |
| } as const; |
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 { useLocation } from 'react-router-dom'; | |
| export default function useRouterQuery() { | |
| const { search } = useLocation(); | |
| return new URLSearchParams(search); | |
| } |
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 * as React from 'react'; | |
| import PropTypes from 'prop-types'; | |
| function MainPanel({ children }) { | |
| return <section className="flex-grow">{children}</section>; | |
| } | |
| function SidePanel({ children }) { | |
| return <aside className="flex-grow max-w-none md:max-w-75">{children}</aside>; | |
| } |
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
| /** | |
| * Returns the current object from `localStorage` associated with the given `key`. | |
| */ | |
| export function getLocalStorageData<T = unknown>(key: string): T | undefined { | |
| const data = window.localStorage.getItem(key); | |
| try { | |
| return data ? JSON.parse(data) : undefined; | |
| } catch { | |
| return undefined; | |
| } |
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 from 'react'; | |
| import PropTypes from 'prop-types'; | |
| import { useLocation, Route } from 'react-router'; | |
| export default function DynamicRoute({ children, path, element }) { | |
| const location = useLocation(); | |
| return ( | |
| <Route path={path} element={element(location)}> | |
| {children} |
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 axios from 'axios'; | |
| import { env } from '../lib/env'; | |
| import { request, response } from './interceptor'; | |
| const instance = axios.create({ | |
| baseURL: env.apiBaseUrl, | |
| }); | |
| async function get<Data>(endpoint: string): Promise<Data> { | |
| const { data } = await instance.get(endpoint); |
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
| /** | |
| * Returns the current object from local storage associated with the given key. | |
| * @template T | |
| * @param {String} key The key to set in localStorage for this value | |
| * @returns {T|undefined} | |
| */ | |
| export function getLocalStorageData(key) { | |
| const data = window.localStorage.getItem(key); | |
| try { | |
| return data ? JSON.parse(data) : undefined; |
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 * as React from 'react'; | |
| type ErrorBoundaryState = { | |
| error?: Error; | |
| }; | |
| type ErrorBoundaryProps = { | |
| children: React.ReactNode; | |
| fallback: React.ReactNode | ((state: ErrorBoundaryState) => void); | |
| }; |