Merged in chore/refactor-trpc-booking-routes (pull request #3510)
feat(BOOK-750): refactor booking endpoints * WIP * wip * wip * parse dates in UTC * wip * no more errors * Merge branch 'master' of bitbucket.org:scandic-swap/web into chore/refactor-trpc-booking-routes * . * cleanup * import named z from zod * fix(BOOK-750): updateBooking api endpoint expects dateOnly, we passed ISO date Approved-by: Anton Gunnarsson
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
import { createRefIdPlugin } from "../../../plugins/refIdToConfirmationNumber"
|
||||
import { safeProtectedServiceProcedure } from "../../../procedures"
|
||||
import { getLinkedReservations } from "../../../services/booking/linkedReservations"
|
||||
import { isValidSession } from "../../../utils/session"
|
||||
import { getLinkedReservationsInput } from "../input"
|
||||
|
||||
const refIdPlugin = createRefIdPlugin()
|
||||
export const getLinkedReservationsRoute = safeProtectedServiceProcedure
|
||||
.input(getLinkedReservationsInput)
|
||||
.concat(refIdPlugin.toConfirmationNumber)
|
||||
.use(async ({ ctx, input, next }) => {
|
||||
const lang = input.lang ?? ctx.lang
|
||||
const token = isValidSession(ctx.session)
|
||||
? ctx.session.token.access_token
|
||||
: ctx.serviceToken
|
||||
|
||||
return next({
|
||||
ctx: {
|
||||
lang,
|
||||
token,
|
||||
},
|
||||
})
|
||||
})
|
||||
.query(async function ({ ctx }) {
|
||||
const { confirmationNumber, lang, token } = ctx
|
||||
|
||||
return getLinkedReservations(
|
||||
{
|
||||
confirmationNumber,
|
||||
lang,
|
||||
},
|
||||
token
|
||||
)
|
||||
})
|
||||
Reference in New Issue
Block a user