Files
Folo/apps/ssr/client/query/list.ts
T
Innei 4953caf5de feat(header): re-design share header
- Introduced enhanced scroll state management to adjust header elevation and compactness based on scroll position.
- Updated the layout of the header and container components for better responsiveness and visual appeal.
- Improved logo and social media links sections with animations and transitions for a more dynamic user experience.

These changes aim to provide a more intuitive and visually appealing header that adapts to user interactions.

Signed-off-by: Innei <tukon479@gmail.com>
2025-06-17 20:53:12 +08:00

34 lines
1.0 KiB
TypeScript

import { apiClient } from "@client/lib/api-fetch"
import { getHydrateData } from "@client/lib/helper"
import { useQuery } from "@tanstack/react-query"
const fetchListById = async (id: string) => {
const res = await apiClient.lists.$get({ query: { listId: id } })
return res.data
}
export const useList = ({ id }: { id?: string }) =>
useQuery({
queryKey: ["lists", id],
queryFn: () => fetchListById(id!),
enabled: !!id,
initialData: getHydrateData(`lists.$get,query:listId=${id}`) as any as Awaited<
ReturnType<typeof fetchListById>
>,
})
const fetchListsByUserId = async (userId: string) => {
const res = await apiClient.lists.list.$get({ query: { userId } })
return res.data
}
export const useListsByUserId = (userId: string) =>
useQuery({
queryKey: ["lists", userId],
queryFn: () => fetchListsByUserId(userId),
enabled: !!userId,
initialData: getHydrateData(`lists.list.$get,query:userId=${userId}`) as any as Awaited<
ReturnType<typeof fetchListsByUserId>
>,
})