mirror of
https://github.com/Monadical-SAS/reflector.git
synced 2025-12-22 21:29:05 +00:00
schema generator error type doc
This commit is contained in:
@@ -92,7 +92,12 @@ export default function RoomsList() {
|
||||
);
|
||||
const [isEditing, setIsEditing] = useState(false);
|
||||
const [editRoomId, setEditRoomId] = useState<string | null>(null);
|
||||
const { loading, response, refetch } = useRoomList(PaginationPage(1));
|
||||
const {
|
||||
loading,
|
||||
response,
|
||||
refetch,
|
||||
error: roomListError,
|
||||
} = useRoomList(PaginationPage(1));
|
||||
const [nameError, setNameError] = useState("");
|
||||
const [linkCopied, setLinkCopied] = useState("");
|
||||
const [selectedStreamId, setSelectedStreamId] = useState<number | null>(null);
|
||||
@@ -114,6 +119,8 @@ export default function RoomsList() {
|
||||
error: detailedEditedRoomError,
|
||||
} = useRoomGet(editRoomId);
|
||||
|
||||
const error = roomListError || detailedEditedRoomError;
|
||||
|
||||
// room being edited, as fetched from the server
|
||||
const editedRoom: typeof roomInitialState | null = useMemo(
|
||||
() =>
|
||||
@@ -359,6 +366,9 @@ export default function RoomsList() {
|
||||
</Flex>
|
||||
);
|
||||
|
||||
if (roomListError)
|
||||
return <div>{`${roomListError.name}: ${roomListError.message}`}</div>;
|
||||
|
||||
return (
|
||||
<Flex
|
||||
flexDir="column"
|
||||
|
||||
@@ -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