feat: open billing for lmz customers #538
This commit is contained in:
@@ -37,7 +37,7 @@ async function getOrganisationAnalytics(orgId: string): Promise<OrganisationAnal
|
||||
};
|
||||
// Run all queries in parallel
|
||||
const [statsResult, topCoursesResult, enrollmentsResult] = await Promise.all([
|
||||
supabase.from('dash_org_stats').select('*').eq('org_id', orgId).single(),
|
||||
supabase.from('dash_org_stats').select('*').eq('org_id', orgId),
|
||||
|
||||
supabase
|
||||
.rpc('get_dash_org_top_courses', {
|
||||
@@ -66,8 +66,8 @@ async function getOrganisationAnalytics(orgId: string): Promise<OrganisationAnal
|
||||
|
||||
// Set analytics data
|
||||
analytics.revenue = 0; // Hardcode until we implement payment
|
||||
analytics.numberOfCourses = statsResult.data.no_of_courses;
|
||||
analytics.totalStudents = statsResult.data.enrolled_students;
|
||||
analytics.numberOfCourses = statsResult.data?.[0]?.no_of_courses;
|
||||
analytics.totalStudents = statsResult.data?.[0]?.enrolled_students;
|
||||
|
||||
analytics.topCourses = topCoursesResult.data.map((course) => ({
|
||||
id: course.course_id,
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
import { configureLemonSqueezy } from '$lib/utils/services/lemonsqueezy';
|
||||
import { getSubscription } from '@lemonsqueezy/lemonsqueezy.js';
|
||||
import { json } from '@sveltejs/kit';
|
||||
|
||||
export async function GET({ url }) {
|
||||
const subscriptionId = url.searchParams.get('subscriptionId');
|
||||
|
||||
await configureLemonSqueezy();
|
||||
|
||||
if (!subscriptionId) {
|
||||
return json({ success: false, message: 'Subscription id is required' }, { status: 400 });
|
||||
}
|
||||
|
||||
const response = await getSubscription(subscriptionId);
|
||||
const customerPortal = response?.data?.data?.attributes?.urls?.customer_portal;
|
||||
|
||||
console.log({ customerPortal });
|
||||
|
||||
return json({
|
||||
success: true,
|
||||
customerPortal
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user