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:
Igor Monadical
2025-09-02 11:49:00 -04:00
committed by GitHub
parent 0df1b224f2
commit ca75a4c95e
14 changed files with 67 additions and 74 deletions

View File

@@ -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,
};
};