diff --git a/src/visits/VisitsStats.tsx b/src/visits/VisitsStats.tsx index c117e16d..f0f86fa0 100644 --- a/src/visits/VisitsStats.tsx +++ b/src/visits/VisitsStats.tsx @@ -59,6 +59,15 @@ Object.freeze(sections); let selectedBar: string | undefined; +const VisitsSectionWithFallback: FC> = ( + { children, showFallback }, +) => ( + <> + {showFallback && There are no visits matching current filter} + {!showFallback && <>{children}} + +); + export const VisitsStats: FC = (props) => { const { children, @@ -154,10 +163,6 @@ export const VisitsStats: FC = (props) => { ); } - if (visits.length === 0) { - return There are no visits matching current filter; - } - return ( <> @@ -177,22 +182,24 @@ export const VisitsStats: FC = (props) => { - - + +
+ +
+
)} /> +
@@ -228,14 +235,14 @@ export const VisitsStats: FC = (props) => { /> )} - +
)} /> +
= (props) => { onClick={(value) => highlightVisitsForProp('city', value)} />
- +
)} /> diff --git a/src/visits/VisitsTable.tsx b/src/visits/VisitsTable.tsx index ed52d138..0644a40e 100644 --- a/src/visits/VisitsTable.tsx +++ b/src/visits/VisitsTable.tsx @@ -136,7 +136,7 @@ export const VisitsTable = ({ {paginator.total === 0 && ( - No visits found with current filtering + There are no visits matching current filter )} diff --git a/test/visits/VisitsTable.test.tsx b/test/visits/VisitsTable.test.tsx index ce1f2cbd..4342d3a1 100644 --- a/test/visits/VisitsTable.test.tsx +++ b/test/visits/VisitsTable.test.tsx @@ -38,7 +38,7 @@ describe('', () => { it('shows warning when no visits are found', () => { setUp([]); - expect(screen.getByText('No visits found with current filtering')).toBeInTheDocument(); + expect(screen.getByText('There are no visits matching current filter')).toBeInTheDocument(); }); it.each([ @@ -138,7 +138,7 @@ describe('', () => { await user.type(screen.getByPlaceholderText('Search...'), 'foo'); // Search is deferred, so let's wait for it to apply - await waitFor(() => screen.getByText('No visits found with current filtering')); + await waitFor(() => screen.getByText('There are no visits matching current filter')); expect(setSelectedVisits).toHaveBeenCalledWith([]); });