This commit is contained in:
Jake Kasper
2025-08-26 14:16:58 -04:00
parent 2f5355db73
commit dba0951aba

View File

@@ -613,7 +613,24 @@ const ApplicationPlanModal = ({
// Determine application type from the first product // Determine application type from the first product
const firstProduct = editingPlan.products?.[0]; const firstProduct = editingPlan.products?.[0];
const applicationType = firstProduct?.productType === 'granular' ? 'granular' : 'liquid'; let applicationType = 'liquid'; // Default to liquid
if (firstProduct) {
const productType = firstProduct.productType || firstProduct.customProductType;
// Use flexible matching like elsewhere in the codebase
const isGranular = productType && (
productType.toLowerCase().includes('granular') ||
productType.toLowerCase().includes('granule')
);
applicationType = isGranular ? 'granular' : 'liquid';
console.log('Edit plan - application type detection:', {
productType: productType,
isGranular: isGranular,
applicationType: applicationType,
productName: firstProduct.productName
});
}
// Handle different application types // Handle different application types
if (applicationType === 'granular') { if (applicationType === 'granular') {
@@ -721,10 +738,9 @@ const ApplicationPlanModal = ({
try { try {
// Check if spreader setting exists // Check if spreader setting exists
const productApiId = product.isShared ? product.id : product.id;
const endpoint = product.isShared const endpoint = product.isShared
? `/api/product-spreader-settings/product/${productApiId}` ? `/api/product-spreader-settings/product/${product.productId || product.id}`
: `/api/product-spreader-settings/user-product/${productApiId}`; : `/api/product-spreader-settings/user-product/${product.id}`;
const response = await fetch(endpoint, { const response = await fetch(endpoint, {
headers: { headers: {
@@ -744,7 +760,7 @@ const ApplicationPlanModal = ({
if (!existingSetting) { if (!existingSetting) {
// No setting found - prompt user to create one // No setting found - prompt user to create one
setMissingSpreaderSetting({ setMissingSpreaderSetting({
productId: product.isShared ? product.id : null, productId: product.isShared ? (product.productId || product.id) : null,
userProductId: product.isShared ? null : product.id, userProductId: product.isShared ? null : product.id,
equipmentId: selectedEquipment.id, equipmentId: selectedEquipment.id,
productName: product.customName || product.name, productName: product.customName || product.name,