edit
This commit is contained in:
@@ -826,9 +826,14 @@ const EditProductModal = ({ product, onSubmit, onCancel, sharedProducts, categor
|
||||
// Load existing spreader settings when modal opens
|
||||
useEffect(() => {
|
||||
const loadSpreaderSettings = async () => {
|
||||
console.log('Loading spreader settings for product:', product);
|
||||
console.log('Product type:', product.productType);
|
||||
console.log('Product ID:', product.id);
|
||||
|
||||
if (product.productType === 'granular' && product.id) {
|
||||
setLoadingSettings(true);
|
||||
try {
|
||||
console.log('Fetching spreader settings from:', `/api/product-spreader-settings/user-product/${product.id}`);
|
||||
const response = await fetch(`/api/product-spreader-settings/user-product/${product.id}`, {
|
||||
headers: {
|
||||
'Authorization': `Bearer ${localStorage.getItem('token')}`
|
||||
@@ -836,13 +841,18 @@ const EditProductModal = ({ product, onSubmit, onCancel, sharedProducts, categor
|
||||
});
|
||||
if (response.ok) {
|
||||
const data = await response.json();
|
||||
console.log('Received spreader settings data:', data);
|
||||
setEditSpreaderSettings(data.data?.settings || []);
|
||||
} else {
|
||||
console.error('Failed to fetch spreader settings:', response.status, response.statusText);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Failed to load spreader settings:', error);
|
||||
} finally {
|
||||
setLoadingSettings(false);
|
||||
}
|
||||
} else {
|
||||
console.log('Not loading spreader settings - conditions not met');
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1291,6 +1301,7 @@ const EditProductModal = ({ product, onSubmit, onCancel, sharedProducts, categor
|
||||
<label className="label">Spreader Settings</label>
|
||||
<div className="border border-gray-200 rounded-lg p-4 space-y-3">
|
||||
{/* Existing spreader settings */}
|
||||
{console.log('Rendering existing spreader settings:', editSpreaderSettings)}
|
||||
{editSpreaderSettings.length > 0 && (
|
||||
<div className="space-y-2">
|
||||
<h4 className="text-sm font-medium text-gray-700 mb-2">Current Settings:</h4>
|
||||
|
||||
Reference in New Issue
Block a user