asdfasf
This commit is contained in:
@@ -165,7 +165,7 @@ router.get('/plans', async (req, res, next) => {
|
|||||||
console.log('Detected product type:', productType);
|
console.log('Detected product type:', productType);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (productType === 'granular') {
|
if (productType === 'granular' || productType === 'seed') {
|
||||||
// Use equipment_id directly to avoid name-based lookup
|
// Use equipment_id directly to avoid name-based lookup
|
||||||
const equipmentId = plan.equipment_id;
|
const equipmentId = plan.equipment_id;
|
||||||
spreaderSetting = await getSpreaderSettingsForEquipment(
|
spreaderSetting = await getSpreaderSettingsForEquipment(
|
||||||
|
|||||||
@@ -193,7 +193,7 @@ const ApplicationPlanModal = ({
|
|||||||
productBrand: '',
|
productBrand: '',
|
||||||
productType: applicationType,
|
productType: applicationType,
|
||||||
rateAmount: '',
|
rateAmount: '',
|
||||||
rateUnit: applicationType === 'granular' ? 'lb/1000sqft' : 'oz/1000sqft',
|
rateUnit: (applicationType === 'granular' || applicationType === 'seed') ? 'lb/1000sqft' : 'oz/1000sqft',
|
||||||
isUserProduct: false
|
isUserProduct: false
|
||||||
}]);
|
}]);
|
||||||
};
|
};
|
||||||
@@ -213,7 +213,7 @@ const ApplicationPlanModal = ({
|
|||||||
productBrand: '',
|
productBrand: '',
|
||||||
productType: type,
|
productType: type,
|
||||||
rateAmount: '',
|
rateAmount: '',
|
||||||
rateUnit: type === 'granular' ? 'lb/1000sqft' : 'oz/1000sqft',
|
rateUnit: (type === 'granular' || type === 'seed') ? 'lb/1000sqft' : 'oz/1000sqft',
|
||||||
isUserProduct: false
|
isUserProduct: false
|
||||||
}]);
|
}]);
|
||||||
}, 0);
|
}, 0);
|
||||||
@@ -383,7 +383,7 @@ const ApplicationPlanModal = ({
|
|||||||
const calculations = selectedProducts.map(product => {
|
const calculations = selectedProducts.map(product => {
|
||||||
const rateAmount = parseFloat(product.rateAmount) || 0;
|
const rateAmount = parseFloat(product.rateAmount) || 0;
|
||||||
|
|
||||||
if (product.productType === 'granular') {
|
if (product.productType === 'granular' || product.productType === 'seed') {
|
||||||
// Granular calculations - total product needed
|
// Granular calculations - total product needed
|
||||||
const totalProductNeeded = (rateAmount * totalArea) / 1000; // Rate is per 1000 sq ft
|
const totalProductNeeded = (rateAmount * totalArea) / 1000; // Rate is per 1000 sq ft
|
||||||
return {
|
return {
|
||||||
@@ -576,6 +576,17 @@ const ApplicationPlanModal = ({
|
|||||||
/>
|
/>
|
||||||
Granular (Spreader)
|
Granular (Spreader)
|
||||||
</label>
|
</label>
|
||||||
|
<label className="flex items-center">
|
||||||
|
<input
|
||||||
|
type="radio"
|
||||||
|
name="applicationType"
|
||||||
|
value="seed"
|
||||||
|
checked={applicationType === 'seed'}
|
||||||
|
onChange={(e) => handleApplicationTypeChange(e.target.value)}
|
||||||
|
className="mr-2"
|
||||||
|
/>
|
||||||
|
Seed (Spreader)
|
||||||
|
</label>
|
||||||
<label className="flex items-center">
|
<label className="flex items-center">
|
||||||
<input
|
<input
|
||||||
type="radio"
|
type="radio"
|
||||||
@@ -607,7 +618,7 @@ const ApplicationPlanModal = ({
|
|||||||
.filter(eq => {
|
.filter(eq => {
|
||||||
if (!applicationType) return true;
|
if (!applicationType) return true;
|
||||||
// Filter by application type - granular needs Spreader, liquid needs Sprayer
|
// Filter by application type - granular needs Spreader, liquid needs Sprayer
|
||||||
if (applicationType === 'granular') {
|
if (applicationType === 'granular' || applicationType === 'seed') {
|
||||||
return eq.categoryName === 'Spreader';
|
return eq.categoryName === 'Spreader';
|
||||||
} else if (applicationType === 'liquid') {
|
} else if (applicationType === 'liquid') {
|
||||||
return eq.categoryName === 'Sprayer';
|
return eq.categoryName === 'Sprayer';
|
||||||
@@ -713,15 +724,15 @@ const ApplicationPlanModal = ({
|
|||||||
|
|
||||||
// Set default rate unit if no rate was found
|
// Set default rate unit if no rate was found
|
||||||
if (!rateSet) {
|
if (!rateSet) {
|
||||||
if (selectedProduct.productType === 'granular') {
|
if (selectedProduct.productType === 'granular' || selectedProduct.productType === 'seed') {
|
||||||
updateProduct(index, 'rateUnit', 'lb/1000sqft');
|
updateProduct(index, 'rateUnit', 'lb/1000sqft');
|
||||||
} else if (selectedProduct.productType === 'liquid') {
|
} else if (selectedProduct.productType === 'liquid') {
|
||||||
updateProduct(index, 'rateUnit', 'oz/1000sqft');
|
updateProduct(index, 'rateUnit', 'oz/1000sqft');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// For granular products, check if spreader settings exist
|
// For granular or seed products, check if spreader settings exist
|
||||||
if (selectedProduct.productType === 'granular' && selectedEquipmentId) {
|
if ((selectedProduct.productType === 'granular' || selectedProduct.productType === 'seed') && selectedEquipmentId) {
|
||||||
checkSpreaderSettings(selectedProduct, selectedEquipmentId);
|
checkSpreaderSettings(selectedProduct, selectedEquipmentId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -762,11 +773,11 @@ const ApplicationPlanModal = ({
|
|||||||
<div>
|
<div>
|
||||||
<label className="block text-xs text-gray-600 mb-1">Rate Unit</label>
|
<label className="block text-xs text-gray-600 mb-1">Rate Unit</label>
|
||||||
<select
|
<select
|
||||||
value={product.rateUnit || (applicationType === 'granular' ? 'lb/1000sqft' : 'oz/1000sqft')}
|
value={product.rateUnit || ((applicationType === 'granular' || applicationType === 'seed') ? 'lb/1000sqft' : 'oz/1000sqft')}
|
||||||
onChange={(e) => updateProduct(index, 'rateUnit', e.target.value)}
|
onChange={(e) => updateProduct(index, 'rateUnit', e.target.value)}
|
||||||
className="w-full border border-gray-300 rounded px-3 py-2"
|
className="w-full border border-gray-300 rounded px-3 py-2"
|
||||||
>
|
>
|
||||||
{applicationType === 'granular' ? (
|
{(applicationType === 'granular' || applicationType === 'seed') ? (
|
||||||
<>
|
<>
|
||||||
<option value="lb/1000sqft">lb/1000sqft</option>
|
<option value="lb/1000sqft">lb/1000sqft</option>
|
||||||
<option value="oz/1000sqft">oz/1000sqft</option>
|
<option value="oz/1000sqft">oz/1000sqft</option>
|
||||||
@@ -1027,4 +1038,4 @@ const ApplicationPlanModal = ({
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default ApplicationPlanModal;
|
export default ApplicationPlanModal;
|
||||||
|
|||||||
@@ -867,7 +867,7 @@ const Applications = () => {
|
|||||||
),
|
),
|
||||||
rateAmount: parseFloat(item.rateAmount || 1),
|
rateAmount: parseFloat(item.rateAmount || 1),
|
||||||
rateUnit: item.rateUnit || 'oz/1000 sq ft',
|
rateUnit: item.rateUnit || 'oz/1000 sq ft',
|
||||||
applicationType: planData.applicationType
|
applicationType: (planData.applicationType === 'seed' ? 'granular' : planData.applicationType)
|
||||||
}))
|
}))
|
||||||
: [{
|
: [{
|
||||||
...(planData.selectedProduct?.isShared
|
...(planData.selectedProduct?.isShared
|
||||||
@@ -876,7 +876,7 @@ const Applications = () => {
|
|||||||
),
|
),
|
||||||
rateAmount: parseFloat(planData.selectedProduct?.customRateAmount || planData.selectedProduct?.rateAmount || 1),
|
rateAmount: parseFloat(planData.selectedProduct?.customRateAmount || planData.selectedProduct?.rateAmount || 1),
|
||||||
rateUnit: planData.selectedProduct?.customRateUnit || planData.selectedProduct?.rateUnit || 'per 1000sqft',
|
rateUnit: planData.selectedProduct?.customRateUnit || planData.selectedProduct?.rateUnit || 'per 1000sqft',
|
||||||
applicationType: planData.applicationType
|
applicationType: (planData.applicationType === 'seed' ? 'granular' : planData.applicationType)
|
||||||
}]
|
}]
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -924,7 +924,7 @@ const Applications = () => {
|
|||||||
),
|
),
|
||||||
rateAmount: parseFloat(item.rateAmount || 1),
|
rateAmount: parseFloat(item.rateAmount || 1),
|
||||||
rateUnit: item.rateUnit || 'oz/1000 sq ft',
|
rateUnit: item.rateUnit || 'oz/1000 sq ft',
|
||||||
applicationType: planData.applicationType
|
applicationType: (planData.applicationType === 'seed' ? 'granular' : planData.applicationType)
|
||||||
}))
|
}))
|
||||||
: [{
|
: [{
|
||||||
...(planData.selectedProduct?.isShared
|
...(planData.selectedProduct?.isShared
|
||||||
@@ -933,7 +933,7 @@ const Applications = () => {
|
|||||||
),
|
),
|
||||||
rateAmount: parseFloat(planData.selectedProduct?.customRateAmount || planData.selectedProduct?.rateAmount || 1),
|
rateAmount: parseFloat(planData.selectedProduct?.customRateAmount || planData.selectedProduct?.rateAmount || 1),
|
||||||
rateUnit: planData.selectedProduct?.customRateUnit || planData.selectedProduct?.rateUnit || 'per 1000sqft',
|
rateUnit: planData.selectedProduct?.customRateUnit || planData.selectedProduct?.rateUnit || 'per 1000sqft',
|
||||||
applicationType: planData.applicationType
|
applicationType: (planData.applicationType === 'seed' ? 'granular' : planData.applicationType)
|
||||||
}]
|
}]
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user