mirror of
https://github.com/Sosokker/B2D-Ventures.git
synced 2025-12-18 21:44:06 +01:00
feat: enhance user experience by optimizing loading times for dashboard components
This commit is contained in:
parent
1c8d68183a
commit
1c46887cef
@ -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,95 +133,95 @@ 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">
|
||||
<TabsList>
|
||||
{projects && projects.length > 0 && (
|
||||
<Tabs className="space-y-4" defaultValue={projects[0].project_name}>
|
||||
<TabsList>
|
||||
{projects.map((project) => (
|
||||
<TabsTrigger
|
||||
key={project.id}
|
||||
value={project.project_name}
|
||||
onClick={() => setCurrentProjectId(project.id)}
|
||||
>
|
||||
{project.project_name}
|
||||
</TabsTrigger>
|
||||
))}
|
||||
</TabsList>
|
||||
{projects.map((project) => (
|
||||
<TabsTrigger
|
||||
key={project.id}
|
||||
value={project.project_name}
|
||||
onClick={() => setCurrentProjectId(project.id)}
|
||||
>
|
||||
{project.project_name}
|
||||
</TabsTrigger>
|
||||
))}
|
||||
</TabsList>
|
||||
{projects.map((project) => (
|
||||
<TabsContent value={project.project_name} className="space-y-4">
|
||||
<div className="grid gap-4 md:grid-cols-2 lg:grid-cols-4">
|
||||
<Card>
|
||||
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
|
||||
<CardTitle className="text-sm font-medium">Total Funds Raised</CardTitle>
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
strokeWidth="2"
|
||||
className="h-4 w-4 text-muted-foreground"
|
||||
>
|
||||
<path d="M12 2v20M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6" />
|
||||
</svg>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<div className="text-2xl font-bold">${}</div>
|
||||
{/* <p className="text-xs text-muted-foreground">
|
||||
<TabsContent value={project.project_name} className="space-y-4">
|
||||
<div className="grid gap-4 md:grid-cols-2 lg:grid-cols-4">
|
||||
<Card>
|
||||
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
|
||||
<CardTitle className="text-sm font-medium">Total Funds Raised</CardTitle>
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
strokeWidth="2"
|
||||
className="h-4 w-4 text-muted-foreground"
|
||||
>
|
||||
<path d="M12 2v20M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6" />
|
||||
</svg>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<div className="text-2xl font-bold">${}</div>
|
||||
{/* <p className="text-xs text-muted-foreground">
|
||||
+20.1% from last month
|
||||
</p> */}
|
||||
</CardContent>
|
||||
</Card>
|
||||
<Card>
|
||||
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
|
||||
<CardTitle className="text-sm font-medium">Profile Views</CardTitle>
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
strokeWidth="2"
|
||||
className="h-4 w-4 text-muted-foreground"
|
||||
>
|
||||
<path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"></path>
|
||||
<circle cx="12" cy="12" r="3"></circle>
|
||||
</svg>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<div className="text-2xl font-bold">+2350</div>
|
||||
{/* <p className="text-xs text-muted-foreground">
|
||||
</CardContent>
|
||||
</Card>
|
||||
<Card>
|
||||
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
|
||||
<CardTitle className="text-sm font-medium">Profile Views</CardTitle>
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
strokeWidth="2"
|
||||
className="h-4 w-4 text-muted-foreground"
|
||||
>
|
||||
<path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"></path>
|
||||
<circle cx="12" cy="12" r="3"></circle>
|
||||
</svg>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<div className="text-2xl font-bold">+2350</div>
|
||||
{/* <p className="text-xs text-muted-foreground">
|
||||
+180.1% from last month
|
||||
</p> */}
|
||||
</CardContent>
|
||||
</Card>
|
||||
<Card>
|
||||
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
|
||||
<CardTitle className="text-sm font-medium">Total Followers</CardTitle>
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
strokeWidth="2"
|
||||
className="h-4 w-4 text-muted-foreground"
|
||||
>
|
||||
<path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2" />
|
||||
<circle cx="9" cy="7" r="4" />
|
||||
<path d="M22 21v-2a4 4 0 0 0-3-3.87M16 3.13a4 4 0 0 1 0 7.75" />
|
||||
</svg>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<div className="text-2xl font-bold">+12,234</div>
|
||||
{/* <p className="text-xs text-muted-foreground">
|
||||
</CardContent>
|
||||
</Card>
|
||||
<Card>
|
||||
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
|
||||
<CardTitle className="text-sm font-medium">Total Followers</CardTitle>
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
strokeWidth="2"
|
||||
className="h-4 w-4 text-muted-foreground"
|
||||
>
|
||||
<path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2" />
|
||||
<circle cx="9" cy="7" r="4" />
|
||||
<path d="M22 21v-2a4 4 0 0 0-3-3.87M16 3.13a4 4 0 0 1 0 7.75" />
|
||||
</svg>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<div className="text-2xl font-bold">+12,234</div>
|
||||
{/* <p className="text-xs text-muted-foreground">
|
||||
+19% from last month
|
||||
</p> */}
|
||||
</CardContent>
|
||||
</Card>
|
||||
{/* <Card>
|
||||
</CardContent>
|
||||
</Card>
|
||||
{/* <Card>
|
||||
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
|
||||
<CardTitle className="text-sm font-medium">
|
||||
Active Now
|
||||
@ -248,59 +246,60 @@ export default function Dashboard() {
|
||||
</p>
|
||||
</CardContent>
|
||||
</Card> */}
|
||||
</div>
|
||||
<div className="grid gap-4 md:grid-cols-2 lg:grid-cols-7">
|
||||
<Card className="col-span-4">
|
||||
<CardHeader>
|
||||
<CardTitle>Overview</CardTitle>
|
||||
</CardHeader>
|
||||
<Tabs value={activeTab} onValueChange={handleTabChange} className="w-full">
|
||||
<TabsList className="grid w-56 grid-cols-3 ml-5">
|
||||
{tabOptions.map((tab) => (
|
||||
<TabsTrigger key={tab} value={tab}>
|
||||
{tab.charAt(0).toUpperCase() + tab.slice(1)}
|
||||
</TabsTrigger>
|
||||
))}
|
||||
</TabsList>
|
||||
<CardContent className="pl-2 mt-5">
|
||||
<Overview graphType={graphType} data={graphData} />
|
||||
</div>
|
||||
<div className="grid gap-4 md:grid-cols-2 lg:grid-cols-7">
|
||||
<Card className="col-span-4">
|
||||
<CardHeader>
|
||||
<CardTitle>Overview</CardTitle>
|
||||
</CardHeader>
|
||||
<Tabs value={activeTab} onValueChange={handleTabChange} className="w-full">
|
||||
<TabsList className="grid w-56 grid-cols-3 ml-5">
|
||||
{tabOptions.map((tab) => (
|
||||
<TabsTrigger key={tab} value={tab}>
|
||||
{tab.charAt(0).toUpperCase() + tab.slice(1)}
|
||||
</TabsTrigger>
|
||||
))}
|
||||
</TabsList>
|
||||
<CardContent className="pl-2 mt-5">
|
||||
<Overview graphType={graphType} data={graphData} />
|
||||
|
||||
<Tabs defaultValue="line" className="space-y-4 ml-[50%] mt-2">
|
||||
<TabsList>
|
||||
<TabsTrigger value="line" onClick={() => setGraphType("line")}>
|
||||
Line
|
||||
</TabsTrigger>
|
||||
<TabsTrigger value="bar" onClick={() => setGraphType("bar")}>
|
||||
Bar
|
||||
</TabsTrigger>
|
||||
</TabsList>
|
||||
</Tabs>
|
||||
<Tabs defaultValue="line" className="space-y-4 ml-[50%] mt-2">
|
||||
<TabsList>
|
||||
<TabsTrigger value="line" onClick={() => setGraphType("line")}>
|
||||
Line
|
||||
</TabsTrigger>
|
||||
<TabsTrigger value="bar" onClick={() => setGraphType("bar")}>
|
||||
Bar
|
||||
</TabsTrigger>
|
||||
</TabsList>
|
||||
</Tabs>
|
||||
</CardContent>
|
||||
</Tabs>
|
||||
</Card>
|
||||
<Card className="col-span-3">
|
||||
<CardHeader>
|
||||
<CardTitle>Recent Funds</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<RecentFunds
|
||||
data={latestInvestment.map((item) => {
|
||||
return {
|
||||
name: item.username,
|
||||
amount: item.dealAmount,
|
||||
avatar: item.avatarUrl,
|
||||
date: new Date(item.createdTime),
|
||||
status: item.dealStatus,
|
||||
profile_url: `/profile/${item.investorId}`,
|
||||
};
|
||||
})}
|
||||
/>
|
||||
</CardContent>
|
||||
</Tabs>
|
||||
</Card>
|
||||
<Card className="col-span-3">
|
||||
<CardHeader>
|
||||
<CardTitle>Recent Funds</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<RecentFunds
|
||||
data={latestInvestment.map((item) => {
|
||||
return {
|
||||
name: item.username,
|
||||
amount: item.dealAmount,
|
||||
avatar: item.avatarUrl,
|
||||
date: new Date(item.createdTime),
|
||||
status: item.dealStatus,
|
||||
profile_url: `/profile/${item.investorId}`,
|
||||
};
|
||||
})}
|
||||
/>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
</TabsContent>
|
||||
))}
|
||||
</Tabs>
|
||||
</Card>
|
||||
</div>
|
||||
</TabsContent>
|
||||
))}
|
||||
</Tabs>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user