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

/**
 * SWR Hooks for TOTP Management
 *
 * 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__totp_management'
import type { API } from '../../index'
import type { DisableRequest } from '../schemas/DisableRequest.schema'
import type { PaginatedDeviceListResponseList } from '../schemas/PaginatedDeviceListResponseList.schema'

/**
 * API operation
 *
 * @method GET
 * @path /cfg/totp/devices/
 */
export function useTotpDevicesList(params?: { page?: number; page_size?: number }, client?: API): ReturnType<typeof useSWR<PaginatedDeviceListResponseList>> {
  return useSWR<PaginatedDeviceListResponseList>(
    params ? ['cfg-totp-devices', params] : 'cfg-totp-devices',
    () => Fetchers.getTotpDevicesList(params, client)
  )
}


/**
 * API operation
 *
 * @method POST
 * @path /cfg/totp/disable/
 */
export function useCreateTotpDisableCreate() {
  const { mutate } = useSWRConfig()

  return async (data: DisableRequest, client?: API): Promise<any> => {
    const result = await Fetchers.createTotpDisableCreate(data, client)
    // Revalidate related queries
    mutate('cfg-totp-disable')
    return result
  }
}


