feat: enhance user experience by optimizing loading times for dashboard components

This commit is contained in:
THIS ONE IS A LITTLE BIT TRICKY KRUB 2024-11-09 15:10:15 +07:00
parent 1c8d68183a
commit 1c46887cef

View File

@ -93,13 +93,13 @@ export default function Dashboard() {
const fetchProjects = async () => {
if (userId) {
const { data, error } = await getProjectByUserId(supabase, userId);
// alert(JSON.stringify(data));
if (error) {
console.error("Error while fetching projects");
}
if (data) {
// set project and current project id
setProjects(data);
// console.table(data);
setCurrentProjectId(data[0].id);
}
} else {
console.error("Error with UserId while fetching projects");
@ -108,8 +108,6 @@ export default function Dashboard() {
};
fetchProjects();
}, [supabase, userId]);
// console.table(projects);
// console.table(latestInvestment);
return (
<div className="container max-w-screen-xl">
@ -135,8 +133,8 @@ export default function Dashboard() {
<div className="flex items-center justify-between space-y-2">
<h2 className="text-3xl font-bold tracking-tight">Business Dashboard</h2>
</div>
<Tabs className="space-y-4">
{projects && projects.length > 0 && (
<Tabs className="space-y-4" defaultValue={projects[0].project_name}>
<TabsList>
{projects.map((project) => (
<TabsTrigger
@ -301,6 +299,7 @@ export default function Dashboard() {
</TabsContent>
))}
</Tabs>
)}
</div>
</div>
</div>