Skip to content

Commit 4fa88a0

Browse files
committed
Merge branch 'main' into deployments/ood.antenna.insectai.org
2 parents 8942b72 + 015aaf6 commit 4fa88a0

File tree

5 files changed

+69
-26
lines changed

5 files changed

+69
-26
lines changed
Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,44 @@
11
import { Button } from 'nova-ui-kit'
2+
import { ReactNode } from 'react'
23
import { STRING, translate } from 'utils/language'
34
import { useFilters } from 'utils/useFilters'
5+
import { usePagination } from 'utils/usePagination'
46

57
export const EmptyState = () => {
68
const { filters, activeFilters, clearFilter } = useFilters()
9+
const { pagination, resetPage } = usePagination()
710

8-
return (
9-
<div className="flex flex-col gap-6 items-center py-24">
10-
<span className="body-base text-muted-foreground">
11-
{translate(
12-
activeFilters.length
13-
? STRING.MESSAGE_NO_RESULTS_FOR_FILTERING
14-
: STRING.MESSAGE_NO_RESULTS
15-
)}
16-
</span>
17-
{activeFilters.length ? (
11+
if (pagination.page) {
12+
return (
13+
<Container>
14+
<p>{translate(STRING.MESSAGE_NO_RESULTS_FOR_PAGE)}</p>
15+
<Button onClick={() => resetPage()}>
16+
{translate(STRING.RESET_PAGE)}
17+
</Button>
18+
</Container>
19+
)
20+
}
21+
22+
if (activeFilters.length) {
23+
return (
24+
<Container>
25+
<p>{translate(STRING.MESSAGE_NO_RESULTS_FOR_FILTERING)}</p>
1826
<Button
1927
onClick={() => filters.map((filter) => clearFilter(filter.field))}
2028
>
2129
{translate(STRING.CLEAR_FILTERS)}
2230
</Button>
23-
) : null}
24-
</div>
31+
</Container>
32+
)
33+
}
34+
35+
return (
36+
<Container>
37+
<p>{translate(STRING.MESSAGE_NO_RESULTS)}</p>
38+
</Container>
2539
)
2640
}
41+
42+
const Container = ({ children }: { children: ReactNode }) => (
43+
<div className="flex flex-col gap-6 items-center py-24">{children}</div>
44+
)

ui/src/design-system/variables/typography.scss

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
@import 'src/design-system/variables/variables.scss';
22

33
@mixin heading-6 {
4-
font-family: 'Mazzard';
4+
font-family: 'Mazzard', sans-serif;
55
font-style: normal;
66
font-weight: 600;
77
font-size: 20px;
@@ -14,7 +14,7 @@
1414
}
1515

1616
@mixin heading-5 {
17-
font-family: 'Mazzard';
17+
font-family: 'Mazzard', sans-serif;
1818
font-style: normal;
1919
font-weight: 600;
2020
font-size: 24px;
@@ -28,7 +28,7 @@
2828
}
2929

3030
@mixin heading-4-italic {
31-
font-family: 'Mazzard';
31+
font-family: 'Mazzard', sans-serif;
3232
font-style: normal;
3333
font-weight: 400;
3434
font-size: 28px;
@@ -42,39 +42,39 @@
4242
}
4343

4444
@mixin paragraph-xx-small {
45-
font-family: 'Mazzard';
45+
font-family: 'Mazzard', sans-serif;
4646
font-style: normal;
4747
font-weight: 400;
4848
font-size: 10px;
4949
line-height: 16px;
5050
}
5151

5252
@mixin paragraph-x-small {
53-
font-family: 'Mazzard';
53+
font-family: 'Mazzard', sans-serif;
5454
font-style: normal;
5555
font-weight: 400;
5656
font-size: 12px;
5757
line-height: 16px;
5858
}
5959

6060
@mixin paragraph-small {
61-
font-family: 'Mazzard';
61+
font-family: 'Mazzard', sans-serif;
6262
font-style: normal;
6363
font-weight: 400;
6464
font-size: 14px;
6565
line-height: 20px;
6666
}
6767

6868
@mixin paragraph-medium {
69-
font-family: 'Mazzard';
69+
font-family: 'Mazzard', sans-serif;
7070
font-style: normal;
7171
font-weight: 400;
7272
font-size: 16px;
7373
line-height: 22px;
7474
}
7575

7676
@mixin paragraph-large {
77-
font-family: 'Mazzard';
77+
font-family: 'Mazzard', sans-serif;
7878
font-style: normal;
7979
font-weight: 400;
8080
font-size: 18px;
@@ -83,7 +83,7 @@
8383

8484
// Not present in Figma
8585
@mixin label {
86-
font-family: 'Mazzard';
86+
font-family: 'Mazzard', sans-serif;
8787
font-style: normal;
8888
font-weight: 600;
8989
font-size: 12px;

ui/src/utils/language.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export enum STRING {
2424
QUEUED,
2525
REFRESH,
2626
RESET,
27+
RESET_PAGE,
2728
RETRY,
2829
RERUN,
2930
SAVE,
@@ -169,6 +170,7 @@ export enum STRING {
169170
MESSAGE_NO_IMAGE,
170171
MESSAGE_NO_RESULTS,
171172
MESSAGE_NO_RESULTS_FOR_FILTERING,
173+
MESSAGE_NO_RESULTS_FOR_PAGE,
172174
MESSAGE_PASSWORD_FORMAT,
173175
MESSAGE_PASSWORD_UPDATED,
174176
MESSAGE_PERMISSIONS_MISSING,
@@ -299,6 +301,7 @@ const ENGLISH_STRINGS: { [key in STRING]: string } = {
299301
[STRING.QUEUED]: 'Queued',
300302
[STRING.REFRESH]: 'Refresh',
301303
[STRING.RESET]: 'Reset',
304+
[STRING.RESET_PAGE]: 'Reset page',
302305
[STRING.RETRY]: 'Retry',
303306
[STRING.RERUN]: 'Re-run',
304307
[STRING.SAVE]: 'Save',
@@ -453,7 +456,9 @@ const ENGLISH_STRINGS: { [key in STRING]: string } = {
453456
[STRING.MESSAGE_NO_IMAGE]: 'No image',
454457
[STRING.MESSAGE_NO_RESULTS]: 'No results to show.',
455458
[STRING.MESSAGE_NO_RESULTS_FOR_FILTERING]:
456-
'No results to show for the current fitering.',
459+
'No results to show for the current filtering.',
460+
[STRING.MESSAGE_NO_RESULTS_FOR_PAGE]:
461+
'No results to show for the current page.',
457462
[STRING.MESSAGE_PASSWORD_FORMAT]:
458463
'The password must contain at least 8 characters and cannot be entirely numeric.',
459464
[STRING.MESSAGE_PASSWORD_UPDATED]: 'Your password has been updated!',

ui/src/utils/useFilters.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { isBefore, isValid } from 'date-fns'
22
import { useSearchParams } from 'react-router-dom'
33
import { STRING, translate } from './language'
4+
import { SEARCH_PARAM_KEY_PAGE } from './usePagination'
45

56
export const AVAILABLE_FILTERS: {
67
label: string
@@ -166,13 +167,25 @@ export const useFilters = (defaultFilters?: { [field: string]: string }) => {
166167
const addFilter = (field: string, value: string) => {
167168
if (AVAILABLE_FILTERS.some((filter) => filter.field === field)) {
168169
searchParams.set(field, value)
170+
171+
// Reset page param if set, when filters are updated
172+
if (searchParams.has(SEARCH_PARAM_KEY_PAGE)) {
173+
searchParams.delete(SEARCH_PARAM_KEY_PAGE)
174+
}
175+
169176
setSearchParams(searchParams)
170177
}
171178
}
172179

173180
const clearFilter = (field: string) => {
174181
if (AVAILABLE_FILTERS.some((filter) => filter.field === field)) {
175182
searchParams.delete(field)
183+
184+
// Reset page param if set, when filters are updated
185+
if (searchParams.has(SEARCH_PARAM_KEY_PAGE)) {
186+
searchParams.delete(SEARCH_PARAM_KEY_PAGE)
187+
}
188+
176189
setSearchParams(searchParams)
177190
}
178191
}

ui/src/utils/usePagination.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,22 @@ const useSearchParam = ({
2929
}
3030
}
3131

32-
const clearValue = () => {
32+
const resetValue = () => {
3333
if (searchParams.has(key)) {
3434
searchParams.delete(key)
3535
setSearchParams(searchParams)
3636
}
3737
}
3838

39-
return { value, setValue, clearValue }
39+
return { value, setValue, resetValue }
4040
}
4141

42-
export const usePagination = ({ perPage }: { perPage?: number } = {}) => {
43-
const { value: page, setValue: setPage } = useSearchParam({
42+
const usePagination = ({ perPage }: { perPage?: number } = {}) => {
43+
const {
44+
value: page,
45+
setValue: setPage,
46+
resetValue: resetPage,
47+
} = useSearchParam({
4448
key: SEARCH_PARAM_KEY_PAGE,
4549
defaultValue: DEFAULT_PAGINATION.page,
4650
})
@@ -50,6 +54,9 @@ export const usePagination = ({ perPage }: { perPage?: number } = {}) => {
5054
page,
5155
perPage: perPage ?? DEFAULT_PAGINATION.perPage,
5256
},
57+
resetPage,
5358
setPage,
5459
}
5560
}
61+
62+
export { SEARCH_PARAM_KEY_PAGE, usePagination }

0 commit comments

Comments
 (0)