Skip to content

Commit cf8aaca

Browse files
fix(Tenants): do not add empty search to query
1 parent 410d4d4 commit cf8aaca

3 files changed

Lines changed: 5 additions & 4 deletions

File tree

src/containers/Tenants/Tenants.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ export const Tenants = ({additionalTenantsProps}: TenantsProps) => {
8383
};
8484

8585
const handleSearchChange = (value: string) => {
86-
dispatch(setSearchValue(value));
86+
// Do not add empty string to store
87+
dispatch(setSearchValue(value || undefined));
8788
};
8889

8990
const renderCreateDBButton = () => {

src/store/reducers/tenants/tenants.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ import {api} from '../api';
66
import type {PreparedTenant, TenantsState} from './types';
77
import {prepareTenants} from './utils';
88

9-
const initialState: TenantsState = {searchValue: ''};
9+
const initialState: TenantsState = {};
1010

1111
const slice = createSlice({
1212
name: 'tenants',
1313
initialState,
1414
reducers: {
15-
setSearchValue: (state, action: PayloadAction<string>) => {
15+
setSearchValue: (state, action: PayloadAction<string | undefined>) => {
1616
state.searchValue = action.payload;
1717
},
1818
},

src/store/reducers/tenants/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export interface PreparedTenant extends TTenant {
1515
}
1616

1717
export interface TenantsState {
18-
searchValue: string;
18+
searchValue?: string;
1919
}
2020

2121
export interface TenantsStateSlice {

0 commit comments

Comments
 (0)