add: organization type filter
This commit is contained in:
@@ -6,12 +6,12 @@ import { OrganizationsTypes } from "../partials/management/OrganizationsTypes";
|
|||||||
|
|
||||||
export default function Organizations() {
|
export default function Organizations() {
|
||||||
const tabItems = [
|
const tabItems = [
|
||||||
{ label: "سازمان ها" },
|
|
||||||
{
|
{
|
||||||
label: "نهاد",
|
label: "نهاد",
|
||||||
page: "organizations",
|
page: "organizations",
|
||||||
access: "Show-Organization-Type",
|
access: "Show-Organization-Type",
|
||||||
},
|
},
|
||||||
|
{ label: "سازمان ها" },
|
||||||
];
|
];
|
||||||
|
|
||||||
const [selectedTab, setSelectedTab] = useState<number>(0);
|
const [selectedTab, setSelectedTab] = useState<number>(0);
|
||||||
@@ -22,7 +22,7 @@ export default function Organizations() {
|
|||||||
return (
|
return (
|
||||||
<Grid container column className="gap-2">
|
<Grid container column className="gap-2">
|
||||||
<Tabs tabs={tabItems} onChange={handleTabChange} size="medium" />
|
<Tabs tabs={tabItems} onChange={handleTabChange} size="medium" />
|
||||||
{selectedTab === 0 ? <OrganizationsList /> : <OrganizationsTypes />}
|
{selectedTab === 0 ? <OrganizationsTypes /> : <OrganizationsList />}
|
||||||
</Grid>
|
</Grid>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { Grid } from "../../components/Grid/Grid";
|
|||||||
import Button from "../../components/Button/Button";
|
import Button from "../../components/Button/Button";
|
||||||
import { AddOrganization } from "./AddOrganization";
|
import { AddOrganization } from "./AddOrganization";
|
||||||
import AutoComplete from "../../components/AutoComplete/AutoComplete";
|
import AutoComplete from "../../components/AutoComplete/AutoComplete";
|
||||||
|
import { FormApiBasedAutoComplete } from "../../components/FormItems/FormApiBasedAutoComplete";
|
||||||
import Table from "../../components/Table/Table";
|
import Table from "../../components/Table/Table";
|
||||||
import { useModalStore } from "../../context/zustand-store/appStore";
|
import { useModalStore } from "../../context/zustand-store/appStore";
|
||||||
import { useApiRequest } from "../../utils/useApiRequest";
|
import { useApiRequest } from "../../utils/useApiRequest";
|
||||||
@@ -19,6 +20,9 @@ export const OrganizationsList = () => {
|
|||||||
const [selectedProvinceKeys, setSelectedProvinceKeys] = useState<
|
const [selectedProvinceKeys, setSelectedProvinceKeys] = useState<
|
||||||
(string | number)[]
|
(string | number)[]
|
||||||
>([]);
|
>([]);
|
||||||
|
const [selectedOrganizationType, setSelectedOrganizationType] = useState<
|
||||||
|
string | number
|
||||||
|
>("");
|
||||||
const [params, setParams] = useState({ page: 1, page_size: 10 });
|
const [params, setParams] = useState({ page: 1, page_size: 10 });
|
||||||
const [tableData, setTableData] = useState([]);
|
const [tableData, setTableData] = useState([]);
|
||||||
const { profile } = useUserProfileStore();
|
const { profile } = useUserProfileStore();
|
||||||
@@ -32,11 +36,16 @@ export const OrganizationsList = () => {
|
|||||||
|
|
||||||
const { data: apiData, refetch } = useApiRequest({
|
const { data: apiData, refetch } = useApiRequest({
|
||||||
api: selectedProvinceKeys?.length
|
api: selectedProvinceKeys?.length
|
||||||
? `/auth/api/v1/organization/organizations_by_province?province=${selectedProvinceKeys[0]}`
|
? `/auth/api/v1/organization/organizations_by_province?province=${selectedProvinceKeys[0]}${selectedOrganizationType ? `&org_type=${selectedOrganizationType}` : ""}`
|
||||||
: "/auth/api/v1/organization/",
|
: `/auth/api/v1/organization/${selectedOrganizationType ? `?org_type=${selectedOrganizationType}` : ""}`,
|
||||||
method: "get",
|
method: "get",
|
||||||
params: params,
|
params: params,
|
||||||
queryKey: ["organizations", params, selectedProvinceKeys],
|
queryKey: [
|
||||||
|
"organizations",
|
||||||
|
params,
|
||||||
|
selectedProvinceKeys,
|
||||||
|
selectedOrganizationType,
|
||||||
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -159,6 +168,16 @@ export const OrganizationsList = () => {
|
|||||||
ایجاد سازمان
|
ایجاد سازمان
|
||||||
</Button>
|
</Button>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
<Grid>
|
||||||
|
<FormApiBasedAutoComplete
|
||||||
|
size="small"
|
||||||
|
title="فیلتر نهاد"
|
||||||
|
api={`auth/api/v1/organization-type`}
|
||||||
|
keyField="id"
|
||||||
|
valueField="name"
|
||||||
|
onChange={(r) => setSelectedOrganizationType(r)}
|
||||||
|
/>
|
||||||
|
</Grid>
|
||||||
{profile?.organization?.type?.org_type_field === "CO" && (
|
{profile?.organization?.type?.org_type_field === "CO" && (
|
||||||
<Grid>
|
<Grid>
|
||||||
<AutoComplete
|
<AutoComplete
|
||||||
|
|||||||
Reference in New Issue
Block a user