fixes and final pre launch verifcation md
This commit is contained in:
@@ -84,6 +84,10 @@ export default function AIAutomationSettings({ siteId }: AIAutomationSettingsPro
|
||||
const [landscapeImageSize, setLandscapeImageSize] = useState('2560x1440');
|
||||
const [squareImageSize, setSquareImageSize] = useState('2048x2048');
|
||||
|
||||
// Toast ref to avoid dependency issues
|
||||
const toastRef = React.useRef(toast);
|
||||
toastRef.current = toast;
|
||||
|
||||
// Load unified settings
|
||||
const loadSettings = useCallback(async () => {
|
||||
try {
|
||||
@@ -92,11 +96,11 @@ export default function AIAutomationSettings({ siteId }: AIAutomationSettingsPro
|
||||
setSettings(data);
|
||||
} catch (error) {
|
||||
console.error('Failed to load unified settings:', error);
|
||||
toast.error(`Failed to load settings: ${(error as Error).message}`);
|
||||
toastRef.current.error(`Failed to load settings: ${(error as Error).message}`);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
}, [siteId, toast]);
|
||||
}, [siteId]);
|
||||
|
||||
// Load image settings from tenant-wide AI settings API
|
||||
const loadImageSettings = useCallback(async () => {
|
||||
@@ -133,9 +137,13 @@ export default function AIAutomationSettings({ siteId }: AIAutomationSettingsPro
|
||||
try {
|
||||
setSaving(true);
|
||||
|
||||
// Save unified settings
|
||||
const updated = await updateUnifiedSiteSettings(siteId, {
|
||||
automation: settings.automation,
|
||||
// Build payload - only send fields that can be updated (not read-only ones)
|
||||
const payload = {
|
||||
automation: {
|
||||
enabled: settings.automation.enabled,
|
||||
frequency: settings.automation.frequency,
|
||||
time: settings.automation.time,
|
||||
},
|
||||
stages: settings.stages.map(s => ({
|
||||
number: s.number,
|
||||
enabled: s.enabled,
|
||||
@@ -151,7 +159,13 @@ export default function AIAutomationSettings({ siteId }: AIAutomationSettingsPro
|
||||
publish_days: settings.publishing.publish_days,
|
||||
time_slots: settings.publishing.time_slots,
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
console.log('[AIAutomationSettings] Saving payload:', JSON.stringify(payload, null, 2));
|
||||
|
||||
// Save unified settings
|
||||
const updated = await updateUnifiedSiteSettings(siteId, payload);
|
||||
console.log('[AIAutomationSettings] Received updated settings:', JSON.stringify(updated.stages, null, 2));
|
||||
setSettings(updated);
|
||||
|
||||
// Save image settings
|
||||
@@ -165,10 +179,10 @@ export default function AIAutomationSettings({ siteId }: AIAutomationSettingsPro
|
||||
}),
|
||||
});
|
||||
|
||||
toast.success('Settings saved successfully');
|
||||
toastRef.current.success('Settings saved successfully');
|
||||
} catch (error) {
|
||||
console.error('Failed to save settings:', error);
|
||||
toast.error(`Failed to save settings: ${(error as Error).message}`);
|
||||
toastRef.current.error(`Failed to save settings: ${(error as Error).message}`);
|
||||
} finally {
|
||||
setSaving(false);
|
||||
}
|
||||
@@ -178,7 +192,7 @@ export default function AIAutomationSettings({ siteId }: AIAutomationSettingsPro
|
||||
const handleReset = () => {
|
||||
loadSettings();
|
||||
loadImageSettings();
|
||||
toast.info('Settings reset to last saved values');
|
||||
toastRef.current.info('Settings reset to last saved values');
|
||||
};
|
||||
|
||||
// Update automation settings
|
||||
@@ -460,7 +474,7 @@ export default function AIAutomationSettings({ siteId }: AIAutomationSettingsPro
|
||||
<BoltIcon className="w-5 h-5 text-purple-600 dark:text-purple-400" />
|
||||
</div>
|
||||
<div>
|
||||
<h3 className="font-semibold text-gray-900 dark:text-white">Stage Configuration</h3>
|
||||
<h3 className="font-semibold text-gray-900 dark:text-white">Automation Stages Settings</h3>
|
||||
<p className="text-sm text-gray-500">Configure each automation stage</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user