All files / src/components/settings SettingsPasskeys.tsx

100% Statements 5/5
62.5% Branches 5/8
100% Functions 2/2
100% Lines 5/5

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53        5x   5x 3x             2x                               4x                                            
import usePasskeys from '../../hooks/usePasskeys'
import PasskeyItem from './PasskeyItem'
 
export default function SettingsPasskeys() {
  const { credentials, loading, error, adding, handleAdd, handleDelete } = usePasskeys()
 
  if (loading) {
    return (
      <div className="flex items-center justify-center py-12">
        <div className="text-muted-foreground">Loading...</div>
      </div>
    )
  }
 
  return (
    <div className="space-y-6">
      <div className="rounded-lg border border-border bg-card p-4">
        <h2 className="mb-1 text-lg font-medium text-foreground">Manage Passkeys</h2>
        <p className="mb-4 text-sm text-muted-foreground">
          {credentials.length} passkey{credentials.length !== 1 ? 's' : ''} registered
        </p>
 
        {error && (
          <div role="alert" className="mb-4 rounded-md bg-red-50 p-3 text-sm text-red-800 dark:bg-red-900/20 dark:text-red-300">
            {error}
          </div>
        )}
 
        <div className="space-y-3">
          {credentials.map((cred) => (
            <PasskeyItem
              key={cred.id}
              id={cred.id}
              createdAt={cred.created_at}
              lastUsedAt={cred.last_used_at}
              isDeletable={cred.is_deletable}
              onDelete={handleDelete}
            />
          ))}
        </div>
 
        <button
          onClick={handleAdd}
          disabled={adding}
          className="mt-4 w-full rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground shadow-sm hover:bg-primary/90 disabled:opacity-50"
        >
          {adding ? 'Adding passkey...' : 'Add Passkey'}
        </button>
      </div>
    </div>
  )
}
 
← Back to Dashboard