weiterer fortschritt mit tamagui und dem neuen mobile event admin
This commit is contained in:
@@ -65,10 +65,13 @@ export async function createGiftVoucherCheckout(data: GiftVoucherCheckoutRequest
|
||||
const payload = await response.json().catch(() => ({}));
|
||||
|
||||
if (!response.ok) {
|
||||
const message =
|
||||
(payload?.errors && typeof payload.errors === 'object' && Object.values(payload.errors)[0]?.[0]) ||
|
||||
payload?.message ||
|
||||
'Unable to start checkout';
|
||||
const errors = (payload?.errors ?? {}) as Record<string, unknown>;
|
||||
const firstErrorEntry = Object.values(errors)[0];
|
||||
const firstError =
|
||||
Array.isArray(firstErrorEntry) && typeof firstErrorEntry[0] === 'string'
|
||||
? firstErrorEntry[0]
|
||||
: null;
|
||||
const message = firstError || (typeof payload?.message === 'string' ? payload.message : null) || 'Unable to start checkout';
|
||||
throw new Error(message);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user