import { useState } from 'react'; import Head from 'next/head'; import Layout from '../../components/Layout'; import { adminAPI } from '../../services/api'; export default function AdminLicenses() { const [genForm, setGenForm] = useState({ userId: '', plan: 'PRO_MONTHLY', durationDays: 30 }); const [loading, setLoading] = useState(false); const handleGenerateLicense = async () => { if (!genForm.userId) return alert('User ID required'); setLoading(true); try { await adminAPI.generateLicense({ userId: genForm.userId, plan: genForm.plan, durationDays: genForm.durationDays }); alert('License generated successfully!'); setGenForm({ userId: '', plan: 'PRO_MONTHLY', durationDays: 30 }); } catch (err: any) { alert(err.response?.data?.message || 'Failed to generate license'); } setLoading(false); }; return ( <>
Note: Generating a license will automatically assign it to the specified user and set their role to USER_PRO if not already set. The user will need to restart their extension or wait for the 24h cache to refresh.