diff --git a/app/[lang]/(live)/(protected)/my-pages/stays/page.tsx b/app/[lang]/(live)/(protected)/my-pages/stays/page.tsx index 575a6767d..c6fe2ad06 100644 --- a/app/[lang]/(live)/(protected)/my-pages/stays/page.tsx +++ b/app/[lang]/(live)/(protected)/my-pages/stays/page.tsx @@ -1,3 +1,4 @@ +import MaxWidth from "@/components/MaxWidth" import PreviousStays from "@/components/MyPages/Blocks/Stays/Previous" import UpcomingStays from "@/components/MyPages/Blocks/Stays/Upcoming" @@ -7,9 +8,9 @@ import { LangParams, PageArgs } from "@/types/params" export default async function MyStays({ params }: PageArgs) { return ( -
+ -
+ ) } diff --git a/components/MyPages/Blocks/Stays/Container/container.module.css b/components/MyPages/Blocks/Stays/Container/container.module.css index 0a8e6cdac..f4a93c4e0 100644 --- a/components/MyPages/Blocks/Stays/Container/container.module.css +++ b/components/MyPages/Blocks/Stays/Container/container.module.css @@ -1,5 +1,4 @@ .container { - max-width: var(--max-width); display: grid; gap: 2rem; } diff --git a/components/MyPages/Blocks/Stays/Previous/EmptyPreviousStays/emptyPreviousStays.module.css b/components/MyPages/Blocks/Stays/Previous/EmptyPreviousStays/emptyPreviousStays.module.css index 44999673c..72e8229d0 100644 --- a/components/MyPages/Blocks/Stays/Previous/EmptyPreviousStays/emptyPreviousStays.module.css +++ b/components/MyPages/Blocks/Stays/Previous/EmptyPreviousStays/emptyPreviousStays.module.css @@ -5,5 +5,4 @@ min-height: 25rem; background-color: var(--some-grey-color, #f2f2f2); border-radius: 0.8rem; - max-width: var(--max-width); } diff --git a/components/MyPages/Blocks/Stays/Previous/EmptyPreviousStays/index.tsx b/components/MyPages/Blocks/Stays/Previous/EmptyPreviousStays/index.tsx index d2c9b517a..1d7675412 100644 --- a/components/MyPages/Blocks/Stays/Previous/EmptyPreviousStays/index.tsx +++ b/components/MyPages/Blocks/Stays/Previous/EmptyPreviousStays/index.tsx @@ -8,7 +8,7 @@ export default function EmptyPreviousStaysBlock() { return (
- {_("You have no previous stays.")}{" "} + {_("You have no previous stays.")}
) diff --git a/components/MyPages/Blocks/Stays/Previous/index.tsx b/components/MyPages/Blocks/Stays/Previous/index.tsx index 1069d2223..e6c03eb4c 100644 --- a/components/MyPages/Blocks/Stays/Previous/index.tsx +++ b/components/MyPages/Blocks/Stays/Previous/index.tsx @@ -33,7 +33,7 @@ export default function PreviousStays({ lang }: LangParams) { subtitle={_( "Revisit your stays and rekindle those our moments together, with ease." )} - > + /> {data?.pages.length ? ( - diff --git a/components/MyPages/Blocks/Stays/Upcoming/index.tsx b/components/MyPages/Blocks/Stays/Upcoming/index.tsx index ee06df0ae..441710fd3 100644 --- a/components/MyPages/Blocks/Stays/Upcoming/index.tsx +++ b/components/MyPages/Blocks/Stays/Upcoming/index.tsx @@ -33,7 +33,7 @@ export default function UpcomingStays({ lang }: LangParams) { subtitle={_( "Excited about your next trip? So are we. Below are your upcoming stays with us, complete with all the details you need to make each visit perfect. Can't wait to welcome you back, friend!" )} - > + /> {data?.pages.length ? ( { - const { perPage, page, cursor } = opts.input - let nextCursor: typeof cursor | undefined = undefined - const nrPages = Math.ceil(previousStays.length / perPage) + previous: protectedProcedure.input(staysInput).query(async (opts) => { + const { perPage, page, cursor } = opts.input + let nextCursor: typeof cursor | undefined = undefined + const nrPages = Math.ceil(previousStays.length / perPage) - let stays, nextPage - if (cursor) { - stays = previousStays.slice(cursor, perPage + cursor + 1) - nextPage = cursor / perPage + 1 - } else { - stays = previousStays.slice( - page * perPage, - page * perPage + perPage + 1 - ) + let stays, nextPage + if (cursor) { + stays = previousStays.slice(cursor, perPage + cursor + 1) + nextPage = cursor / perPage + 1 + } else { + stays = previousStays.slice( + page * perPage, + page * perPage + perPage + 1 + ) + } + + if ( + (nextPage && nextPage < nrPages && stays.length == perPage + 1) || + (!nextPage && nrPages > 1) + ) { + const nextItem = stays.pop() + if (nextItem) { + nextCursor = previousStays.indexOf(nextItem) } + } // TODO: Make request to get user data from Scandic API + return { data: stays, nextCursor } + }), - if ( - (nextPage && nextPage < nrPages && stays.length == perPage + 1) || - (!nextPage && nrPages > 1) - ) { - const nextItem = stays.pop() - if (nextItem) { - nextCursor = previousStays.indexOf(nextItem) - } - } // TODO: Make request to get user data from Scandic API - return { data: stays, nextCursor } - }), + upcoming: protectedProcedure.input(staysInput).query(async (opts) => { + const { perPage, page, cursor } = opts.input + let nextCursor: typeof cursor | undefined = undefined + const nrPages = Math.ceil(upcomingStays.length / perPage) - upcoming: protectedProcedure - .input( - z - .object({ - perPage: z.number().min(0).default(6), - page: z.number().min(0).default(0), - cursor: z.number().nullish(), - }) - .default({}) - ) - .query(async (opts) => { - const { perPage, page, cursor } = opts.input - let nextCursor: typeof cursor | undefined = undefined - const nrPages = Math.ceil(upcomingStays.length / perPage) + let stays, nextPage + if (cursor) { + stays = upcomingStays.slice(cursor, perPage + cursor + 1) + nextPage = cursor / perPage + 1 + } else { + stays = upcomingStays.slice( + page * perPage, + page * perPage + perPage + 1 + ) + } - let stays, nextPage - if (cursor) { - stays = upcomingStays.slice(cursor, perPage + cursor + 1) - nextPage = cursor / perPage + 1 - } else { - stays = upcomingStays.slice( - page * perPage, - page * perPage + perPage + 1 - ) + if ( + (nextPage && nextPage < nrPages && stays.length == perPage + 1) || + (!nextPage && nrPages > 1) + ) { + const nextItem = stays.pop() + if (nextItem) { + nextCursor = upcomingStays.indexOf(nextItem) } - - if ( - (nextPage && nextPage < nrPages && stays.length == perPage + 1) || - (!nextPage && nrPages > 1) - ) { - const nextItem = stays.pop() - if (nextItem) { - nextCursor = upcomingStays.indexOf(nextItem) - } - } // TODO: Make request to get user data from Scandic API - return { data: stays, nextCursor } - }), + } // TODO: Make request to get user data from Scandic API + return { data: stays, nextCursor } + }), }), }) diff --git a/server/routers/user/temp.ts b/server/routers/user/temp.ts index 110db45c5..1d10371fc 100644 --- a/server/routers/user/temp.ts +++ b/server/routers/user/temp.ts @@ -1,7 +1,5 @@ import { randomUUID } from "crypto" -import { dt } from "@/lib/dt" - export const benefits = [ { id: 1, @@ -290,7 +288,6 @@ export const upcomingStays = [ ] export const extendedUser = { - dob: dt("1977-07-05").format("YYYY-MM-DD"), journeys: challenges.journeys, nights: 14, shortcuts,