diff --git a/.gitignore b/.gitignore index 533cf75ab..1e2395721 100644 --- a/.gitignore +++ b/.gitignore @@ -38,3 +38,6 @@ next-env.d.ts certificates # Local Netlify folder .netlify + +#vscode +.vscode/ \ No newline at end of file diff --git a/app/[lang]/(live)/(protected)/my-pages/stays/page.module.css b/app/[lang]/(live)/(protected)/my-pages/stays/page.module.css index 0902c782c..85483cea5 100644 --- a/app/[lang]/(live)/(protected)/my-pages/stays/page.module.css +++ b/app/[lang]/(live)/(protected)/my-pages/stays/page.module.css @@ -9,7 +9,7 @@ @media screen and (min-width: 950px) { .container { - gap: 10rem; + gap: 6rem; padding-left: 0; padding-right: 0; margin: 0; 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/Overview/UpcomingStays/index.tsx b/components/MyPages/Blocks/Overview/UpcomingStays/index.tsx index 6a3bfff33..592276300 100644 --- a/components/MyPages/Blocks/Overview/UpcomingStays/index.tsx +++ b/components/MyPages/Blocks/Overview/UpcomingStays/index.tsx @@ -1,11 +1,11 @@ +import { _ } from "@/lib/translation" import { serverClient } from "@/lib/trpc/server" +import StayCard from "@/components/MyPages/Blocks/Stays/StayCard" +import EmptyUpcomingStaysBlock from "@/components/MyPages/Blocks/Stays/Upcoming/EmptyUpcomingStays" import Title from "@/components/MyPages/Title" import Link from "@/components/TempDesignSystem/Link" -import EmptyUpcomingStaysBlock from "../../Stays/EmptyUpcomingStays" -import StayCard from "../../Stays/StayCard" - import styles from "./upcoming.module.css" import type { LangParams } from "@/types/params" @@ -19,15 +19,15 @@ export default async function UpcomingStays({ lang }: LangParams) {
- Your upcoming stays + {_("Your upcoming stays")} - See all + {_("See all")}
- {stays.length ? ( + {stays.data.length ? (
- {stays.map((stay) => ( + {stays.data.map((stay) => ( ))}
diff --git a/components/MyPages/Blocks/Stays/Container/container.module.css b/components/MyPages/Blocks/Stays/Container/container.module.css new file mode 100644 index 000000000..00ad315a8 --- /dev/null +++ b/components/MyPages/Blocks/Stays/Container/container.module.css @@ -0,0 +1,9 @@ +.container { + display: grid; + gap: 2rem; +} +@media screen and (min-width: 950px) { + .container { + gap: 3.5rem; + } +} diff --git a/components/MyPages/Blocks/Stays/Container/index.tsx b/components/MyPages/Blocks/Stays/Container/index.tsx new file mode 100644 index 000000000..db08a3348 --- /dev/null +++ b/components/MyPages/Blocks/Stays/Container/index.tsx @@ -0,0 +1,5 @@ +import styles from "./container.module.css" + +export default function Container({ children }: React.PropsWithChildren) { + return
{children}
+} diff --git a/components/MyPages/Blocks/Stays/Header/header.module.css b/components/MyPages/Blocks/Stays/Header/header.module.css index f16c5f6d3..680a68d4a 100644 --- a/components/MyPages/Blocks/Stays/Header/header.module.css +++ b/components/MyPages/Blocks/Stays/Header/header.module.css @@ -1,13 +1,4 @@ -.subtitle { - padding-top: 0.5rem; - padding-bottom: 2.5rem; - margin: 0; -} - -@media screen and (min-width: 950px) { - .subtitle { - width: 60%; - padding-top: 2.5rem; - padding-bottom: 5rem; - } +.header { + display: grid; + gap: 0.5rem; } diff --git a/components/MyPages/Blocks/Stays/Header/index.tsx b/components/MyPages/Blocks/Stays/Header/index.tsx index 6d7ea5bca..d4fbeee68 100644 --- a/components/MyPages/Blocks/Stays/Header/index.tsx +++ b/components/MyPages/Blocks/Stays/Header/index.tsx @@ -2,15 +2,15 @@ import Title from "@/components/MyPages/Title" import styles from "./header.module.css" -import { HeaderProps } from "@/types/components/myPages/stays/title" +import type { HeaderProps } from "@/types/components/myPages/myStays/title" export default function Header({ title, subtitle }: HeaderProps) { return (
- + <Title as="h3" level="h2" weight="semiBold" uppercase> {title} - + <Title as="h5" level="h3" weight="regular"> {subtitle}
diff --git a/components/MyPages/Blocks/Stays/ListContainer/container.module.css b/components/MyPages/Blocks/Stays/ListContainer/container.module.css new file mode 100644 index 000000000..966cd1208 --- /dev/null +++ b/components/MyPages/Blocks/Stays/ListContainer/container.module.css @@ -0,0 +1,4 @@ +.container { + display: grid; + gap: 3rem; +} diff --git a/components/MyPages/Blocks/Stays/ListContainer/index.tsx b/components/MyPages/Blocks/Stays/ListContainer/index.tsx new file mode 100644 index 000000000..5908c0ff0 --- /dev/null +++ b/components/MyPages/Blocks/Stays/ListContainer/index.tsx @@ -0,0 +1,5 @@ +import styles from "./container.module.css" + +export default function ListContainer({ children }: React.PropsWithChildren) { + return
{children}
+} diff --git a/components/MyPages/Blocks/Stays/EmptyPreviousStays/emptyPreviousStays.module.css b/components/MyPages/Blocks/Stays/Previous/EmptyPreviousStays/emptyPreviousStays.module.css similarity index 85% rename from components/MyPages/Blocks/Stays/EmptyPreviousStays/emptyPreviousStays.module.css rename to components/MyPages/Blocks/Stays/Previous/EmptyPreviousStays/emptyPreviousStays.module.css index 44999673c..72e8229d0 100644 --- a/components/MyPages/Blocks/Stays/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/EmptyPreviousStays/index.tsx b/components/MyPages/Blocks/Stays/Previous/EmptyPreviousStays/index.tsx similarity index 77% rename from components/MyPages/Blocks/Stays/EmptyPreviousStays/index.tsx rename to components/MyPages/Blocks/Stays/Previous/EmptyPreviousStays/index.tsx index c773ced0d..1d7675412 100644 --- a/components/MyPages/Blocks/Stays/EmptyPreviousStays/index.tsx +++ b/components/MyPages/Blocks/Stays/Previous/EmptyPreviousStays/index.tsx @@ -1,3 +1,5 @@ +import { _ } from "@/lib/translation" + import Title from "@/components/MyPages/Title" import styles from "./emptyPreviousStays.module.css" @@ -6,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 d5e6ab44b..e6c03eb4c 100644 --- a/components/MyPages/Blocks/Stays/Previous/index.tsx +++ b/components/MyPages/Blocks/Stays/Previous/index.tsx @@ -1,28 +1,52 @@ -import { serverClient } from "@/lib/trpc/server" +"use client" -import EmptyPreviousStaysBlock from "../EmptyPreviousStays" +import { _ } from "@/lib/translation" +import { trpc } from "@/lib/trpc/client" + +import Container from "../Container" import Header from "../Header" +import ListContainer from "../ListContainer" +import ShowMoreButton from "../ShowMoreButton" import StayList from "../StayList" +import EmptyPreviousStaysBlock from "./EmptyPreviousStays" -import styles from "./previous.module.css" - +import type { Page } from "@/types/components/myPages/myStays/page" import type { LangParams } from "@/types/params" -export default async function PreviousStays({ lang }: LangParams) { - const stays = await serverClient().user.stays.previous() +export default function PreviousStays({ lang }: LangParams) { + const { data, isFetching, fetchNextPage, hasNextPage } = + trpc.user.stays.previous.useInfiniteQuery( + {}, + { + getNextPageParam: (lastPage: Page) => lastPage.nextCursor, + } + ) + + function loadMoreData() { + fetchNextPage() + } return ( -
+
- - {stays.length ? ( - + title={_("Previous stays")} + subtitle={_( + "Revisit your stays and rekindle those our moments together, with ease." + )} + /> + {data?.pages.length ? ( + + page.data) ?? []} + /> + {hasNextPage ? ( + + ) : null} + ) : ( )} -
+ ) } diff --git a/components/MyPages/Blocks/Stays/Previous/previous.module.css b/components/MyPages/Blocks/Stays/Previous/previous.module.css deleted file mode 100644 index 020f53751..000000000 --- a/components/MyPages/Blocks/Stays/Previous/previous.module.css +++ /dev/null @@ -1,3 +0,0 @@ -.container { - max-width: var(--max-width); -} diff --git a/components/MyPages/Blocks/Stays/ShowMoreButton/button.module.css b/components/MyPages/Blocks/Stays/ShowMoreButton/button.module.css new file mode 100644 index 000000000..f55557f33 --- /dev/null +++ b/components/MyPages/Blocks/Stays/ShowMoreButton/button.module.css @@ -0,0 +1,4 @@ +.container { + display: flex; + justify-content: center; +} diff --git a/components/MyPages/Blocks/Stays/ShowMoreButton/index.tsx b/components/MyPages/Blocks/Stays/ShowMoreButton/index.tsx new file mode 100644 index 000000000..cd9a3a8d9 --- /dev/null +++ b/components/MyPages/Blocks/Stays/ShowMoreButton/index.tsx @@ -0,0 +1,24 @@ +import Button from "@/components/TempDesignSystem/Button" + +import styles from "./button.module.css" + +import type { ShowMoreButtonParams } from "@/types/components/myPages/myStays/button" + +export default function ShowMoreButton({ + disabled, + loadMoreData, +}: ShowMoreButtonParams) { + return ( +
+ +
+ ) +} diff --git a/components/MyPages/Blocks/Stays/StayCard/index.tsx b/components/MyPages/Blocks/Stays/StayCard/index.tsx index a6c6ba44a..459f7fb6e 100644 --- a/components/MyPages/Blocks/Stays/StayCard/index.tsx +++ b/components/MyPages/Blocks/Stays/StayCard/index.tsx @@ -5,16 +5,11 @@ import Title from "@/components/MyPages/Title" import styles from "./stay.module.css" -import type { StayCardProps } from "@/types/components/myPages/stays/stayCard" +import type { StayCardProps } from "@/types/components/myPages/myStays/stayCard" -export default function StayCard({ - stay, - lang, - showDayCount = false, -}: StayCardProps) { +export default function StayCard({ stay, lang }: StayCardProps) { const { dateArrive, dateDepart, guests, hotel } = stay - const daysUntilArrival = dt(dateArrive).diff(dt(), "days") const arrival = dt(dateArrive).locale(lang) const arrivalDate = arrival.format("DD MMM") const arrivalDateTime = arrival.format("YYYY-MM-DD") @@ -24,21 +19,14 @@ export default function StayCard({ return (
-
- {showDayCount ? ( -
- -
- ) : null} - Placeholder image flower -