social 계정 재연동 로직 추가 .
This commit is contained in:
1 parent
3eedb8dc17
commit
29fdb7e65c
5 files changed
+106
-27
No files matched your search
@@ -1,6 +1,6 @@
|
||||
|
||||
import React, { useState, useEffect, useRef } from 'react';
|
||||
import { generateVideo, waitForVideoComplete, getYouTubeConnectUrl, getSocialAccounts, disconnectSocialAccount } from '../../utils/api';
|
||||
import { generateVideo, waitForVideoComplete, getYouTubeConnectUrl, getSocialAccounts, disconnectSocialAccount, TokenExpiredError, handleSocialReconnect } from '../../utils/api';
|
||||
import { SocialAccount } from '../../types/api';
|
||||
|
||||
interface CompletionContentProps {
|
||||
@@ -317,6 +317,11 @@ const CompletionContent: React.FC<CompletionContentProps> = ({
|
||||
console.log('[YouTube] No YouTube account connected');
|
||||
}
|
||||
} catch (error) {
|
||||
if (error instanceof TokenExpiredError) {
|
||||
alert('YouTube 인증이 만료되었습니다. 재연동 페이지로 이동합니다.');
|
||||
handleSocialReconnect(error.reconnectUrl);
|
||||
return;
|
||||
}
|
||||
console.error('[YouTube] Failed to check connection:', error);
|
||||
// API 에러 시에도 localStorage에서 확인한 값 유지
|
||||
}
|
||||
@@ -351,6 +356,11 @@ const CompletionContent: React.FC<CompletionContentProps> = ({
|
||||
// OAuth URL로 리다이렉트
|
||||
window.location.href = response.auth_url;
|
||||
} catch (error) {
|
||||
if (error instanceof TokenExpiredError) {
|
||||
alert('YouTube 인증이 만료되었습니다. 재연동 페이지로 이동합니다.');
|
||||
handleSocialReconnect(error.reconnectUrl);
|
||||
return;
|
||||
}
|
||||
console.error('YouTube connect failed:', error);
|
||||
setYoutubeError('YouTube 연결에 실패했습니다.');
|
||||
setIsYoutubeConnecting(false);
|
||||
@@ -366,6 +376,11 @@ const CompletionContent: React.FC<CompletionContentProps> = ({
|
||||
setYoutubeAccount(null);
|
||||
setSelectedSocials(prev => prev.filter(s => s !== 'Youtube'));
|
||||
} catch (error) {
|
||||
if (error instanceof TokenExpiredError) {
|
||||
alert('YouTube 인증이 만료되었습니다. 재연동 페이지로 이동합니다.');
|
||||
handleSocialReconnect(error.reconnectUrl);
|
||||
return;
|
||||
}
|
||||
console.error('YouTube disconnect failed:', error);
|
||||
setYoutubeError('연결 해제에 실패했습니다.');
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { getSocialAccounts, getYouTubeConnectUrl, disconnectSocialAccount } from '../../utils/api';
|
||||
import { getSocialAccounts, getYouTubeConnectUrl, disconnectSocialAccount, TokenExpiredError, handleSocialReconnect } from '../../utils/api';
|
||||
import { SocialAccount } from '../../types/api';
|
||||
|
||||
type TabType = 'basic' | 'payment' | 'business';
|
||||
@@ -23,6 +23,11 @@ const MyInfoContent: React.FC = () => {
|
||||
const response = await getSocialAccounts();
|
||||
setSocialAccounts(response.accounts || []);
|
||||
} catch (error) {
|
||||
if (error instanceof TokenExpiredError) {
|
||||
alert('YouTube 인증이 만료되었습니다. 재연동 페이지로 이동합니다.');
|
||||
handleSocialReconnect(error.reconnectUrl);
|
||||
return;
|
||||
}
|
||||
console.error('Failed to load social accounts:', error);
|
||||
} finally {
|
||||
setIsLoadingAccounts(false);
|
||||
@@ -36,6 +41,11 @@ const MyInfoContent: React.FC = () => {
|
||||
const response = await getYouTubeConnectUrl();
|
||||
window.location.href = response.auth_url;
|
||||
} catch (error) {
|
||||
if (error instanceof TokenExpiredError) {
|
||||
alert('YouTube 인증이 만료되었습니다. 재연동 페이지로 이동합니다.');
|
||||
handleSocialReconnect(error.reconnectUrl);
|
||||
return;
|
||||
}
|
||||
console.error('Failed to get YouTube connect URL:', error);
|
||||
setIsConnecting(null);
|
||||
}
|
||||
@@ -47,6 +57,11 @@ const MyInfoContent: React.FC = () => {
|
||||
await disconnectSocialAccount(accountId);
|
||||
setSocialAccounts(prev => prev.filter(acc => acc.id !== accountId));
|
||||
} catch (error) {
|
||||
if (error instanceof TokenExpiredError) {
|
||||
alert('YouTube 인증이 만료되었습니다. 재연동 페이지로 이동합니다.');
|
||||
handleSocialReconnect(error.reconnectUrl);
|
||||
return;
|
||||
}
|
||||
console.error('Failed to disconnect:', error);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user