feat: add shortcuts component to loyaltypage
This commit is contained in:
@@ -4,7 +4,11 @@ import { badRequestError } from "@/server/errors/trpc"
|
||||
import { publicProcedure, router } from "@/server/trpc"
|
||||
|
||||
import { getLoyaltyPageInput } from "./input"
|
||||
import { type LoyaltyPage, validateLoyaltyPageSchema } from "./output"
|
||||
import {
|
||||
type LoyaltyPage,
|
||||
type LoyaltyPageDataRaw,
|
||||
validateLoyaltyPageSchema,
|
||||
} from "./output"
|
||||
|
||||
import {
|
||||
LoyaltyBlocksTypenameEnum,
|
||||
@@ -17,7 +21,7 @@ import { RTEDocument } from "@/types/rte/node"
|
||||
export const loyaltyPageQueryRouter = router({
|
||||
get: publicProcedure.input(getLoyaltyPageInput).query(async ({ input }) => {
|
||||
try {
|
||||
const loyaltyPageRes = await request<LoyaltyPage>(GetLoyaltyPage, {
|
||||
const loyaltyPageRes = await request<LoyaltyPageDataRaw>(GetLoyaltyPage, {
|
||||
locale: input.locale,
|
||||
url: input.href,
|
||||
})
|
||||
@@ -108,6 +112,22 @@ export const loyaltyPageQueryRouter = router({
|
||||
},
|
||||
},
|
||||
}
|
||||
case LoyaltyBlocksTypenameEnum.LoyaltyPageBlocksShortcuts:
|
||||
return {
|
||||
...block,
|
||||
shortcuts: {
|
||||
...block.shortcuts,
|
||||
shortcuts: block.shortcuts.shortcuts.map((shortcut) => ({
|
||||
text: shortcut.text,
|
||||
openInNewTab: shortcut.open_in_new_tab,
|
||||
...shortcut.linkConnection.edges[0].node,
|
||||
url:
|
||||
shortcut.linkConnection.edges[0].node.web
|
||||
?.original_url ||
|
||||
`/${shortcut.linkConnection.edges[0].node.system.locale}${shortcut.linkConnection.edges[0].node.url}`,
|
||||
})),
|
||||
},
|
||||
}
|
||||
default:
|
||||
return block
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user