mirror of
https://github.com/Monadical-SAS/reflector.git
synced 2025-12-22 21:29:05 +00:00
Igor/mathieu/frontend openapi react query (#597)
* small typing * typing fixes --------- Co-authored-by: Igor Loskutov <igor.loskutoff@gmail.com>
This commit is contained in:
@@ -11,6 +11,12 @@ 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);
|
||||
@@ -18,7 +24,11 @@ const useRoomList = (page: PaginationPage): RoomList => {
|
||||
return {
|
||||
response: data || null,
|
||||
loading: isLoading,
|
||||
error: error as Error | null,
|
||||
error: error
|
||||
? new Error(
|
||||
error.detail ? formatValidationErrors(error.detail) : undefined,
|
||||
)
|
||||
: null,
|
||||
refetch,
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user