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 ( <> Licenses – MarketScope Admin

🔑 License Management

Generate New License

setGenForm({ ...genForm, userId: e.target.value })} className="input-field" placeholder="e.g. 550e8400-e29b-41d4-a716-446655440000" />
setGenForm({ ...genForm, durationDays: Number(e.target.value) })} className="input-field" />

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.

); }