mirror of
https://github.com/Sosokker/B2D-Ventures.git
synced 2025-12-19 05:54:06 +01:00
fix: fix build fail and eslint
This commit is contained in:
parent
a440110098
commit
2ead19ec67
@ -5,7 +5,6 @@ export type Deal = {
|
|||||||
created_time: Date;
|
created_time: Date;
|
||||||
investor_id: string;
|
investor_id: string;
|
||||||
};
|
};
|
||||||
const supabase = createSupabaseClient();
|
|
||||||
|
|
||||||
export async function getDealList(userId: string | undefined) {
|
export async function getDealList(userId: string | undefined) {
|
||||||
if (!userId) {
|
if (!userId) {
|
||||||
|
|||||||
@ -10,7 +10,7 @@ export function useDealList() {
|
|||||||
const fetchDealList = async () => {
|
const fetchDealList = async () => {
|
||||||
// set the state to the deal list of current business user
|
// set the state to the deal list of current business user
|
||||||
setDealList(await getDealList(await getCurrentUserID()));
|
setDealList(await getDealList(await getCurrentUserID()));
|
||||||
}
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetchDealList();
|
fetchDealList();
|
||||||
@ -28,7 +28,7 @@ export function useGraphData() {
|
|||||||
if (dealList) {
|
if (dealList) {
|
||||||
setGraphData(convertToGraphData(dealList));
|
setGraphData(convertToGraphData(dealList));
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetchGraphData();
|
fetchGraphData();
|
||||||
@ -43,7 +43,7 @@ export function useRecentDealData() {
|
|||||||
const fetchRecentDealData = async () => {
|
const fetchRecentDealData = async () => {
|
||||||
// set the state to the deal list of current business user
|
// set the state to the deal list of current business user
|
||||||
setRecentDealData(await getRecentDealData(await getCurrentUserID()));
|
setRecentDealData(await getRecentDealData(await getCurrentUserID()));
|
||||||
}
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetchRecentDealData();
|
fetchRecentDealData();
|
||||||
|
|||||||
@ -6,18 +6,73 @@ import { Overview } from "@/components/ui/overview";
|
|||||||
import { RecentFunds } from "@/components/recent-funds";
|
import { RecentFunds } from "@/components/recent-funds";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
|
|
||||||
import { useDealList, useGraphData, useRecentDealData } from "./hook";
|
import { useDealList } from "./hook";
|
||||||
import { sumByKey } from "@/lib/utils";
|
|
||||||
|
const data = [
|
||||||
|
{
|
||||||
|
name: "Jan",
|
||||||
|
value: Math.floor(Math.random() * 5000) + 1000,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Feb",
|
||||||
|
value: Math.floor(Math.random() * 5000) + 1000,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Mar",
|
||||||
|
value: Math.floor(Math.random() * 5000) + 1000,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Apr",
|
||||||
|
value: Math.floor(Math.random() * 5000) + 1000,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "May",
|
||||||
|
value: Math.floor(Math.random() * 5000) + 1000,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Jun",
|
||||||
|
value: Math.floor(Math.random() * 5000) + 1000,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Jul",
|
||||||
|
value: Math.floor(Math.random() * 5000) + 1000,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Aug",
|
||||||
|
value: Math.floor(Math.random() * 5000) + 1000,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Sep",
|
||||||
|
value: Math.floor(Math.random() * 5000) + 1000,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Oct",
|
||||||
|
value: Math.floor(Math.random() * 5000) + 1000,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Nov",
|
||||||
|
value: Math.floor(Math.random() * 5000) + 1000,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Dec",
|
||||||
|
value: Math.floor(Math.random() * 5000) + 1000,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
export default function Dashboard() {
|
export default function Dashboard() {
|
||||||
const [graphType, setGraphType] = useState("line");
|
const [graphType, setGraphType] = useState("line");
|
||||||
const graphData = useGraphData();
|
|
||||||
const dealList = useDealList();
|
const dealList = useDealList();
|
||||||
// #TODO dependency injection refactor + define default value inside function (and not here)
|
const totalDealAmount = dealList?.reduce((sum, deal) => sum + deal.deal_amount, 0) || 0;
|
||||||
const recentDealData = useRecentDealData() || [];
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
{dealList?.map((deal, index) => (
|
||||||
|
<div key={index} className="deal-item">
|
||||||
|
<p>Deal Amount: {deal.deal_amount}</p>
|
||||||
|
<p>Created Time: {new Date(deal.created_time).toUTCString()}</p>
|
||||||
|
<p>Investor ID: {deal.investor_id}</p>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
<div className="md:hidden">
|
<div className="md:hidden">
|
||||||
<Image
|
<Image
|
||||||
src="/examples/dashboard-light.png"
|
src="/examples/dashboard-light.png"
|
||||||
@ -63,7 +118,7 @@ export default function Dashboard() {
|
|||||||
</svg>
|
</svg>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardContent>
|
<CardContent>
|
||||||
<div className="text-2xl font-bold">${sumByKey(dealList, "deal_amount")}</div>
|
<div className="text-2xl font-bold">${totalDealAmount}</div>
|
||||||
{/* <p className="text-xs text-muted-foreground">
|
{/* <p className="text-xs text-muted-foreground">
|
||||||
+20.1% from last month
|
+20.1% from last month
|
||||||
</p> */}
|
</p> */}
|
||||||
@ -150,7 +205,7 @@ export default function Dashboard() {
|
|||||||
<CardTitle>Overview</CardTitle>
|
<CardTitle>Overview</CardTitle>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardContent className="pl-2">
|
<CardContent className="pl-2">
|
||||||
<Overview graphType={graphType} graphData={graphData} />
|
<Overview graphType={graphType} data={data} />
|
||||||
{/* tab to switch between line and bar graph */}
|
{/* tab to switch between line and bar graph */}
|
||||||
<Tabs defaultValue="line" className="space-y-4 ml-[50%] mt-2">
|
<Tabs defaultValue="line" className="space-y-4 ml-[50%] mt-2">
|
||||||
<TabsList>
|
<TabsList>
|
||||||
@ -170,7 +225,7 @@ export default function Dashboard() {
|
|||||||
<CardDescription>You made {dealList?.length || 0} sales this month.</CardDescription>
|
<CardDescription>You made {dealList?.length || 0} sales this month.</CardDescription>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardContent>
|
<CardContent>
|
||||||
<RecentFunds recentDealData={recentDealData}></RecentFunds>
|
<RecentFunds></RecentFunds>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -13,7 +13,7 @@ interface Project {
|
|||||||
id: number;
|
id: number;
|
||||||
project_name: string;
|
project_name: string;
|
||||||
project_short_description: string;
|
project_short_description: string;
|
||||||
project_logo: string;
|
card_image_url: string;
|
||||||
published_time: string;
|
published_time: string;
|
||||||
business: { location: string }[];
|
business: { location: string }[];
|
||||||
project_tag: { tag: { id: number; value: string }[] }[];
|
project_tag: { tag: { id: number; value: string }[] }[];
|
||||||
@ -38,7 +38,7 @@ const TopProjects: FC<TopProjectsProps> = ({ projects }) => {
|
|||||||
<ProjectCard
|
<ProjectCard
|
||||||
name={project.project_name}
|
name={project.project_name}
|
||||||
description={project.project_short_description}
|
description={project.project_short_description}
|
||||||
imageUri={project.project_logo}
|
imageUri={project.card_image_url}
|
||||||
joinDate={new Date(project.published_time).toLocaleDateString()}
|
joinDate={new Date(project.published_time).toLocaleDateString()}
|
||||||
location={project.business[0]?.location || ""}
|
location={project.business[0]?.location || ""}
|
||||||
tags={project.project_tag.flatMap((item: { tag: { id: number; value: string }[] }) =>
|
tags={project.project_tag.flatMap((item: { tag: { id: number; value: string }[] }) =>
|
||||||
|
|||||||
@ -115,16 +115,6 @@ function overAllGraphData(deals: Deal[]): GraphData[] {
|
|||||||
return acc;
|
return acc;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Deal {
|
|
||||||
created_time: string | number | Date;
|
|
||||||
deal_amount: any;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface GraphData {
|
|
||||||
name: string;
|
|
||||||
value: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
function fourYearGraphData(deals: Deal[]): GraphData[] {
|
function fourYearGraphData(deals: Deal[]): GraphData[] {
|
||||||
const currentYear = new Date().getFullYear();
|
const currentYear = new Date().getFullYear();
|
||||||
const acc: GraphData[] = Array.from({ length: 4 }, (_, i) => ({
|
const acc: GraphData[] = Array.from({ length: 4 }, (_, i) => ({
|
||||||
|
|||||||
@ -1,8 +1,18 @@
|
|||||||
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";
|
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";
|
||||||
|
|
||||||
|
export type RecentDealData = {
|
||||||
|
created_time: Date;
|
||||||
|
deal_amount: number;
|
||||||
|
investor_id: string;
|
||||||
|
username: string;
|
||||||
|
avatar_url?: string;
|
||||||
|
// email: string;
|
||||||
|
};
|
||||||
|
|
||||||
interface RecentFundsProps {
|
interface RecentFundsProps {
|
||||||
data?: { name?: string; amount?: number; avatar?: string; date?: Date }[];
|
data?: { name?: string; amount?: number; avatar?: string; date?: Date }[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export function RecentFunds(props: RecentFundsProps) {
|
export function RecentFunds(props: RecentFundsProps) {
|
||||||
return (
|
return (
|
||||||
<div className="space-y-8">
|
<div className="space-y-8">
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user