From 9c1564f8748fffbb6e42edfa4add13e4ccc5701e Mon Sep 17 00:00:00 2001 From: THIS ONE IS A LITTLE BIT TRICKY KRUB Date: Sat, 9 Nov 2024 16:00:32 +0700 Subject: [PATCH] feat: add animated count-up for total completed deal amounts on dashboard --- src/app/dashboard/page.tsx | 19 +++++++++++++------ src/app/dashboard/query.ts | 1 - src/app/portfolio/[uid]/page.tsx | 19 ------------------- 3 files changed, 13 insertions(+), 26 deletions(-) delete mode 100644 src/app/dashboard/query.ts diff --git a/src/app/dashboard/page.tsx b/src/app/dashboard/page.tsx index 21f9dd1..2742e29 100644 --- a/src/app/dashboard/page.tsx +++ b/src/app/dashboard/page.tsx @@ -12,6 +12,7 @@ import { Loader } from "@/components/loading/loader"; import { getInvestmentByProjectsIds } from "@/lib/data/investmentQuery"; import { useQuery } from "@supabase-cache-helpers/postgrest-react-query"; import { overAllGraphData, Deal, fourYearGraphData, dayOftheWeekData } from "../portfolio/[uid]/query"; +import CountUp from "react-countup"; export default function Dashboard() { const supabase = createSupabaseClient(); @@ -34,6 +35,7 @@ export default function Dashboard() { const [isSuccess, setIsSuccess] = useState(false); const [graphType, setGraphType] = useState("line"); const [currentProjectId, setCurrentProjectId] = useState(projects[0]?.id); + const investmentDetail = useQuery( getInvestmentByProjectsIds( supabase, @@ -42,11 +44,11 @@ export default function Dashboard() { }) ) ); + let graphData = []; + const filteredData = (investmentDetail?.data || []).filter((deal) => deal.project_id === currentProjectId); const handleTabChange = (tab: string) => { setActiveTab(tab); }; - let graphData = []; - const filteredData = (investmentDetail?.data || []).filter((deal) => deal.project_id === currentProjectId); if (activeTab === "daily") { graphData = dayOftheWeekData(filteredData); @@ -166,10 +168,15 @@ export default function Dashboard() { -
${}
- {/*

- +20.1% from last month -

*/} +
+ $ + project.deal_status === "Completed") + .reduce((sum, current) => sum + current.deal_amount, 0)} + duration={1} + /> +
diff --git a/src/app/dashboard/query.ts b/src/app/dashboard/query.ts deleted file mode 100644 index 8b13789..0000000 --- a/src/app/dashboard/query.ts +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/app/portfolio/[uid]/page.tsx b/src/app/portfolio/[uid]/page.tsx index 8356d48..b154941 100644 --- a/src/app/portfolio/[uid]/page.tsx +++ b/src/app/portfolio/[uid]/page.tsx @@ -52,7 +52,6 @@ export default async function Portfolio({ params }: { params: { uid: string } }) ); } const username = localUser ? localUser.user.user_metadata.name : "Anonymous"; - // console.log(username) const overAllData = deals ? overAllGraphData(deals) : []; const fourYearData = deals ? fourYearGraphData(deals) : []; const dayOfWeekData = deals ? dayOftheWeekData(deals) : []; @@ -66,31 +65,13 @@ export default async function Portfolio({ params }: { params: { uid: string } }) ) : []; const totalInvestment = deals ? getTotalInvestment(deals) : 0; - // console.log(latestDeals); - const tagCount = countTags(tags); - // console.log(investedBusinessIds); const businessType = deals ? await Promise.all(deals.map(async (item) => await getBusinessTypeName(supabase, item.project_id))) : []; const countedBusinessType = countValues(businessType.filter((item) => item !== null)); - // console.log(countedBusinessType); - - // console.log(tagCount); return (
- {/* {JSON.stringify(params.uid)} */} - {/* {JSON.stringify(tagCount)} */} - {/* {JSON.stringify(deals)} */} - {/* {JSON.stringify(dayOfWeekData)} */} - {/* {JSON.stringify(overAllGraphData)} */} - {/* {JSON.stringify(threeYearGraphData)} */} - {/* {JSON.stringify(uniqueProjectIds)} */} - {/*
-

Total Invest :

-
{totalInvest}
-
*/} - {/* */}

Welcome to your Portfolio, {username}!