Refactor site building workflow and context handling; update API response structure for improved clarity and consistency. Adjust frontend components to align with new data structure, including error handling and loading states.
This commit is contained in:
@@ -15,6 +15,7 @@ import FormModal, { FormField } from '../../components/common/FormModal';
|
||||
import Alert from '../../components/ui/alert/Alert';
|
||||
import Switch from '../../components/form/switch/Switch';
|
||||
import ViewToggle from '../../components/common/ViewToggle';
|
||||
import ModuleNavigationTabs from '../../components/navigation/ModuleNavigationTabs';
|
||||
import {
|
||||
PlusIcon,
|
||||
PencilIcon,
|
||||
@@ -108,9 +109,13 @@ export default function SiteList() {
|
||||
}
|
||||
} catch (error: any) {
|
||||
// 404 means preferences don't exist yet - that's fine
|
||||
if (error.status !== 404) {
|
||||
console.warn('Failed to load user preferences:', error);
|
||||
// 500 and other errors should be handled silently - user can still use the page
|
||||
if (error?.status === 404) {
|
||||
// Preferences don't exist yet - this is expected for new users
|
||||
return;
|
||||
}
|
||||
// Silently handle other errors (500, network errors, etc.) - don't spam console
|
||||
// User can still use the page without preferences
|
||||
}
|
||||
};
|
||||
|
||||
@@ -166,10 +171,9 @@ export default function SiteList() {
|
||||
allIndustries = allIndustries.filter(i => i.slug === preferences.selectedIndustry);
|
||||
}
|
||||
} catch (error: any) {
|
||||
// 404 means preferences don't exist yet - show all industries
|
||||
if (error.status !== 404) {
|
||||
console.warn('Failed to load user preferences for filtering:', error);
|
||||
}
|
||||
// 404 means preferences don't exist yet - show all industries (expected for new users)
|
||||
// 500 and other errors - show all industries (graceful degradation)
|
||||
// Silently handle errors - user can still use the page
|
||||
}
|
||||
|
||||
setIndustries(allIndustries);
|
||||
@@ -678,6 +682,13 @@ export default function SiteList() {
|
||||
);
|
||||
}
|
||||
|
||||
// Navigation tabs for Sites module
|
||||
const sitesTabs = [
|
||||
{ label: 'All Sites', path: '/sites', icon: <TableIcon className="w-4 h-4" /> },
|
||||
{ label: 'Create Site', path: '/sites/builder', icon: <PlusIcon className="w-4 h-4" /> },
|
||||
{ label: 'Blueprints', path: '/sites/blueprints', icon: <FileIcon className="w-4 h-4" /> },
|
||||
];
|
||||
|
||||
return (
|
||||
<div className="p-6">
|
||||
<PageMeta title="Sites Management - IGNY8" />
|
||||
@@ -687,6 +698,9 @@ export default function SiteList() {
|
||||
hideSiteSector={true}
|
||||
/>
|
||||
|
||||
{/* In-page navigation tabs */}
|
||||
<ModuleNavigationTabs tabs={sitesTabs} />
|
||||
|
||||
{/* Info Alert */}
|
||||
<div className="mb-6">
|
||||
<Alert
|
||||
|
||||
Reference in New Issue
Block a user