lint stuff
This commit is contained in:
@@ -20,6 +20,8 @@ const ApplicationPlanModal = ({
|
||||
const [selectedNozzleId, setSelectedNozzleId] = useState('');
|
||||
const [selectedProducts, setSelectedProducts] = useState([]);
|
||||
const [applicationType, setApplicationType] = useState('');
|
||||
// Seed-specific scenario
|
||||
const [seedMode, setSeedMode] = useState('overseed');
|
||||
const [plannedDate, setPlannedDate] = useState(new Date().toISOString().split('T')[0]);
|
||||
const [notes, setNotes] = useState('');
|
||||
const [loading, setLoading] = useState(false);
|
||||
@@ -75,16 +77,44 @@ const ApplicationPlanModal = ({
|
||||
|
||||
// Initialize form with editing data if provided
|
||||
useEffect(() => {
|
||||
if (editingPlan) {
|
||||
setSelectedPropertyId(editingPlan.propertyId || '');
|
||||
setSelectedAreas(editingPlan.selectedAreas || []);
|
||||
setSelectedEquipmentId(editingPlan.equipmentId || '');
|
||||
setSelectedNozzleId(editingPlan.nozzleId || '');
|
||||
setSelectedProducts(editingPlan.products || []);
|
||||
setPlannedDate(editingPlan.plannedDate || '');
|
||||
setNotes(editingPlan.notes || '');
|
||||
if (!editingPlan) return;
|
||||
// Property and sections
|
||||
const propId = editingPlan.property?.id || editingPlan.propertyId;
|
||||
if (propId) {
|
||||
setSelectedPropertyId(String(propId));
|
||||
if (onPropertySelect) onPropertySelect(propId);
|
||||
}
|
||||
}, [editingPlan]);
|
||||
const areaIds = (editingPlan.sections || editingPlan.selectedAreas || []).map(s => (typeof s === 'object' ? s.id : s));
|
||||
setSelectedAreas(areaIds);
|
||||
|
||||
// Equipment/nozzle
|
||||
if (editingPlan.equipment?.id || editingPlan.equipmentId) setSelectedEquipmentId(String(editingPlan.equipment?.id || editingPlan.equipmentId));
|
||||
if (editingPlan.nozzle?.id || editingPlan.nozzleId) setSelectedNozzleId(String(editingPlan.nozzle?.id || editingPlan.nozzleId));
|
||||
|
||||
// Date/notes
|
||||
setPlannedDate(editingPlan.plannedDate || new Date().toISOString().split('T')[0]);
|
||||
setNotes(editingPlan.notes || '');
|
||||
|
||||
// Determine application type
|
||||
const ptypes = (editingPlan.products || []).map(p => (p.productType || '').toLowerCase());
|
||||
const derivedType = ptypes.includes('liquid') ? 'liquid' : (ptypes.includes('seed') ? 'seed' : 'granular');
|
||||
setApplicationType(derivedType);
|
||||
if (derivedType === 'seed') setSeedMode('overseed');
|
||||
|
||||
// Map products into modal structure
|
||||
const mapped = (editingPlan.products || []).map(p => ({
|
||||
uniqueId: p.userProductId ? `user_${p.userProductId}` : `shared_${p.productId}`,
|
||||
productId: p.productId || null,
|
||||
userProductId: p.userProductId || null,
|
||||
productName: p.productName,
|
||||
productBrand: p.productBrand,
|
||||
productType: p.productType,
|
||||
rateAmount: p.rateAmount,
|
||||
rateUnit: p.rateUnit,
|
||||
isUserProduct: !!p.userProductId
|
||||
}));
|
||||
setSelectedProducts(mapped);
|
||||
}, [editingPlan, onPropertySelect]);
|
||||
|
||||
// Handle property selection
|
||||
const handlePropertyChange = async (propertyId) => {
|
||||
@@ -201,6 +231,7 @@ const ApplicationPlanModal = ({
|
||||
// Handle application type change
|
||||
const handleApplicationTypeChange = (type) => {
|
||||
setApplicationType(type);
|
||||
if (type === 'seed') setSeedMode('overseed');
|
||||
// Clear products when switching type
|
||||
setSelectedProducts([]);
|
||||
// Add initial product
|
||||
|
||||
Reference in New Issue
Block a user