feat(SW-556): add surprise notification component
This commit is contained in:
@@ -19,6 +19,7 @@ import {
|
||||
rewardsAllInput,
|
||||
rewardsByLevelInput,
|
||||
rewardsCurrentInput,
|
||||
rewardsUpdateInput,
|
||||
} from "./input"
|
||||
import {
|
||||
CmsRewardsResponse,
|
||||
@@ -242,10 +243,10 @@ export const rewardQueryRouter = router({
|
||||
return null
|
||||
}
|
||||
|
||||
const rewardIds = validatedApiRewards.data.data
|
||||
const rewardIds = validatedApiRewards.data
|
||||
.map((reward) => reward?.rewardId)
|
||||
.filter(Boolean)
|
||||
.sort() as string[]
|
||||
.filter((rewardId): rewardId is string => !!rewardId)
|
||||
.sort()
|
||||
|
||||
const slicedData = rewardIds.slice(cursor, limit + cursor)
|
||||
|
||||
@@ -259,8 +260,35 @@ export const rewardQueryRouter = router({
|
||||
limit + cursor < rewardIds.length ? limit + cursor : undefined
|
||||
|
||||
getCurrentRewardSuccessCounter.add(1)
|
||||
|
||||
return {
|
||||
rewards: cmsRewards,
|
||||
apiRewards: validatedApiRewards.data
|
||||
// FIXME: Remove these mocks before merging
|
||||
.concat([
|
||||
{
|
||||
autoApplyReward: false,
|
||||
title: "Free kids drink when staying",
|
||||
id: "fake-id",
|
||||
type: "surprise",
|
||||
status: "active",
|
||||
rewardId: "tier_free_kids_drink",
|
||||
redeemLocation: "On-site",
|
||||
rewardType: "Tier",
|
||||
rewardTierLevel: "L1",
|
||||
},
|
||||
{
|
||||
autoApplyReward: false,
|
||||
title: "Free kanelbulle",
|
||||
id: "fake-id-2",
|
||||
type: "surprise",
|
||||
status: "active",
|
||||
rewardId: "tier_free_kanelbulle",
|
||||
redeemLocation: "On-site",
|
||||
rewardType: "Tier",
|
||||
rewardTierLevel: "L1",
|
||||
},
|
||||
]),
|
||||
nextCursor,
|
||||
}
|
||||
}),
|
||||
@@ -374,4 +402,19 @@ export const rewardQueryRouter = router({
|
||||
getAllRewardSuccessCounter.add(1)
|
||||
return levelsWithRewards
|
||||
}),
|
||||
update: contentStackBaseWithProtectedProcedure
|
||||
.input(rewardsUpdateInput)
|
||||
.mutation(async ({ input, ctx }) => {
|
||||
const response = await Promise.resolve({ ok: true })
|
||||
// const response = await api.post(api.endpoints.v1.rewards, {
|
||||
// body: {
|
||||
// ids: [input.id],
|
||||
// },
|
||||
// })
|
||||
if (!response.ok) {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}),
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user