Skip to content

Commit

Permalink
fix: Fixed filtering by function name in the form
Browse files Browse the repository at this point in the history
  • Loading branch information
antonko committed Mar 30, 2024
1 parent 25c2071 commit dbc2429
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
5 changes: 3 additions & 2 deletions frontend/src/components/filters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
CloseButton,
Grid,
MultiSelect,
Select,
TextInput,
rem,
} from "@mantine/core";
Expand All @@ -15,10 +16,10 @@ export const Filters = observer(() => {
return (
<Grid>
<Grid.Col span="auto">
<MultiSelect
<Select
multiple={false}
placeholder="Function"
data={[...rootStore.functions]}
defaultValue={[]}
value={rootStore.filterJobs.function}
onChange={(value) => {
rootStore.setFilterFunction(value);
Expand Down
9 changes: 7 additions & 2 deletions frontend/src/stores/RootStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ export class RootStore {
if (this.filterJobs.search) {
params.search = this.filterJobs.search;
}

if (this.filterJobs.function.length) {
params.functionName = this.filterJobs.function;
}

try {
const jobsData: IJobsInfo = await fetchJobs(params);
runInAction(() => {
Expand Down Expand Up @@ -131,8 +136,8 @@ export class RootStore {
return Math.ceil(this.tableJobs.offset / this.tableJobs.limit) + 1;
}

setFilterFunction(value: string[]) {
this.filterJobs.function = value;
setFilterFunction(value: string | null) {
this.filterJobs.function = value || "";
this.loadData();
}

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/stores/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export class JobsInfo {
}

export class FilterJobs {
function: string[] = [];
function: string = "";
status: string[] = [];
search: string = "";

Expand Down

0 comments on commit dbc2429

Please sign in to comment.