Skip to content

Commit

Permalink
[#375] Handle event filter by case owner & year
Browse files Browse the repository at this point in the history
  • Loading branch information
wayangalihpratama committed Nov 18, 2024
1 parent 87679b4 commit c1c1193
Showing 1 changed file with 42 additions and 3 deletions.
45 changes: 42 additions & 3 deletions frontend/src/pages/cases/Cases.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,17 @@ import {
} from "@ant-design/icons";
import { api } from "../../lib";
import { UIState, UserState } from "../../store";
import { Select, Space, Button, Row, Col, Popconfirm, message } from "antd";
import {
Select,
Space,
Button,
Row,
Col,
Popconfirm,
message,
Input,
InputNumber,
} from "antd";
import { selectProps, DebounceSelect } from "./components";
import { isEmpty } from "lodash";
import { adminRole } from "../../store/static";
Expand All @@ -25,7 +35,7 @@ const defData = {
};
const filterProps = {
...selectProps,
style: { width: window.innerHeight * 0.225 },
style: { width: window.innerHeight * 0.175 },
};

const Cases = () => {
Expand All @@ -36,6 +46,8 @@ const Cases = () => {
const [country, setCountry] = useState(null);
const [commodity, setCommodity] = useState(null);
const [tags, setTags] = useState([]);
const [email, setEmail] = useState(null);
const [year, setYear] = useState(null);

const tagOptions = UIState.useState((s) => s.tagOptions);
const {
Expand Down Expand Up @@ -79,6 +91,12 @@ const Cases = () => {
const tagQuery = tags.join("&tags=");
url = `${url}&tags=${tagQuery}`;
}
if (email) {
url = `${url}&email=${email}`;
}
if (year) {
url = `${url}&year=${year}`;
}
api
.get(url)
.then((res) => {
Expand All @@ -96,7 +114,17 @@ const Cases = () => {
setRefresh(false);
});
}
}, [currentPage, search, userID, commodity, country, tags, refresh]);
}, [
currentPage,
search,
userID,
commodity,
country,
tags,
refresh,
year,
email,
]);

const fetchUsers = (searchValue) => {
return api
Expand Down Expand Up @@ -318,6 +346,17 @@ const Cases = () => {
value={tags}
onChange={setTags}
/>
<Input
key="4"
placeholder="Case owner email"
onChange={(e) => setEmail(e.target.value)}
/>
<InputNumber
key="5"
placeholder="Year"
controls={false}
onChange={setYear}
/>
</Space>
);

Expand Down

0 comments on commit c1c1193

Please sign in to comment.