feat(backend): complete AI and business migration
This commit is contained in:
@@ -1,40 +1,18 @@
|
||||
import { createClient } from "@/lib/supabase/server";
|
||||
import { requireFreelancerBackend } from "@/server/web/freelancer";
|
||||
import { SubscriptionsClient, type SubscriptionRow } from "./subscriptions-client";
|
||||
|
||||
export default async function SubscriptionsPage() {
|
||||
const supabase = await createClient();
|
||||
const { data: { user } } = await supabase.auth.getUser();
|
||||
|
||||
if (!user) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const { data: subscriptionsData } = await supabase
|
||||
.from("subscriptions")
|
||||
.select(`
|
||||
id,
|
||||
name,
|
||||
amount,
|
||||
currency,
|
||||
billing_cycle,
|
||||
status,
|
||||
category,
|
||||
next_billing_date,
|
||||
created_at
|
||||
`)
|
||||
.eq("user_id", user.id)
|
||||
.order("created_at", { ascending: false });
|
||||
|
||||
const subscriptions: SubscriptionRow[] = (subscriptionsData || []).map((s: any) => ({
|
||||
id: s.id,
|
||||
name: s.name,
|
||||
amount: Number(s.amount),
|
||||
currency: s.currency,
|
||||
billing_cycle: s.billing_cycle,
|
||||
status: s.status,
|
||||
category: s.category,
|
||||
next_billing_date: s.next_billing_date,
|
||||
created_at: s.created_at,
|
||||
const { actor, service } = await requireFreelancerBackend();
|
||||
const subscriptions: SubscriptionRow[] = service.listSubscriptions(actor).map((subscription) => ({
|
||||
id: subscription.id,
|
||||
name: subscription.name,
|
||||
amount: subscription.amountMinor / 100,
|
||||
currency: subscription.currency,
|
||||
billing_cycle: subscription.billingCycle,
|
||||
status: subscription.status,
|
||||
category: subscription.category,
|
||||
next_billing_date: subscription.nextBillingDate,
|
||||
created_at: subscription.createdAt.toISOString(),
|
||||
}));
|
||||
|
||||
return <SubscriptionsClient subscriptions={subscriptions} />;
|
||||
|
||||
Reference in New Issue
Block a user