feat: add plan assignment to user management
- Added plan dropdown to user edit modal - Shows current plan with highlighted card - Allows admin to assign/change user's subscription plan - Loads user's current plan when opening edit modal - Updates plan via setUserPlan service - Visual feedback with success/error messages Admins can now: - View user's current subscription plan - Assign users to different plans (Starter, Bronze, Silver, Gold) - See plan details (credits/month, price) in dropdown This completes the subscription plan system!
This commit is contained in:
@@ -3,6 +3,7 @@ import { cookies } from 'next/headers';
|
||||
import { redirect } from 'next/navigation';
|
||||
import { checkIsAdmin } from '@/services/track-api-usage';
|
||||
import { getAllUsersWithCredits } from '@/services/admin-credit-service';
|
||||
import { getAllPlans } from '@/services/subscription-service';
|
||||
import Link from 'next/link';
|
||||
import { ChevronLeft, Users, Coins, TrendingUp, TrendingDown } from 'lucide-react';
|
||||
import UserManagementClient from '@/components/UserManagementClient';
|
||||
@@ -23,6 +24,9 @@ export default async function AdminUsersPage() {
|
||||
// Fetch all users with credits
|
||||
const users = await getAllUsersWithCredits();
|
||||
|
||||
// Fetch all plans
|
||||
const plans = await getAllPlans();
|
||||
|
||||
// Calculate statistics
|
||||
const totalUsers = users.length;
|
||||
const totalCreditsInCirculation = users.reduce((sum, u) => sum + u.balance, 0);
|
||||
@@ -91,7 +95,7 @@ export default async function AdminUsersPage() {
|
||||
</div>
|
||||
|
||||
{/* User Management Table */}
|
||||
<UserManagementClient initialUsers={users} />
|
||||
<UserManagementClient initialUsers={users} plans={plans} />
|
||||
</div>
|
||||
</main>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user