UPDATE
This commit is contained in:
@@ -1,7 +1,361 @@
|
||||
"use client";
|
||||
|
||||
import { useMemo, useState } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
|
||||
import Alert from "@mui/material/Alert";
|
||||
import Box from "@mui/material/Box";
|
||||
import Button from "@mui/material/Button";
|
||||
import Card from "@mui/material/Card";
|
||||
import CardContent from "@mui/material/CardContent";
|
||||
import Chip from "@mui/material/Chip";
|
||||
import Divider from "@mui/material/Divider";
|
||||
import IconButton from "@mui/material/IconButton";
|
||||
import Stack from "@mui/material/Stack";
|
||||
import Table from "@mui/material/Table";
|
||||
import TableBody from "@mui/material/TableBody";
|
||||
import TableCell from "@mui/material/TableCell";
|
||||
import TableContainer from "@mui/material/TableContainer";
|
||||
import TableHead from "@mui/material/TableHead";
|
||||
import TableRow from "@mui/material/TableRow";
|
||||
import Tooltip from "@mui/material/Tooltip";
|
||||
import Typography from "@mui/material/Typography";
|
||||
|
||||
import FertilizationPlanParserPage from "@views/dashboards/farm/fertilizationPlanParser/FertilizationPlanParserPage";
|
||||
import RelatedPlanSelector, {
|
||||
type RelatedPlanItem,
|
||||
} from "@views/dashboards/farm/planSelector/RelatedPlanSelector";
|
||||
|
||||
import CustomTextField from "@core/components/mui/TextField";
|
||||
|
||||
type FertilizationPlanRow = {
|
||||
id: number;
|
||||
planName: string;
|
||||
finalProduct: string;
|
||||
harvestTime: string;
|
||||
outputTon: number;
|
||||
fertilizerType: string;
|
||||
status: "active" | "draft";
|
||||
};
|
||||
|
||||
const mockFertilizationPlans: FertilizationPlanRow[] = [
|
||||
{
|
||||
id: 1,
|
||||
planName: "برنامه کوددهی گوجه فرنگی گلخانهای",
|
||||
finalProduct: "گوجه فرنگی ممتاز",
|
||||
harvestTime: "۱۴۰۴/۰۶/۱۲",
|
||||
outputTon: 52,
|
||||
fertilizerType: "NPK 20-20-20",
|
||||
status: "active",
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
planName: "برنامه کوددهی فلفل دلمهای",
|
||||
finalProduct: "فلفل دلمهای رنگی",
|
||||
harvestTime: "۱۴۰۴/۰۵/۲۰",
|
||||
outputTon: 34,
|
||||
fertilizerType: "نیترات کلسیم",
|
||||
status: "draft",
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
planName: "برنامه کوددهی خیار گلخانهای",
|
||||
finalProduct: "خیار ممتاز صادراتی",
|
||||
harvestTime: "۱۴۰۴/۰۴/۲۸",
|
||||
outputTon: 41,
|
||||
fertilizerType: "سولفات پتاسیم",
|
||||
status: "draft",
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
planName: "برنامه کوددهی هندوانه",
|
||||
finalProduct: "هندوانه شیرین بازارپسند",
|
||||
harvestTime: "۱۴۰۴/۰۵/۲۹",
|
||||
outputTon: 57,
|
||||
fertilizerType: "اوره + هیومیک اسید",
|
||||
status: "draft",
|
||||
},
|
||||
];
|
||||
|
||||
const relatedIrrigationPlans: RelatedPlanItem[] = [
|
||||
{
|
||||
id: 301,
|
||||
title: "آبیاری قطرهای صبحگاهی",
|
||||
finalProduct: "گوجه فرنگی ممتاز",
|
||||
harvestTime: "۱۴۰۴/۰۶/۰۸",
|
||||
outputTon: 45,
|
||||
methodLabel: "روش آبیاری: قطرهای",
|
||||
status: "active",
|
||||
},
|
||||
{
|
||||
id: 302,
|
||||
title: "آبیاری تنظیمشده مرحله گلدهی",
|
||||
finalProduct: "گوجه فرنگی ممتاز",
|
||||
harvestTime: "۱۴۰۴/۰۶/۱۰",
|
||||
outputTon: 49,
|
||||
methodLabel: "روش آبیاری: تیپ",
|
||||
status: "draft",
|
||||
},
|
||||
{
|
||||
id: 303,
|
||||
title: "آبیاری تقویتی پیش از برداشت",
|
||||
finalProduct: "گوجه فرنگی ممتاز",
|
||||
harvestTime: "۱۴۰۴/۰۶/۱۴",
|
||||
outputTon: 53,
|
||||
methodLabel: "روش آبیاری: بارانی سبک",
|
||||
status: "draft",
|
||||
},
|
||||
];
|
||||
|
||||
const FertilizationPlanPage = () => {
|
||||
return <FertilizationPlanParserPage />;
|
||||
const router = useRouter();
|
||||
const [plans, setPlans] = useState(mockFertilizationPlans);
|
||||
const [minOutputTon, setMinOutputTon] = useState("0");
|
||||
const [selectedPlan, setSelectedPlan] = useState<FertilizationPlanRow | null>(
|
||||
mockFertilizationPlans[0],
|
||||
);
|
||||
const [detailsOpen, setDetailsOpen] = useState(false);
|
||||
const [selectedRelatedPlanId, setSelectedRelatedPlanId] = useState<number | null>(
|
||||
relatedIrrigationPlans[0]?.id ?? null,
|
||||
);
|
||||
|
||||
const filteredPlans = useMemo(() => {
|
||||
const minTon = Number(minOutputTon);
|
||||
|
||||
return plans
|
||||
.filter((plan) => plan.outputTon >= minTon)
|
||||
.sort((firstPlan, secondPlan) => secondPlan.outputTon - firstPlan.outputTon);
|
||||
}, [minOutputTon, plans]);
|
||||
|
||||
const handleActivate = (planId: number) => {
|
||||
setPlans((currentPlans) =>
|
||||
currentPlans.map((plan) => ({
|
||||
...plan,
|
||||
status: plan.id === planId ? "active" : "draft",
|
||||
})),
|
||||
);
|
||||
|
||||
const activePlan = plans.find((plan) => plan.id === planId);
|
||||
|
||||
if (activePlan) {
|
||||
setSelectedPlan({ ...activePlan, status: "active" });
|
||||
}
|
||||
};
|
||||
|
||||
const handleDelete = (planId: number) => {
|
||||
setPlans((currentPlans) => currentPlans.filter((plan) => plan.id !== planId));
|
||||
|
||||
if (selectedPlan?.id === planId) {
|
||||
setSelectedPlan(null);
|
||||
setDetailsOpen(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleShowDetails = (plan: FertilizationPlanRow) => {
|
||||
setSelectedPlan(plan);
|
||||
setSelectedRelatedPlanId(relatedIrrigationPlans[0]?.id ?? null);
|
||||
setDetailsOpen(true);
|
||||
};
|
||||
|
||||
const handleConfirmRelatedPlan = (relatedPlan: RelatedPlanItem) => {
|
||||
setDetailsOpen(false);
|
||||
if (!selectedPlan) return;
|
||||
|
||||
const query = new URLSearchParams({
|
||||
from: "fertilization-plan",
|
||||
planType: "fertilization",
|
||||
planId: String(selectedPlan.id),
|
||||
planName: selectedPlan.planName,
|
||||
relatedType: "irrigation",
|
||||
relatedPlanId: String(relatedPlan.id),
|
||||
relatedPlanName: relatedPlan.title,
|
||||
});
|
||||
|
||||
router.push(`/yield-harvest?${query.toString()}`);
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<Stack spacing={6}>
|
||||
<FertilizationPlanParserPage />
|
||||
|
||||
<Card>
|
||||
<CardContent>
|
||||
<Stack spacing={4}>
|
||||
<Stack
|
||||
direction={{ xs: "column", md: "row" }}
|
||||
spacing={3}
|
||||
alignItems={{ xs: "stretch", md: "center" }}
|
||||
justifyContent="space-between"
|
||||
>
|
||||
<Box>
|
||||
<Typography variant="h5">لیست برنامههای کوددهی</Typography>
|
||||
<Typography color="text.secondary">
|
||||
نمایش همه برنامهها با داده ماک و امکان فیلتر بر اساس بیشترین تن خروجی محصول
|
||||
</Typography>
|
||||
</Box>
|
||||
|
||||
<CustomTextField
|
||||
select
|
||||
value={minOutputTon}
|
||||
onChange={(event) => setMinOutputTon(event.target.value)}
|
||||
label="فیلتر تن خروجی محصول"
|
||||
sx={{ minWidth: { xs: "100%", md: 260 } }}
|
||||
SelectProps={{ native: true }}
|
||||
>
|
||||
<option value="0">همه برنامهها</option>
|
||||
<option value="30">بیشتر از ۳۰ تن</option>
|
||||
<option value="40">بیشتر از ۴۰ تن</option>
|
||||
<option value="50">بیشتر از ۵۰ تن</option>
|
||||
</CustomTextField>
|
||||
</Stack>
|
||||
|
||||
<TableContainer>
|
||||
<Table>
|
||||
<TableHead>
|
||||
<TableRow>
|
||||
<TableCell>نام برنامه</TableCell>
|
||||
<TableCell>محصول نهایی</TableCell>
|
||||
<TableCell>زمان برداشت</TableCell>
|
||||
<TableCell>تن خروجی</TableCell>
|
||||
<TableCell>نوع کود</TableCell>
|
||||
<TableCell>وضعیت</TableCell>
|
||||
<TableCell align="center">عملیات</TableCell>
|
||||
</TableRow>
|
||||
</TableHead>
|
||||
<TableBody>
|
||||
{filteredPlans.map((plan) => (
|
||||
<TableRow hover key={plan.id}>
|
||||
<TableCell>{plan.planName}</TableCell>
|
||||
<TableCell>{plan.finalProduct}</TableCell>
|
||||
<TableCell>{plan.harvestTime}</TableCell>
|
||||
<TableCell>{plan.outputTon} تن</TableCell>
|
||||
<TableCell>{plan.fertilizerType}</TableCell>
|
||||
<TableCell>
|
||||
<Chip
|
||||
size="small"
|
||||
label={plan.status === "active" ? "فعال" : "پیشنویس"}
|
||||
color={plan.status === "active" ? "success" : "default"}
|
||||
variant={plan.status === "active" ? "filled" : "tonal"}
|
||||
/>
|
||||
</TableCell>
|
||||
<TableCell align="center">
|
||||
<Stack direction="row" spacing={1} justifyContent="center">
|
||||
<Tooltip title="فعالسازی برنامه">
|
||||
<span>
|
||||
<IconButton
|
||||
color="success"
|
||||
onClick={() => handleActivate(plan.id)}
|
||||
disabled={plan.status === "active"}
|
||||
>
|
||||
<i className="tabler-player-play text-[20px]" />
|
||||
</IconButton>
|
||||
</span>
|
||||
</Tooltip>
|
||||
|
||||
<Tooltip title="مشاهده جزئیات">
|
||||
<IconButton
|
||||
color="primary"
|
||||
onClick={() => handleShowDetails(plan)}
|
||||
>
|
||||
<i className="tabler-eye text-[20px]" />
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
|
||||
<Tooltip title="حذف برنامه">
|
||||
<IconButton
|
||||
color="error"
|
||||
onClick={() => handleDelete(plan.id)}
|
||||
>
|
||||
<i className="tabler-trash text-[20px]" />
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
</Stack>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
|
||||
{filteredPlans.length === 0 ? (
|
||||
<TableRow>
|
||||
<TableCell colSpan={7}>
|
||||
<Alert severity="info">
|
||||
برنامهای با این فیلتر پیدا نشد.
|
||||
</Alert>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
) : null}
|
||||
</TableBody>
|
||||
</Table>
|
||||
</TableContainer>
|
||||
|
||||
<Divider />
|
||||
|
||||
<Stack spacing={2}>
|
||||
<Typography variant="h6">جزئیات برنامه انتخابشده</Typography>
|
||||
|
||||
{selectedPlan ? (
|
||||
<Stack
|
||||
direction={{ xs: "column", md: "row" }}
|
||||
spacing={2}
|
||||
useFlexGap
|
||||
flexWrap="wrap"
|
||||
>
|
||||
<Chip label={`محصول نهایی: ${selectedPlan.finalProduct}`} variant="tonal" />
|
||||
<Chip label={`زمان برداشت: ${selectedPlan.harvestTime}`} variant="tonal" />
|
||||
<Chip label={`تن خروجی: ${selectedPlan.outputTon} تن`} variant="tonal" />
|
||||
<Chip label={`نوع کود: ${selectedPlan.fertilizerType}`} variant="tonal" />
|
||||
<Button
|
||||
variant="outlined"
|
||||
color="primary"
|
||||
startIcon={<i className="tabler-list-details" />}
|
||||
onClick={() => handleShowDetails(selectedPlan)}
|
||||
>
|
||||
مشاهده و انتخاب برنامه آبیاری
|
||||
</Button>
|
||||
<Button
|
||||
variant="contained"
|
||||
color="success"
|
||||
startIcon={<i className="tabler-check" />}
|
||||
onClick={() => handleActivate(selectedPlan.id)}
|
||||
>
|
||||
فعال کردن این برنامه
|
||||
</Button>
|
||||
</Stack>
|
||||
) : (
|
||||
<Alert severity="warning">
|
||||
برای دیدن جزئیات، یکی از برنامههای کوددهی را انتخاب کنید.
|
||||
</Alert>
|
||||
)}
|
||||
</Stack>
|
||||
</Stack>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</Stack>
|
||||
|
||||
{selectedPlan ? (
|
||||
<RelatedPlanSelector
|
||||
open={detailsOpen}
|
||||
onClose={() => setDetailsOpen(false)}
|
||||
title="جزییات برنامه کوددهی"
|
||||
description="برای تکمیل اجرای این برنامه کوددهی، یکی از برنامههای آبیاری مرتبط را انتخاب کنید."
|
||||
currentPlanName={selectedPlan.planName}
|
||||
currentPlanStatus={selectedPlan.status === "active" ? "برنامه فعال" : "آماده برای فعالسازی"}
|
||||
currentPlanOutput={`خروجی هدف: ${selectedPlan.outputTon} تن محصول نهایی`}
|
||||
summaryItems={[
|
||||
{ label: "محصول نهایی", value: selectedPlan.finalProduct },
|
||||
{ label: "زمان برداشت", value: selectedPlan.harvestTime },
|
||||
{ label: "نوع کود", value: selectedPlan.fertilizerType },
|
||||
]}
|
||||
relatedTitle="برنامههای آبیاری پیشنهادی"
|
||||
relatedDescription="از بین برنامههای زیر، مناسبترین برنامه آبیاری را برای این برنامه کوددهی انتخاب کنید."
|
||||
relatedPlans={relatedIrrigationPlans}
|
||||
selectedRelatedPlanId={selectedRelatedPlanId}
|
||||
onSelectRelatedPlan={setSelectedRelatedPlanId}
|
||||
onConfirm={handleConfirmRelatedPlan}
|
||||
/>
|
||||
) : null}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default FertilizationPlanPage;
|
||||
|
||||
@@ -0,0 +1,364 @@
|
||||
"use client";
|
||||
|
||||
import { useMemo, useState } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
|
||||
import Alert from "@mui/material/Alert";
|
||||
import Box from "@mui/material/Box";
|
||||
import Button from "@mui/material/Button";
|
||||
import Card from "@mui/material/Card";
|
||||
import CardContent from "@mui/material/CardContent";
|
||||
import Chip from "@mui/material/Chip";
|
||||
import Divider from "@mui/material/Divider";
|
||||
import IconButton from "@mui/material/IconButton";
|
||||
import Stack from "@mui/material/Stack";
|
||||
import Table from "@mui/material/Table";
|
||||
import TableBody from "@mui/material/TableBody";
|
||||
import TableCell from "@mui/material/TableCell";
|
||||
import TableContainer from "@mui/material/TableContainer";
|
||||
import TableHead from "@mui/material/TableHead";
|
||||
import TableRow from "@mui/material/TableRow";
|
||||
import Tooltip from "@mui/material/Tooltip";
|
||||
import Typography from "@mui/material/Typography";
|
||||
|
||||
import FertilizationPlanParserPage from "@views/dashboards/farm/fertilizationPlanParser/FertilizationPlanParserPage";
|
||||
import RelatedPlanSelector, {
|
||||
type RelatedPlanItem,
|
||||
} from "@views/dashboards/farm/planSelector/RelatedPlanSelector";
|
||||
|
||||
import CustomTextField from "@core/components/mui/TextField";
|
||||
|
||||
type IrrigationPlanRow = {
|
||||
id: number;
|
||||
planName: string;
|
||||
finalProduct: string;
|
||||
harvestTime: string;
|
||||
outputTon: number;
|
||||
irrigationMethod: string;
|
||||
status: "active" | "draft";
|
||||
};
|
||||
|
||||
const mockIrrigationPlans: IrrigationPlanRow[] = [
|
||||
{
|
||||
id: 1,
|
||||
planName: "برنامه آبیاری گوجه فرنگی گلخانهای",
|
||||
finalProduct: "گوجه فرنگی ممتاز",
|
||||
harvestTime: "۱۴۰۴/۰۶/۱۰",
|
||||
outputTon: 48,
|
||||
irrigationMethod: "قطرهای",
|
||||
status: "active",
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
planName: "برنامه آبیاری ذرت علوفهای",
|
||||
finalProduct: "ذرت علوفهای درجه یک",
|
||||
harvestTime: "۱۴۰۴/۰۵/۲۲",
|
||||
outputTon: 36,
|
||||
irrigationMethod: "بارانی",
|
||||
status: "draft",
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
planName: "برنامه آبیاری خیار فضای باز",
|
||||
finalProduct: "خیار صادراتی",
|
||||
harvestTime: "۱۴۰۴/۰۴/۱۸",
|
||||
outputTon: 28,
|
||||
irrigationMethod: "تیپ",
|
||||
status: "draft",
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
planName: "برنامه آبیاری هندوانه",
|
||||
finalProduct: "هندوانه شیرین بازارپسند",
|
||||
harvestTime: "۱۴۰۴/۰۵/۳۰",
|
||||
outputTon: 55,
|
||||
irrigationMethod: "قطرهای",
|
||||
status: "draft",
|
||||
},
|
||||
];
|
||||
|
||||
const relatedFertilizationPlans: RelatedPlanItem[] = [
|
||||
{
|
||||
id: 201,
|
||||
title: "کوددهی آغاز رشد رویشی",
|
||||
finalProduct: "گوجه فرنگی ممتاز",
|
||||
harvestTime: "۱۴۰۴/۰۵/۲۰",
|
||||
outputTon: 42,
|
||||
methodLabel: "نوع کود: NPK 20-20-20",
|
||||
status: "active",
|
||||
},
|
||||
{
|
||||
id: 202,
|
||||
title: "کوددهی تقویت گلدهی",
|
||||
finalProduct: "گوجه فرنگی ممتاز",
|
||||
harvestTime: "۱۴۰۴/۰۶/۰۵",
|
||||
outputTon: 47,
|
||||
methodLabel: "نوع کود: کلسیم بور",
|
||||
status: "draft",
|
||||
},
|
||||
{
|
||||
id: 203,
|
||||
title: "کوددهی پتاس بالا برای رنگگیری",
|
||||
finalProduct: "گوجه فرنگی ممتاز",
|
||||
harvestTime: "۱۴۰۴/۰۶/۱۲",
|
||||
outputTon: 51,
|
||||
methodLabel: "نوع کود: سولفات پتاسیم",
|
||||
status: "draft",
|
||||
},
|
||||
];
|
||||
|
||||
const IrrigationPlanPage = () => {
|
||||
const router = useRouter();
|
||||
const [plans, setPlans] = useState(mockIrrigationPlans);
|
||||
const [minOutputTon, setMinOutputTon] = useState("0");
|
||||
const [selectedPlan, setSelectedPlan] = useState<IrrigationPlanRow | null>(
|
||||
mockIrrigationPlans[0],
|
||||
);
|
||||
const [detailsOpen, setDetailsOpen] = useState(false);
|
||||
const [selectedRelatedPlanId, setSelectedRelatedPlanId] = useState<number | null>(
|
||||
relatedFertilizationPlans[0]?.id ?? null,
|
||||
);
|
||||
|
||||
const filteredPlans = useMemo(() => {
|
||||
const minTon = Number(minOutputTon);
|
||||
|
||||
return plans
|
||||
.filter((plan) => plan.outputTon >= minTon)
|
||||
.sort((firstPlan, secondPlan) => secondPlan.outputTon - firstPlan.outputTon);
|
||||
}, [minOutputTon, plans]);
|
||||
|
||||
const handleActivate = (planId: number) => {
|
||||
setPlans((currentPlans) =>
|
||||
currentPlans.map((plan) => ({
|
||||
...plan,
|
||||
status: plan.id === planId ? "active" : "draft",
|
||||
})),
|
||||
);
|
||||
|
||||
const activePlan = plans.find((plan) => plan.id === planId);
|
||||
|
||||
if (activePlan) {
|
||||
setSelectedPlan({ ...activePlan, status: "active" });
|
||||
}
|
||||
};
|
||||
|
||||
const handleDelete = (planId: number) => {
|
||||
setPlans((currentPlans) => currentPlans.filter((plan) => plan.id !== planId));
|
||||
|
||||
if (selectedPlan?.id === planId) {
|
||||
setSelectedPlan(null);
|
||||
setDetailsOpen(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleShowDetails = (plan: IrrigationPlanRow) => {
|
||||
setSelectedPlan(plan);
|
||||
setSelectedRelatedPlanId(relatedFertilizationPlans[0]?.id ?? null);
|
||||
setDetailsOpen(true);
|
||||
};
|
||||
|
||||
const handleConfirmRelatedPlan = (relatedPlan: RelatedPlanItem) => {
|
||||
setDetailsOpen(false);
|
||||
if (!selectedPlan) return;
|
||||
|
||||
const query = new URLSearchParams({
|
||||
from: "irrigation-plan",
|
||||
planType: "irrigation",
|
||||
planId: String(selectedPlan.id),
|
||||
planName: selectedPlan.planName,
|
||||
relatedType: "fertilization",
|
||||
relatedPlanId: String(relatedPlan.id),
|
||||
relatedPlanName: relatedPlan.title,
|
||||
});
|
||||
|
||||
router.push(`/yield-harvest?${query.toString()}`);
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<Stack spacing={6}>
|
||||
<FertilizationPlanParserPage
|
||||
initialTab="irrigation"
|
||||
enabledTabs={["irrigation"]}
|
||||
/>
|
||||
|
||||
<Card>
|
||||
<CardContent>
|
||||
<Stack spacing={4}>
|
||||
<Stack
|
||||
direction={{ xs: "column", md: "row" }}
|
||||
spacing={3}
|
||||
alignItems={{ xs: "stretch", md: "center" }}
|
||||
justifyContent="space-between"
|
||||
>
|
||||
<Box>
|
||||
<Typography variant="h5">لیست برنامههای آبیاری</Typography>
|
||||
<Typography color="text.secondary">
|
||||
نمایش همه برنامهها با داده ماک و امکان فیلتر بر اساس بیشترین تن خروجی محصول
|
||||
</Typography>
|
||||
</Box>
|
||||
|
||||
<CustomTextField
|
||||
select
|
||||
value={minOutputTon}
|
||||
onChange={(event) => setMinOutputTon(event.target.value)}
|
||||
label="فیلتر تن خروجی محصول"
|
||||
sx={{ minWidth: { xs: "100%", md: 260 } }}
|
||||
SelectProps={{ native: true }}
|
||||
>
|
||||
<option value="0">همه برنامهها</option>
|
||||
<option value="30">بیشتر از ۳۰ تن</option>
|
||||
<option value="40">بیشتر از ۴۰ تن</option>
|
||||
<option value="50">بیشتر از ۵۰ تن</option>
|
||||
</CustomTextField>
|
||||
</Stack>
|
||||
|
||||
<TableContainer>
|
||||
<Table>
|
||||
<TableHead>
|
||||
<TableRow>
|
||||
<TableCell>نام برنامه</TableCell>
|
||||
<TableCell>محصول نهایی</TableCell>
|
||||
<TableCell>زمان برداشت</TableCell>
|
||||
<TableCell>تن خروجی</TableCell>
|
||||
<TableCell>روش آبیاری</TableCell>
|
||||
<TableCell>وضعیت</TableCell>
|
||||
<TableCell align="center">عملیات</TableCell>
|
||||
</TableRow>
|
||||
</TableHead>
|
||||
<TableBody>
|
||||
{filteredPlans.map((plan) => (
|
||||
<TableRow hover key={plan.id}>
|
||||
<TableCell>{plan.planName}</TableCell>
|
||||
<TableCell>{plan.finalProduct}</TableCell>
|
||||
<TableCell>{plan.harvestTime}</TableCell>
|
||||
<TableCell>{plan.outputTon} تن</TableCell>
|
||||
<TableCell>{plan.irrigationMethod}</TableCell>
|
||||
<TableCell>
|
||||
<Chip
|
||||
size="small"
|
||||
label={plan.status === "active" ? "فعال" : "پیشنویس"}
|
||||
color={plan.status === "active" ? "success" : "default"}
|
||||
variant={plan.status === "active" ? "filled" : "tonal"}
|
||||
/>
|
||||
</TableCell>
|
||||
<TableCell align="center">
|
||||
<Stack direction="row" spacing={1} justifyContent="center">
|
||||
<Tooltip title="فعالسازی برنامه">
|
||||
<span>
|
||||
<IconButton
|
||||
color="success"
|
||||
onClick={() => handleActivate(plan.id)}
|
||||
disabled={plan.status === "active"}
|
||||
>
|
||||
<i className="tabler-player-play text-[20px]" />
|
||||
</IconButton>
|
||||
</span>
|
||||
</Tooltip>
|
||||
|
||||
<Tooltip title="مشاهده جزئیات">
|
||||
<IconButton
|
||||
color="primary"
|
||||
onClick={() => handleShowDetails(plan)}
|
||||
>
|
||||
<i className="tabler-eye text-[20px]" />
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
|
||||
<Tooltip title="حذف برنامه">
|
||||
<IconButton
|
||||
color="error"
|
||||
onClick={() => handleDelete(plan.id)}
|
||||
>
|
||||
<i className="tabler-trash text-[20px]" />
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
</Stack>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
|
||||
{filteredPlans.length === 0 ? (
|
||||
<TableRow>
|
||||
<TableCell colSpan={7}>
|
||||
<Alert severity="info">
|
||||
برنامهای با این فیلتر پیدا نشد.
|
||||
</Alert>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
) : null}
|
||||
</TableBody>
|
||||
</Table>
|
||||
</TableContainer>
|
||||
|
||||
<Divider />
|
||||
|
||||
<Stack spacing={2}>
|
||||
<Typography variant="h6">جزئیات برنامه انتخابشده</Typography>
|
||||
|
||||
{selectedPlan ? (
|
||||
<Stack
|
||||
direction={{ xs: "column", md: "row" }}
|
||||
spacing={2}
|
||||
useFlexGap
|
||||
flexWrap="wrap"
|
||||
>
|
||||
<Chip label={`محصول نهایی: ${selectedPlan.finalProduct}`} variant="tonal" />
|
||||
<Chip label={`زمان برداشت: ${selectedPlan.harvestTime}`} variant="tonal" />
|
||||
<Chip label={`تن خروجی: ${selectedPlan.outputTon} تن`} variant="tonal" />
|
||||
<Chip label={`روش آبیاری: ${selectedPlan.irrigationMethod}`} variant="tonal" />
|
||||
<Button
|
||||
variant="outlined"
|
||||
color="primary"
|
||||
startIcon={<i className="tabler-list-details" />}
|
||||
onClick={() => handleShowDetails(selectedPlan)}
|
||||
>
|
||||
مشاهده و انتخاب برنامه کوددهی
|
||||
</Button>
|
||||
<Button
|
||||
variant="contained"
|
||||
color="success"
|
||||
startIcon={<i className="tabler-check" />}
|
||||
onClick={() => handleActivate(selectedPlan.id)}
|
||||
>
|
||||
فعال کردن این برنامه
|
||||
</Button>
|
||||
</Stack>
|
||||
) : (
|
||||
<Alert severity="warning">
|
||||
برای دیدن جزئیات، یکی از برنامههای آبیاری را انتخاب کنید.
|
||||
</Alert>
|
||||
)}
|
||||
</Stack>
|
||||
</Stack>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</Stack>
|
||||
|
||||
{selectedPlan ? (
|
||||
<RelatedPlanSelector
|
||||
open={detailsOpen}
|
||||
onClose={() => setDetailsOpen(false)}
|
||||
title="جزییات برنامه آبیاری"
|
||||
description="برای تکمیل اجرای این برنامه آبیاری، یکی از برنامههای کوددهی مرتبط را انتخاب کنید."
|
||||
currentPlanName={selectedPlan.planName}
|
||||
currentPlanStatus={selectedPlan.status === "active" ? "برنامه فعال" : "آماده برای فعالسازی"}
|
||||
currentPlanOutput={`خروجی هدف: ${selectedPlan.outputTon} تن محصول نهایی`}
|
||||
summaryItems={[
|
||||
{ label: "محصول نهایی", value: selectedPlan.finalProduct },
|
||||
{ label: "زمان برداشت", value: selectedPlan.harvestTime },
|
||||
{ label: "روش آبیاری", value: selectedPlan.irrigationMethod },
|
||||
]}
|
||||
relatedTitle="برنامههای کوددهی پیشنهادی"
|
||||
relatedDescription="از بین برنامههای زیر، مناسبترین برنامه کوددهی را برای این برنامه آبیاری انتخاب کنید."
|
||||
relatedPlans={relatedFertilizationPlans}
|
||||
selectedRelatedPlanId={selectedRelatedPlanId}
|
||||
onSelectRelatedPlan={setSelectedRelatedPlanId}
|
||||
onConfirm={handleConfirmRelatedPlan}
|
||||
/>
|
||||
) : null}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default IrrigationPlanPage;
|
||||
@@ -1,7 +1,105 @@
|
||||
import PlantProductionPage from '@views/dashboards/farm/PlantProductionPage'
|
||||
"use client";
|
||||
|
||||
import { useMemo } from "react";
|
||||
import { useRouter, useSearchParams } from "next/navigation";
|
||||
|
||||
import Box from "@mui/material/Box";
|
||||
import Button from "@mui/material/Button";
|
||||
import Card from "@mui/material/Card";
|
||||
import CardContent from "@mui/material/CardContent";
|
||||
import Chip from "@mui/material/Chip";
|
||||
import Stack from "@mui/material/Stack";
|
||||
import Typography from "@mui/material/Typography";
|
||||
|
||||
import PlantProductionPage from "@views/dashboards/farm/PlantProductionPage";
|
||||
|
||||
const YieldHarvestPage = () => {
|
||||
return <PlantProductionPage />
|
||||
}
|
||||
const router = useRouter();
|
||||
const searchParams = useSearchParams();
|
||||
|
||||
export default YieldHarvestPage
|
||||
const selectionSummary = useMemo(() => {
|
||||
const from = searchParams.get("from");
|
||||
const planType = searchParams.get("planType");
|
||||
const planName = searchParams.get("planName");
|
||||
const relatedType = searchParams.get("relatedType");
|
||||
const relatedPlanName = searchParams.get("relatedPlanName");
|
||||
|
||||
if (!from || !planType || !planName || !relatedType || !relatedPlanName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return {
|
||||
from,
|
||||
planType,
|
||||
planName,
|
||||
relatedType,
|
||||
relatedPlanName,
|
||||
};
|
||||
}, [searchParams]);
|
||||
|
||||
const handleBack = () => {
|
||||
const from = selectionSummary?.from;
|
||||
|
||||
if (from === "irrigation-plan") {
|
||||
router.push("/irrigation-plan");
|
||||
return;
|
||||
}
|
||||
|
||||
if (from === "fertilization-plan") {
|
||||
router.push("/fertilization-plan");
|
||||
return;
|
||||
}
|
||||
|
||||
router.back();
|
||||
};
|
||||
|
||||
return (
|
||||
<Stack spacing={6}>
|
||||
{selectionSummary ? (
|
||||
<Card variant="outlined">
|
||||
<CardContent>
|
||||
<Stack
|
||||
direction={{ xs: "column", md: "row" }}
|
||||
spacing={2}
|
||||
alignItems={{ xs: "stretch", md: "center" }}
|
||||
justifyContent="space-between"
|
||||
>
|
||||
<Box>
|
||||
<Typography variant="h5">تحلیل عملکرد و برداشت</Typography>
|
||||
<Typography color="text.secondary">
|
||||
بر اساس انتخاب برنامهها وارد این صفحه شدهاید.
|
||||
</Typography>
|
||||
</Box>
|
||||
|
||||
<Button
|
||||
variant="outlined"
|
||||
color="secondary"
|
||||
startIcon={<i className="tabler-arrow-right text-[18px]" />}
|
||||
onClick={handleBack}
|
||||
>
|
||||
بازگشت به صفحه قبل
|
||||
</Button>
|
||||
</Stack>
|
||||
|
||||
<Stack direction={{ xs: "column", md: "row" }} spacing={1.5} useFlexGap flexWrap="wrap" sx={{ mt: 3 }}>
|
||||
<Chip
|
||||
variant="tonal"
|
||||
color="primary"
|
||||
label={`برنامه ${selectionSummary.planType === "irrigation" ? "آبیاری" : "کوددهی"}: ${selectionSummary.planName}`}
|
||||
/>
|
||||
<Chip
|
||||
variant="tonal"
|
||||
color="success"
|
||||
label={`برنامه ${selectionSummary.relatedType === "irrigation" ? "آبیاری" : "کوددهی"} انتخابشده: ${selectionSummary.relatedPlanName}`}
|
||||
/>
|
||||
</Stack>
|
||||
</CardContent>
|
||||
</Card>
|
||||
) : null}
|
||||
|
||||
<PlantProductionPage />
|
||||
</Stack>
|
||||
);
|
||||
};
|
||||
|
||||
export default YieldHarvestPage;
|
||||
|
||||
Reference in New Issue
Block a user