afasd
This commit is contained in:
@@ -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 => (
|
||||
<option key={prod.uniqueId || prod.id} value={prod.uniqueId || prod.id}>
|
||||
{prod.name} - {prod.brand}
|
||||
{/* For shared products: use name and brand */}
|
||||
{/* For custom products: use customName or name, and customBrand or brand */}
|
||||
{prod.isShared ?
|
||||
`${prod.name} - ${prod.brand}` :
|
||||
`${prod.customName || prod.baseProductName || prod.name} - ${prod.customBrand || prod.brand || 'Unknown Brand'}`
|
||||
}
|
||||
{prod.isShared === false && ' (Custom)'}
|
||||
</option>
|
||||
))}
|
||||
|
||||
Reference in New Issue
Block a user