diff --git a/src/app/(investment)/invest/[id]/checkoutPage.tsx b/src/app/(investment)/invest/[id]/checkoutPage.tsx
index 5fbdf49..7c6bbb4 100644
--- a/src/app/(investment)/invest/[id]/checkoutPage.tsx
+++ b/src/app/(investment)/invest/[id]/checkoutPage.tsx
@@ -81,7 +81,7 @@ const CheckoutPage = ({
} else {
try {
const supabase = createSupabaseClient();
- const { data, error } = await supabase.from("InvestmentDeal").insert([
+ const { data, error } = await supabase.from("investment_deal").insert([
{
investorId: investor_id,
projectId: project_id,
diff --git a/src/app/page.tsx b/src/app/page.tsx
index eebac2c..4e03c19 100644
--- a/src/app/page.tsx
+++ b/src/app/page.tsx
@@ -25,15 +25,15 @@ const TopProjects = async () => {
{topProjectsData.map((project) => (
item.Tag.value)}
- minInvestment={project.ProjectInvestmentDetail[0]?.minInvestment || 0}
+ name={project.project_name}
+ description={project.project_short_description}
+ imageUri={project.card_image_url}
+ joinDate={new Date(project.published_time).toLocaleDateString()}
+ location={project.business.location}
+ tags={project.item_tag.map((item) => item.tag.value)}
+ minInvestment={project.project_investment_detail[0]?.min_investment || 0}
totalInvestor={0}
- totalRaised={project.ProjectInvestmentDetail[0]?.totalInvestment || 0}
+ totalRaised={project.project_investment_detail[0]?.total_investment || 0}
/>
))}
diff --git a/src/lib/data/dropdownQuery.ts b/src/lib/data/dropdownQuery.ts
index f6ac3dc..2216190 100644
--- a/src/lib/data/dropdownQuery.ts
+++ b/src/lib/data/dropdownQuery.ts
@@ -1,16 +1,15 @@
import { SupabaseClient } from "@supabase/supabase-js";
-
function getAllTagsQuery(client: SupabaseClient) {
- return client.from("Tag").select("id, value");
+ return client.from("tag").select("id, value");
}
function getALlFundedStatusQuery(client: SupabaseClient) {
- return client.from("FundedStatus").select("id, value, description");
+ return client.from("funded_status").select("id, value, description");
}
function getAllBusinessTypeQuery(client: SupabaseClient) {
- return client.from("BusinessType").select("id, value, description");
+ return client.from("business_type").select("id, value, description");
}
-export { getAllTagsQuery, getALlFundedStatusQuery, getAllBusinessTypeQuery };
\ No newline at end of file
+export { getAllBusinessTypeQuery, getALlFundedStatusQuery, getAllTagsQuery };
diff --git a/src/lib/data/projectQuery.ts b/src/lib/data/projectQuery.ts
index ff64ab3..f1a5d3c 100644
--- a/src/lib/data/projectQuery.ts
+++ b/src/lib/data/projectQuery.ts
@@ -6,33 +6,33 @@ async function getTopProjects(
) {
try {
const { data, error } = await client
- .from("Project")
+ .from("project")
.select(
`
id,
- projectName,
- businessId,
- publishedTime,
- projectShortDescription,
- cardImage,
- ProjectInvestmentDetail (
- minInvestment,
- totalInvestment,
- targetInvestment,
- investmentDeadline
+ project_name,
+ business_id,
+ published_time,
+ project_short_description,
+ card_image_url,
+ project_investment_detail (
+ min_investment,
+ total_investment,
+ target_investment,
+ investment_deadline
),
- ItemTag (
- Tag (
+ item_tag (
+ tag (
id,
value
)
),
- Business (
+ business (
location
)
`,
)
- .order("publishedTime", { ascending: false })
+ .order("published_time", { ascending: false })
.limit(numberOfRecords);
if (error) {
@@ -48,20 +48,20 @@ async function getTopProjects(
}
function getProjectDataQuery(client: SupabaseClient, projectId: number) {
- return client.from("Project").select(
+ return client.from("project").select(
`
- project_name:projectName,
- project_short_description:projectShortDescription,
- project_description:projectDescription,
- published_time:publishedTime,
- ...ProjectInvestmentDetail!inner (
- min_investment:minInvestment,
- total_investment:totalInvestment,
- target_investment:targetInvestment,
- investment_deadline:investmentDeadline
+ project_name,
+ project_short_description,
+ project_description,
+ published_time,
+ ...project_investment_detail!inner (
+ min_investment,
+ total_investment,
+ target_investment,
+ investment_deadline
),
- tags:ItemTag!inner (
- ...Tag!inner (
+ tags:item_tag!inner (
+ ...tag!inner (
tag_name:value
)
)
@@ -70,20 +70,20 @@ function getProjectDataQuery(client: SupabaseClient, projectId: number) {
}
async function getProjectData(client: SupabaseClient, projectId: number) {
- const query = client.from("Project").select(
+ const query = client.from("project").select(
`
- project_name:projectName,
- project_short_description:projectShortDescription,
- project_description:projectDescription,
- published_time:publishedTime,
- ...ProjectInvestmentDetail!inner (
- min_investment:minInvestment,
- total_investment:totalInvestment,
- target_investment:targetInvestment,
- investment_deadline:investmentDeadline
+ project_name,
+ project_short_description,
+ project_description,
+ published_time,
+ ...project_investment_detail!inner (
+ min_investment,
+ total_investment,
+ target_investment,
+ investment_deadline
),
- tags:ItemTag!inner (
- ...Tag!inner (
+ tags:item_tag!inner (
+ ...tag!inner (
tag_name:value
)
)
@@ -123,35 +123,35 @@ function searchProjectsQuery(
const start = (page - 1) * pageSize;
const end = start + pageSize - 1;
- let query = client.from("Project").select(
+ let query = client.from("project").select(
`
project_id:id,
- project_name:projectName,
- published_time:publishedTime,
- project_short_description:projectShortDescription,
- card_image_url:cardImage,
- ...ProjectStatus!Project_projectStatusId_fkey!inner (
+ project_name,
+ published_time,
+ project_short_description,
+ card_image_url,
+ ...project_status!project_project_status_id_fkey!inner (
project_status:value
),
- ...ProjectInvestmentDetail!inner (
- min_investment:minInvestment,
- total_investment:totalInvestment,
- target_investment:targetInvestment,
- investment_deadline:investmentDeadline
+ ...project_investment_detail!inner (
+ min_investment,
+ total_investment,
+ target_investment,
+ investment_deadline
),
- tags:ItemTag!inner (
- ...Tag!inner (
+ tags:item_tag!inner (
+ ...tag!inner (
tag_name:value
)
),
- ...Business!inner (
- ...businessType!inner (
+ ...business!inner (
+ ...business_type!inner (
business_type:value
),
business_location:location
)
`,
- ).order("publishedTime", { ascending: false }).range(start, end);
+ ).order("published_time", { ascending: false }).range(start, end);
if (sortByTimeFilter === "all") {
sortByTimeFilter = undefined;
@@ -170,19 +170,19 @@ function searchProjectsQuery(
}
if (searchTerm) {
- query = query.ilike("projectName", `%${searchTerm}%`);
+ query = query.ilike("project_name", `%${searchTerm}%`);
}
if (tagsFilter) {
- query = query.in("ItemTag.Tag.value", tagsFilter);
+ query = query.in("item_tag.tag.value", tagsFilter);
}
if (projectStatus) {
- query = query.eq("ProjectStatus.value", projectStatus);
+ query = query.eq("project_status.value", projectStatus);
}
if (businessTypeFilter) {
- query = query.eq("Business.businessType.value", businessTypeFilter);
+ query = query.eq("business.business_type.value", businessTypeFilter);
}
return query;
diff --git a/src/lib/data/query.ts b/src/lib/data/query.ts
index 2af3209..6689a34 100644
--- a/src/lib/data/query.ts
+++ b/src/lib/data/query.ts
@@ -1,35 +1,44 @@
import { SupabaseClient } from "@supabase/supabase-js";
function getBusinesses(client: SupabaseClient, query: string | null) {
- return client.from("Business").select("id, businessName, joinedDate").ilike("businessName", `%${query}%`);
+ return client.from("business").select("id, business_name, joined_date").ilike(
+ "business_name",
+ `%${query}%`,
+ );
}
function getProjects(client: SupabaseClient, businessIds: string[]) {
return client
- .from("Project")
+ .from("project")
.select(
`
id,
- projectName,
- businessId,
- publishedTime,
- projectShortDescription,
- ProjectInvestmentDetail (
- minInvestment,
- totalInvestment,
- targetInvestment
+ project_name,
+ business_id,
+ published_time,
+ project_short_description,
+ project_investment_detail (
+ min_investment,
+ total_investment,
+ target_investment
)
- `
+ `,
)
- .in("businessId", businessIds);
+ .in("business_id", businessIds);
}
function getTags(client: SupabaseClient, projectIds: string[]) {
- return client.from("ItemTag").select("itemId, Tag (value)").in("itemId", projectIds);
+ return client.from("item_tag").select("item_id, tag (value)").in(
+ "item_id",
+ projectIds,
+ );
}
function getInvestmentCounts(client: SupabaseClient, projectIds: string[]) {
- return client.from("InvestmentDeal").select("*", { count: "exact", head: true }).in("projectId", projectIds);
+ return client.from("investment_deal").select("*", {
+ count: "exact",
+ head: true,
+ }).in("project_id", projectIds);
}
-export { getBusinesses, getProjects, getTags, getInvestmentCounts };
\ No newline at end of file
+export { getBusinesses, getInvestmentCounts, getProjects, getTags };
diff --git a/src/lib/data/userQuery.ts b/src/lib/data/userQuery.ts
index 5ddd8f0..f693786 100644
--- a/src/lib/data/userQuery.ts
+++ b/src/lib/data/userQuery.ts
@@ -3,7 +3,7 @@ import { SupabaseClient } from "@supabase/supabase-js";
async function getUserProfile(client: SupabaseClient, userId: string) {
try {
const { data, error } = await client
- .from("Profiles")
+ .from("profiles")
.select("updated_at, username, full_name, avatar_url, website, bio")
.eq("id", userId)
.single();