add: tags filter
This commit is contained in:
@@ -10,6 +10,7 @@ import { DeleteButtonForPopOver } from "../components/PopOverButtons/PopOverButt
|
|||||||
import { TagDetails } from "../partials/tagging/TagDetails";
|
import { TagDetails } from "../partials/tagging/TagDetails";
|
||||||
import { useParams } from "@tanstack/react-router";
|
import { useParams } from "@tanstack/react-router";
|
||||||
import { TableButton } from "../components/TableButton/TableButton";
|
import { TableButton } from "../components/TableButton/TableButton";
|
||||||
|
import AutoComplete from "../components/AutoComplete/AutoComplete";
|
||||||
|
|
||||||
const speciesMap: Record<number, string> = {
|
const speciesMap: Record<number, string> = {
|
||||||
1: "گاو",
|
1: "گاو",
|
||||||
@@ -19,18 +20,26 @@ const speciesMap: Record<number, string> = {
|
|||||||
5: "بز",
|
5: "بز",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const statusOptions = [
|
||||||
|
{ key: "F", value: "آزاد" },
|
||||||
|
{ key: "A", value: "پلاک شده" },
|
||||||
|
{ key: "R", value: "رزرو" },
|
||||||
|
];
|
||||||
|
|
||||||
export default function Tags() {
|
export default function Tags() {
|
||||||
const { openModal } = useModalStore();
|
const { openModal } = useModalStore();
|
||||||
const [tableInfo, setTableInfo] = useState({ page: 1, page_size: 10 });
|
const [tableInfo, setTableInfo] = useState({ page: 1, page_size: 10 });
|
||||||
const [tagsTableData, setTagsTableData] = useState([]);
|
const [tagsTableData, setTagsTableData] = useState([]);
|
||||||
const { id, from, to } = useParams({ strict: false });
|
const { id, from, to } = useParams({ strict: false });
|
||||||
|
const [selectedStatus, setSelectedStatus] = useState<(string | number)[]>([]);
|
||||||
|
|
||||||
const { data: tagsData, refetch } = useApiRequest({
|
const { data: tagsData, refetch } = useApiRequest({
|
||||||
api: `/tag/web/api/v1/tag/${id ? id + "/tags_by_batch" : ""}`,
|
api: `/tag/web/api/v1/tag/${id ? id + "/tags_by_batch" : ""}`,
|
||||||
method: "get",
|
method: "get",
|
||||||
queryKey: ["tagsList", tableInfo],
|
queryKey: ["tagsList", tableInfo, selectedStatus],
|
||||||
params: {
|
params: {
|
||||||
...tableInfo,
|
...tableInfo,
|
||||||
|
status: selectedStatus.length ? selectedStatus[0] : undefined,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -236,6 +245,17 @@ export default function Tags() {
|
|||||||
</Grid>
|
</Grid>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
<Grid container className="items-center gap-2">
|
||||||
|
<Grid>
|
||||||
|
<AutoComplete
|
||||||
|
data={statusOptions}
|
||||||
|
selectedKeys={selectedStatus}
|
||||||
|
onChange={setSelectedStatus}
|
||||||
|
title="فیلتر پلاک ها"
|
||||||
|
/>
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
|
|
||||||
<Table
|
<Table
|
||||||
className="mt-2"
|
className="mt-2"
|
||||||
onChange={setTableInfo}
|
onChange={setTableInfo}
|
||||||
|
|||||||
Reference in New Issue
Block a user