mirror of
https://github.com/Monadical-SAS/reflector.git
synced 2025-12-23 05:39:05 +00:00
schema generator error type doc
This commit is contained in:
@@ -11,23 +11,14 @@ type RoomList = {
|
||||
refetch: () => void;
|
||||
};
|
||||
|
||||
type ValidationError = components["schemas"]["ValidationError"];
|
||||
|
||||
const formatValidationErrors = (errors: ValidationError[]) => {
|
||||
return errors.map((error) => error.msg).join(", ");
|
||||
};
|
||||
|
||||
// Wrapper to maintain backward compatibility
|
||||
const useRoomList = (page: PaginationPage): RoomList => {
|
||||
const { data, isLoading, error, refetch } = useRoomsList(page);
|
||||
|
||||
return {
|
||||
response: data || null,
|
||||
loading: isLoading,
|
||||
error: error
|
||||
? new Error(
|
||||
error.detail ? formatValidationErrors(error.detail) : undefined,
|
||||
)
|
||||
? new Error(error.detail ? JSON.stringify(error.detail) : undefined)
|
||||
: null,
|
||||
refetch,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user