feat: implement public booking cancellation feature

- Added cancelPublicBooking handler to manage booking cancellations.
- Updated public booking service to include cancellation logic.
- Created cancelPublicBooking schema for input validation.
- Modified public booking confirmation page to allow users to cancel their bookings.
- Enhanced email service to send cancellation confirmation emails.
- Made customerEmail field required in booking schemas and updated related components.
- Updated API client to support cancellation requests.
- Added migration to enforce non-nullable customer_email fields in the database.
This commit is contained in:
Jose Selesan
2026-06-05 11:24:02 -03:00
parent 1210854c22
commit 260d79fc99
24 changed files with 488 additions and 105 deletions

View File

@@ -10,13 +10,35 @@ export const http: AxiosInstance = axios.create({
});
function extractMessage(details: unknown, fallback: string): string {
if (
typeof details === 'object' &&
details &&
'message' in details &&
typeof details.message === 'string'
) {
return details.message;
if (typeof details === 'object' && details) {
if ('message' in details && typeof details.message === 'string') {
return details.message;
}
if ('detail' in details && typeof details.detail === 'string') {
return details.detail;
}
if ('error' in details && typeof details.error === 'object' && details.error) {
const zodError = details.error as Record<string, unknown>;
if (Array.isArray(zodError.issues) && zodError.issues.length > 0) {
const firstIssue = zodError.issues[0] as { message?: string };
if (typeof firstIssue.message === 'string') return firstIssue.message;
}
if (typeof zodError.message === 'string') {
try {
const parsed = JSON.parse(zodError.message);
if (
Array.isArray(parsed) &&
parsed.length > 0 &&
typeof parsed[0]?.message === 'string'
) {
return parsed[0].message;
}
} catch {
/* not JSON, use raw string */
}
return zodError.message;
}
}
}
return fallback;
}