Refactor authActions module

Refactor authActions.ts into smaller files for better maintainability and readability.
This commit is contained in:
gpt-engineer-app[bot]
2025-03-15 13:08:22 +00:00
parent 8931ee4bb6
commit 068482e8e6
6 changed files with 201 additions and 205 deletions

View File

@@ -0,0 +1,32 @@
import { toast } from '@/hooks/useToast.wrapper';
import { supabase } from '@/lib/supabase';
// 토스트 메시지 표시 유틸리티 함수
export const showAuthToast = (title: string, description: string, variant: 'default' | 'destructive' = 'default') => {
toast({ title, description, variant });
};
// 에러 메시지 처리 유틸리티 함수
export const handleNetworkError = (error: any): string => {
return error.message && error.message.includes('fetch')
? '서버 연결에 실패했습니다. 네트워크 연결을 확인해주세요.'
: (error.message || '예상치 못한 오류가 발생했습니다.');
};
// 응답 파싱 유틸리티 함수
export const parseResponse = async (response: Response) => {
try {
const responseText = await response.text();
console.log('응답 원본:', responseText);
if (!responseText || responseText.trim() === '') {
throw new Error('서버가 빈 응답을 반환했습니다');
}
return JSON.parse(responseText);
} catch (parseError) {
console.error('응답 파싱 오류:', parseError);
throw parseError;
}
};