afasd
This commit is contained in:
@@ -615,8 +615,17 @@ const ApplicationPlanModal = ({
|
|||||||
updateProduct(index, 'productId', selectedProduct.isShared ? selectedProduct.id : null);
|
updateProduct(index, 'productId', selectedProduct.isShared ? selectedProduct.id : null);
|
||||||
updateProduct(index, 'userProductId', !selectedProduct.isShared ? selectedProduct.id : null);
|
updateProduct(index, 'userProductId', !selectedProduct.isShared ? selectedProduct.id : null);
|
||||||
updateProduct(index, 'isUserProduct', !selectedProduct.isShared);
|
updateProduct(index, 'isUserProduct', !selectedProduct.isShared);
|
||||||
updateProduct(index, 'productName', selectedProduct.name);
|
// Set product name and brand based on whether it's shared or custom
|
||||||
updateProduct(index, 'productBrand', selectedProduct.brand);
|
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);
|
updateProduct(index, 'productType', selectedProduct.productType);
|
||||||
|
|
||||||
// Pre-populate application rate if available
|
// Pre-populate application rate if available
|
||||||
@@ -624,26 +633,22 @@ const ApplicationPlanModal = ({
|
|||||||
|
|
||||||
let rateSet = false;
|
let rateSet = false;
|
||||||
|
|
||||||
// Check for rates array
|
// For shared products: check rates array
|
||||||
if (selectedProduct.rates && selectedProduct.rates.length > 0) {
|
if (selectedProduct.isShared && selectedProduct.rates && selectedProduct.rates.length > 0) {
|
||||||
const defaultRate = selectedProduct.rates[0];
|
const defaultRate = selectedProduct.rates[0];
|
||||||
updateProduct(index, 'rateAmount', defaultRate.amount);
|
updateProduct(index, 'rateAmount', defaultRate.rateAmount || defaultRate.amount);
|
||||||
updateProduct(index, 'rateUnit', defaultRate.unit);
|
updateProduct(index, 'rateUnit', defaultRate.rateUnit || defaultRate.unit);
|
||||||
rateSet = true;
|
|
||||||
}
|
|
||||||
// Check for applicationRate field (custom products might use this)
|
|
||||||
else if (selectedProduct.applicationRate) {
|
|
||||||
updateProduct(index, 'rateAmount', selectedProduct.applicationRate);
|
|
||||||
rateSet = true;
|
rateSet = true;
|
||||||
}
|
}
|
||||||
// Check for recommendedRate field
|
// For custom products: check customRateAmount and customRateUnit
|
||||||
else if (selectedProduct.recommendedRate) {
|
else if (!selectedProduct.isShared && selectedProduct.customRateAmount) {
|
||||||
updateProduct(index, 'rateAmount', selectedProduct.recommendedRate);
|
updateProduct(index, 'rateAmount', selectedProduct.customRateAmount);
|
||||||
|
updateProduct(index, 'rateUnit', selectedProduct.customRateUnit || (selectedProduct.productType === 'granular' ? 'lb/1000sqft' : 'oz/1000sqft'));
|
||||||
rateSet = true;
|
rateSet = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set default rate unit if no rate was found or if unit wasn't set
|
// Set default rate unit if no rate was found
|
||||||
if (!rateSet || !selectedProduct.rates?.[0]?.unit) {
|
if (!rateSet) {
|
||||||
if (selectedProduct.productType === 'granular') {
|
if (selectedProduct.productType === 'granular') {
|
||||||
updateProduct(index, 'rateUnit', 'lb/1000sqft');
|
updateProduct(index, 'rateUnit', 'lb/1000sqft');
|
||||||
} else if (selectedProduct.productType === 'liquid') {
|
} else if (selectedProduct.productType === 'liquid') {
|
||||||
@@ -665,7 +670,12 @@ const ApplicationPlanModal = ({
|
|||||||
.filter(prod => !applicationType || prod.productType === applicationType)
|
.filter(prod => !applicationType || prod.productType === applicationType)
|
||||||
.map(prod => (
|
.map(prod => (
|
||||||
<option key={prod.uniqueId || prod.id} value={prod.uniqueId || prod.id}>
|
<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)'}
|
{prod.isShared === false && ' (Custom)'}
|
||||||
</option>
|
</option>
|
||||||
))}
|
))}
|
||||||
|
|||||||
Reference in New Issue
Block a user