@@ -3,19 +3,16 @@ import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
33import { StatusBadge } from "@/components/StatusBadge" ;
44import { EmptyState } from "@/components/EmptyState" ;
55import { ErrorBanner } from "@/components/ErrorBanner" ;
6- import { listDesigns , listComments } from "@/api/client" ;
7- import type { Design , ReviewComment } from "@/types/api" ;
6+ import { listDesigns } from "@/api/client" ;
7+ import type { Design } from "@/types/api" ;
88import { formatDateTime } from "@/lib/utils" ;
9+ import { ReviewHistoryPanel } from "@/pages/design-detail/components/ReviewHistoryPanel" ;
910
1011export function HistoryPage ( ) {
1112 const [ designs , setDesigns ] = useState < Design [ ] > ( [ ] ) ;
1213 const [ loading , setLoading ] = useState ( true ) ;
1314 const [ error , setError ] = useState < string | null > ( null ) ;
14-
1515 const [ expandedId , setExpandedId ] = useState < string | null > ( null ) ;
16- const [ comments , setComments ] = useState < ReviewComment [ ] > ( [ ] ) ;
17- const [ commentsLoading , setCommentsLoading ] = useState ( false ) ;
18- const [ commentsError , setCommentsError ] = useState < string | null > ( null ) ;
1916
2017 useEffect ( ( ) => {
2118 const ctrl = new AbortController ( ) ;
@@ -33,23 +30,6 @@ export function HistoryPage() {
3330 return ( ) => ctrl . abort ( ) ;
3431 } , [ ] ) ;
3532
36- useEffect ( ( ) => {
37- if ( ! expandedId ) {
38- setComments ( [ ] ) ;
39- return ;
40- }
41- const ctrl = new AbortController ( ) ;
42- setCommentsLoading ( true ) ;
43- setCommentsError ( null ) ;
44- listComments ( expandedId , ctrl . signal )
45- . then ( ( res ) => setComments ( res . comments ) )
46- . catch ( ( err ) => {
47- if ( err . name !== "AbortError" ) setCommentsError ( err . message ) ;
48- } )
49- . finally ( ( ) => setCommentsLoading ( false ) ) ;
50- return ( ) => ctrl . abort ( ) ;
51- } , [ expandedId ] ) ;
52-
5333 const handleToggle = ( id : string ) => {
5434 setExpandedId ( ( prev ) => ( prev === id ? null : id ) ) ;
5535 } ;
@@ -81,7 +61,6 @@ export function HistoryPage() {
8161 { designs . map ( ( design ) => {
8262 const isCreated = design . created_at === design . updated_at ;
8363 const isExpanded = expandedId === design . id ;
84- const showEmptyComments = isExpanded && ! commentsLoading && ! commentsError && comments . length === 0 ;
8564
8665 return (
8766 < Card
@@ -102,35 +81,7 @@ export function HistoryPage() {
10281
10382 { isExpanded && (
10483 < CardContent onClick = { ( e ) => e . stopPropagation ( ) } >
105- < h3 className = "mb-2 text-sm font-semibold" > Review History</ h3 >
106- { commentsLoading && (
107- < p className = "text-sm text-muted-foreground" > Loading...</ p >
108- ) }
109- { commentsError && < ErrorBanner message = { commentsError } /> }
110- { showEmptyComments && (
111- < p className = "text-sm text-muted-foreground" >
112- No review comments
113- </ p >
114- ) }
115- { comments . length > 0 && (
116- < div className = "space-y-3" >
117- { comments . map ( ( c ) => (
118- < div
119- key = { c . id }
120- className = "rounded border p-3 text-sm"
121- >
122- < div className = "mb-1 flex items-center gap-2" >
123- < span className = "font-medium" > { c . reviewer } </ span >
124- < StatusBadge status = { c . status_after } />
125- < span className = "text-muted-foreground" >
126- { formatDateTime ( c . created_at ) }
127- </ span >
128- </ div >
129- < p > { c . comment } </ p >
130- </ div >
131- ) ) }
132- </ div >
133- ) }
84+ < ReviewHistoryPanel designId = { design . id } />
13485 </ CardContent >
13586 ) }
13687 </ Card >
0 commit comments