11import {
22 AtSign ,
33 CheckCircle2 ,
4- ChevronDown ,
54 Circle ,
65 Code ,
76 ExternalLink ,
@@ -15,7 +14,7 @@ import {
1514 Trash2 ,
1615 XCircle ,
1716} from 'lucide-react'
18- import React , { useMemo , useState } from 'react'
17+ import { useMemo , useState } from 'react'
1918
2019// Mock data generator
2120const generateMockDrafts = ( ) => [
@@ -116,8 +115,9 @@ const generateMockDrafts = () => [
116115]
117116
118117// Helper function for relative time
119- const timeAgo = ( date ) => {
120- const seconds = Math . floor ( ( Date . now ( ) - date . getTime ( ) ) / 1000 )
118+ const timeAgo = ( date : Date | number ) => {
119+ const timestamp = typeof date === 'number' ? date : date . getTime ( )
120+ const seconds = Math . floor ( ( Date . now ( ) - timestamp ) / 1000 )
121121 const intervals = [
122122 { label : 'y' , secs : 31536000 } ,
123123 { label : 'mo' , secs : 2592000 } ,
@@ -176,7 +176,7 @@ const DraftsTable = () => {
176176 d . title . toLowerCase ( ) . includes ( query ) ||
177177 d . content . toLowerCase ( ) . includes ( query ) ||
178178 d . repoSlug . toLowerCase ( ) . includes ( query ) ||
179- ( d . number && d . number . toString ( ) . includes ( query ) ) ,
179+ d . number ?. toString ( ) . includes ( query ) ,
180180 )
181181 }
182182
@@ -196,7 +196,7 @@ const DraftsTable = () => {
196196 return filtered
197197 } , [ drafts , platformFilter , typeFilter , hasCodeFilter , privateOnlyFilter , searchQuery , sortBy ] )
198198
199- const toggleSelection = ( id ) => {
199+ const toggleSelection = ( id : string ) => {
200200 const newSelected = new Set ( selectedIds )
201201 if ( newSelected . has ( id ) ) {
202202 newSelected . delete ( id )
@@ -214,7 +214,7 @@ const DraftsTable = () => {
214214 }
215215 }
216216
217- const getStateIcon = ( state ) => {
217+ const getStateIcon = ( state : { type : string } ) => {
218218 switch ( state . type ) {
219219 case 'open' :
220220 return < Circle className = 'w-3 h-3 text-sky-500' />
@@ -229,7 +229,7 @@ const DraftsTable = () => {
229229 }
230230 }
231231
232- const getKindIcon = ( kind ) => {
232+ const getKindIcon = ( kind : string ) => {
233233 switch ( kind ) {
234234 case 'PR' :
235235 return < GitPullRequest className = 'w-3 h-3' />
@@ -244,11 +244,11 @@ const DraftsTable = () => {
244244 }
245245 }
246246
247- const handleOpen = ( url ) => {
247+ const handleOpen = ( url : string ) => {
248248 window . open ( url , '_blank' )
249249 }
250250
251- const handleTrash = ( draft ) => {
251+ const handleTrash = ( draft : { charCount : number ; id : string } ) => {
252252 if ( draft . charCount > 20 ) {
253253 if ( confirm ( 'Are you sure you want to discard this draft?' ) ) {
254254 console . log ( 'Trashing draft:' , draft . id )
@@ -269,9 +269,13 @@ const DraftsTable = () => {
269269 Reddit.
270270 </ p >
271271 < div className = 'space-y-2' >
272- < button className = 'text-blue-600 hover:underline' > How it works</ button >
272+ < button type = 'button' className = 'text-blue-600 hover:underline' >
273+ How it works
274+ </ button >
273275 < span className = 'mx-2' > ·</ span >
274- < button className = 'text-blue-600 hover:underline' > Check permissions</ button >
276+ < button type = 'button' className = 'text-blue-600 hover:underline' >
277+ Check permissions
278+ </ button >
275279 </ div >
276280 </ div >
277281 </ div >
@@ -332,6 +336,7 @@ const DraftsTable = () => {
332336 < div className = 'text-center py-16' >
333337 < p className = 'text-gray-600 mb-4' > No matches found</ p >
334338 < button
339+ type = 'button'
335340 onClick = { ( ) => {
336341 setPlatformFilter ( 'All' )
337342 setTypeFilter ( 'All' )
@@ -426,10 +431,18 @@ const DraftsTable = () => {
426431 { selectedIds . size > 0 && (
427432 < div className = 'mt-3 p-3 bg-blue-50 rounded-md flex items-center gap-3' >
428433 < span className = 'text-sm font-medium' > { selectedIds . size } selected</ span >
429- < button className = 'text-sm text-blue-600 hover:underline' > Copy</ button >
430- < button className = 'text-sm text-blue-600 hover:underline' > Preview</ button >
431- < button className = 'text-sm text-blue-600 hover:underline' > Discard</ button >
432- < button className = 'text-sm text-blue-600 hover:underline' > Open</ button >
434+ < button type = 'button' className = 'text-sm text-blue-600 hover:underline' >
435+ Copy
436+ </ button >
437+ < button type = 'button' className = 'text-sm text-blue-600 hover:underline' >
438+ Preview
439+ </ button >
440+ < button type = 'button' className = 'text-sm text-blue-600 hover:underline' >
441+ Discard
442+ </ button >
443+ < button type = 'button' className = 'text-sm text-blue-600 hover:underline' >
444+ Open
445+ </ button >
433446 </ div >
434447 ) }
435448 </ div >
@@ -553,6 +566,7 @@ const DraftsTable = () => {
553566 < td className = 'px-3 py-3' >
554567 < div className = 'flex items-center justify-end gap-1' >
555568 < button
569+ type = 'button'
556570 onClick = { ( ) => handleOpen ( draft . url ) }
557571 className = 'p-1.5 hover:bg-gray-100 rounded'
558572 aria-label = 'Open in context'
@@ -561,6 +575,7 @@ const DraftsTable = () => {
561575 < ExternalLink className = 'w-4 h-4 text-gray-600' />
562576 </ button >
563577 < button
578+ type = 'button'
564579 onClick = { ( ) => handleTrash ( draft ) }
565580 className = 'p-1.5 hover:bg-gray-100 rounded'
566581 aria-label = 'Discard'
0 commit comments