feat: enhance stays with api data

This commit is contained in:
Christel Westerberg
2024-05-08 14:56:39 +02:00
parent 57fd59ebe2
commit 661a8019d3
18 changed files with 223 additions and 108 deletions

View File

@@ -1,6 +1,5 @@
"use client"
import { Lang } from "@/constants/languages"
import { _ } from "@/lib/translation"
import { trpc } from "@/lib/trpc/client"
@@ -12,7 +11,7 @@ import StayList from "../StayList"
import EmptyUpcomingStaysBlock from "./EmptyUpcomingStays"
import { AccountPageComponentProps } from "@/types/components/myPages/myPage/accountPage"
import type { Page } from "@/types/components/myPages/myStays/page"
import type { Page } from "@/types/components/myPages/stays/page"
export default function UpcomingStays({
lang,
@@ -22,14 +21,16 @@ export default function UpcomingStays({
}: AccountPageComponentProps) {
const { data, hasNextPage, isFetching, fetchNextPage } =
trpc.user.stays.upcoming.useInfiniteQuery(
{},
{ limit: 6 },
{
getNextPageParam: (lastPage: Page) => lastPage.nextCursor,
}
)
function loadMoreData() {
fetchNextPage()
if (hasNextPage) {
fetchNextPage()
}
}
return (