@@ -26,6 +26,7 @@ export default function Dashboard() {
2626 const [ isLoading , setIsLoading ] = useState ( true ) ;
2727 const [ error , setError ] = useState ( '' ) ;
2828 const [ searchQuery , setSearchQuery ] = useState ( '' ) ;
29+ const [ pauseFilter , setPauseFilter ] = useState < 'all' | 'active' | 'paused' > ( 'all' ) ;
2930 const [ sortBy , setSortBy ] = useState < SortOption > ( ( ) => {
3031 const saved = localStorage . getItem ( 'dashboard_sort_by' ) ;
3132 return ( saved as SortOption ) || 'date_added' ;
@@ -253,6 +254,42 @@ export default function Dashboard() {
253254 }
254255 } ;
255256
257+ const handleBulkPause = async ( ) => {
258+ setIsSavingBulk ( true ) ;
259+ setShowBulkActions ( false ) ;
260+ try {
261+ await productsApi . bulkPause ( Array . from ( selectedIds ) , true ) ;
262+ setProducts ( prev =>
263+ prev . map ( p =>
264+ selectedIds . has ( p . id ) ? { ...p , checking_paused : true } : p
265+ )
266+ ) ;
267+ setSelectedIds ( new Set ( ) ) ;
268+ } catch {
269+ alert ( 'Failed to pause some products' ) ;
270+ } finally {
271+ setIsSavingBulk ( false ) ;
272+ }
273+ } ;
274+
275+ const handleBulkResume = async ( ) => {
276+ setIsSavingBulk ( true ) ;
277+ setShowBulkActions ( false ) ;
278+ try {
279+ await productsApi . bulkPause ( Array . from ( selectedIds ) , false ) ;
280+ setProducts ( prev =>
281+ prev . map ( p =>
282+ selectedIds . has ( p . id ) ? { ...p , checking_paused : false } : p
283+ )
284+ ) ;
285+ setSelectedIds ( new Set ( ) ) ;
286+ } catch {
287+ alert ( 'Failed to resume some products' ) ;
288+ } finally {
289+ setIsSavingBulk ( false ) ;
290+ }
291+ } ;
292+
256293 const clearSelection = ( ) => {
257294 setSelectedIds ( new Set ( ) ) ;
258295 setShowBulkActions ( false ) ;
@@ -301,6 +338,13 @@ export default function Dashboard() {
301338 const filteredAndSortedProducts = useMemo ( ( ) => {
302339 let result = [ ...products ] ;
303340
341+ // Filter by pause status
342+ if ( pauseFilter === 'active' ) {
343+ result = result . filter ( p => ! p . checking_paused ) ;
344+ } else if ( pauseFilter === 'paused' ) {
345+ result = result . filter ( p => p . checking_paused ) ;
346+ }
347+
304348 // Filter by search query
305349 if ( searchQuery . trim ( ) ) {
306350 const query = searchQuery . toLowerCase ( ) ;
@@ -340,7 +384,7 @@ export default function Dashboard() {
340384 } ) ;
341385
342386 return result ;
343- } , [ products , searchQuery , sortBy , sortOrder ] ) ;
387+ } , [ products , pauseFilter , searchQuery , sortBy , sortOrder ] ) ;
344388
345389 return (
346390 < Layout >
@@ -431,6 +475,26 @@ export default function Dashboard() {
431475 box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
432476 }
433477
478+ .filter-select {
479+ padding: 0.75rem 2rem 0.75rem 0.875rem;
480+ border: 1px solid var(--border);
481+ border-radius: 0.5rem;
482+ background: var(--surface);
483+ color: var(--text);
484+ font-size: 0.9375rem;
485+ cursor: pointer;
486+ appearance: none;
487+ background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 4.5L6 7.5L9 4.5'/%3E%3C/svg%3E");
488+ background-repeat: no-repeat;
489+ background-position: right 0.75rem center;
490+ }
491+
492+ .filter-select:focus {
493+ outline: none;
494+ border-color: var(--primary);
495+ box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
496+ }
497+
434498 .sort-order-btn {
435499 padding: 0.75rem;
436500 border: 1px solid var(--border);
@@ -763,6 +827,15 @@ export default function Dashboard() {
763827 />
764828 </ div >
765829 < div className = "sort-controls" >
830+ < select
831+ className = "filter-select"
832+ value = { pauseFilter }
833+ onChange = { ( e ) => setPauseFilter ( e . target . value as 'all' | 'active' | 'paused' ) }
834+ >
835+ < option value = "all" > All Products</ option >
836+ < option value = "active" > Active</ option >
837+ < option value = "paused" > Paused</ option >
838+ </ select >
766839 < select
767840 className = "sort-select"
768841 value = { sortBy }
@@ -834,6 +907,20 @@ export default function Dashboard() {
834907 Enable Stock Alerts
835908 </ button >
836909 < hr />
910+ < button onClick = { handleBulkPause } >
911+ < svg viewBox = "0 0 24 24" fill = "none" stroke = "currentColor" strokeWidth = "2" strokeLinecap = "round" strokeLinejoin = "round" >
912+ < rect x = "6" y = "4" width = "4" height = "16" />
913+ < rect x = "14" y = "4" width = "4" height = "16" />
914+ </ svg >
915+ Pause Checking
916+ </ button >
917+ < button onClick = { handleBulkResume } >
918+ < svg viewBox = "0 0 24 24" fill = "none" stroke = "currentColor" strokeWidth = "2" strokeLinecap = "round" strokeLinejoin = "round" >
919+ < polygon points = "5 3 19 12 5 21 5 3" />
920+ </ svg >
921+ Resume Checking
922+ </ button >
923+ < hr />
837924 < button className = "danger" onClick = { handleBulkDelete } >
838925 < svg viewBox = "0 0 24 24" fill = "none" stroke = "currentColor" strokeWidth = "2" strokeLinecap = "round" strokeLinejoin = "round" >
839926 < path d = "M3 6h18" />
0 commit comments