fix: structure logged data
This commit is contained in:
@@ -35,7 +35,10 @@ import { RTEDocument } from "@/types/rte/node"
|
|||||||
export const accountPageQueryRouter = router({
|
export const accountPageQueryRouter = router({
|
||||||
get: contentstackExtendedProcedureUID.query(async ({ ctx }) => {
|
get: contentstackExtendedProcedureUID.query(async ({ ctx }) => {
|
||||||
const { lang, uid } = ctx
|
const { lang, uid } = ctx
|
||||||
|
console.info(
|
||||||
|
"contentstack.accountPage.refs start",
|
||||||
|
JSON.stringify({ query: { lang, uid } })
|
||||||
|
)
|
||||||
const refsResponse = await request<AccountPageRefsDataRaw>(
|
const refsResponse = await request<AccountPageRefsDataRaw>(
|
||||||
GetAccountPageRefs,
|
GetAccountPageRefs,
|
||||||
{
|
{
|
||||||
@@ -48,6 +51,10 @@ export const accountPageQueryRouter = router({
|
|||||||
)
|
)
|
||||||
|
|
||||||
if (!refsResponse.data) {
|
if (!refsResponse.data) {
|
||||||
|
console.error(
|
||||||
|
"contentstack.accountPage.refs not found error",
|
||||||
|
JSON.stringify({ query: { lang, uid }, error: refsResponse })
|
||||||
|
)
|
||||||
throw notFound(refsResponse)
|
throw notFound(refsResponse)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,8 +63,13 @@ export const accountPageQueryRouter = router({
|
|||||||
const validatedAccountPageRefs =
|
const validatedAccountPageRefs =
|
||||||
validateAccountPageRefsSchema.safeParse(cleanedData)
|
validateAccountPageRefsSchema.safeParse(cleanedData)
|
||||||
if (!validatedAccountPageRefs.success) {
|
if (!validatedAccountPageRefs.success) {
|
||||||
console.error(`Failed to validate My Page Refs - (uid: ${uid})`)
|
console.error(
|
||||||
console.error(validatedAccountPageRefs.error)
|
"contentstack.accountPage.refs validation error",
|
||||||
|
JSON.stringify({
|
||||||
|
query: { lang, uid },
|
||||||
|
error: validatedAccountPageRefs.error,
|
||||||
|
})
|
||||||
|
)
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,7 +79,10 @@ export const accountPageQueryRouter = router({
|
|||||||
generateTags(lang, connections),
|
generateTags(lang, connections),
|
||||||
generateTag(lang, validatedAccountPageRefs.data.account_page.system.uid),
|
generateTag(lang, validatedAccountPageRefs.data.account_page.system.uid),
|
||||||
].flat()
|
].flat()
|
||||||
console.info("contentstack.accountPage start ", { lang, uid })
|
console.info(
|
||||||
|
"contentstack.accountPage start",
|
||||||
|
JSON.stringify({ query: { lang, uid } })
|
||||||
|
)
|
||||||
const response = await request<AccountPageDataRaw>(
|
const response = await request<AccountPageDataRaw>(
|
||||||
GetAccountPage,
|
GetAccountPage,
|
||||||
{
|
{
|
||||||
@@ -78,7 +93,13 @@ export const accountPageQueryRouter = router({
|
|||||||
)
|
)
|
||||||
|
|
||||||
if (!response.data) {
|
if (!response.data) {
|
||||||
console.error("contentstack.accountPage not found error", { lang, uid })
|
console.error(
|
||||||
|
"contentstack.accountPage not found error",
|
||||||
|
JSON.stringify({
|
||||||
|
query: { lang, uid },
|
||||||
|
error: response,
|
||||||
|
})
|
||||||
|
)
|
||||||
throw notFound(response)
|
throw notFound(response)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,11 +110,17 @@ export const accountPageQueryRouter = router({
|
|||||||
if (!validatedAccountPage.success) {
|
if (!validatedAccountPage.success) {
|
||||||
console.error(
|
console.error(
|
||||||
"contentstack.accountPage validation error",
|
"contentstack.accountPage validation error",
|
||||||
JSON.stringify(validatedAccountPage.error)
|
JSON.stringify({
|
||||||
|
query: { lang, uid },
|
||||||
|
error: validatedAccountPage.error,
|
||||||
|
})
|
||||||
)
|
)
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
console.info("contentstack.accountPage success ", { lang, uid })
|
console.info(
|
||||||
|
"contentstack.accountPage success",
|
||||||
|
JSON.stringify({ query: { lang, uid } })
|
||||||
|
)
|
||||||
// TODO: Make returned data nicer
|
// TODO: Make returned data nicer
|
||||||
const content = validatedAccountPage.data.account_page.content.map(
|
const content = validatedAccountPage.data.account_page.content.map(
|
||||||
(block) => {
|
(block) => {
|
||||||
|
|||||||
@@ -33,16 +33,18 @@ import {
|
|||||||
export const baseQueryRouter = router({
|
export const baseQueryRouter = router({
|
||||||
contact: contentstackBaseProcedure.query(async ({ ctx }) => {
|
contact: contentstackBaseProcedure.query(async ({ ctx }) => {
|
||||||
const { lang } = ctx
|
const { lang } = ctx
|
||||||
console.info("contentstack.config start ", JSON.stringify({ lang }))
|
console.info(
|
||||||
|
"contentstack.config start",
|
||||||
|
JSON.stringify({ query: { lang } })
|
||||||
|
)
|
||||||
const response = await request<ContactConfigData>(GetContactConfig, {
|
const response = await request<ContactConfigData>(GetContactConfig, {
|
||||||
locale: lang,
|
locale: lang,
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!response.data) {
|
if (!response.data) {
|
||||||
console.error(
|
console.error(
|
||||||
"contentstack.config not found error ",
|
"contentstack.config not found error",
|
||||||
JSON.stringify({ lang }),
|
JSON.stringify({ query: { lang }, error: response })
|
||||||
JSON.stringify(response)
|
|
||||||
)
|
)
|
||||||
throw notFound(response)
|
throw notFound(response)
|
||||||
}
|
}
|
||||||
@@ -53,29 +55,34 @@ export const baseQueryRouter = router({
|
|||||||
|
|
||||||
if (!validatedContactConfigConfig.success) {
|
if (!validatedContactConfigConfig.success) {
|
||||||
console.error(
|
console.error(
|
||||||
"contentstack.config validation error ",
|
"contentstack.config validation error",
|
||||||
JSON.stringify({ lang }),
|
JSON.stringify({
|
||||||
JSON.stringify(validatedContactConfigConfig.error)
|
query: { lang },
|
||||||
|
error: validatedContactConfigConfig.error,
|
||||||
|
})
|
||||||
)
|
)
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
console.info("contentstack.config success ", JSON.stringify({ lang }))
|
console.info(
|
||||||
|
"contentstack.config success",
|
||||||
|
JSON.stringify({ query: { lang } })
|
||||||
|
)
|
||||||
return validatedContactConfigConfig.data.all_contact_config.items[0]
|
return validatedContactConfigConfig.data.all_contact_config.items[0]
|
||||||
}),
|
}),
|
||||||
header: contentstackBaseProcedure
|
header: contentstackBaseProcedure
|
||||||
.input(langInput)
|
.input(langInput)
|
||||||
.query(async ({ input }) => {
|
.query(async ({ input }) => {
|
||||||
console.info(
|
console.info(
|
||||||
"contentstack.header.ref start ",
|
"contentstack.header.ref start",
|
||||||
JSON.stringify({ lang: input.lang })
|
JSON.stringify({ query: { lang: input.lang } })
|
||||||
)
|
)
|
||||||
const responseRef = await request<HeaderRefDataRaw>(GetCurrentHeaderRef, {
|
const responseRef = await request<HeaderRefDataRaw>(GetCurrentHeaderRef, {
|
||||||
locale: input.lang,
|
locale: input.lang,
|
||||||
})
|
})
|
||||||
console.info(
|
console.info(
|
||||||
"contentstack.header. start ",
|
"contentstack.header start",
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
lang: input.lang,
|
query: { lang: input.lang },
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -95,11 +102,13 @@ export const baseQueryRouter = router({
|
|||||||
|
|
||||||
if (!response.data) {
|
if (!response.data) {
|
||||||
console.error(
|
console.error(
|
||||||
"contentstack.header not found error ",
|
"contentstack.header not found error",
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
lang: input.lang,
|
query: {
|
||||||
}),
|
lang: input.lang,
|
||||||
JSON.stringify(response)
|
},
|
||||||
|
error: response,
|
||||||
|
})
|
||||||
)
|
)
|
||||||
throw notFound(response)
|
throw notFound(response)
|
||||||
}
|
}
|
||||||
@@ -112,16 +121,18 @@ export const baseQueryRouter = router({
|
|||||||
console.error(
|
console.error(
|
||||||
"contentstack.header validation error",
|
"contentstack.header validation error",
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
lang: input.lang,
|
query: {
|
||||||
}),
|
lang: input.lang,
|
||||||
JSON.stringify(validatedHeaderConfig.error)
|
},
|
||||||
|
error: validatedHeaderConfig.error,
|
||||||
|
})
|
||||||
)
|
)
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
console.info(
|
console.info(
|
||||||
"contentstack.header success ",
|
"contentstack.header success",
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
lang: input.lang,
|
query: { lang: input.lang },
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
const logo =
|
const logo =
|
||||||
@@ -136,15 +147,20 @@ export const baseQueryRouter = router({
|
|||||||
footer: contentstackBaseProcedure
|
footer: contentstackBaseProcedure
|
||||||
.input(langInput)
|
.input(langInput)
|
||||||
.query(async ({ input }) => {
|
.query(async ({ input }) => {
|
||||||
console.info("contentstack.footer.ref start ", { lang: input.lang })
|
console.info(
|
||||||
|
"contentstack.footer.ref start",
|
||||||
|
JSON.stringify({ query: { lang: input.lang } })
|
||||||
|
)
|
||||||
const responseRef = await request<FooterRefDataRaw>(GetCurrentFooterRef, {
|
const responseRef = await request<FooterRefDataRaw>(GetCurrentFooterRef, {
|
||||||
locale: input.lang,
|
locale: input.lang,
|
||||||
})
|
})
|
||||||
// There's currently no error handling/validation for the responseRef, should it be added?
|
// There's currently no error handling/validation for the responseRef, should it be added?
|
||||||
console.info(
|
console.info(
|
||||||
"contentstack.footer start ",
|
"contentstack.footer start",
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
lang: input.lang,
|
query: {
|
||||||
|
lang: input.lang,
|
||||||
|
},
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
const response = await request<FooterDataRaw>(
|
const response = await request<FooterDataRaw>(
|
||||||
@@ -164,11 +180,13 @@ export const baseQueryRouter = router({
|
|||||||
|
|
||||||
if (!response.data) {
|
if (!response.data) {
|
||||||
console.error(
|
console.error(
|
||||||
"contentstack.footer not found error ",
|
"contentstack.footer not found error",
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
lang: input.lang,
|
query: {
|
||||||
}),
|
lang: input.lang,
|
||||||
JSON.stringify(response)
|
},
|
||||||
|
error: response,
|
||||||
|
})
|
||||||
)
|
)
|
||||||
throw notFound(response)
|
throw notFound(response)
|
||||||
}
|
}
|
||||||
@@ -180,12 +198,17 @@ export const baseQueryRouter = router({
|
|||||||
if (!validatedFooterConfig.success) {
|
if (!validatedFooterConfig.success) {
|
||||||
console.error(
|
console.error(
|
||||||
"contentstack.footer validation error",
|
"contentstack.footer validation error",
|
||||||
JSON.stringify({ lang: input.lang }),
|
JSON.stringify({
|
||||||
JSON.stringify(validatedFooterConfig.error)
|
query: { lang: input.lang },
|
||||||
|
error: validatedFooterConfig.error,
|
||||||
|
})
|
||||||
)
|
)
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
console.info("contentstack.footer success ", { lang: input.lang })
|
console.info(
|
||||||
|
"contentstack.footer success",
|
||||||
|
JSON.stringify({ query: { lang: input.lang } })
|
||||||
|
)
|
||||||
return validatedFooterConfig.data.all_current_footer.items[0]
|
return validatedFooterConfig.data.all_current_footer.items[0]
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -8,7 +8,12 @@ import { HotelPage, HotelPageDataRaw, validateHotelPageSchema } from "./output"
|
|||||||
export const hotelPageQueryRouter = router({
|
export const hotelPageQueryRouter = router({
|
||||||
get: contentstackBaseProcedure.query(async ({ ctx }) => {
|
get: contentstackBaseProcedure.query(async ({ ctx }) => {
|
||||||
const { lang, uid } = ctx
|
const { lang, uid } = ctx
|
||||||
console.info("contentstack.hotelPage start ", JSON.stringify({ lang, uid }))
|
console.info(
|
||||||
|
"contentstack.hotelPage start",
|
||||||
|
JSON.stringify({
|
||||||
|
query: { lang, uid },
|
||||||
|
})
|
||||||
|
)
|
||||||
const response = await request<HotelPageDataRaw>(GetHotelPage, {
|
const response = await request<HotelPageDataRaw>(GetHotelPage, {
|
||||||
locale: lang,
|
locale: lang,
|
||||||
uid,
|
uid,
|
||||||
@@ -16,7 +21,10 @@ export const hotelPageQueryRouter = router({
|
|||||||
if (!response.data) {
|
if (!response.data) {
|
||||||
console.error(
|
console.error(
|
||||||
"contentstack.hotelPage not found error",
|
"contentstack.hotelPage not found error",
|
||||||
JSON.stringify({ lang, uid })
|
JSON.stringify({
|
||||||
|
query: { lang, uid },
|
||||||
|
error: response,
|
||||||
|
})
|
||||||
)
|
)
|
||||||
throw notFound(response)
|
throw notFound(response)
|
||||||
}
|
}
|
||||||
@@ -26,8 +34,10 @@ export const hotelPageQueryRouter = router({
|
|||||||
if (!validatedHotelPage.success) {
|
if (!validatedHotelPage.success) {
|
||||||
console.error(
|
console.error(
|
||||||
"contentstack.hotelPage validation error",
|
"contentstack.hotelPage validation error",
|
||||||
JSON.stringify({ lang, uid }),
|
JSON.stringify({
|
||||||
JSON.stringify(validatedHotelPage.error)
|
query: { lang, uid },
|
||||||
|
error: validatedHotelPage.error,
|
||||||
|
})
|
||||||
)
|
)
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
@@ -35,7 +45,12 @@ export const hotelPageQueryRouter = router({
|
|||||||
const hotelPage = {
|
const hotelPage = {
|
||||||
...validatedHotelPage.data.hotel_page,
|
...validatedHotelPage.data.hotel_page,
|
||||||
} as HotelPage
|
} as HotelPage
|
||||||
|
console.info(
|
||||||
|
"contentstack.hotelPage success",
|
||||||
|
JSON.stringify({
|
||||||
|
query: { lang, uid },
|
||||||
|
})
|
||||||
|
)
|
||||||
return hotelPage
|
return hotelPage
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -132,11 +132,13 @@ export const languageSwitcherQueryRouter = router({
|
|||||||
return { lang: ctx.lang, urls: baseUrls }
|
return { lang: ctx.lang, urls: baseUrls }
|
||||||
}
|
}
|
||||||
console.info(
|
console.info(
|
||||||
"contentstack.languageSwitcher start ",
|
"contentstack.languageSwitcher start",
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
uid: ctx.uid,
|
query: {
|
||||||
lang: ctx.lang,
|
uid: ctx.uid,
|
||||||
contentType: ctx.contentType,
|
lang: ctx.lang,
|
||||||
|
contentType: ctx.contentType,
|
||||||
|
},
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
const res = await getLanguageSwitcher({
|
const res = await getLanguageSwitcher({
|
||||||
@@ -164,11 +166,27 @@ export const languageSwitcherQueryRouter = router({
|
|||||||
if (!validatedLanguageSwitcherData.success) {
|
if (!validatedLanguageSwitcherData.success) {
|
||||||
console.error(
|
console.error(
|
||||||
"contentstack.languageSwitcher validation error",
|
"contentstack.languageSwitcher validation error",
|
||||||
JSON.stringify(validatedLanguageSwitcherData.error)
|
JSON.stringify({
|
||||||
|
query: {
|
||||||
|
uid: ctx.uid,
|
||||||
|
lang: ctx.lang,
|
||||||
|
contentType: ctx.contentType,
|
||||||
|
},
|
||||||
|
error: validatedLanguageSwitcherData.error,
|
||||||
|
})
|
||||||
)
|
)
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
console.info("contentstack.languageSwitcher success")
|
console.info(
|
||||||
|
"contentstack.languageSwitcher success",
|
||||||
|
JSON.stringify({
|
||||||
|
query: {
|
||||||
|
uid: ctx.uid,
|
||||||
|
lang: ctx.lang,
|
||||||
|
contentType: ctx.contentType,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
)
|
||||||
return {
|
return {
|
||||||
lang: ctx.lang,
|
lang: ctx.lang,
|
||||||
urls,
|
urls,
|
||||||
|
|||||||
@@ -37,7 +37,12 @@ import {
|
|||||||
export const loyaltyPageQueryRouter = router({
|
export const loyaltyPageQueryRouter = router({
|
||||||
get: contentstackExtendedProcedureUID.query(async ({ ctx }) => {
|
get: contentstackExtendedProcedureUID.query(async ({ ctx }) => {
|
||||||
const { lang, uid } = ctx
|
const { lang, uid } = ctx
|
||||||
console.info("contentstack.loyaltyPage.refs start ", { lang, uid })
|
console.info(
|
||||||
|
"contentstack.loyaltyPage.refs start",
|
||||||
|
JSON.stringify({
|
||||||
|
query: { lang, uid },
|
||||||
|
})
|
||||||
|
)
|
||||||
const refsResponse = await request<LoyaltyPageRefsDataRaw>(
|
const refsResponse = await request<LoyaltyPageRefsDataRaw>(
|
||||||
GetLoyaltyPageRefs,
|
GetLoyaltyPageRefs,
|
||||||
{
|
{
|
||||||
@@ -50,10 +55,16 @@ export const loyaltyPageQueryRouter = router({
|
|||||||
)
|
)
|
||||||
|
|
||||||
if (!refsResponse.data) {
|
if (!refsResponse.data) {
|
||||||
console.error("contentstack.loyaltyPage.refs not found error", {
|
console.error(
|
||||||
lang,
|
"contentstack.loyaltyPage.refs not found error",
|
||||||
uid,
|
JSON.stringify({
|
||||||
})
|
query: {
|
||||||
|
lang,
|
||||||
|
uid,
|
||||||
|
},
|
||||||
|
error: JSON.stringify(refsResponse),
|
||||||
|
})
|
||||||
|
)
|
||||||
throw notFound(refsResponse)
|
throw notFound(refsResponse)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,19 +75,31 @@ export const loyaltyPageQueryRouter = router({
|
|||||||
if (!validatedLoyaltyPageRefs.success) {
|
if (!validatedLoyaltyPageRefs.success) {
|
||||||
console.error(
|
console.error(
|
||||||
"contentstack.loyaltyPage.refs validation error",
|
"contentstack.loyaltyPage.refs validation error",
|
||||||
{ lang, uid },
|
JSON.stringify({
|
||||||
JSON.stringify(validatedLoyaltyPageRefs.error)
|
query: { lang, uid },
|
||||||
|
error: validatedLoyaltyPageRefs.error,
|
||||||
|
})
|
||||||
)
|
)
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
console.info("contentstack.loyaltyPage.refs success ", { lang, uid })
|
console.info(
|
||||||
|
"contentstack.loyaltyPage.refs success",
|
||||||
|
JSON.stringify({
|
||||||
|
query: { lang, uid },
|
||||||
|
})
|
||||||
|
)
|
||||||
const connections = getConnections(validatedLoyaltyPageRefs.data)
|
const connections = getConnections(validatedLoyaltyPageRefs.data)
|
||||||
|
|
||||||
const tags = [
|
const tags = [
|
||||||
generateTags(lang, connections),
|
generateTags(lang, connections),
|
||||||
generateTag(lang, validatedLoyaltyPageRefs.data.loyalty_page.system.uid),
|
generateTag(lang, validatedLoyaltyPageRefs.data.loyalty_page.system.uid),
|
||||||
].flat()
|
].flat()
|
||||||
console.info("contentstack.loyaltyPage start ", { lang, uid })
|
console.info(
|
||||||
|
"contentstack.loyaltyPage start",
|
||||||
|
JSON.stringify({
|
||||||
|
query: { lang, uid },
|
||||||
|
})
|
||||||
|
)
|
||||||
const response = await request<any>(
|
const response = await request<any>(
|
||||||
GetLoyaltyPage,
|
GetLoyaltyPage,
|
||||||
{
|
{
|
||||||
@@ -87,7 +110,13 @@ export const loyaltyPageQueryRouter = router({
|
|||||||
)
|
)
|
||||||
|
|
||||||
if (!response.data) {
|
if (!response.data) {
|
||||||
console.error("contentstack.loyaltyPage not found error", { lang, uid })
|
console.error(
|
||||||
|
"contentstack.loyaltyPage not found error",
|
||||||
|
JSON.stringify({
|
||||||
|
query: { lang, uid },
|
||||||
|
error: response,
|
||||||
|
})
|
||||||
|
)
|
||||||
throw notFound(response)
|
throw notFound(response)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -198,8 +227,10 @@ export const loyaltyPageQueryRouter = router({
|
|||||||
if (!validatedLoyaltyPage.success) {
|
if (!validatedLoyaltyPage.success) {
|
||||||
console.error(
|
console.error(
|
||||||
"contentstack.loyaltyPage validation error",
|
"contentstack.loyaltyPage validation error",
|
||||||
{ lang, uid },
|
JSON.stringify({
|
||||||
JSON.stringify(validatedLoyaltyPage.error)
|
query: { lang, uid },
|
||||||
|
error: validatedLoyaltyPage.error,
|
||||||
|
})
|
||||||
)
|
)
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
@@ -212,7 +243,10 @@ export const loyaltyPageQueryRouter = router({
|
|||||||
channel: TrackingChannelEnum["scandic-friends"],
|
channel: TrackingChannelEnum["scandic-friends"],
|
||||||
pageType: "loyaltycontentpage",
|
pageType: "loyaltycontentpage",
|
||||||
}
|
}
|
||||||
console.info("contentstack.loyaltyPage success ", { lang, uid })
|
console.info(
|
||||||
|
"contentstack.loyaltyPage success",
|
||||||
|
JSON.stringify({ query: { lang, uid } })
|
||||||
|
)
|
||||||
// Assert LoyaltyPage type to get correct typings for RTE fields
|
// Assert LoyaltyPage type to get correct typings for RTE fields
|
||||||
return {
|
return {
|
||||||
loyaltyPage,
|
loyaltyPage,
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import { error } from "console"
|
||||||
|
|
||||||
import {
|
import {
|
||||||
GetNavigationMyPages,
|
GetNavigationMyPages,
|
||||||
GetNavigationMyPagesRefs,
|
GetNavigationMyPagesRefs,
|
||||||
@@ -61,7 +63,10 @@ export function mapMenuItems(menuItems: MenuItems) {
|
|||||||
export const navigationQueryRouter = router({
|
export const navigationQueryRouter = router({
|
||||||
get: contentstackBaseProcedure.query(async function ({ ctx }) {
|
get: contentstackBaseProcedure.query(async function ({ ctx }) {
|
||||||
const { lang } = ctx
|
const { lang } = ctx
|
||||||
console.info("contentstack.myPages.navigation.ref start ", { lang })
|
console.info(
|
||||||
|
"contentstack.myPages.navigation.refs start",
|
||||||
|
JSON.stringify({ query: { lang } })
|
||||||
|
)
|
||||||
const refsResponse = await request<GetNavigationMyPagesRefsData>(
|
const refsResponse = await request<GetNavigationMyPagesRefsData>(
|
||||||
GetNavigationMyPagesRefs,
|
GetNavigationMyPagesRefs,
|
||||||
{ locale: lang },
|
{ locale: lang },
|
||||||
@@ -71,21 +76,36 @@ export const navigationQueryRouter = router({
|
|||||||
)
|
)
|
||||||
|
|
||||||
if (!refsResponse.data) {
|
if (!refsResponse.data) {
|
||||||
console.error("contentstack.myPages.navigation.ref not found error ", {
|
console.error(
|
||||||
lang,
|
"contentstack.myPages.navigation.refs not found error",
|
||||||
})
|
JSON.stringify({
|
||||||
|
query: {
|
||||||
|
lang,
|
||||||
|
},
|
||||||
|
error: refsResponse,
|
||||||
|
})
|
||||||
|
)
|
||||||
throw notFound(refsResponse)
|
throw notFound(refsResponse)
|
||||||
}
|
}
|
||||||
|
|
||||||
const validatedMyPagesNavigationRefs =
|
const validatedMyPagesNavigationRefs =
|
||||||
navigationRefsPayloadSchema.safeParse(refsResponse.data)
|
navigationRefsPayloadSchema.safeParse(refsResponse.data)
|
||||||
if (!validatedMyPagesNavigationRefs.success) {
|
if (!validatedMyPagesNavigationRefs.success) {
|
||||||
console.error("contentstack.myPages.navigation.ref validation error ", {
|
console.error(
|
||||||
lang,
|
"contentstack.myPages.navigation.refs validation error",
|
||||||
})
|
JSON.stringify({
|
||||||
|
query: {
|
||||||
|
lang,
|
||||||
|
},
|
||||||
|
error: validatedMyPagesNavigationRefs.error,
|
||||||
|
})
|
||||||
|
)
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
console.info("contentstack.myPages.navigation.ref success ", { lang })
|
console.info(
|
||||||
|
"contentstack.myPages.navigation.refs success",
|
||||||
|
JSON.stringify({ query: { lang } })
|
||||||
|
)
|
||||||
const connections = getConnections(validatedMyPagesNavigationRefs.data)
|
const connections = getConnections(validatedMyPagesNavigationRefs.data)
|
||||||
|
|
||||||
const tags = [
|
const tags = [
|
||||||
@@ -96,7 +116,10 @@ export const navigationQueryRouter = router({
|
|||||||
.system.uid
|
.system.uid
|
||||||
),
|
),
|
||||||
].flat()
|
].flat()
|
||||||
console.info("contentstack.myPages.navigation start ", { lang })
|
console.info(
|
||||||
|
"contentstack.myPages.navigation start",
|
||||||
|
JSON.stringify({ query: { lang } })
|
||||||
|
)
|
||||||
const response = await request<GetNavigationMyPagesData>(
|
const response = await request<GetNavigationMyPagesData>(
|
||||||
GetNavigationMyPages,
|
GetNavigationMyPages,
|
||||||
{ locale: lang },
|
{ locale: lang },
|
||||||
@@ -104,8 +127,11 @@ export const navigationQueryRouter = router({
|
|||||||
)
|
)
|
||||||
|
|
||||||
if (!response.data) {
|
if (!response.data) {
|
||||||
console.error("contentstack.myPages.navigation not found error ", {
|
console.error("contentstack.myPages.navigation not found error", {
|
||||||
lang,
|
query: {
|
||||||
|
lang,
|
||||||
|
},
|
||||||
|
error: response,
|
||||||
})
|
})
|
||||||
throw notFound(response)
|
throw notFound(response)
|
||||||
}
|
}
|
||||||
@@ -115,9 +141,11 @@ export const navigationQueryRouter = router({
|
|||||||
)
|
)
|
||||||
if (!validatedMyPagesNavigation.success) {
|
if (!validatedMyPagesNavigation.success) {
|
||||||
console.error(
|
console.error(
|
||||||
"contentstack.myPages.navigation validation error ",
|
"contentstack.myPages.navigation.payload validation error",
|
||||||
JSON.stringify({ lang }),
|
JSON.stringify({
|
||||||
JSON.stringify(validatedMyPagesNavigation.error)
|
query: { lang },
|
||||||
|
error: validatedMyPagesNavigation.error,
|
||||||
|
})
|
||||||
)
|
)
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
@@ -133,12 +161,20 @@ export const navigationQueryRouter = router({
|
|||||||
const validatedNav = getNavigationSchema.safeParse(nav)
|
const validatedNav = getNavigationSchema.safeParse(nav)
|
||||||
if (!validatedNav.success) {
|
if (!validatedNav.success) {
|
||||||
console.error(
|
console.error(
|
||||||
`Failed to validate My Pages Navigation Return Data - (lang: ${lang}`
|
"contentstack.myPages.navigation validation error",
|
||||||
|
JSON.stringify({
|
||||||
|
query: { lang },
|
||||||
|
error: validatedNav.error,
|
||||||
|
})
|
||||||
)
|
)
|
||||||
|
|
||||||
console.error(validatedNav.error)
|
console.error(validatedNav.error)
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
console.info(
|
||||||
|
"contentstack.myPages.navigation success",
|
||||||
|
JSON.stringify({ query: { lang } })
|
||||||
|
)
|
||||||
return validatedNav.data
|
return validatedNav.data
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -32,7 +32,12 @@ export const hotelQueryRouter = router({
|
|||||||
params.include = include.join(",")
|
params.include = include.join(",")
|
||||||
}
|
}
|
||||||
|
|
||||||
console.info("api.hotels.hotel start")
|
console.info(
|
||||||
|
"api.hotels.hotel start",
|
||||||
|
JSON.stringify({
|
||||||
|
query: { hotelId, params: params.toString() },
|
||||||
|
})
|
||||||
|
)
|
||||||
const apiResponse = await api.get(
|
const apiResponse = await api.get(
|
||||||
`${api.endpoints.v1.hotels}/${hotelId}`,
|
`${api.endpoints.v1.hotels}/${hotelId}`,
|
||||||
{
|
{
|
||||||
@@ -45,7 +50,13 @@ export const hotelQueryRouter = router({
|
|||||||
)
|
)
|
||||||
|
|
||||||
if (!apiResponse.ok) {
|
if (!apiResponse.ok) {
|
||||||
console.error("api.hotels.hotel error, ", JSON.stringify(apiResponse))
|
console.error(
|
||||||
|
"api.hotels.hotel error",
|
||||||
|
JSON.stringify({
|
||||||
|
query: { hotelId, params: params.toString() },
|
||||||
|
error: apiResponse,
|
||||||
|
})
|
||||||
|
)
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
const apiJson = await apiResponse.json()
|
const apiJson = await apiResponse.json()
|
||||||
@@ -53,8 +64,11 @@ export const hotelQueryRouter = router({
|
|||||||
|
|
||||||
if (!validatedHotelData.success) {
|
if (!validatedHotelData.success) {
|
||||||
console.error(
|
console.error(
|
||||||
"api.hotels.hotel validation error ",
|
"api.hotels.hotel validation error",
|
||||||
JSON.stringify(validatedHotelData.error)
|
JSON.stringify({
|
||||||
|
query: { hotelId, params: params.toString() },
|
||||||
|
error: validatedHotelData.error,
|
||||||
|
})
|
||||||
)
|
)
|
||||||
throw badRequestError()
|
throw badRequestError()
|
||||||
}
|
}
|
||||||
@@ -63,18 +77,28 @@ export const hotelQueryRouter = router({
|
|||||||
|
|
||||||
const roomCategories = included
|
const roomCategories = included
|
||||||
? included
|
? included
|
||||||
.filter((item) => item.type === "roomcategories")
|
.filter((item) => item.type === "roomcategories")
|
||||||
.map((roomCategory) => {
|
.map((roomCategory) => {
|
||||||
const validatedRoom = roomSchema.safeParse(roomCategory)
|
const validatedRoom = roomSchema.safeParse(roomCategory)
|
||||||
if (!validatedRoom.success) {
|
if (!validatedRoom.success) {
|
||||||
console.error(`Get Room Category Data - Verified Data Error`)
|
console.error(
|
||||||
console.error(validatedRoom.error)
|
"api.hotels.hotel validation error",
|
||||||
throw badRequestError()
|
JSON.stringify({
|
||||||
}
|
query: { hotelId, params: params.toString() },
|
||||||
return validatedRoom.data
|
error: validatedRoom.error,
|
||||||
})
|
})
|
||||||
|
)
|
||||||
|
throw badRequestError()
|
||||||
|
}
|
||||||
|
return validatedRoom.data
|
||||||
|
})
|
||||||
: []
|
: []
|
||||||
console.info("api.hotels.hotel success")
|
console.info(
|
||||||
|
"api.hotels.hotel success",
|
||||||
|
JSON.stringify({
|
||||||
|
query: { hotelId, params: params.toString() },
|
||||||
|
})
|
||||||
|
)
|
||||||
return {
|
return {
|
||||||
hotel: validatedHotelData.data.data.attributes,
|
hotel: validatedHotelData.data.data.attributes,
|
||||||
roomCategories: roomCategories,
|
roomCategories: roomCategories,
|
||||||
@@ -90,31 +114,36 @@ export const hotelQueryRouter = router({
|
|||||||
// const apiLang = toApiLang(language)
|
// const apiLang = toApiLang(language)
|
||||||
// params.set("hotelId", hotelId.toString())
|
// params.set("hotelId", hotelId.toString())
|
||||||
// params.set("language", apiLang)
|
// params.set("language", apiLang)
|
||||||
console.info("api.hotels.rates start")
|
console.info("api.hotels.rates start", JSON.stringify({}))
|
||||||
const validatedHotelData = getRatesSchema.safeParse(tempRatesData)
|
const validatedHotelData = getRatesSchema.safeParse(tempRatesData)
|
||||||
|
|
||||||
if (!tempRatesData) {
|
if (!tempRatesData) {
|
||||||
console.error("api.hotels.rates error, ", {})
|
console.error("api.hotels.rates error", JSON.stringify({ error: null }))
|
||||||
//Can't return null here since consuming component does not handle null yet
|
//Can't return null here since consuming component does not handle null yet
|
||||||
// return null
|
// return null
|
||||||
}
|
}
|
||||||
if (!validatedHotelData.success) {
|
if (!validatedHotelData.success) {
|
||||||
console.error(
|
console.error(
|
||||||
"api.hotels.rates validation error ",
|
"api.hotels.rates validation error",
|
||||||
JSON.stringify(validatedHotelData.error)
|
JSON.stringify({
|
||||||
|
error: validatedHotelData.error,
|
||||||
|
})
|
||||||
)
|
)
|
||||||
throw badRequestError()
|
throw badRequestError()
|
||||||
}
|
}
|
||||||
console.info("api.hotels.rates success")
|
console.info("api.hotels.rates success", JSON.stringify({}))
|
||||||
return validatedHotelData.data
|
return validatedHotelData.data
|
||||||
}),
|
}),
|
||||||
getFilters: publicProcedure
|
getFilters: publicProcedure
|
||||||
.input(getFiltersInputSchema)
|
.input(getFiltersInputSchema)
|
||||||
.query(async ({ input, ctx }) => {
|
.query(async ({ input, ctx }) => {
|
||||||
console.info("api.hotels.filters start")
|
console.info("api.hotels.filters start", JSON.stringify({}))
|
||||||
|
|
||||||
if (!tempFilterData) {
|
if (!tempFilterData) {
|
||||||
console.error("api.hotels.filters error, ", {})
|
console.error(
|
||||||
|
"api.hotels.filters error",
|
||||||
|
JSON.stringify({ error: null })
|
||||||
|
)
|
||||||
//Can't return null here since consuming component does not handle null yet
|
//Can't return null here since consuming component does not handle null yet
|
||||||
// return null
|
// return null
|
||||||
}
|
}
|
||||||
@@ -123,11 +152,13 @@ export const hotelQueryRouter = router({
|
|||||||
if (!validateFilterData.success) {
|
if (!validateFilterData.success) {
|
||||||
console.error(
|
console.error(
|
||||||
"api.hotels.filters validation error",
|
"api.hotels.filters validation error",
|
||||||
JSON.stringify(validateFilterData.error)
|
JSON.stringify({
|
||||||
|
error: validateFilterData.error,
|
||||||
|
})
|
||||||
)
|
)
|
||||||
throw badRequestError()
|
throw badRequestError()
|
||||||
}
|
}
|
||||||
|
console.info("api.hotels.rates success", JSON.stringify({}))
|
||||||
return validateFilterData.data
|
return validateFilterData.data
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ async function getVerifiedUser({ session }: { session: Session }) {
|
|||||||
if (session.token.expires_at && session.token.expires_at < now) {
|
if (session.token.expires_at && session.token.expires_at < now) {
|
||||||
return { error: true, cause: "token_expired" } as const
|
return { error: true, cause: "token_expired" } as const
|
||||||
}
|
}
|
||||||
console.info("api.user.profile start,")
|
console.info("api.user.profile start", JSON.stringify({}))
|
||||||
const apiResponse = await api.get(api.endpoints.v1.profile, {
|
const apiResponse = await api.get(api.endpoints.v1.profile, {
|
||||||
cache: "no-store",
|
cache: "no-store",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -51,7 +51,12 @@ async function getVerifiedUser({ session }: { session: Session }) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
if (!apiResponse.ok) {
|
if (!apiResponse.ok) {
|
||||||
console.error("api.user.profile error ", JSON.stringify(apiResponse))
|
console.error(
|
||||||
|
"api.user.profile error",
|
||||||
|
JSON.stringify({
|
||||||
|
error: apiResponse,
|
||||||
|
})
|
||||||
|
)
|
||||||
if (apiResponse.status === 401) {
|
if (apiResponse.status === 401) {
|
||||||
return { error: true, cause: "unauthorized" } as const
|
return { error: true, cause: "unauthorized" } as const
|
||||||
} else if (apiResponse.status === 403) {
|
} else if (apiResponse.status === 403) {
|
||||||
@@ -68,16 +73,16 @@ async function getVerifiedUser({ session }: { session: Session }) {
|
|||||||
|
|
||||||
const apiJson = await apiResponse.json()
|
const apiJson = await apiResponse.json()
|
||||||
if (!apiJson.data?.attributes) {
|
if (!apiJson.data?.attributes) {
|
||||||
console.error("api.user.profile data error")
|
console.error("api.user.profile data error", JSON.stringify({})) // not passing the data to avoid logging sensitive data
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
const verifiedData = getUserSchema.safeParse(apiJson.data.attributes)
|
const verifiedData = getUserSchema.safeParse(apiJson.data.attributes)
|
||||||
if (!verifiedData.success) {
|
if (!verifiedData.success) {
|
||||||
console.error("api.user.profile validation error")
|
console.error("api.user.profile validation error", JSON.stringify({})) // not passing the data to avoid logging sensitive data
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
console.info("api.user.profile success")
|
console.info("api.user.profile success", JSON.stringify({}))
|
||||||
return verifiedData
|
return verifiedData
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,7 +112,7 @@ async function updateStaysBookingUrl(
|
|||||||
lang: Lang
|
lang: Lang
|
||||||
) {
|
) {
|
||||||
// Tenporary API call needed till we have user name in ctx session data
|
// Tenporary API call needed till we have user name in ctx session data
|
||||||
console.info("api.user.profile start")
|
console.info("api.user.profile start", JSON.stringify({}))
|
||||||
const apiResponse = await api.get(api.endpoints.v1.profile, {
|
const apiResponse = await api.get(api.endpoints.v1.profile, {
|
||||||
cache: "no-store",
|
cache: "no-store",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -144,7 +149,7 @@ async function updateStaysBookingUrl(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (apiResponse.ok) {
|
if (apiResponse.ok) {
|
||||||
console.info("api.user.profile success")
|
console.info("api.user.profile success", JSON.stringify({}))
|
||||||
const apiJson = await apiResponse.json()
|
const apiJson = await apiResponse.json()
|
||||||
if (apiJson.data?.attributes) {
|
if (apiJson.data?.attributes) {
|
||||||
return data.map((d) => {
|
return data.map((d) => {
|
||||||
@@ -170,7 +175,7 @@ async function updateStaysBookingUrl(
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.info("api.user.profile error", JSON.stringify(apiResponse))
|
console.info("api.user.profile error", JSON.stringify({ error: apiResponse }))
|
||||||
|
|
||||||
return data
|
return data
|
||||||
}
|
}
|
||||||
@@ -281,7 +286,10 @@ export const userQueryRouter = router({
|
|||||||
const params = new URLSearchParams()
|
const params = new URLSearchParams()
|
||||||
params.set("limit", "1")
|
params.set("limit", "1")
|
||||||
|
|
||||||
console.info("api.booking.stays.past start")
|
console.info(
|
||||||
|
"api.booking.stays.past start",
|
||||||
|
JSON.stringify({ query: { params } })
|
||||||
|
)
|
||||||
const previousStaysResponse = await api.get(
|
const previousStaysResponse = await api.get(
|
||||||
api.endpoints.v1.previousStays,
|
api.endpoints.v1.previousStays,
|
||||||
{
|
{
|
||||||
@@ -294,8 +302,8 @@ export const userQueryRouter = router({
|
|||||||
|
|
||||||
if (!previousStaysResponse.ok) {
|
if (!previousStaysResponse.ok) {
|
||||||
console.error(
|
console.error(
|
||||||
"api.booking.stays.past error ",
|
"api.booking.stays.past error",
|
||||||
JSON.stringify(previousStaysResponse)
|
JSON.stringify({ error: previousStaysResponse })
|
||||||
)
|
)
|
||||||
return notLoggedInUserTrackingData
|
return notLoggedInUserTrackingData
|
||||||
}
|
}
|
||||||
@@ -306,11 +314,11 @@ export const userQueryRouter = router({
|
|||||||
if (!verifiedPreviousStaysData.success) {
|
if (!verifiedPreviousStaysData.success) {
|
||||||
console.error(
|
console.error(
|
||||||
"api.booking.stays.past validation error, ",
|
"api.booking.stays.past validation error, ",
|
||||||
JSON.stringify(verifiedPreviousStaysData.error)
|
JSON.stringify({ error: verifiedPreviousStaysData.error })
|
||||||
)
|
)
|
||||||
return notLoggedInUserTrackingData
|
return notLoggedInUserTrackingData
|
||||||
}
|
}
|
||||||
console.info("api.booking.stays.past success")
|
console.info("api.booking.stays.past success", JSON.stringify({}))
|
||||||
|
|
||||||
const membership = getMembership(verifiedUserData.data.memberships)
|
const membership = getMembership(verifiedUserData.data.memberships)
|
||||||
|
|
||||||
@@ -345,7 +353,10 @@ export const userQueryRouter = router({
|
|||||||
if (cursor) {
|
if (cursor) {
|
||||||
params.offset = cursor
|
params.offset = cursor
|
||||||
}
|
}
|
||||||
console.info("api.booking.stays.past start")
|
console.info(
|
||||||
|
"api.booking.stays.past start",
|
||||||
|
JSON.stringify({ query: { params: params.toString() } })
|
||||||
|
)
|
||||||
|
|
||||||
const apiResponse = await api.get(
|
const apiResponse = await api.get(
|
||||||
api.endpoints.v1.previousStays,
|
api.endpoints.v1.previousStays,
|
||||||
@@ -370,7 +381,10 @@ export const userQueryRouter = router({
|
|||||||
// }
|
// }
|
||||||
console.error(
|
console.error(
|
||||||
"api.booking.stays.past error ",
|
"api.booking.stays.past error ",
|
||||||
JSON.stringify(apiResponse)
|
JSON.stringify({
|
||||||
|
query: { params: params.toString() },
|
||||||
|
error: apiResponse,
|
||||||
|
})
|
||||||
)
|
)
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
@@ -381,12 +395,18 @@ export const userQueryRouter = router({
|
|||||||
if (!verifiedData.success) {
|
if (!verifiedData.success) {
|
||||||
console.error(
|
console.error(
|
||||||
"api.booking.stays.past validation error ",
|
"api.booking.stays.past validation error ",
|
||||||
JSON.stringify(verifiedData.error)
|
JSON.stringify({
|
||||||
|
query: { params: params.toString() },
|
||||||
|
error: verifiedData.error,
|
||||||
|
})
|
||||||
)
|
)
|
||||||
|
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
console.info("api.booking.stays.past success")
|
console.info(
|
||||||
|
"api.booking.stays.past success",
|
||||||
|
JSON.stringify({ query: { params: params.toString() } })
|
||||||
|
)
|
||||||
const nextCursor =
|
const nextCursor =
|
||||||
verifiedData.data.links &&
|
verifiedData.data.links &&
|
||||||
verifiedData.data.links.offset < verifiedData.data.links.totalCount
|
verifiedData.data.links.offset < verifiedData.data.links.totalCount
|
||||||
@@ -414,7 +434,10 @@ export const userQueryRouter = router({
|
|||||||
if (cursor) {
|
if (cursor) {
|
||||||
params.offset = cursor
|
params.offset = cursor
|
||||||
}
|
}
|
||||||
console.info("api.booking.stays.future start")
|
console.info(
|
||||||
|
"api.booking.stays.future start",
|
||||||
|
JSON.stringify({ query: { params: params.toString() } })
|
||||||
|
)
|
||||||
const apiResponse = await api.get(
|
const apiResponse = await api.get(
|
||||||
api.endpoints.v1.upcomingStays,
|
api.endpoints.v1.upcomingStays,
|
||||||
{
|
{
|
||||||
@@ -438,7 +461,10 @@ export const userQueryRouter = router({
|
|||||||
// }
|
// }
|
||||||
console.error(
|
console.error(
|
||||||
"api.booking.stays.future error ",
|
"api.booking.stays.future error ",
|
||||||
JSON.stringify(apiResponse)
|
JSON.stringify({
|
||||||
|
query: { params: params.toString() },
|
||||||
|
error: apiResponse,
|
||||||
|
})
|
||||||
)
|
)
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
@@ -448,11 +474,16 @@ export const userQueryRouter = router({
|
|||||||
if (!verifiedData.success) {
|
if (!verifiedData.success) {
|
||||||
console.error(
|
console.error(
|
||||||
"api.booking.stays.future validation error ",
|
"api.booking.stays.future validation error ",
|
||||||
JSON.stringify(verifiedData.error)
|
JSON.stringify({
|
||||||
|
query: { params: params.toString() },
|
||||||
|
error: verifiedData.error,
|
||||||
|
})
|
||||||
)
|
)
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
console.info("api.booking.stays.future success")
|
console.info("api.booking.stays.future success", {
|
||||||
|
query: { params: params.toString() },
|
||||||
|
})
|
||||||
const nextCursor =
|
const nextCursor =
|
||||||
verifiedData.data.links &&
|
verifiedData.data.links &&
|
||||||
verifiedData.data.links.offset < verifiedData.data.links.totalCount
|
verifiedData.data.links.offset < verifiedData.data.links.totalCount
|
||||||
@@ -476,7 +507,10 @@ export const userQueryRouter = router({
|
|||||||
.input(friendTransactionsInput)
|
.input(friendTransactionsInput)
|
||||||
.query(async ({ ctx, input }) => {
|
.query(async ({ ctx, input }) => {
|
||||||
const { limit, page } = input
|
const { limit, page } = input
|
||||||
console.info("api.transaction.friendTransactions start")
|
console.info(
|
||||||
|
"api.transaction.friendTransactions start",
|
||||||
|
JSON.stringify({})
|
||||||
|
)
|
||||||
const apiResponse = await api.get(api.endpoints.v1.friendTransactions, {
|
const apiResponse = await api.get(api.endpoints.v1.friendTransactions, {
|
||||||
cache: undefined, // override defaultOptions
|
cache: undefined, // override defaultOptions
|
||||||
headers: {
|
headers: {
|
||||||
@@ -498,7 +532,7 @@ export const userQueryRouter = router({
|
|||||||
// }
|
// }
|
||||||
console.error(
|
console.error(
|
||||||
"api.transaction.friendTransactions error ",
|
"api.transaction.friendTransactions error ",
|
||||||
JSON.stringify(apiResponse)
|
JSON.stringify({ error: apiResponse })
|
||||||
)
|
)
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
@@ -508,12 +542,15 @@ export const userQueryRouter = router({
|
|||||||
if (!verifiedData.success) {
|
if (!verifiedData.success) {
|
||||||
console.error(
|
console.error(
|
||||||
"api.transaction.friendTransactions validation error ",
|
"api.transaction.friendTransactions validation error ",
|
||||||
JSON.stringify(verifiedData.error)
|
JSON.stringify({ error: verifiedData.error })
|
||||||
)
|
)
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
console.info("api.transaction.friendTransactions success")
|
console.info(
|
||||||
|
"api.transaction.friendTransactions success",
|
||||||
|
JSON.stringify({})
|
||||||
|
)
|
||||||
const updatedData = await updateStaysBookingUrl(
|
const updatedData = await updateStaysBookingUrl(
|
||||||
verifiedData.data.data,
|
verifiedData.data.data,
|
||||||
ctx.session.token.access_token,
|
ctx.session.token.access_token,
|
||||||
@@ -580,7 +617,7 @@ export const userQueryRouter = router({
|
|||||||
}),
|
}),
|
||||||
|
|
||||||
creditCards: protectedProcedure.query(async function ({ ctx }) {
|
creditCards: protectedProcedure.query(async function ({ ctx }) {
|
||||||
console.info("api.profile.creditCards start")
|
console.info("api.profile.creditCards start", JSON.stringify({}))
|
||||||
const apiResponse = await api.get(api.endpoints.v1.creditCards, {
|
const apiResponse = await api.get(api.endpoints.v1.creditCards, {
|
||||||
cache: "no-store",
|
cache: "no-store",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -591,7 +628,7 @@ export const userQueryRouter = router({
|
|||||||
if (!apiResponse.ok) {
|
if (!apiResponse.ok) {
|
||||||
console.error(
|
console.error(
|
||||||
"api.profile.creditCards error ",
|
"api.profile.creditCards error ",
|
||||||
JSON.stringify(apiResponse)
|
JSON.stringify({ error: apiResponse })
|
||||||
)
|
)
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
@@ -601,16 +638,16 @@ export const userQueryRouter = router({
|
|||||||
if (!verifiedData.success) {
|
if (!verifiedData.success) {
|
||||||
console.error(
|
console.error(
|
||||||
"api.profile.creditCards validation error ",
|
"api.profile.creditCards validation error ",
|
||||||
JSON.stringify(verifiedData.error)
|
JSON.stringify({ error: verifiedData.error })
|
||||||
)
|
)
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
console.info("api.profile.creditCards success")
|
console.info("api.profile.creditCards success", JSON.stringify({}))
|
||||||
return verifiedData.data.data
|
return verifiedData.data.data
|
||||||
}),
|
}),
|
||||||
|
|
||||||
membershipCards: protectedProcedure.query(async function ({ ctx }) {
|
membershipCards: protectedProcedure.query(async function ({ ctx }) {
|
||||||
console.info("api.profile start")
|
console.info("api.profile start", JSON.stringify({}))
|
||||||
const apiResponse = await api.get(api.endpoints.v1.profile, {
|
const apiResponse = await api.get(api.endpoints.v1.profile, {
|
||||||
cache: "no-store",
|
cache: "no-store",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -629,7 +666,7 @@ export const userQueryRouter = router({
|
|||||||
// default:
|
// default:
|
||||||
// throw internalServerError()
|
// throw internalServerError()
|
||||||
// }
|
// }
|
||||||
console.log("api.profile error ", JSON.stringify(apiResponse))
|
console.log("api.profile error", JSON.stringify({ error: apiResponse }))
|
||||||
}
|
}
|
||||||
|
|
||||||
const apiJson = await apiResponse.json()
|
const apiJson = await apiResponse.json()
|
||||||
@@ -640,12 +677,12 @@ export const userQueryRouter = router({
|
|||||||
|
|
||||||
if (!verifiedData.success) {
|
if (!verifiedData.success) {
|
||||||
console.error(
|
console.error(
|
||||||
"api.profile validation error ",
|
"api.profile validation error",
|
||||||
JSON.stringify(verifiedData)
|
JSON.stringify({ error: verifiedData })
|
||||||
)
|
)
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
console.info("api.profile success")
|
console.info("api.profile success", JSON.stringify({}))
|
||||||
const cards = getMembershipCards(verifiedData.data)
|
const cards = getMembershipCards(verifiedData.data)
|
||||||
|
|
||||||
return cards
|
return cards
|
||||||
|
|||||||
Reference in New Issue
Block a user