diff --git a/components/Current/Header/index.tsx b/components/Current/Header/index.tsx index 0f932cfc8..de5948d30 100644 --- a/components/Current/Header/index.tsx +++ b/components/Current/Header/index.tsx @@ -2,7 +2,6 @@ import { homeHrefs } from "@/constants/homeHrefs" import { env } from "@/env/server" import { serverClient } from "@/lib/trpc/server" -import { auth } from "@/auth" import { BookingWidget } from "@/components/BookingWidget" import { getLang } from "@/i18n/serverContext" diff --git a/components/Image.tsx b/components/Image.tsx index e5a4c5ade..cf88c6e01 100644 --- a/components/Image.tsx +++ b/components/Image.tsx @@ -5,7 +5,8 @@ import NextImage from "next/image" import type { ImageLoaderProps, ImageProps } from "next/image" function imageLoader({ quality, src, width }: ImageLoaderProps) { - return `${src}?w=${width}${quality ? "&q=" + quality : ""}` + const hasQS = src.indexOf("?") !== -1 + return `${src}${hasQS ? "&" : "?"}w=${width}${quality ? "&q=" + quality : ""}` } // Next/Image adds & instead of ? before the params diff --git a/components/MyPages/Blocks/Stays/Previous/Client.tsx b/components/MyPages/Blocks/Stays/Previous/Client.tsx index d680edc56..08986ae13 100644 --- a/components/MyPages/Blocks/Stays/Previous/Client.tsx +++ b/components/MyPages/Blocks/Stays/Previous/Client.tsx @@ -19,9 +19,13 @@ export default function ClientPreviousStays({ }: PreviousStaysClientProps) { const { data, isFetching, fetchNextPage, hasNextPage, isLoading } = trpc.user.stays.previous.useInfiniteQuery( - {}, { - getNextPageParam: (lastPage) => lastPage?.nextCursor, + limit: 6, + }, + { + getNextPageParam: (lastPage) => { + return lastPage?.nextCursor + }, initialData: { pageParams: [undefined, 1], pages: [initialPreviousStays], diff --git a/components/MyPages/Blocks/Stays/Previous/index.tsx b/components/MyPages/Blocks/Stays/Previous/index.tsx index e83a189a0..03605d96e 100644 --- a/components/MyPages/Blocks/Stays/Previous/index.tsx +++ b/components/MyPages/Blocks/Stays/Previous/index.tsx @@ -5,7 +5,6 @@ import SectionHeader from "@/components/Section/Header" import SectionLink from "@/components/Section/Link" import ClientPreviousStays from "./Client" -import EmptyPreviousStaysBlock from "./EmptyPreviousStays" import type { AccountPageComponentProps } from "@/types/components/myPages/myPage/accountPage" @@ -14,18 +13,18 @@ export default async function PreviousStays({ subtitle, link, }: AccountPageComponentProps) { - const initialPreviousStays = await serverClient().user.stays.previous() - if (!initialPreviousStays?.data) { + const initialPreviousStays = await serverClient().user.stays.previous({ + limit: 6, + }) + + if (!initialPreviousStays?.data.length) { return null } + return ( - {initialPreviousStays.data.length ? ( - - ) : ( - - )} + ) diff --git a/components/MyPages/Blocks/Stays/ShowMoreButton/index.tsx b/components/MyPages/Blocks/Stays/ShowMoreButton/index.tsx index 64fc3a3de..6e9cae7bf 100644 --- a/components/MyPages/Blocks/Stays/ShowMoreButton/index.tsx +++ b/components/MyPages/Blocks/Stays/ShowMoreButton/index.tsx @@ -21,7 +21,6 @@ export default function ShowMoreButton({ onClick={loadMoreData} variant="icon" type="button" - className={styles.button} theme="base" intent="text" > diff --git a/components/MyPages/Blocks/Stays/Upcoming/Client.tsx b/components/MyPages/Blocks/Stays/Upcoming/Client.tsx index 94230f570..07c406904 100644 --- a/components/MyPages/Blocks/Stays/Upcoming/Client.tsx +++ b/components/MyPages/Blocks/Stays/Upcoming/Client.tsx @@ -19,9 +19,13 @@ export default function ClientUpcomingStays({ }: UpcomingStaysClientProps) { const { data, isFetching, fetchNextPage, hasNextPage, isLoading } = trpc.user.stays.upcoming.useInfiniteQuery( - {}, { - getNextPageParam: (lastPage) => lastPage?.nextCursor, + limit: 6, + }, + { + getNextPageParam: (lastPage) => { + return lastPage?.nextCursor + }, initialData: { pageParams: [undefined, 1], pages: [initialUpcomingStays], diff --git a/components/MyPages/Blocks/Stays/Upcoming/index.tsx b/components/MyPages/Blocks/Stays/Upcoming/index.tsx index 7e221e449..c56bf8f41 100644 --- a/components/MyPages/Blocks/Stays/Upcoming/index.tsx +++ b/components/MyPages/Blocks/Stays/Upcoming/index.tsx @@ -7,6 +7,8 @@ import SectionLink from "@/components/Section/Link" import ClientUpcomingStays from "./Client" import EmptyUpcomingStaysBlock from "./EmptyUpcomingStays" +import styles from "./upcoming.module.css" + import type { AccountPageComponentProps } from "@/types/components/myPages/myPage/accountPage" export default async function UpcomingStays({ @@ -14,14 +16,14 @@ export default async function UpcomingStays({ subtitle, link, }: AccountPageComponentProps) { - const initialUpcomingStays = await serverClient().user.stays.upcoming() - if (!initialUpcomingStays?.data) { - return null - } + const initialUpcomingStays = await serverClient().user.stays.upcoming({ + limit: 6, + }) + return ( - + - {initialUpcomingStays.data.length ? ( + {initialUpcomingStays?.data.length ? ( ) : ( diff --git a/components/MyPages/Blocks/Stays/Upcoming/upcoming.module.css b/components/MyPages/Blocks/Stays/Upcoming/upcoming.module.css new file mode 100644 index 000000000..5abd71abb --- /dev/null +++ b/components/MyPages/Blocks/Stays/Upcoming/upcoming.module.css @@ -0,0 +1,3 @@ +.container { + display: inline-grid; +} diff --git a/lib/api/index.ts b/lib/api/index.ts index 82a75704c..104c8c17d 100644 --- a/lib/api/index.ts +++ b/lib/api/index.ts @@ -7,7 +7,7 @@ import type { RequestOptionsWithJSONBody, RequestOptionsWithOutBody, } from "@/types/fetch" -import type { Endpoint, endpoints } from "./endpoints" +import type { Endpoint } from "./endpoints" export { endpoints } from "./endpoints" @@ -26,13 +26,13 @@ const fetch = fetchRetry(global.fetch, { return Math.pow(2, attempt) * 150 // 150, 300, 600 }, }) -const url = new URL(env.API_BASEURL) export async function get( endpoint: Endpoint | `${Endpoint}/${string}`, options: RequestOptionsWithOutBody, params = {} ) { + const url = new URL(env.API_BASEURL) url.pathname = endpoint const searchParams = new URLSearchParams(params) if (searchParams.size) { @@ -50,6 +50,7 @@ export async function patch( params = {} ) { const { body, ...requestOptions } = options + const url = new URL(env.API_BASEURL) url.pathname = endpoint const searchParams = new URLSearchParams(params) if (searchParams.size) { @@ -71,9 +72,10 @@ export async function patch( export async function post( endpoint: Endpoint | `${Endpoint}/${string}`, options: RequestOptionsWithJSONBody, - params = {}, + params = {} ) { const { body, ...requestOptions } = options + const url = new URL(env.API_BASEURL) url.pathname = endpoint const searchParams = new URLSearchParams(params) if (searchParams.size) { @@ -95,8 +97,9 @@ export async function post( export async function remove( endpoint: Endpoint | `${Endpoint}/${string}`, options: RequestOptionsWithOutBody, - params = {}, + params = {} ) { + const url = new URL(env.API_BASEURL) url.pathname = endpoint const searchParams = new URLSearchParams(params) if (searchParams.size) { diff --git a/server/routers/user/input.ts b/server/routers/user/input.ts index 283f12d5e..98715cd0a 100644 --- a/server/routers/user/input.ts +++ b/server/routers/user/input.ts @@ -28,7 +28,6 @@ export const friendTransactionsInput = z }) .default({ limit: 5, page: 1 }) - // Mutation export const addCreditCardInput = z.object({ language: z.string(), diff --git a/server/routers/user/query.ts b/server/routers/user/query.ts index 53640009c..e50d024dd 100644 --- a/server/routers/user/query.ts +++ b/server/routers/user/query.ts @@ -379,16 +379,6 @@ export const userQueryRouter = router({ ) if (!apiResponse.ok) { - // switch (apiResponse.status) { - // case 400: - // throw badRequestError(apiResponse) - // case 401: - // throw unauthorizedError(apiResponse) - // case 403: - // throw forbiddenError(apiResponse) - // default: - // throw internalServerError(apiResponse) - // } const text = await apiResponse.text() console.error( "api.booking.stays.past error ", @@ -464,16 +454,6 @@ export const userQueryRouter = router({ ) if (!apiResponse.ok) { - // switch (apiResponse.status) { - // case 400: - // throw badRequestError(apiResponse) - // case 401: - // throw unauthorizedError(apiResponse) - // case 403: - // throw forbiddenError(apiResponse) - // default: - // throw internalServerError(apiResponse) - // } const text = await apiResponse.text() console.error( "api.booking.stays.future error ",