@@ -6,7 +6,6 @@ import { useStore } from '@nanostores/react';
66import { classNames } from '~/utils/classNames' ;
77import * as DropdownMenu from '@radix-ui/react-dropdown-menu' ;
88import { Dialog , DialogRoot , DialogTitle } from '~/components/ui/Dialog' ;
9- import { jsPDF } from 'jspdf' ;
109import { toast } from 'react-toastify' ;
1110
1211interface SelectOption {
@@ -272,18 +271,20 @@ export function EventLogsTab() {
272271
273272 const filteredLogs = useMemo ( ( ) => {
274273 const allLogs = Object . values ( logs ) ;
275-
276- if ( selectedLevel === 'all' ) {
277- return allLogs . filter ( ( log ) =>
278- searchQuery ? log . message . toLowerCase ( ) . includes ( searchQuery . toLowerCase ( ) ) : true ,
279- ) ;
280- }
274+ const lowerSearchQuery = searchQuery . toLowerCase ( ) ;
275+ const hasSearch = Boolean ( searchQuery ) ;
276+ const isAllLevel = selectedLevel === 'all' ;
281277
282278 return allLogs . filter ( ( log ) => {
283- const matchesType = log . category === selectedLevel || log . level === selectedLevel ;
284- const matchesSearch = searchQuery ? log . message . toLowerCase ( ) . includes ( searchQuery . toLowerCase ( ) ) : true ;
279+ if ( ! isAllLevel && log . category !== selectedLevel && log . level !== selectedLevel ) {
280+ return false ;
281+ }
285282
286- return matchesType && matchesSearch ;
283+ if ( hasSearch && ! log . message . toLowerCase ( ) . includes ( lowerSearchQuery ) ) {
284+ return false ;
285+ }
286+
287+ return true ;
287288 } ) ;
288289 } , [ logs , selectedLevel , searchQuery ] ) ;
289290
@@ -471,8 +472,10 @@ export function EventLogsTab() {
471472 }
472473 } ;
473474
474- const exportAsPDF = ( ) => {
475+ const exportAsPDF = async ( ) => {
475476 try {
477+ const { jsPDF } = await import ( 'jspdf' ) ;
478+
476479 // Create new PDF document
477480 const doc = new jsPDF ( ) ;
478481 const lineHeight = 7 ;
0 commit comments