// Auto-generated by DjangoCFG - see CLAUDE.md
'use client';

/**
 * SWR Hooks for Backup Codes
 *
 * React hooks powered by SWR for data fetching with automatic caching,
 * revalidation, and optimistic updates.
 *
 * Usage:
 * ```typescript
 * // Query hooks (GET)
 * const { data, error, isLoading } = useUsers({ page: 1 })
 *
 * // Mutation hooks (POST/PUT/PATCH/DELETE)
 * const createUser = useCreateUser()
 * await createUser({ name: 'John', email: 'john@example.com' })
 * ```
 */
import useSWR from 'swr'
import { useSWRConfig } from 'swr'
import * as Fetchers from '../fetchers/totp__backup_codes'
import type { API } from '../../index'
import type { BackupCodesRegenerateRequest } from '../schemas/BackupCodesRegenerateRequest.schema'
import type { BackupCodesRegenerateResponse } from '../schemas/BackupCodesRegenerateResponse.schema'
import type { BackupCodesStatus } from '../schemas/BackupCodesStatus.schema'

/**
 * API operation
 *
 * @method GET
 * @path /cfg/totp/backup-codes/
 */
export function useTotpBackupCodesRetrieve(client?: API): ReturnType<typeof useSWR<BackupCodesStatus>> {
  return useSWR<BackupCodesStatus>(
    'cfg-totp-backup-code',
    () => Fetchers.getTotpBackupCodesRetrieve(client)
  )
}


/**
 * API operation
 *
 * @method POST
 * @path /cfg/totp/backup-codes/regenerate/
 */
export function useCreateTotpBackupCodesRegenerateCreate() {
  const { mutate } = useSWRConfig()

  return async (data: BackupCodesRegenerateRequest, client?: API): Promise<BackupCodesRegenerateResponse> => {
    const result = await Fetchers.createTotpBackupCodesRegenerateCreate(data, client)
    // Revalidate related queries
    mutate('cfg-totp-backup-codes-regenerate')
    return result
  }
}


