- Database schema: * subscription_plans table - stores plan tiers (Starter, Bronze, Silver, Gold) * user_subscriptions table - assigns users to plans * Default plans created (10, 50, 100, 250 credits/month) * All existing users assigned to Starter plan - Subscription service (subscription-service.ts): * getAllPlans() - fetch all plans * getActivePlans() - fetch active plans for users * createPlan() - admin creates new plan * updatePlan() - admin edits plan * deletePlan() - admin removes plan * getUserSubscription() - get user's current plan * setUserPlan() - admin assigns user to plan * grantMonthlyCredits() - distribute credits to all users - Plan management interface (/admin/plans): * Visual plan cards with credits, price, description * Create/Edit/Delete plans * Toggle active/inactive status * Sort order management * Grant monthly credits button (manual trigger) - Features: * Monthly credit allocation based on plan * Prevents duplicate credit grants (tracks last_credit_grant_at) * Admin can manually trigger monthly credit distribution * Plans can be activated/deactivated * Custom pricing and credit amounts per plan - UI: * Beautiful plan cards with color coding * Modal for create/edit with validation * Success/error messages * Manage Plans button in admin dashboard Ready for future automation (cron job for monthly credits) and payment integration (Stripe/PayPal).
16 KiB
16 KiB