dfa
This commit is contained in:
@@ -613,7 +613,24 @@ const ApplicationPlanModal = ({
|
||||
|
||||
// Determine application type from the first product
|
||||
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
|
||||
if (applicationType === 'granular') {
|
||||
@@ -721,10 +738,9 @@ const ApplicationPlanModal = ({
|
||||
|
||||
try {
|
||||
// Check if spreader setting exists
|
||||
const productApiId = product.isShared ? product.id : product.id;
|
||||
const endpoint = product.isShared
|
||||
? `/api/product-spreader-settings/product/${productApiId}`
|
||||
: `/api/product-spreader-settings/user-product/${productApiId}`;
|
||||
? `/api/product-spreader-settings/product/${product.productId || product.id}`
|
||||
: `/api/product-spreader-settings/user-product/${product.id}`;
|
||||
|
||||
const response = await fetch(endpoint, {
|
||||
headers: {
|
||||
@@ -744,7 +760,7 @@ const ApplicationPlanModal = ({
|
||||
if (!existingSetting) {
|
||||
// No setting found - prompt user to create one
|
||||
setMissingSpreaderSetting({
|
||||
productId: product.isShared ? product.id : null,
|
||||
productId: product.isShared ? (product.productId || product.id) : null,
|
||||
userProductId: product.isShared ? null : product.id,
|
||||
equipmentId: selectedEquipment.id,
|
||||
productName: product.customName || product.name,
|
||||
|
||||
Reference in New Issue
Block a user