mirror of
https://github.com/luxfi/explore.git
synced 2026-09-24 00:28:18 +00:00
* add address widgets * Update ENVS.md * fix long values * fix responsive size and hover border color * improve url template formatting, add chainId mapping * add hover animation * add widgets tab * filter widgets by address type * fix link style * add mixpanel event * fix stub * fix result check * add tests * fix tabs loading * Check the workflow: generate chakra types if the node_modules cache is hit * fix loading * fix loading view all link * fix loading issue * post-review changes * rename envs and feature * rename components and hook * rename config prop and change url template format * change validation schema * add chain_id to request params * update tests * rename, improve * improve grid logic * improve formatting func * simplify grid logic * update hint text * duplicate widgets in env for tests * update mocks and snapshots * fix text * fix grid one more time * update envs with test config * update snapshots * fix grid max width * update mock and snapshots * use separator * Update .env.eth * fix * update snapshots --------- Co-authored-by: tom <[email protected]>
25 lines
1.0 KiB
TypeScript
25 lines
1.0 KiB
TypeScript
import { useQuery } from '@tanstack/react-query';
|
|
|
|
import type { Address3rdPartyWidget } from 'types/views/address';
|
|
|
|
import config from 'configs/app';
|
|
import type { ResourceError } from 'lib/api/resources';
|
|
import useApiFetch from 'lib/hooks/useFetch';
|
|
import { WIDGET_CONFIG } from 'stubs/address3rdPartyWidgets';
|
|
|
|
const feature = config.features.address3rdPartyWidgets;
|
|
const configUrl = (feature.isEnabled && feature.configUrl) || '';
|
|
const widgets = (feature.isEnabled && feature.widgets) || [];
|
|
|
|
export default function useWidgetsConfigQuery(isQueryEnabled = true) {
|
|
const apiFetch = useApiFetch();
|
|
|
|
return useQuery<unknown, ResourceError<unknown>, Record<string, Address3rdPartyWidget>>({
|
|
queryKey: [ 'address-3rd-party-widgets-config' ],
|
|
queryFn: async() => apiFetch(configUrl, undefined, { resource: 'address-3rd-party-widgets-config' }),
|
|
placeholderData: widgets.reduce((acc, widget) => ({ ...acc, [widget]: WIDGET_CONFIG }), {}),
|
|
staleTime: Infinity,
|
|
enabled: Boolean(configUrl) && isQueryEnabled,
|
|
});
|
|
}
|