= ({
display: 'flex',
flexDirection: 'row',
justifyContent: 'end',
+ flexWrap: 'wrap',
+ gap: '0.5rem',
}}
>
-
{
+ if (ticket.buyable) {
+ resetGroupDiscount()
+ resetCodeDiscount()
+ setOpenGroupDiscount(false)
+ setOpenCodeDiscount(false)
+ }
+ setTicket({ ...ticket, buyable: !ticket.buyable })
+ onChange?.({ ...ticket, buyable: !ticket.buyable })
}}
>
+ {ticket.buyable ? 'Disable Buying' : 'Enable Buying'}
+
+ {ticket.buyable && (
- {openGroupDiscount ? (
- <>
-
- {
- const groupDiscount = e.target.value
- setTicket({ ...ticket, groupDiscount })
- onChange?.({ ...ticket, groupDiscount })
- }}
- />
-
-
% Discount for
-
- {
- const groupNumber = e.target.value
- setTicket({ ...ticket, groupNumber })
- onChange?.({ ...ticket, groupNumber })
- }}
- />
-
-
- >
- ) : (
- <>
-
- >
- )}
-
+ )}
+ {ticket.buyable && (
+
+ )}
+ {openGroupDiscount && (
+
+
+ {
+ const groupDiscount = e.target.value
+ setTicket({ ...ticket, groupDiscount })
+ onChange?.({ ...ticket, groupDiscount })
+ }}
+ />
+
+
% Group Discount for
+
+ {
+ const groupNumber = e.target.value
+ setTicket({ ...ticket, groupNumber })
+ onChange?.({ ...ticket, groupNumber })
+ }}
+ />
+
+
+ )}
+ {openCodeDiscount && (
+
+
+ {
+ const codeDiscount = e.target.value
+ setTicket({ ...ticket, codeDiscount })
+ onChange?.({ ...ticket, codeDiscount })
+ }}
+ />
+
+
% Promo Code Discount
+
+ )}
)
}
@@ -218,6 +268,7 @@ type Ticket = {
price: string | null // Free if null
groupDiscount: string | null // If null, no group discount
groupNumber: string | null // If null, no group discount
+ codeDiscount: string | null // If null, no code discount
buyable: boolean
}
@@ -245,6 +296,7 @@ const TicketsModal = ({
price: '0.00',
groupDiscount: null,
groupNumber: null,
+ codeDiscount: null,
buyable: true,
},
])
@@ -259,6 +311,7 @@ const TicketsModal = ({
price: '0.00',
groupDiscount: null,
groupNumber: null,
+ codeDiscount: null,
buyable: true,
},
])
@@ -274,12 +327,15 @@ const TicketsModal = ({
type: ticket.name,
count: parseInt(ticket.count ?? '0'),
price: parseFloat(ticket.price ?? '0'),
- groupDiscount: usingGroupPricing
- ? parseFloat(ticket.groupDiscount!)
+ group_discount: usingGroupPricing
+ ? parseFloat(ticket.groupDiscount!) / 100
: null,
- groupNumber: usingGroupPricing
+ group_size: usingGroupPricing
? parseFloat(ticket.groupNumber!)
: null,
+ code_discount: ticket.codeDiscount
+ ? parseFloat(ticket.codeDiscount!) / 100
+ : null,
buyable: ticket.buyable,
}
})
@@ -297,8 +353,10 @@ const TicketsModal = ({
router.push(`/tickets/${id}`)
}, 500)
} else {
- notify(<>Error creating tickets>, 'error')
- setSubmitting(false)
+ res.json().then((data) => {
+ notify(<>Error creating tickets: {data.detail}>, 'error')
+ setSubmitting(false)
+ })
}
})
}
@@ -326,10 +384,7 @@ const TicketsModal = ({
/>