refactor: refactor according to PR comments
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
import MaxWidth from "@/components/MaxWidth"
|
||||||
import PreviousStays from "@/components/MyPages/Blocks/Stays/Previous"
|
import PreviousStays from "@/components/MyPages/Blocks/Stays/Previous"
|
||||||
import UpcomingStays from "@/components/MyPages/Blocks/Stays/Upcoming"
|
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<LangParams>) {
|
export default async function MyStays({ params }: PageArgs<LangParams>) {
|
||||||
return (
|
return (
|
||||||
<main className={styles.container}>
|
<MaxWidth className={styles.container} tag="main">
|
||||||
<UpcomingStays lang={params.lang} />
|
<UpcomingStays lang={params.lang} />
|
||||||
<PreviousStays lang={params.lang} />
|
<PreviousStays lang={params.lang} />
|
||||||
</main>
|
</MaxWidth>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
.container {
|
.container {
|
||||||
max-width: var(--max-width);
|
|
||||||
display: grid;
|
display: grid;
|
||||||
gap: 2rem;
|
gap: 2rem;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,5 +5,4 @@
|
|||||||
min-height: 25rem;
|
min-height: 25rem;
|
||||||
background-color: var(--some-grey-color, #f2f2f2);
|
background-color: var(--some-grey-color, #f2f2f2);
|
||||||
border-radius: 0.8rem;
|
border-radius: 0.8rem;
|
||||||
max-width: var(--max-width);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ export default function EmptyPreviousStaysBlock() {
|
|||||||
return (
|
return (
|
||||||
<section className={styles.container}>
|
<section className={styles.container}>
|
||||||
<Title level="h3" as="h5" uppercase>
|
<Title level="h3" as="h5" uppercase>
|
||||||
{_("You have no previous stays.")}{" "}
|
{_("You have no previous stays.")}
|
||||||
</Title>
|
</Title>
|
||||||
</section>
|
</section>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ export default function PreviousStays({ lang }: LangParams) {
|
|||||||
subtitle={_(
|
subtitle={_(
|
||||||
"Revisit your stays and rekindle those our moments together, with ease."
|
"Revisit your stays and rekindle those our moments together, with ease."
|
||||||
)}
|
)}
|
||||||
></Header>
|
/>
|
||||||
{data?.pages.length ? (
|
{data?.pages.length ? (
|
||||||
<ListContainer>
|
<ListContainer>
|
||||||
<StayList
|
<StayList
|
||||||
|
|||||||
@@ -20,7 +20,6 @@
|
|||||||
gap: 2.5rem;
|
gap: 2.5rem;
|
||||||
background-color: var(--some-grey-color, #f2f2f2);
|
background-color: var(--some-grey-color, #f2f2f2);
|
||||||
border-radius: 0.8rem;
|
border-radius: 0.8rem;
|
||||||
max-width: var(--max-width);
|
|
||||||
margin-bottom: 0.5rem;
|
margin-bottom: 0.5rem;
|
||||||
padding: 0 2rem;
|
padding: 0 2rem;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,8 +17,8 @@ export default function EmptyUpcomingStaysBlock() {
|
|||||||
{_("Where should you go next?")}
|
{_("Where should you go next?")}
|
||||||
</span>
|
</span>
|
||||||
</Title>
|
</Title>
|
||||||
<Button intent={"primary"} bgcolor={"quarternary"} asChild type="button">
|
<Button intent="primary" bgcolor="quarternary" asChild type="button">
|
||||||
<Link className={styles.link} href={"#"} key={"getInspired"}>
|
<Link className={styles.link} href={"#"} key="getInspired">
|
||||||
{_("Get inspired")}
|
{_("Get inspired")}
|
||||||
</Link>
|
</Link>
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ export default function UpcomingStays({ lang }: LangParams) {
|
|||||||
subtitle={_(
|
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!"
|
"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!"
|
||||||
)}
|
)}
|
||||||
></Header>
|
/>
|
||||||
{data?.pages.length ? (
|
{data?.pages.length ? (
|
||||||
<ListContainer>
|
<ListContainer>
|
||||||
<StayList
|
<StayList
|
||||||
|
|||||||
@@ -1,3 +1,9 @@
|
|||||||
/**
|
import { z } from "zod"
|
||||||
* Add route inputs (both query & mutation)
|
|
||||||
*/
|
export const staysInput = z
|
||||||
|
.object({
|
||||||
|
perPage: z.number().min(0).default(6),
|
||||||
|
page: z.number().min(0).default(0),
|
||||||
|
cursor: z.number().nullish(),
|
||||||
|
})
|
||||||
|
.default({})
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import {
|
|||||||
} from "@/server/errors/trpc"
|
} from "@/server/errors/trpc"
|
||||||
import { protectedProcedure, router } from "@/server/trpc"
|
import { protectedProcedure, router } from "@/server/trpc"
|
||||||
|
|
||||||
|
import { staysInput } from "./input"
|
||||||
import { getUserSchema } from "./output"
|
import { getUserSchema } from "./output"
|
||||||
import {
|
import {
|
||||||
benefits,
|
benefits,
|
||||||
@@ -84,17 +85,7 @@ export const userQueryRouter = router({
|
|||||||
}),
|
}),
|
||||||
|
|
||||||
stays: router({
|
stays: router({
|
||||||
previous: protectedProcedure
|
previous: protectedProcedure.input(staysInput).query(async (opts) => {
|
||||||
.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
|
const { perPage, page, cursor } = opts.input
|
||||||
let nextCursor: typeof cursor | undefined = undefined
|
let nextCursor: typeof cursor | undefined = undefined
|
||||||
const nrPages = Math.ceil(previousStays.length / perPage)
|
const nrPages = Math.ceil(previousStays.length / perPage)
|
||||||
@@ -122,17 +113,7 @@ export const userQueryRouter = router({
|
|||||||
return { data: stays, nextCursor }
|
return { data: stays, nextCursor }
|
||||||
}),
|
}),
|
||||||
|
|
||||||
upcoming: protectedProcedure
|
upcoming: protectedProcedure.input(staysInput).query(async (opts) => {
|
||||||
.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
|
const { perPage, page, cursor } = opts.input
|
||||||
let nextCursor: typeof cursor | undefined = undefined
|
let nextCursor: typeof cursor | undefined = undefined
|
||||||
const nrPages = Math.ceil(upcomingStays.length / perPage)
|
const nrPages = Math.ceil(upcomingStays.length / perPage)
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
import { randomUUID } from "crypto"
|
import { randomUUID } from "crypto"
|
||||||
|
|
||||||
import { dt } from "@/lib/dt"
|
|
||||||
|
|
||||||
export const benefits = [
|
export const benefits = [
|
||||||
{
|
{
|
||||||
id: 1,
|
id: 1,
|
||||||
@@ -290,7 +288,6 @@ export const upcomingStays = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
export const extendedUser = {
|
export const extendedUser = {
|
||||||
dob: dt("1977-07-05").format("YYYY-MM-DD"),
|
|
||||||
journeys: challenges.journeys,
|
journeys: challenges.journeys,
|
||||||
nights: 14,
|
nights: 14,
|
||||||
shortcuts,
|
shortcuts,
|
||||||
|
|||||||
Reference in New Issue
Block a user