mirror of
https://github.com/Sosokker/B2D-Ventures.git
synced 2025-12-19 05:54:06 +01:00
69 lines
1.5 KiB
TypeScript
69 lines
1.5 KiB
TypeScript
import { SupabaseClient } from "@supabase/supabase-js";
|
|
|
|
export const getAllBusinesses = (client: SupabaseClient) => {
|
|
return client.from("business").select(`
|
|
id,
|
|
location,
|
|
business_name,
|
|
...business_type (
|
|
business_type:value
|
|
),
|
|
joined_date,
|
|
...user_id (
|
|
user_id:id,
|
|
username,
|
|
full_name,
|
|
email
|
|
)
|
|
`);
|
|
};
|
|
|
|
export const getBusinessAndProject = (
|
|
client: SupabaseClient,
|
|
params: { businessName?: String | null; businessId?: number | null; single?: boolean } = { single: false }
|
|
) => {
|
|
const query = client.from("business").select(`
|
|
business_id:id,
|
|
location,
|
|
business_name,
|
|
business_type:business_type (
|
|
business_type_id:id,
|
|
value
|
|
),
|
|
joined_date,
|
|
user_id,
|
|
projects:project (
|
|
id,
|
|
project_name,
|
|
business_id,
|
|
published_time,
|
|
card_image_url,
|
|
project_short_description,
|
|
...project_investment_detail (
|
|
min_investment,
|
|
total_investment,
|
|
target_investment
|
|
),
|
|
tags:project_tag (
|
|
...tag (
|
|
tag_value:value
|
|
)
|
|
)
|
|
)
|
|
`);
|
|
|
|
if (params.businessName && params.businessName.trim() !== "") {
|
|
return query.ilike("business_name", `%${params.businessName}%`);
|
|
}
|
|
|
|
if (params.businessId) {
|
|
query.eq("id", params.businessId);
|
|
}
|
|
|
|
if (params.single) {
|
|
query.single();
|
|
}
|
|
|
|
return query;
|
|
};
|