@@ -100,6 +100,13 @@ const updateState = (state: WriterState, event: WriterEvent): WriterState => {
100
100
}
101
101
} ;
102
102
103
+ const stateIcon : Record < EventState , React . ReactNode > = {
104
+ pending : < Clock className = "w-4 h-4 text-yellow-500" /> ,
105
+ inprogress : < CircleDashed className = "w-4 h-4 text-blue-500 animate-spin" /> ,
106
+ done : < CheckCircle2 className = "w-4 h-4 text-green-500" /> ,
107
+ error : < AlertCircle className = "w-4 h-4 text-red-500" /> ,
108
+ } ;
109
+
103
110
export function WriterCard ( { message } : { message : Message } ) {
104
111
const [ state , setState ] = useState < WriterState > ( {
105
112
retrieve : { state : null } ,
@@ -116,21 +123,6 @@ export function WriterCard({ message }: { message: Message }) {
116
123
}
117
124
} , [ writerEvents ] ) ;
118
125
119
- const getStateIcon = ( state : EventState | null ) => {
120
- switch ( state ) {
121
- case "pending" :
122
- return < Clock className = "w-4 h-4 text-yellow-500" /> ;
123
- case "inprogress" :
124
- return < CircleDashed className = "w-4 h-4 text-blue-500 animate-spin" /> ;
125
- case "done" :
126
- return < CheckCircle2 className = "w-4 h-4 text-green-500" /> ;
127
- case "error" :
128
- return < AlertCircle className = "w-4 h-4 text-red-500" /> ;
129
- default :
130
- return null ;
131
- }
132
- } ;
133
-
134
126
if ( ! writerEvents ?. length ) {
135
127
return null ;
136
128
}
@@ -167,7 +159,7 @@ export function WriterCard({ message }: { message: Message }) {
167
159
< CollapsibleTrigger className = "w-full" >
168
160
< div className = "flex items-center gap-2 p-3 hover:bg-gray-50 transition-colors rounded-lg border border-gray-200" >
169
161
< div className = "flex-shrink-0" >
170
- { getStateIcon ( question . state ) }
162
+ { stateIcon [ question . state ] }
171
163
</ div >
172
164
< span className = "font-medium text-left flex-1" >
173
165
{ question . question }
0 commit comments