asdfa
This commit is contained in:
@@ -245,7 +245,10 @@ const Applications = () => {
|
|||||||
<p className="text-gray-600">Plan, track, and log your lawn applications</p>
|
<p className="text-gray-600">Plan, track, and log your lawn applications</p>
|
||||||
</div>
|
</div>
|
||||||
<button
|
<button
|
||||||
onClick={() => setShowPlanForm(true)}
|
onClick={() => {
|
||||||
|
setSelectedPropertyDetails(null); // Clear previous property data
|
||||||
|
setShowPlanForm(true);
|
||||||
|
}}
|
||||||
className="btn-primary flex items-center gap-2"
|
className="btn-primary flex items-center gap-2"
|
||||||
>
|
>
|
||||||
<PlusIcon className="h-5 w-5" />
|
<PlusIcon className="h-5 w-5" />
|
||||||
@@ -262,7 +265,10 @@ const Applications = () => {
|
|||||||
Start by planning your first lawn application
|
Start by planning your first lawn application
|
||||||
</p>
|
</p>
|
||||||
<button
|
<button
|
||||||
onClick={() => setShowPlanForm(true)}
|
onClick={() => {
|
||||||
|
setSelectedPropertyDetails(null); // Clear previous property data
|
||||||
|
setShowPlanForm(true);
|
||||||
|
}}
|
||||||
className="btn-primary"
|
className="btn-primary"
|
||||||
>
|
>
|
||||||
Plan Your First Application
|
Plan Your First Application
|
||||||
@@ -569,7 +575,7 @@ const ApplicationPlanModal = ({
|
|||||||
|
|
||||||
// Reset form when modal opens fresh (not editing)
|
// Reset form when modal opens fresh (not editing)
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!editingPlan) {
|
if (!editingPlan && showPlanForm) {
|
||||||
setPlanData({
|
setPlanData({
|
||||||
propertyId: '',
|
propertyId: '',
|
||||||
selectedAreas: [],
|
selectedAreas: [],
|
||||||
@@ -582,8 +588,25 @@ const ApplicationPlanModal = ({
|
|||||||
plannedDate: '',
|
plannedDate: '',
|
||||||
notes: ''
|
notes: ''
|
||||||
});
|
});
|
||||||
|
// Also clear property details for new plans to prevent showing previous property's map
|
||||||
|
setSelectedPropertyDetails(null);
|
||||||
}
|
}
|
||||||
}, [editingPlan]);
|
}, [editingPlan, showPlanForm]);
|
||||||
|
|
||||||
|
// Check spreader settings when both product and equipment are selected for granular applications
|
||||||
|
useEffect(() => {
|
||||||
|
if (planData.applicationType === 'granular' &&
|
||||||
|
planData.selectedProduct &&
|
||||||
|
planData.equipmentId &&
|
||||||
|
!editingPlan) { // Only for new plans, not when editing
|
||||||
|
console.log('Triggering spreader setting check from useEffect:', {
|
||||||
|
product: planData.selectedProduct?.customName || planData.selectedProduct?.name,
|
||||||
|
equipmentId: planData.equipmentId,
|
||||||
|
applicationType: planData.applicationType
|
||||||
|
});
|
||||||
|
checkSpreaderSetting(planData.selectedProduct, planData.equipmentId);
|
||||||
|
}
|
||||||
|
}, [planData.applicationType, planData.selectedProduct, planData.equipmentId, editingPlan]);
|
||||||
|
|
||||||
// Initialize form with editing data
|
// Initialize form with editing data
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -668,16 +691,36 @@ const ApplicationPlanModal = ({
|
|||||||
|
|
||||||
// Check for spreader settings when granular product + equipment selected
|
// Check for spreader settings when granular product + equipment selected
|
||||||
const checkSpreaderSetting = async (product, equipmentId) => {
|
const checkSpreaderSetting = async (product, equipmentId) => {
|
||||||
if (!product || !equipmentId ||
|
if (!product || !equipmentId) {
|
||||||
(product.productType !== 'granular' && product.customProductType !== 'granular')) {
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if product is granular (more flexible matching like the product filter)
|
||||||
|
const productType = product.productType || product.customProductType;
|
||||||
|
const isGranular = productType && (
|
||||||
|
productType.toLowerCase().includes('granular') ||
|
||||||
|
productType.toLowerCase().includes('granule')
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!isGranular) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const selectedEquipment = equipment.find(eq => eq.id === parseInt(equipmentId));
|
const selectedEquipment = equipment.find(eq => eq.id === parseInt(equipmentId));
|
||||||
if (!selectedEquipment || selectedEquipment.categoryName !== 'Spreader') {
|
if (!selectedEquipment || selectedEquipment.categoryName !== 'Spreader') {
|
||||||
|
console.log('Spreader setting check skipped - equipment not a spreader:', {
|
||||||
|
selectedEquipment: selectedEquipment?.customName,
|
||||||
|
category: selectedEquipment?.categoryName
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log('Checking spreader setting for:', {
|
||||||
|
product: product.customName || product.name,
|
||||||
|
equipment: selectedEquipment.customName,
|
||||||
|
productType: productType
|
||||||
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Check if spreader setting exists
|
// Check if spreader setting exists
|
||||||
const productApiId = product.isShared ? product.id : product.id;
|
const productApiId = product.isShared ? product.id : product.id;
|
||||||
|
|||||||
Reference in New Issue
Block a user