import jwt from 'jsonwebtoken'

interface AdminPayload {
    role: string
}

export function verifyAdminToken(token: string | undefined): boolean {
    if (!token) return false

    try {
        const decoded = jwt.verify(token, process.env.JWT_SECRET!) as AdminPayload
        return decoded.role === 'admin'
    } catch {
        return false
    }
}
