UPDATE
This commit is contained in:
@@ -20,23 +20,50 @@ const YieldHarvestPage = () => {
|
||||
const selectionSummary = useMemo(() => {
|
||||
const from = searchParams.get("from");
|
||||
const planType = searchParams.get("planType");
|
||||
const planId = searchParams.get("planId");
|
||||
const planName = searchParams.get("planName");
|
||||
const relatedType = searchParams.get("relatedType");
|
||||
const relatedPlanId = searchParams.get("relatedPlanId");
|
||||
const relatedPlanName = searchParams.get("relatedPlanName");
|
||||
|
||||
if (!from || !planType || !planName || !relatedType || !relatedPlanName) {
|
||||
if (!from || !planType || !planId || !planName || !relatedType || !relatedPlanId || !relatedPlanName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return {
|
||||
from,
|
||||
planType,
|
||||
planId,
|
||||
planName,
|
||||
relatedType,
|
||||
relatedPlanId,
|
||||
relatedPlanName,
|
||||
};
|
||||
}, [searchParams]);
|
||||
|
||||
const planContext = useMemo(() => {
|
||||
if (!selectionSummary) return undefined;
|
||||
|
||||
const context: {
|
||||
irrigationPlanId?: string;
|
||||
fertilizationPlanId?: string;
|
||||
} = {};
|
||||
|
||||
if (selectionSummary.planType === "irrigation") {
|
||||
context.irrigationPlanId = selectionSummary.planId;
|
||||
} else {
|
||||
context.fertilizationPlanId = selectionSummary.planId;
|
||||
}
|
||||
|
||||
if (selectionSummary.relatedType === "irrigation") {
|
||||
context.irrigationPlanId = selectionSummary.relatedPlanId;
|
||||
} else {
|
||||
context.fertilizationPlanId = selectionSummary.relatedPlanId;
|
||||
}
|
||||
|
||||
return context;
|
||||
}, [selectionSummary]);
|
||||
|
||||
const handleBack = () => {
|
||||
const from = selectionSummary?.from;
|
||||
|
||||
@@ -97,7 +124,7 @@ const YieldHarvestPage = () => {
|
||||
</Card>
|
||||
) : null}
|
||||
|
||||
<PlantProductionPage />
|
||||
<PlantProductionPage planContext={planContext} />
|
||||
</Stack>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user