Feature/update datatable filter
This commit is contained in:
@@ -6,8 +6,11 @@ import Toolbar from "./Toolbar";
|
||||
import { GET_SUPERVISOR_LIST } from "@/core/utils/routes";
|
||||
import moment from "jalali-moment";
|
||||
import RowActions from "./RowActions";
|
||||
import useProvinces from "@/lib/hooks/useProvince";
|
||||
|
||||
const OperatorList = () => {
|
||||
const { provinces, errorProvinces, loadingProvinces } = useProvinces();
|
||||
const citiesListApi = "https://rms.rmto.ir/public/contents/edarate_shahri_by_province";
|
||||
const columns = useMemo(
|
||||
() => [
|
||||
{
|
||||
@@ -24,18 +27,38 @@ const OperatorList = () => {
|
||||
header: "استان",
|
||||
id: "province",
|
||||
enableColumnFilter: true,
|
||||
datatype: "text",
|
||||
datatype: "numeric",
|
||||
filterFn: "equals",
|
||||
columnFilterModeOptions: ["equals", "contains"],
|
||||
columnSelectOption: () => {
|
||||
if (loadingProvinces) {
|
||||
return [{ value: "", label: "در حال بارگذاری..." }];
|
||||
}
|
||||
|
||||
if (errorProvinces) {
|
||||
return [{ value: "", label: "خطا در بارگذاری" }];
|
||||
}
|
||||
|
||||
return provinces.map((province) => ({
|
||||
value: province.id,
|
||||
label: province.name_fa,
|
||||
}));
|
||||
},
|
||||
},
|
||||
{
|
||||
accessorKey: "office",
|
||||
header: "اداره",
|
||||
id: "office",
|
||||
enableColumnFilter: true,
|
||||
datatype: "text",
|
||||
datatype: "numeric",
|
||||
filterFn: "equals",
|
||||
columnFilterModeOptions: ["equals", "contains"],
|
||||
dependencyId: "province",
|
||||
columnSelectOption: (dependencyField) => {
|
||||
if (dependencyField.value === "") {
|
||||
return [{ value: "", label: "ابتدا استان را انتخاب کنید" }];
|
||||
}
|
||||
|
||||
return [{ value: dependencyField.value, label: dependencyField.value }];
|
||||
},
|
||||
},
|
||||
{
|
||||
accessorKey: "operator_name",
|
||||
@@ -107,7 +130,7 @@ const OperatorList = () => {
|
||||
),
|
||||
},
|
||||
],
|
||||
[]
|
||||
[provinces]
|
||||
);
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user