Skip to content

Commit

Permalink
throw error in unexpected cases
Browse files Browse the repository at this point in the history
  • Loading branch information
langovoi committed Aug 15, 2024
1 parent ee3bda7 commit f5a74c3
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/app/(main)/events/[id]/order/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,31 +54,29 @@ export async function createOrder(
const event = await getEvent(eventId)

if (!event || !event.qtickets_id) {
// TODO
notFound()
}

const tickets = await getTickets(event.qtickets_id)

if (!tickets) {
// TODO
notFound()
}

const order = createOrderSchema.safeParse(data)

if (!order.success) {
// TODO
notFound()
// TODO: add client handling
throw new Error('Invalid order data')
}

const payment = tickets.payments.find(
(payment) => payment.type === order.data.payment.type
)

if (!payment) {
// TODO
notFound()
// TODO: add client handling
throw new Error('Payment method not found')
}

const requestBody = {
Expand Down

0 comments on commit f5a74c3

Please sign in to comment.