feat: some ui updates

This commit is contained in:
ivannoskov
2026-01-07 15:46:30 +03:00
parent 3b6b97447b
commit 073be940b5
9 changed files with 840 additions and 722 deletions

View File

@@ -20,7 +20,8 @@ import type {
PermissionKey,
} from "@/lib/types/api";
import { STORAGE_KEYS } from "@/lib/utils/constants";
import { isDemoWorkspace, demoApi, demoWorkspace, demoProjects } from "@/lib/demo";
import { isDemoWorkspace, demoApi, demoWorkspace, demoProjects, DEMO_WORKSPACE_ID } from "@/lib/demo";
import { useAuth } from "@/components/auth/auth-provider";
// ============================================================================
// Types
@@ -96,6 +97,7 @@ export const WorkspaceProvider: React.FC<WorkspaceProviderProps> = ({
const params = useParams();
const router = useRouter();
const pathname = usePathname();
const { user } = useAuth();
// State
const [workspaces, setWorkspaces] = useState<Workspace[]>([]);
@@ -170,12 +172,25 @@ export const WorkspaceProvider: React.FC<WorkspaceProviderProps> = ({
setIsLoading(true);
setError(null);
// Demo mode - use mock data
// Demo mode - use mock data, but also load real workspaces if user is logged in
if (isDemoMode) {
setWorkspaces([demoWorkspace]);
const allWorkspaces: Workspace[] = [demoWorkspace];
// If user is logged in, also load their real workspaces
if (user) {
try {
const response = await workspacesApi.list({ size: 100 });
allWorkspaces.push(...response.items);
} catch (err) {
// If loading real workspaces fails, just use demo workspace
console.warn("Failed to load real workspaces in demo mode:", err);
}
}
setWorkspaces(allWorkspaces);
setCurrentWorkspaceState(demoWorkspace);
setIsLoading(false);
return [demoWorkspace];
return allWorkspaces;
}
const response = await workspacesApi.list({ size: 100 });
@@ -218,7 +233,7 @@ export const WorkspaceProvider: React.FC<WorkspaceProviderProps> = ({
} finally {
setIsLoading(false);
}
}, [workspaceIdFromUrl, pathname, router, isDemoMode]);
}, [workspaceIdFromUrl, pathname, router, isDemoMode, user]);
// ============================================================================
// Load Projects & Permissions