feat: allocate incentive plan to rancher

This commit is contained in:
2026-02-14 13:20:10 +03:30
parent 468ad9079e
commit ec087e59bc

View File

@@ -1,13 +1,12 @@
import { useEffect, useState } from "react";
import { Popover } from "../components/PopOver/PopOver";
import { Tooltip } from "../components/Tooltip/Tooltip";
import Button from "../components/Button/Button";
import { DeleteButtonForPopOver } from "../components/PopOverButtons/PopOverButtons";
import { useModalStore } from "../context/zustand-store/appStore";
import { useApiRequest } from "../utils/useApiRequest";
import { Grid } from "../components/Grid/Grid";
import Table from "../components/Table/Table";
import { AddIncentivePlan } from "../partials/quota/AddIncentivePlan";
import { LiveStockRancherAllocateIncentivePlan } from "../partials/live-stock/LiveStockRancherAllocateIncentivePlan";
import { useParams } from "@tanstack/react-router";
export default function RancherPlans() {
@@ -34,25 +33,11 @@ export default function RancherPlans() {
item?.livestock_type_name,
item?.allowed_quantity?.toLocaleString(),
<Popover key={i}>
<Tooltip title="ویرایش طرح" position="right">
<Button
page="farmer_plans"
access="Edit-Rancher-Incentive-Plan"
variant="edit"
onClick={() => {
openModal({
title: "ویرایش طرح",
content: <AddIncentivePlan getData={refetch} item={item} />,
});
}}
/>
</Tooltip>
<DeleteButtonForPopOver
page="farmer_plans"
access="Delete-Rancher-Incentive-Plan"
title="از حذف طرح تشویقی اطمینان دارید؟"
api={`/product/web/api/v1/incentive_plan/${item?.id}/`}
api={`/product/web/api/v1/rancher_incentive_plan/${item?.id}/`}
getData={refetch}
/>
</Popover>,
@@ -67,7 +52,6 @@ export default function RancherPlans() {
<Grid container className="items-center gap-2">
<Grid>
<Button
className="hidden"
size="small"
page="farmer_plans"
access="Post-Rancher-Incentive-Plan"
@@ -75,7 +59,12 @@ export default function RancherPlans() {
onClick={() =>
openModal({
title: "تخصیص طرح تشویقی",
content: <AddIncentivePlan getData={refetch} />,
content: (
<LiveStockRancherAllocateIncentivePlan
getData={refetch}
rancher={farmid}
/>
),
})
}
>
@@ -95,13 +84,7 @@ export default function RancherPlans() {
title={`طرح های تشویقی دامدار (${name})`}
isPaginated
count={apiData?.count || 10}
columns={[
"ردیف",
"نام طرح",
"نوع دام",
"تعداد راس مجاز",
// , "عملیات"
]}
columns={["ردیف", "نام طرح", "نوع دام", "تعداد راس مجاز", "عملیات"]}
rows={tableData}
/>
</Grid>