import { useSendWithButton } from '..' import { composeTokenURL, processToken } from '../../api/token' import { isTokenResponse } from '../../api/token/types' import { setToken } from '../../utils/auth' function useSignIn() { const { doSend, button } = useSendWithButton( 'Войти', 'Войдено', false, composeTokenURL(), 'POST', false, isTokenResponse, processToken, ) async function handleSignIn(formData: FormData) { const token = await doSend({}, { body: formData }) if (token !== undefined) { setToken(token) } } return { handleSignIn, signInButton: button } } export default useSignIn