mirror of
https://github.com/Sosokker/B2D-Ventures.git
synced 2025-12-20 06:24:06 +01:00
Refactor component and page structure for responsiveness and add remote image patterns
This commit is contained in:
parent
0e1b6c9535
commit
6ba242719c
@ -1,8 +1,39 @@
|
|||||||
"use client";
|
"use client";
|
||||||
import { Input } from "@/components/ui/input";
|
import { Input } from "@/components/ui/input";
|
||||||
import { Label } from "@/components/ui/label";
|
import { Label } from "@/components/ui/label";
|
||||||
|
import {
|
||||||
|
Select,
|
||||||
|
SelectContent,
|
||||||
|
SelectGroup,
|
||||||
|
SelectItem,
|
||||||
|
SelectLabel,
|
||||||
|
SelectTrigger,
|
||||||
|
SelectValue,
|
||||||
|
} from "@/components/ui/select";
|
||||||
|
import { createSupabaseClient } from "@/lib/supabase/clientComponentClient";
|
||||||
|
import { useEffect, useState } from "react";
|
||||||
|
|
||||||
export default function Apply() {
|
export default function Apply() {
|
||||||
|
let supabase = createSupabaseClient();
|
||||||
|
const [industry, setIndustry] = useState<string[]>([]);
|
||||||
|
|
||||||
|
const fetchIndustry = async () => {
|
||||||
|
let { data: BusinessType, error } = await supabase
|
||||||
|
.from("BusinessType")
|
||||||
|
.select("value");
|
||||||
|
|
||||||
|
if (error) {
|
||||||
|
console.error(error);
|
||||||
|
} else {
|
||||||
|
if (BusinessType) {
|
||||||
|
console.table();
|
||||||
|
setIndustry(BusinessType.map((item) => item.value));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
useEffect(() => {
|
||||||
|
fetchIndustry();
|
||||||
|
}, []);
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<div className="grid grid-flow-row auto-rows-max w-full h-52 md:h-92 bg-gray-100 dark:bg-gray-800 p-5">
|
<div className="grid grid-flow-row auto-rows-max w-full h-52 md:h-92 bg-gray-100 dark:bg-gray-800 p-5">
|
||||||
@ -27,10 +58,30 @@ export default function Apply() {
|
|||||||
</p>
|
</p>
|
||||||
{/* form */}
|
{/* form */}
|
||||||
<div className="ml-96 mt-5">
|
<div className="ml-96 mt-5">
|
||||||
|
{/* company name */}
|
||||||
<Label htmlFor="companyName" className="font-bold text-lg">
|
<Label htmlFor="companyName" className="font-bold text-lg">
|
||||||
Company name
|
Company name
|
||||||
</Label>
|
</Label>
|
||||||
<Input type="email" id="companyName" className="mt-2 w-96" />
|
<Input type="text" id="companyName" className="mt-2 w-96" />
|
||||||
|
<div className="mt-5">
|
||||||
|
{/* industry */}
|
||||||
|
<Label htmlFor="industry" className="font-bold text-lg mt-10">
|
||||||
|
Industry
|
||||||
|
</Label>
|
||||||
|
<Select>
|
||||||
|
<SelectTrigger className="w-[180px]">
|
||||||
|
<SelectValue placeholder="Select an industry" />
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
<SelectGroup>
|
||||||
|
<SelectLabel>Industry</SelectLabel>
|
||||||
|
{industry.map((i) => (
|
||||||
|
<SelectItem value={i}>{i}</SelectItem>
|
||||||
|
))}
|
||||||
|
</SelectGroup>
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -3,12 +3,17 @@
|
|||||||
import { useSearchParams } from "next/navigation";
|
import { useSearchParams } from "next/navigation";
|
||||||
import { SupabaseClient } from "@supabase/supabase-js";
|
import { SupabaseClient } from "@supabase/supabase-js";
|
||||||
import { createSupabaseClient } from "@/lib/supabase/clientComponentClient";
|
import { createSupabaseClient } from "@/lib/supabase/clientComponentClient";
|
||||||
import { dehydrate, HydrationBoundary, QueryClient } from "@tanstack/react-query";
|
|
||||||
import { useQuery } from "@supabase-cache-helpers/postgrest-react-query";
|
import { useQuery } from "@supabase-cache-helpers/postgrest-react-query";
|
||||||
import { ReactQueryDevtools } from "@tanstack/react-query-devtools";
|
import { ReactQueryDevtools } from "@tanstack/react-query-devtools";
|
||||||
import { ExtendableCard } from "@/components/extendableCard";
|
import { ExtendableCard } from "@/components/extendableCard";
|
||||||
import { Separator } from "@/components/ui/separator";
|
import { Separator } from "@/components/ui/separator";
|
||||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
|
import {
|
||||||
|
Card,
|
||||||
|
CardContent,
|
||||||
|
CardDescription,
|
||||||
|
CardHeader,
|
||||||
|
CardTitle,
|
||||||
|
} from "@/components/ui/card";
|
||||||
|
|
||||||
interface ProjectInvestmentDetail {
|
interface ProjectInvestmentDetail {
|
||||||
minInvestment: number;
|
minInvestment: number;
|
||||||
@ -35,7 +40,10 @@ interface Business {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getBusinesses(client: SupabaseClient, query: string | null) {
|
function getBusinesses(client: SupabaseClient, query: string | null) {
|
||||||
return client.from("Business").select("id, businessName, joinedDate").ilike("businessName", `%${query}%`);
|
return client
|
||||||
|
.from("Business")
|
||||||
|
.select("id, businessName, joinedDate")
|
||||||
|
.ilike("businessName", `%${query}%`);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getProjects(client: SupabaseClient, businessIds: string[]) {
|
function getProjects(client: SupabaseClient, businessIds: string[]) {
|
||||||
@ -59,11 +67,17 @@ function getProjects(client: SupabaseClient, businessIds: string[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getTags(client: SupabaseClient, projectIds: string[]) {
|
function getTags(client: SupabaseClient, projectIds: string[]) {
|
||||||
return client.from("ItemTag").select("itemId, Tag (value)").in("itemId", projectIds);
|
return client
|
||||||
|
.from("ItemTag")
|
||||||
|
.select("itemId, Tag (value)")
|
||||||
|
.in("itemId", projectIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getInvestmentCounts(client: SupabaseClient, projectIds: string[]) {
|
function getInvestmentCounts(client: SupabaseClient, projectIds: string[]) {
|
||||||
return client.from("InvestmentDeal").select("*", { count: "exact", head: true }).in("projectId", projectIds);
|
return client
|
||||||
|
.from("InvestmentDeal")
|
||||||
|
.select("*", { count: "exact", head: true })
|
||||||
|
.in("projectId", projectIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function Find() {
|
export default function Find() {
|
||||||
@ -84,24 +98,34 @@ export default function Find() {
|
|||||||
data: projects,
|
data: projects,
|
||||||
isLoading: isLoadingProjects,
|
isLoading: isLoadingProjects,
|
||||||
error: projectError,
|
error: projectError,
|
||||||
} = useQuery(getProjects(supabase, businessIds), { enabled: businessIds.length > 0 });
|
} = useQuery(getProjects(supabase, businessIds), {
|
||||||
|
enabled: businessIds.length > 0,
|
||||||
|
});
|
||||||
|
|
||||||
const projectIds = projects?.map((p) => p.id) || [];
|
const projectIds = projects?.map((p) => p.id) || [];
|
||||||
const {
|
const {
|
||||||
data: tags,
|
data: tags,
|
||||||
isLoading: isLoadingTags,
|
isLoading: isLoadingTags,
|
||||||
error: tagError,
|
error: tagError,
|
||||||
} = useQuery(getTags(supabase, projectIds), { enabled: projectIds.length > 0 });
|
} = useQuery(getTags(supabase, projectIds), {
|
||||||
|
enabled: projectIds.length > 0,
|
||||||
|
});
|
||||||
|
|
||||||
const {
|
const {
|
||||||
data: investmentCounts,
|
data: investmentCounts,
|
||||||
isLoading: isLoadingInvestments,
|
isLoading: isLoadingInvestments,
|
||||||
error: investmentError,
|
error: investmentError,
|
||||||
} = useQuery(getInvestmentCounts(supabase, projectIds), { enabled: projectIds.length > 0 });
|
} = useQuery(getInvestmentCounts(supabase, projectIds), {
|
||||||
|
enabled: projectIds.length > 0,
|
||||||
|
});
|
||||||
|
|
||||||
// -----
|
// -----
|
||||||
|
|
||||||
const isLoading = isLoadingBusinesses || isLoadingProjects || isLoadingTags || isLoadingInvestments;
|
const isLoading =
|
||||||
|
isLoadingBusinesses ||
|
||||||
|
isLoadingProjects ||
|
||||||
|
isLoadingTags ||
|
||||||
|
isLoadingInvestments;
|
||||||
const error = businessError || projectError || tagError || investmentError;
|
const error = businessError || projectError || tagError || investmentError;
|
||||||
|
|
||||||
const results: Business[] =
|
const results: Business[] =
|
||||||
@ -112,8 +136,13 @@ export default function Find() {
|
|||||||
?.filter((project) => project.businessId === business.id)
|
?.filter((project) => project.businessId === business.id)
|
||||||
.map((project) => ({
|
.map((project) => ({
|
||||||
...project,
|
...project,
|
||||||
tags: tags?.filter((tag) => tag.itemId === project.id).map((tag) => tag.Tag.value) || [],
|
tags:
|
||||||
investmentCount: investmentCounts?.find((ic) => ic.projectId === project.id)?.count || 0,
|
tags
|
||||||
|
?.filter((tag) => tag.itemId === project.id)
|
||||||
|
.map((tag) => tag.Tag.value) || [],
|
||||||
|
investmentCount:
|
||||||
|
investmentCounts?.find((ic) => ic.projectId === project.id)
|
||||||
|
?.count || 0,
|
||||||
})) || [],
|
})) || [],
|
||||||
})) || [];
|
})) || [];
|
||||||
|
|
||||||
@ -151,7 +180,10 @@ export default function Find() {
|
|||||||
<Card className="w-full">
|
<Card className="w-full">
|
||||||
<CardHeader>
|
<CardHeader>
|
||||||
<CardTitle>{business.businessName}</CardTitle>
|
<CardTitle>{business.businessName}</CardTitle>
|
||||||
<CardDescription>Joined Date: {new Date(business.joinedDate).toLocaleDateString()}</CardDescription>
|
<CardDescription>
|
||||||
|
Joined Date:{" "}
|
||||||
|
{new Date(business.joinedDate).toLocaleDateString()}
|
||||||
|
</CardDescription>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardContent>
|
<CardContent>
|
||||||
{business.Projects.map((project) => (
|
{business.Projects.map((project) => (
|
||||||
@ -161,10 +193,17 @@ export default function Find() {
|
|||||||
description={project.projectName}
|
description={project.projectName}
|
||||||
joinDate={project.projectName}
|
joinDate={project.projectName}
|
||||||
location={"Bangkok"}
|
location={"Bangkok"}
|
||||||
minInvestment={project.ProjectInvestmentDetail[0]?.minInvestment}
|
minInvestment={
|
||||||
totalInvestor={project.ProjectInvestmentDetail[0]?.totalInvestment}
|
project.ProjectInvestmentDetail[0]?.minInvestment
|
||||||
totalRaised={project.ProjectInvestmentDetail[0]?.targetInvestment}
|
}
|
||||||
|
totalInvestor={
|
||||||
|
project.ProjectInvestmentDetail[0]?.totalInvestment
|
||||||
|
}
|
||||||
|
totalRaised={
|
||||||
|
project.ProjectInvestmentDetail[0]?.targetInvestment
|
||||||
|
}
|
||||||
tags={[]}
|
tags={[]}
|
||||||
|
imageUri={null}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</CardContent>
|
</CardContent>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user