Deleted the billing-redirect-button, checkout-redirect-button, and embedded-stripe-checkout components. Additionally, removed the shadcn directory, which encompassed billing-related icons. This change streamlines the subscription settings interface and organizes the system's payment management. This update is a stepping stone towards improving the billing system's overall architecture.
68 lines
1.6 KiB
TypeScript
68 lines
1.6 KiB
TypeScript
import { PageBody } from '@/components/app/Page';
|
|
import appConfig from '@/config/app.config';
|
|
|
|
import getSupabaseServerComponentClient from '@packages/supabase/server-component-client';
|
|
|
|
import AdminDashboard from '../../packages/admin/components/AdminDashboard';
|
|
import AdminGuard from '../../packages/admin/components/AdminGuard';
|
|
import AdminHeader from '../../packages/admin/components/AdminHeader';
|
|
|
|
export const metadata = {
|
|
title: `Admin | ${appConfig.name}`,
|
|
};
|
|
|
|
async function AdminPage() {
|
|
const data = await loadData();
|
|
|
|
return (
|
|
<div className={'flex flex-1 flex-col'}>
|
|
<AdminHeader>Admin</AdminHeader>
|
|
|
|
<PageBody>
|
|
<AdminDashboard data={data} />
|
|
</PageBody>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
export default AdminGuard(AdminPage);
|
|
|
|
async function loadData() {
|
|
const client = getSupabaseServerComponentClient({ admin: true });
|
|
|
|
const { count: usersCount } = await client.from('users').select('*', {
|
|
count: 'exact',
|
|
head: true,
|
|
});
|
|
|
|
const { count: organizationsCount } = await client
|
|
.from('organizations')
|
|
.select('*', {
|
|
count: 'exact',
|
|
head: true,
|
|
});
|
|
|
|
const { count: activeSubscriptions } = await client
|
|
.from('subscriptions')
|
|
.select(`*`, {
|
|
count: 'exact',
|
|
head: true,
|
|
})
|
|
.eq('status', 'active');
|
|
|
|
const { count: trialSubscriptions } = await client
|
|
.from('subscriptions')
|
|
.select(`*`, {
|
|
count: 'exact',
|
|
head: true,
|
|
})
|
|
.eq('status', 'trialing');
|
|
|
|
return {
|
|
usersCount: usersCount || 0,
|
|
organizationsCount: organizationsCount || 0,
|
|
activeSubscriptions: activeSubscriptions || 0,
|
|
trialSubscriptions: trialSubscriptions || 0,
|
|
};
|
|
}
|