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

/**
 * SWR Hooks for Web Push
 *
 * 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/webpush__web_push'
import type { API } from '../../index'
import type { SendPushRequestRequest } from '../schemas/SendPushRequestRequest.schema'
import type { SendPushResponse } from '../schemas/SendPushResponse.schema'
import type { SubscribeRequestRequest } from '../schemas/SubscribeRequestRequest.schema'
import type { SubscribeResponse } from '../schemas/SubscribeResponse.schema'
import type { VapidPublicKeyResponse } from '../schemas/VapidPublicKeyResponse.schema'

/**
 * Send push notification
 *
 * @method POST
 * @path /cfg/webpush/send/
 */
export function useCreateWebpushSendCreate() {
  const { mutate } = useSWRConfig()

  return async (data: SendPushRequestRequest, client?: API): Promise<SendPushResponse> => {
    const result = await Fetchers.createWebpushSendCreate(data, client)
    // Revalidate related queries
    mutate('cfg-webpush-send')
    return result
  }
}


/**
 * Subscribe to push notifications
 *
 * @method POST
 * @path /cfg/webpush/subscribe/
 */
export function useCreateWebpushSubscribeCreate() {
  const { mutate } = useSWRConfig()

  return async (data: SubscribeRequestRequest, client?: API): Promise<SubscribeResponse> => {
    const result = await Fetchers.createWebpushSubscribeCreate(data, client)
    // Revalidate related queries
    mutate('cfg-webpush-subscribe')
    return result
  }
}


/**
 * Get VAPID public key
 *
 * @method GET
 * @path /cfg/webpush/vapid/
 */
export function useWebpushVapidRetrieve(client?: API): ReturnType<typeof useSWR<VapidPublicKeyResponse>> {
  return useSWR<VapidPublicKeyResponse>(
    'cfg-webpush-vapid',
    () => Fetchers.getWebpushVapidRetrieve(client)
  )
}


