feat: add stock pages and ticker navigation
Add stock search and detail pages with charts, dividends and shared event rows. Use verified ticker links for portfolio names and logos, numeric dates and refreshed account cards. Update the generated API contract.
This commit is contained in:
@@ -2,6 +2,7 @@ import {
|
||||
type QueryKey,
|
||||
type UseQueryOptions,
|
||||
type UseQueryResult,
|
||||
useQueries,
|
||||
useQuery,
|
||||
} from "@tanstack/react-query";
|
||||
import { useSyncExternalStore } from "react";
|
||||
@@ -18,11 +19,7 @@ function useAuthenticatedQuery<
|
||||
>(
|
||||
options: UseQueryOptions<TQueryFnData, TError, TData, TQueryKey>,
|
||||
): UseQueryResult<TData, TError> {
|
||||
const hasSession = useSyncExternalStore(
|
||||
subscribeAuthenticatedSession,
|
||||
getAuthenticatedSessionSnapshot,
|
||||
getAuthenticatedSessionSnapshot,
|
||||
);
|
||||
const hasSession = useHasAuthenticatedSession();
|
||||
const enabled = options.enabled;
|
||||
|
||||
return useQuery({
|
||||
@@ -33,4 +30,30 @@ function useAuthenticatedQuery<
|
||||
});
|
||||
}
|
||||
|
||||
export { useAuthenticatedQuery };
|
||||
function useHasAuthenticatedSession() {
|
||||
return useSyncExternalStore(
|
||||
subscribeAuthenticatedSession,
|
||||
getAuthenticatedSessionSnapshot,
|
||||
getAuthenticatedSessionSnapshot,
|
||||
);
|
||||
}
|
||||
|
||||
function useAuthenticatedQueries<TData, TError, TQueryKey extends QueryKey>(
|
||||
queries: UseQueryOptions<TData, TError, TData, TQueryKey>[],
|
||||
) {
|
||||
const hasSession = useHasAuthenticatedSession();
|
||||
return useQueries({
|
||||
queries: queries.map(
|
||||
(options): UseQueryOptions<TData, TError, TData, TQueryKey> => ({
|
||||
...options,
|
||||
enabled: (query) =>
|
||||
hasSession &&
|
||||
(typeof options.enabled === "function"
|
||||
? options.enabled(query)
|
||||
: (options.enabled ?? true)),
|
||||
}),
|
||||
),
|
||||
});
|
||||
}
|
||||
|
||||
export { useAuthenticatedQueries, useAuthenticatedQuery };
|
||||
|
||||
Reference in New Issue
Block a user