UPDATE
This commit is contained in:
@@ -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