improve error handling for useevent hook

This commit is contained in:
2023-12-05 09:42:08 +07:00
parent e06b760e41
commit 482b218f74
6 changed files with 64 additions and 30 deletions

View File

@@ -4,12 +4,22 @@ import { User } from '@shared/user';
import { useEvent } from '@utils/hooks/useEvent';
export function ChildNote({ id, isRoot }: { id: string; isRoot?: boolean }) {
const { status, data } = useEvent(id);
const { isFetching, isError, data } = useEvent(id);
if (status === 'pending' || !data) {
if (isFetching) {
return <NoteSkeleton />;
}
if (isError) {
return (
<div className="relative flex gap-3">
<div className="relative flex-1 rounded-md bg-neutral-200 px-2 py-2 dark:bg-neutral-800">
Failed to fetch event
</div>
</div>
);
}
return (
<div className="relative flex gap-3">
<div className="relative flex-1 rounded-md bg-neutral-200 px-2 py-2 dark:bg-neutral-800">