feat:payments
This commit is contained in:
@@ -76,33 +76,30 @@ export default function EventRegistrationForm() {
|
||||
|
||||
const submitMutation = useMutation({
|
||||
...orpc.submitRegistration.mutationOptions(),
|
||||
onSuccess: (data) => {
|
||||
if (data.managementToken) {
|
||||
onSuccess: async (data, variables) => {
|
||||
if (!data.managementToken) return;
|
||||
|
||||
// If it's a performer, show success immediately
|
||||
if (variables.registrationType === "performer") {
|
||||
setSuccessToken(data.managementToken);
|
||||
return;
|
||||
}
|
||||
|
||||
// For watchers, create a checkout and redirect
|
||||
try {
|
||||
const checkoutResult = await orpc.createCheckout.call({
|
||||
token: data.managementToken,
|
||||
});
|
||||
|
||||
if (checkoutResult.checkoutUrl) {
|
||||
window.location.href = checkoutResult.checkoutUrl;
|
||||
} else {
|
||||
toast.error("Kon betalingspagina niet laden");
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Checkout error:", error);
|
||||
toast.error("Er is iets misgegaan bij het aanmaken van de betaling");
|
||||
}
|
||||
setPerformerData({
|
||||
firstName: "",
|
||||
lastName: "",
|
||||
email: "",
|
||||
phone: "",
|
||||
artForm: "",
|
||||
experience: "",
|
||||
isOver16: false,
|
||||
extraQuestions: "",
|
||||
});
|
||||
setWatcherData({
|
||||
firstName: "",
|
||||
lastName: "",
|
||||
email: "",
|
||||
phone: "",
|
||||
extraQuestions: "",
|
||||
});
|
||||
setGuests([]);
|
||||
setGuestErrors([]);
|
||||
setPerformerErrors({});
|
||||
setWatcherErrors({});
|
||||
setPerformerTouched({});
|
||||
setWatcherTouched({});
|
||||
},
|
||||
onError: (error) => {
|
||||
toast.error(`Er is iets misgegaan: ${error.message}`);
|
||||
|
||||
Reference in New Issue
Block a user