{
+ const date = new Date(dateString);
+ return date.toLocaleString("default", { month: "long" });
+ };
+
+ const graphData = deals
+ ? deals.map((item) => ({
+ // convert month's index to string
+ name: getMonthName(item.created_time),
+ value: item.deal_amount as number,
+ }))
+ : [];
+
+ return (
+
+ {/* {JSON.stringify(deals)} */}
+ {JSON.stringify(graphData)}
+
+
+ );
+}
diff --git a/src/app/project/apply/page.tsx b/src/app/project/apply/page.tsx
index 204164b..abbb012 100644
--- a/src/app/project/apply/page.tsx
+++ b/src/app/project/apply/page.tsx
@@ -17,7 +17,7 @@ const BUCKET_PITCH_APPLICATION_NAME = "project-application";
export default function ApplyProject() {
const [isSuccess, setIsSuccess] = useState(true);
const onSubmit: SubmitHandler = async (data) => {
- alert("มาแน้ววว");
+ // alert("มาแน้ววว");
await sendApplication(data);
// console.table(data);
// console.log(typeof data["projectPhotos"], data["projectPhotos"]);
diff --git a/src/components/ui/overview.tsx b/src/components/ui/overview.tsx
index dbe45f8..1834549 100644
--- a/src/components/ui/overview.tsx
+++ b/src/components/ui/overview.tsx
@@ -2,109 +2,106 @@
import { Bar, BarChart, ResponsiveContainer, XAxis, YAxis, LineChart, Line } from "recharts";
-const data = [
- {
- name: "Jan",
- total: Math.floor(Math.random() * 5000) + 1000,
- },
- {
- name: "Feb",
- total: Math.floor(Math.random() * 5000) + 1000,
- },
- {
- name: "Mar",
- total: Math.floor(Math.random() * 5000) + 1000,
- },
- {
- name: "Apr",
- total: Math.floor(Math.random() * 5000) + 1000,
- },
- {
- name: "May",
- total: Math.floor(Math.random() * 5000) + 1000,
- },
- {
- name: "Jun",
- total: Math.floor(Math.random() * 5000) + 1000,
- },
- {
- name: "Jul",
- total: Math.floor(Math.random() * 5000) + 1000,
- },
- {
- name: "Aug",
- total: Math.floor(Math.random() * 5000) + 1000,
- },
- {
- name: "Sep",
- total: Math.floor(Math.random() * 5000) + 1000,
- },
- {
- name: "Oct",
- total: Math.floor(Math.random() * 5000) + 1000,
- },
- {
- name: "Nov",
- total: Math.floor(Math.random() * 5000) + 1000,
- },
- {
- name: "Dec",
- total: Math.floor(Math.random() * 5000) + 1000,
- },
-];
+// const data = [
+// {
+// name: "Jan",
+// total: Math.floor(Math.random() * 5000) + 1000,
+// },
+// {
+// name: "Feb",
+// total: Math.floor(Math.random() * 5000) + 1000,
+// },
+// {
+// name: "Mar",
+// total: Math.floor(Math.random() * 5000) + 1000,
+// },
+// {
+// name: "Apr",
+// total: Math.floor(Math.random() * 5000) + 1000,
+// },
+// {
+// name: "May",
+// total: Math.floor(Math.random() * 5000) + 1000,
+// },
+// {
+// name: "Jun",
+// total: Math.floor(Math.random() * 5000) + 1000,
+// },
+// {
+// name: "Jul",
+// total: Math.floor(Math.random() * 5000) + 1000,
+// },
+// {
+// name: "Aug",
+// total: Math.floor(Math.random() * 5000) + 1000,
+// },
+// {
+// name: "Sep",
+// total: Math.floor(Math.random() * 5000) + 1000,
+// },
+// {
+// name: "Oct",
+// total: Math.floor(Math.random() * 5000) + 1000,
+// },
+// {
+// name: "Nov",
+// total: Math.floor(Math.random() * 5000) + 1000,
+// },
+// {
+// name: "Dec",
+// total: Math.floor(Math.random() * 5000) + 1000,
+// },
+// ];
interface OverViewProps{
graphType:string;
+ data: {name: string, value: number}[];
}
export function Overview(props: OverViewProps) {
return (
-
- {props.graphType === 'line' ? (
-
-
- `$${value}`}
- />
-
-
- ) : (
-
-
- `$${value}`}
- />
-
-
- )}
-
- );
+
+ {props.graphType === "line" ? (
+
+
+ `$${value}`}
+ />
+
+
+ ) : (
+
+
+ `$${value}`}
+ />
+
+
+ )}
+
+ );
}
diff --git a/src/lib/data/query.ts b/src/lib/data/query.ts
index 6689a34..da4a9da 100644
--- a/src/lib/data/query.ts
+++ b/src/lib/data/query.ts
@@ -1,10 +1,10 @@
import { SupabaseClient } from "@supabase/supabase-js";
function getBusinesses(client: SupabaseClient, query: string | null) {
- return client.from("business").select("id, business_name, joined_date").ilike(
- "business_name",
- `%${query}%`,
- );
+ return client
+ .from("business")
+ .select("id, business_name, joined_date")
+ .ilike("business_name", `%${query}%`);
}
function getProjects(client: SupabaseClient, businessIds: string[]) {
@@ -22,23 +22,36 @@ function getProjects(client: SupabaseClient, businessIds: string[]) {
total_investment,
target_investment
)
- `,
+ `
)
.in("business_id", businessIds);
}
function getTags(client: SupabaseClient, projectIds: string[]) {
- return client.from("item_tag").select("item_id, tag (value)").in(
- "item_id",
- projectIds,
- );
+ return client
+ .from("item_tag")
+ .select("item_id, tag (value)")
+ .in("item_id", projectIds);
}
function getInvestmentCounts(client: SupabaseClient, projectIds: string[]) {
- return client.from("investment_deal").select("*", {
- count: "exact",
- head: true,
- }).in("project_id", projectIds);
+ return client
+ .from("investment_deal")
+ .select("*", {
+ count: "exact",
+ head: true,
+ })
+ .in("project_id", projectIds);
}
-export { getBusinesses, getInvestmentCounts, getProjects, getTags };
+function getInvestorDeal(client: SupabaseClient, userId: string) {
+ return client.from("investment_deal").select("*").in("investor_id", [userId]);
+}
+
+export {
+ getBusinesses,
+ getInvestmentCounts,
+ getProjects,
+ getTags,
+ getInvestorDeal,
+};