import { useState } from 'react' import { Modal } from '@/components/common/Modal' import { cn } from '@/lib/utils' interface RevokeSessionsModalProps { isOpen: boolean onClose: () => void onConfirm: () => Promise scope: 'all' | 'others' activeUserCount: number } /** * Confirmation modal for bulk session revocation. Two scopes: * * - "others" — revokes other users' sessions, caller stays signed in. * - "all" — revokes everyone including the caller; the parent handles * the post-revoke auto-redirect to /login (see plan §4.8 D4). */ export function RevokeSessionsModal({ isOpen, onClose, onConfirm, scope, activeUserCount, }: RevokeSessionsModalProps) { const [busy, setBusy] = useState(false) const isAll = scope === 'all' const otherCount = isAll ? activeUserCount : Math.max(activeUserCount - 1, 0) const title = isAll ? 'Sign out everyone?' : 'Sign out other users?' const body = isAll ? `This signs out all ${activeUserCount} active users including yourself. Everyone will need to sign in again.` : `This signs out the ${otherCount} other active users in your account. They'll need to sign in again. You stay signed in.` const confirmLabel = isAll ? 'Sign out everyone' : otherCount === 1 ? 'Sign out 1 user' : `Sign out ${otherCount} users` const handleConfirm = async () => { setBusy(true) try { await onConfirm() } finally { setBusy(false) } } return ( undefined : onClose} title={title} size="sm" footer={
} >

{body}

) }