feat: add blocks for loyalty page
This commit is contained in:
5
server/routers/loyalty/index.ts
Normal file
5
server/routers/loyalty/index.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
import { mergeRouters } from "@/server/trpc"
|
||||
|
||||
import { lotaltyQueryRouter } from "./query"
|
||||
|
||||
export const loyaltyRouter = mergeRouters(lotaltyQueryRouter)
|
||||
27
server/routers/loyalty/query.ts
Normal file
27
server/routers/loyalty/query.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { allLevels } from "./temp"
|
||||
import { protectedProcedure, publicProcedure, router } from "@/server/trpc"
|
||||
|
||||
function fakingRequest<T>(payload: T): Promise<T> {
|
||||
return new Promise((resolve) => {
|
||||
setTimeout(() => {
|
||||
resolve(payload)
|
||||
}, 1500)
|
||||
})
|
||||
}
|
||||
|
||||
export const lotaltyQueryRouter = router({
|
||||
levels: router({
|
||||
all: publicProcedure.query(async function ({ ctx }) {
|
||||
// TODO: Make request to get user data from Scandic API
|
||||
return await fakingRequest<typeof allLevels>(allLevels)
|
||||
}),
|
||||
current: protectedProcedure.query(async function (opts) {
|
||||
// TODO: Make request to get user data from Scandic API
|
||||
return await fakingRequest<(typeof allLevels)[number]>(allLevels[1])
|
||||
}),
|
||||
next: protectedProcedure.query(async function (opts) {
|
||||
// TODO: Make request to get user data from Scandic API
|
||||
return await fakingRequest<(typeof allLevels)[number]>(allLevels[2])
|
||||
}),
|
||||
}),
|
||||
})
|
||||
68
server/routers/loyalty/temp.ts
Normal file
68
server/routers/loyalty/temp.ts
Normal file
@@ -0,0 +1,68 @@
|
||||
export const allLevels = [
|
||||
{
|
||||
tier: 1,
|
||||
name: "New Friend",
|
||||
requiredPoints: 50000,
|
||||
requiredNights: "X",
|
||||
topBenefits: [
|
||||
"15% on food on weekends",
|
||||
"Always best price",
|
||||
"Book reward nights with points",
|
||||
],
|
||||
},
|
||||
{
|
||||
tier: 2,
|
||||
name: "New Friend",
|
||||
requiredPoints: 50000,
|
||||
requiredNights: "X",
|
||||
topBenefits: [
|
||||
"15% on food on weekends",
|
||||
"Always best price",
|
||||
"Book reward nights with points",
|
||||
],
|
||||
},
|
||||
{
|
||||
tier: 3,
|
||||
name: "New Friend",
|
||||
requiredPoints: 50000,
|
||||
requiredNights: "X",
|
||||
topBenefits: [
|
||||
"15% on food on weekends",
|
||||
"Always best price",
|
||||
"Book reward nights with points",
|
||||
],
|
||||
},
|
||||
{
|
||||
tier: 4,
|
||||
name: "New Friend",
|
||||
requiredPoints: 50000,
|
||||
requiredNights: "X",
|
||||
topBenefits: [
|
||||
"15% on food on weekends",
|
||||
"Always best price",
|
||||
"Book reward nights with points",
|
||||
],
|
||||
},
|
||||
{
|
||||
tier: 5,
|
||||
name: "New Friend",
|
||||
requiredPoints: 50000,
|
||||
requiredNights: "X",
|
||||
topBenefits: [
|
||||
"15% on food on weekends",
|
||||
"Always best price",
|
||||
"Book reward nights with points",
|
||||
],
|
||||
},
|
||||
{
|
||||
tier: 6,
|
||||
name: "New Friend",
|
||||
requiredPoints: 50000,
|
||||
requiredNights: "X",
|
||||
topBenefits: [
|
||||
"15% on food on weekends",
|
||||
"Always best price",
|
||||
"Book reward nights with points",
|
||||
],
|
||||
},
|
||||
]
|
||||
Reference in New Issue
Block a user