Spaces:
Sleeping
Sleeping
| import { rpcClient } from '@/api-client/utils/rpc-client'; | |
| import type { CheckUrlRequest, CheckUrlResponse } from '@/schema/gradio-proxy/check-url'; | |
| import { useMutation } from '@tanstack/react-query'; | |
| /** | |
| * check_url APIを呼び出すカスタムフック(mutation版) | |
| * @returns mutationオブジェクト | |
| */ | |
| export function useCheckUrl() { | |
| return useMutation({ | |
| mutationFn: async (request: CheckUrlRequest): Promise<CheckUrlResponse> => { | |
| console.log('[useCheckUrl] API呼び出し開始:', { | |
| ownUrl: request.ownUrl, | |
| urlCount: request.urlText.length, | |
| dummyMode: request.dummyMode, | |
| }); | |
| try { | |
| const response = await rpcClient['gradio-proxy']['check-url'].$post({ | |
| json: request, | |
| }); | |
| if (!response.ok) { | |
| const errorData = (await response.json()) as { message?: string }; | |
| console.error('[useCheckUrl] API エラー:', errorData); | |
| throw new Error(errorData.message || 'check_url APIの呼び出しに失敗しました'); | |
| } | |
| const data = await response.json(); | |
| console.log('[useCheckUrl] API呼び出し成功'); | |
| return data as CheckUrlResponse; | |
| } catch (error) { | |
| console.error('[useCheckUrl] API呼び出しエラー:', error); | |
| throw error; | |
| } | |
| }, | |
| }); | |
| } | |