Merged in hotfix/mystays-show-more (pull request #1698)
hotfix: my stays - pass language to trpc * hotfix: my stays - pass language to trpc Approved-by: Joakim Jäderberg
This commit is contained in:
@@ -4,6 +4,7 @@ import { trpc } from "@/lib/trpc/client"
|
|||||||
|
|
||||||
import LoadingSpinner from "@/components/LoadingSpinner"
|
import LoadingSpinner from "@/components/LoadingSpinner"
|
||||||
import Grids from "@/components/TempDesignSystem/Grids"
|
import Grids from "@/components/TempDesignSystem/Grids"
|
||||||
|
import useLang from "@/hooks/useLang"
|
||||||
|
|
||||||
import ListContainer from "../ListContainer"
|
import ListContainer from "../ListContainer"
|
||||||
import ShowMoreButton from "../ShowMoreButton"
|
import ShowMoreButton from "../ShowMoreButton"
|
||||||
@@ -17,10 +18,12 @@ import type {
|
|||||||
export default function ClientPreviousStays({
|
export default function ClientPreviousStays({
|
||||||
initialPreviousStays,
|
initialPreviousStays,
|
||||||
}: PreviousStaysClientProps) {
|
}: PreviousStaysClientProps) {
|
||||||
|
const lang = useLang()
|
||||||
const { data, isFetching, fetchNextPage, hasNextPage, isLoading } =
|
const { data, isFetching, fetchNextPage, hasNextPage, isLoading } =
|
||||||
trpc.user.stays.previous.useInfiniteQuery(
|
trpc.user.stays.previous.useInfiniteQuery(
|
||||||
{
|
{
|
||||||
limit: 6,
|
limit: 6,
|
||||||
|
lang,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
getNextPageParam: (lastPage) => {
|
getNextPageParam: (lastPage) => {
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { trpc } from "@/lib/trpc/client"
|
|||||||
|
|
||||||
import LoadingSpinner from "@/components/LoadingSpinner"
|
import LoadingSpinner from "@/components/LoadingSpinner"
|
||||||
import Grids from "@/components/TempDesignSystem/Grids"
|
import Grids from "@/components/TempDesignSystem/Grids"
|
||||||
|
import useLang from "@/hooks/useLang"
|
||||||
|
|
||||||
import ListContainer from "../ListContainer"
|
import ListContainer from "../ListContainer"
|
||||||
import ShowMoreButton from "../ShowMoreButton"
|
import ShowMoreButton from "../ShowMoreButton"
|
||||||
@@ -17,10 +18,12 @@ import type {
|
|||||||
export default function ClientUpcomingStays({
|
export default function ClientUpcomingStays({
|
||||||
initialUpcomingStays,
|
initialUpcomingStays,
|
||||||
}: UpcomingStaysClientProps) {
|
}: UpcomingStaysClientProps) {
|
||||||
|
const lang = useLang()
|
||||||
const { data, isFetching, fetchNextPage, hasNextPage, isLoading } =
|
const { data, isFetching, fetchNextPage, hasNextPage, isLoading } =
|
||||||
trpc.user.stays.upcoming.useInfiniteQuery(
|
trpc.user.stays.upcoming.useInfiniteQuery(
|
||||||
{
|
{
|
||||||
limit: 6,
|
limit: 6,
|
||||||
|
lang,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
getNextPageParam: (lastPage) => {
|
getNextPageParam: (lastPage) => {
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ export const staysInput = z
|
|||||||
.min(0)
|
.min(0)
|
||||||
.default(6)
|
.default(6)
|
||||||
.transform((num) => String(num)),
|
.transform((num) => String(num)),
|
||||||
|
lang: z.nativeEnum(Lang).optional(),
|
||||||
})
|
})
|
||||||
.default({})
|
.default({})
|
||||||
|
|
||||||
|
|||||||
@@ -452,7 +452,8 @@ export const userQueryRouter = router({
|
|||||||
previous: protectedProcedure
|
previous: protectedProcedure
|
||||||
.input(staysInput)
|
.input(staysInput)
|
||||||
.query(async ({ ctx, input }) => {
|
.query(async ({ ctx, input }) => {
|
||||||
const { limit, cursor } = input
|
const { limit, cursor, lang } = input
|
||||||
|
const language = lang || ctx.lang
|
||||||
const params: Record<string, string> = { limit }
|
const params: Record<string, string> = { limit }
|
||||||
if (cursor) {
|
if (cursor) {
|
||||||
params.offset = cursor
|
params.offset = cursor
|
||||||
@@ -533,7 +534,7 @@ export const userQueryRouter = router({
|
|||||||
const updatedData = await updateStaysBookingUrl(
|
const updatedData = await updateStaysBookingUrl(
|
||||||
verifiedData.data.data,
|
verifiedData.data.data,
|
||||||
ctx.session.token.access_token,
|
ctx.session.token.access_token,
|
||||||
ctx.lang
|
language
|
||||||
)
|
)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -545,8 +546,8 @@ export const userQueryRouter = router({
|
|||||||
upcoming: protectedProcedure
|
upcoming: protectedProcedure
|
||||||
.input(staysInput)
|
.input(staysInput)
|
||||||
.query(async ({ ctx, input }) => {
|
.query(async ({ ctx, input }) => {
|
||||||
const { limit, cursor } = input
|
const { limit, cursor, lang } = input
|
||||||
|
const language = lang || ctx.lang
|
||||||
const params: Record<string, string> = { limit }
|
const params: Record<string, string> = { limit }
|
||||||
if (cursor) {
|
if (cursor) {
|
||||||
params.offset = cursor
|
params.offset = cursor
|
||||||
@@ -626,7 +627,7 @@ export const userQueryRouter = router({
|
|||||||
const updatedData = await updateStaysBookingUrl(
|
const updatedData = await updateStaysBookingUrl(
|
||||||
verifiedData.data.data,
|
verifiedData.data.data,
|
||||||
ctx.session.token.access_token,
|
ctx.session.token.access_token,
|
||||||
ctx.lang
|
language
|
||||||
)
|
)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
Reference in New Issue
Block a user