From 074d4094b08b9c2ae5ad00a44267cf805dcda7a9 Mon Sep 17 00:00:00 2001 From: Jake Kasper Date: Thu, 28 Aug 2025 07:54:19 -0500 Subject: [PATCH] afasd --- .../Applications/ApplicationPlanModal.js | 44 ++++++++++++------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/frontend/src/components/Applications/ApplicationPlanModal.js b/frontend/src/components/Applications/ApplicationPlanModal.js index d858c37..7b0ef10 100644 --- a/frontend/src/components/Applications/ApplicationPlanModal.js +++ b/frontend/src/components/Applications/ApplicationPlanModal.js @@ -615,8 +615,17 @@ const ApplicationPlanModal = ({ updateProduct(index, 'productId', selectedProduct.isShared ? selectedProduct.id : null); updateProduct(index, 'userProductId', !selectedProduct.isShared ? selectedProduct.id : null); updateProduct(index, 'isUserProduct', !selectedProduct.isShared); - updateProduct(index, 'productName', selectedProduct.name); - updateProduct(index, 'productBrand', selectedProduct.brand); + // Set product name and brand based on whether it's shared or custom + const productName = selectedProduct.isShared ? + selectedProduct.name : + (selectedProduct.customName || selectedProduct.baseProductName || selectedProduct.name); + + const productBrand = selectedProduct.isShared ? + selectedProduct.brand : + (selectedProduct.customBrand || selectedProduct.brand || 'Unknown Brand'); + + updateProduct(index, 'productName', productName); + updateProduct(index, 'productBrand', productBrand); updateProduct(index, 'productType', selectedProduct.productType); // Pre-populate application rate if available @@ -624,26 +633,22 @@ const ApplicationPlanModal = ({ let rateSet = false; - // Check for rates array - if (selectedProduct.rates && selectedProduct.rates.length > 0) { + // For shared products: check rates array + if (selectedProduct.isShared && selectedProduct.rates && selectedProduct.rates.length > 0) { const defaultRate = selectedProduct.rates[0]; - updateProduct(index, 'rateAmount', defaultRate.amount); - updateProduct(index, 'rateUnit', defaultRate.unit); - rateSet = true; - } - // Check for applicationRate field (custom products might use this) - else if (selectedProduct.applicationRate) { - updateProduct(index, 'rateAmount', selectedProduct.applicationRate); + updateProduct(index, 'rateAmount', defaultRate.rateAmount || defaultRate.amount); + updateProduct(index, 'rateUnit', defaultRate.rateUnit || defaultRate.unit); rateSet = true; } - // Check for recommendedRate field - else if (selectedProduct.recommendedRate) { - updateProduct(index, 'rateAmount', selectedProduct.recommendedRate); + // For custom products: check customRateAmount and customRateUnit + else if (!selectedProduct.isShared && selectedProduct.customRateAmount) { + updateProduct(index, 'rateAmount', selectedProduct.customRateAmount); + updateProduct(index, 'rateUnit', selectedProduct.customRateUnit || (selectedProduct.productType === 'granular' ? 'lb/1000sqft' : 'oz/1000sqft')); rateSet = true; } - // Set default rate unit if no rate was found or if unit wasn't set - if (!rateSet || !selectedProduct.rates?.[0]?.unit) { + // Set default rate unit if no rate was found + if (!rateSet) { if (selectedProduct.productType === 'granular') { updateProduct(index, 'rateUnit', 'lb/1000sqft'); } else if (selectedProduct.productType === 'liquid') { @@ -665,7 +670,12 @@ const ApplicationPlanModal = ({ .filter(prod => !applicationType || prod.productType === applicationType) .map(prod => ( ))}