Merged in fix/STAY-72-resend-booking-confirmation (pull request #3067)
feat(STAY-72): add resend confirmation button and endpoint * feat(STAY-72): add resend confirmation button and endpoint * fix: replace modify buttons with design system button Approved-by: Chuma Mcphoy (We Ahead) Approved-by: Erik Tiekstra
This commit is contained in:
@@ -78,6 +78,9 @@ export namespace endpoints {
|
||||
export function guarantee(confirmationNumber: string) {
|
||||
return `${bookings}/${confirmationNumber}/guarantee`
|
||||
}
|
||||
export function confirmNotification(confirmationNumber: string) {
|
||||
return `${bookings}/${confirmationNumber}/confirmNotification`
|
||||
}
|
||||
|
||||
export const enum Stays {
|
||||
future = `${base.path.booking}/${version}/${base.enitity.Stays}/future`,
|
||||
|
||||
@@ -22,6 +22,10 @@ export const removePackageInput = z.object({
|
||||
language: z.nativeEnum(Lang).transform((val) => langToApiLang[val]),
|
||||
})
|
||||
|
||||
export const resendConfirmationInput = z.object({
|
||||
language: z.nativeEnum(Lang).transform((val) => langToApiLang[val]),
|
||||
})
|
||||
|
||||
export const cancelBookingsInput = z.object({
|
||||
language: z.nativeEnum(Lang),
|
||||
})
|
||||
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
cancelBookingsInput,
|
||||
guaranteeBookingInput,
|
||||
removePackageInput,
|
||||
resendConfirmationInput,
|
||||
updateBookingInput,
|
||||
} from "../input"
|
||||
import { bookingConfirmationSchema } from "../output"
|
||||
@@ -318,6 +319,53 @@ export const bookingMutationRouter = router({
|
||||
|
||||
metricsRemovePackage.success()
|
||||
|
||||
return true
|
||||
}),
|
||||
resendConfirmation: safeProtectedServiceProcedure
|
||||
.input(resendConfirmationInput)
|
||||
.concat(refIdPlugin.toConfirmationNumber)
|
||||
.use(async ({ ctx, next }) => {
|
||||
const token = await ctx.getScandicUserToken()
|
||||
|
||||
return next({
|
||||
ctx: {
|
||||
token,
|
||||
},
|
||||
})
|
||||
})
|
||||
.mutation(async function ({ ctx, input }) {
|
||||
const { confirmationNumber } = ctx
|
||||
|
||||
const resendConfirmationCounter = createCounter(
|
||||
"trpc.booking",
|
||||
"confirmation.resend"
|
||||
)
|
||||
const metricsResendConfirmation = resendConfirmationCounter.init({
|
||||
confirmationNumber,
|
||||
})
|
||||
|
||||
metricsResendConfirmation.start()
|
||||
|
||||
const token = ctx.token ?? ctx.serviceToken
|
||||
const headers = {
|
||||
Authorization: `Bearer ${token}`,
|
||||
}
|
||||
|
||||
const apiResponse = await api.post(
|
||||
api.endpoints.v1.Booking.confirmNotification(confirmationNumber),
|
||||
{
|
||||
headers,
|
||||
},
|
||||
{ language: input.language }
|
||||
)
|
||||
|
||||
if (!apiResponse.ok) {
|
||||
await metricsResendConfirmation.httpError(apiResponse)
|
||||
return false
|
||||
}
|
||||
|
||||
metricsResendConfirmation.success()
|
||||
|
||||
return true
|
||||
}),
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user