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
20 lines
605 B
TypeScript
20 lines
605 B
TypeScript
import { serverErrorByStatus } from "../../../errors"
|
|
import { serviceProcedure } from "../../../procedures"
|
|
import { encrypt } from "../../../utils/encryption"
|
|
import { createRefIdInput } from "../input"
|
|
|
|
export const createRefIdRoute = serviceProcedure
|
|
.input(createRefIdInput)
|
|
.mutation(async function ({ input }) {
|
|
const { confirmationNumber, lastName } = input
|
|
const encryptedRefId = encrypt(`${confirmationNumber},${lastName}`)
|
|
|
|
if (!encryptedRefId) {
|
|
throw serverErrorByStatus(422, "Was not able to encrypt ref id")
|
|
}
|
|
|
|
return {
|
|
refId: encryptedRefId,
|
|
}
|
|
})
|