Skip to content

Commit 4fd4d57

Browse files
committed
[DOP-22569] Add filter by Job.location_type
1 parent 77c4834 commit 4fd4d57

File tree

3 files changed

+36
-57
lines changed

3 files changed

+36
-57
lines changed

src/components/job/JobRaListFilters.tsx

Lines changed: 28 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,43 @@
1-
import { minLength, useTranslate } from "react-admin";
1+
import { FilterLiveForm, minLength, useTranslate } from "react-admin";
22

3-
import { useForm, FormProvider } from "react-hook-form";
43
import { Box, Button, InputAdornment } from "@mui/material";
54
import SearchIcon from "@mui/icons-material/Search";
6-
import { TextInput, useListContext } from "react-admin";
7-
import { useEffect } from "react";
5+
import { TextInput } from "react-admin";
86
import JobTypeRaFilter from "./JobRaTypeFilter";
9-
10-
type JobRaListFilterValues = {
11-
job_type?: string[];
12-
search_query?: string;
13-
};
7+
import { LocationRaTypeFilter } from "../location";
148

159
const JobRaListFilters = () => {
1610
const translate = useTranslate();
17-
const { filterValues, setFilters } = useListContext();
18-
const form = useForm({ defaultValues: filterValues });
19-
20-
const submit = form.handleSubmit((formValues: JobRaListFilterValues) => {
21-
if (Object.keys(formValues).length > 0) {
22-
setFilters(formValues);
23-
}
24-
});
25-
26-
// fill up filters just after opening the page
27-
useEffect(() => {
28-
submit();
29-
}, []);
3011

3112
return (
32-
<FormProvider {...form}>
33-
<form onSubmit={submit}>
34-
<Box display="flex" alignItems="flex-end">
35-
<Box component="span" mr={2}>
36-
<JobTypeRaFilter />
37-
</Box>
13+
<FilterLiveForm>
14+
<Box display="flex" alignItems="flex-end">
15+
<Box component="span" mr={2} sx={{ flex: "0.2" }}>
16+
<LocationRaTypeFilter />
17+
</Box>
3818

39-
<Box component="span" mr={2} sx={{ flex: "0.3 1 1" }}>
40-
{/* Not using SearchInput here because it doesn't match styles with other filters */}
41-
<TextInput
42-
source="search_query"
43-
InputProps={{
44-
endAdornment: (
45-
<InputAdornment position="end">
46-
<SearchIcon color="disabled" />
47-
</InputAdornment>
48-
),
49-
}}
50-
validate={minLength(3)}
51-
label="resources.jobs.filters.search_query.label"
52-
helperText="resources.jobs.filters.search_query.helperText"
53-
/>
54-
</Box>
19+
<Box component="span" mr={2} sx={{ flex: "0.2" }}>
20+
<JobTypeRaFilter />
21+
</Box>
5522

56-
<Box component="span" mb={4}>
57-
<Button
58-
variant="outlined"
59-
color="primary"
60-
type="submit"
61-
>
62-
{translate("resources.jobs.filters.apply_button")}
63-
</Button>
64-
</Box>
23+
<Box component="span" mr={2} sx={{ flex: "0.3 1 1" }}>
24+
{/* Not using SearchInput here because it doesn't match styles with other filters */}
25+
<TextInput
26+
source="search_query"
27+
InputProps={{
28+
endAdornment: (
29+
<InputAdornment position="end">
30+
<SearchIcon color="disabled" />
31+
</InputAdornment>
32+
),
33+
}}
34+
validate={minLength(3)}
35+
label="resources.jobs.filters.search_query.label"
36+
helperText="resources.jobs.filters.search_query.helperText"
37+
/>
6538
</Box>
66-
</form>
67-
</FormProvider>
39+
</Box>
40+
</FilterLiveForm>
6841
);
6942
};
7043

src/i18n/en.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,10 @@ const customEnglishMessages: TranslationMessages = {
127127
lineage: "Lineage",
128128
},
129129
filters: {
130+
location_type: {
131+
label: "Location Type",
132+
helperText: "Only selected",
133+
},
130134
job_type: {
131135
label: "Job Type",
132136
helperText: "Only selected",
@@ -135,7 +139,6 @@ const customEnglishMessages: TranslationMessages = {
135139
label: "Search",
136140
helperText: "Filter by name or address",
137141
},
138-
apply_button: "Apply",
139142
},
140143
},
141144
runs: {

src/i18n/ru.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,10 @@ const customRussianMessages: TranslationMessages = {
127127
lineage: "Линедж",
128128
},
129129
filters: {
130+
location_type: {
131+
label: "Тип расположения",
132+
helperText: "Только выбранные",
133+
},
130134
job_type: {
131135
label: "Тип джобы",
132136
helperText: "Только выбранные",
@@ -135,7 +139,6 @@ const customRussianMessages: TranslationMessages = {
135139
label: "Поиск",
136140
helperText: "Фильтр по имени или адресу",
137141
},
138-
apply_button: "Применить",
139142
},
140143
},
141144
runs: {

0 commit comments

Comments
 (0)