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