import { ErrorBoundary, Suspense, type ErrorBoundaryFallbackProps, } from '@suspensive/react'; import { SuspenseQuery } from '@suspensive/react-query'; import { QueryErrorResetBoundary, useMutation } from '@tanstack/react-query'; import { postMutations, postQueries, type Post } from '@/entities/post'; import { Button } from '@/shared/ui/button'; import { Card, CardContent, CardHeader, CardTitle } from '@/shared/ui/card'; import { openConfirmDialog } from '@/shared/ui/confirm-dialog'; const VISIBLE_COUNT = 6; export const PostListPanel = () => { return ( 최근 글 {({ reset }) => ( }> {({ data: posts }) => (
    {posts.slice(0, VISIBLE_COUNT).map((post) => ( ))}
)}
)}
); }; const PostListItem = ({ post }: { post: Post }) => { const { mutate, isPending } = useMutation(postMutations.remove(post.id)); const handleDelete = async () => { const confirmed = await openConfirmDialog({ title: '글을 삭제할까요?', description: `“${post.title}”이(가) 삭제돼요. 이 작업은 되돌릴 수 없어요.`, confirmLabel: '삭제', tone: 'destructive', }); if (!confirmed) { return; } mutate(); }; return (
  • {post.title}

    {post.body}

  • ); }; const PostListErrorFallback = ({ error, reset, }: ErrorBoundaryFallbackProps) => { return (

    목록을 불러오지 못했어요.

    {error.message}

    ); }; const PostListSkeleton = () => { return (
    {Array.from({ length: VISIBLE_COUNT }, (_, index) => (
    ))}
    ); };