File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -40,12 +40,18 @@ const Stats = () => {
4040
4141 function closeModal ( ) {
4242 setIsOpen ( false ) ;
43- setCount ( 0 ) ;
4443 setSelectedRange ( false ) ;
4544 }
4645
46+ useEffect ( ( ) => {
47+ if ( npmPackage ) {
48+ setCount ( npmPackage . total ) ; // Open the modal when npmPackage is updated
49+ }
50+ } , [ npmPackage ] ) ;
51+
4752 function openModal ( ) {
4853 setIsOpen ( true ) ;
54+ setCount ( npmPackage . total ) ;
4955 }
5056
5157 // Function to fetch download statistics for a given package and period
@@ -250,8 +256,8 @@ const Stats = () => {
250256 < button
251257 className = 'font-bold px-2 py-1 rounded inline-flex items-center'
252258 onClick = { ( ) => {
253- openModal ( ) ;
254259 setNpmPackage ( package_list ) ;
260+ openModal ( ) ;
255261 } }
256262 title = 'Filter'
257263 >
@@ -396,15 +402,13 @@ const Stats = () => {
396402 className = 'bg-gray-50 border text-gray-900 text-sm rounded-lg block w-full p-1 appearance-none outline-none'
397403 onChange = { ( e ) => handleChange ( e , npmPackage ) }
398404 >
399- < option value = 'filter' > Filter</ option >
400405 < option value = 'total' > Total</ option >
401406 < option value = 'Today' > Today</ option >
402407 < option value = 'Yesterday' > Yesterday</ option >
403408 < option value = 'Last month' > Last month</ option >
404409 < option value = 'this month' > This month</ option >
405410 < option value = 'last quarter' > Last quarter</ option >
406411 < option value = 'this year' > This year</ option >
407-
408412 < option value = 'custom' > Custom Range</ option >
409413 </ select >
410414 < div className = 'absolute inset-y-0 right-0 flex items-center px-2 pointer-events-none' >
You can’t perform that action at this time.
0 commit comments