fix: handle empty stays in query
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
import { z } from "zod"
|
||||
|
||||
import * as api from "@/lib/api"
|
||||
import {
|
||||
badRequestError,
|
||||
@@ -43,6 +41,7 @@ export const userQueryRouter = router({
|
||||
}
|
||||
|
||||
const apiJson = await apiResponse.json()
|
||||
|
||||
if (!apiJson.data?.length) {
|
||||
throw internalServerError()
|
||||
}
|
||||
@@ -113,7 +112,7 @@ export const userQueryRouter = router({
|
||||
}
|
||||
|
||||
const apiJson = await apiResponse.json()
|
||||
if (!apiJson.data?.length) {
|
||||
if (!apiJson.data) {
|
||||
console.error(`Get Previous Stays - No data found from api call`)
|
||||
throw internalServerError()
|
||||
}
|
||||
@@ -127,6 +126,7 @@ export const userQueryRouter = router({
|
||||
}
|
||||
|
||||
const nextCursor =
|
||||
verifiedData.data.links &&
|
||||
verifiedData.data.links.offset < verifiedData.data.links.totalCount
|
||||
? verifiedData.data.links.offset
|
||||
: undefined
|
||||
@@ -177,7 +177,7 @@ export const userQueryRouter = router({
|
||||
}
|
||||
|
||||
const apiJson = await apiResponse.json()
|
||||
if (!apiJson.data?.length) {
|
||||
if (!apiJson.data) {
|
||||
console.error(`Get Upcoming Stays - No data found from api call`)
|
||||
throw internalServerError()
|
||||
}
|
||||
@@ -191,6 +191,7 @@ export const userQueryRouter = router({
|
||||
}
|
||||
|
||||
const nextCursor =
|
||||
verifiedData.data.links &&
|
||||
verifiedData.data.links.offset < verifiedData.data.links.totalCount
|
||||
? verifiedData.data.links.offset
|
||||
: undefined
|
||||
|
||||
Reference in New Issue
Block a user