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:
Christel Westerberg
2025-11-06 13:40:15 +00:00
parent ec511e2c8b
commit 20bf89d206
16 changed files with 209 additions and 56 deletions

View File

@@ -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
}),
})