Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
julianbenegas committed Jan 3, 2025
1 parent b476da1 commit 0ab4261
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions packages/basehub/src/events/primitive.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,9 @@ export async function deleteEvent<Key extends `${EventKeys}:${string}`>(
}

// PARSE FORM DATA HELPER ------------------------------------------------------------------------
type SafeReturn<T> = { success: true; data: T } | { success: false; errors: Record<string, string> };
type SafeReturn<T> =
| { success: true; data: T }
| { success: false; errors: Record<string, string> };

export function parseFormData<
Key extends `${EventKeys}:${string}`,
Expand All @@ -290,7 +292,7 @@ export function parseFormData<
key: Key,
schema: Schema,
formData: FormData
): SafeReturn<EventSchemaMap[Key]> {
): SafeReturn<EventSchemaMap[ExtractEventKey<Key>]> {
const formattedData: Record<string, unknown> = {};
const errors: Record<string, string> = {};

Expand Down Expand Up @@ -394,5 +396,8 @@ export function parseFormData<
return { success: false, errors };
}

return { data: formattedData as EventSchemaMap[Key], success: true };
return {
data: formattedData as EventSchemaMap[ExtractEventKey<Key>],
success: true,
};
}

0 comments on commit 0ab4261

Please sign in to comment.