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

/**
 * SWR Hooks for Oauth
 *
 * 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/accounts__oauth'
import type { API } from '../../index'
import type { OAuthAuthorizeRequestRequest } from '../schemas/OAuthAuthorizeRequestRequest.schema'
import type { OAuthAuthorizeResponse } from '../schemas/OAuthAuthorizeResponse.schema'
import type { OAuthCallbackRequestRequest } from '../schemas/OAuthCallbackRequestRequest.schema'
import type { OAuthDisconnectRequestRequest } from '../schemas/OAuthDisconnectRequestRequest.schema'
import type { OAuthProvidersResponse } from '../schemas/OAuthProvidersResponse.schema'
import type { OAuthTokenResponse } from '../schemas/OAuthTokenResponse.schema'

/**
 * List OAuth connections
 *
 * @method GET
 * @path /cfg/accounts/oauth/connections/
 */
export function useAccountsOauthConnectionsList(client?: API): ReturnType<typeof useSWR<any>> {
  return useSWR<any>(
    'cfg-accounts-oauth-connections',
    () => Fetchers.getAccountsOauthConnectionsList(client)
  )
}


/**
 * Disconnect OAuth provider
 *
 * @method POST
 * @path /cfg/accounts/oauth/disconnect/
 */
export function useCreateAccountsOauthDisconnectCreate() {
  const { mutate } = useSWRConfig()

  return async (data: OAuthDisconnectRequestRequest, client?: API): Promise<any> => {
    const result = await Fetchers.createAccountsOauthDisconnectCreate(data, client)
    // Revalidate related queries
    mutate('cfg-accounts-oauth-disconnect')
    return result
  }
}


/**
 * Start GitHub OAuth
 *
 * @method POST
 * @path /cfg/accounts/oauth/github/authorize/
 */
export function useCreateAccountsOauthGithubAuthorizeCreate() {
  const { mutate } = useSWRConfig()

  return async (data: OAuthAuthorizeRequestRequest, client?: API): Promise<OAuthAuthorizeResponse> => {
    const result = await Fetchers.createAccountsOauthGithubAuthorizeCreate(data, client)
    // Revalidate related queries
    mutate('cfg-accounts-oauth-github-authorize')
    return result
  }
}


/**
 * Complete GitHub OAuth
 *
 * @method POST
 * @path /cfg/accounts/oauth/github/callback/
 */
export function useCreateAccountsOauthGithubCallbackCreate() {
  const { mutate } = useSWRConfig()

  return async (data: OAuthCallbackRequestRequest, client?: API): Promise<OAuthTokenResponse> => {
    const result = await Fetchers.createAccountsOauthGithubCallbackCreate(data, client)
    // Revalidate related queries
    mutate('cfg-accounts-oauth-github-callback')
    return result
  }
}


/**
 * List OAuth providers
 *
 * @method GET
 * @path /cfg/accounts/oauth/providers/
 */
export function useAccountsOauthProvidersRetrieve(client?: API): ReturnType<typeof useSWR<OAuthProvidersResponse>> {
  return useSWR<OAuthProvidersResponse>(
    'cfg-accounts-oauth-provider',
    () => Fetchers.getAccountsOauthProvidersRetrieve(client)
  )
}


