유튜브 업로드 기능 완료 .
This commit is contained in:
1 parent
e1b860a15f
commit
fd9db31e52
12 files changed
+2257
-30
No files matched your search
@@ -0,0 +1,239 @@
|
||||
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { getSocialAccounts, getYouTubeConnectUrl, disconnectSocialAccount } from '../../utils/api';
|
||||
import { SocialAccount } from '../../types/api';
|
||||
|
||||
type TabType = 'basic' | 'payment' | 'business';
|
||||
|
||||
const MyInfoContent: React.FC = () => {
|
||||
const [activeTab, setActiveTab] = useState<TabType>('business');
|
||||
const [businessUrl, setBusinessUrl] = useState('');
|
||||
const [socialAccounts, setSocialAccounts] = useState<SocialAccount[]>([]);
|
||||
const [isLoadingAccounts, setIsLoadingAccounts] = useState(false);
|
||||
const [isConnecting, setIsConnecting] = useState<string | null>(null);
|
||||
|
||||
// 소셜 계정 목록 로드
|
||||
useEffect(() => {
|
||||
loadSocialAccounts();
|
||||
}, []);
|
||||
|
||||
const loadSocialAccounts = async () => {
|
||||
setIsLoadingAccounts(true);
|
||||
try {
|
||||
const response = await getSocialAccounts();
|
||||
setSocialAccounts(response.accounts || []);
|
||||
} catch (error) {
|
||||
console.error('Failed to load social accounts:', error);
|
||||
} finally {
|
||||
setIsLoadingAccounts(false);
|
||||
}
|
||||
};
|
||||
|
||||
// YouTube 연결
|
||||
const handleYoutubeConnect = async () => {
|
||||
setIsConnecting('youtube');
|
||||
try {
|
||||
const response = await getYouTubeConnectUrl();
|
||||
window.location.href = response.auth_url;
|
||||
} catch (error) {
|
||||
console.error('Failed to get YouTube connect URL:', error);
|
||||
setIsConnecting(null);
|
||||
}
|
||||
};
|
||||
|
||||
// 소셜 계정 연결 해제 (특정 계정 ID로)
|
||||
const handleDisconnectAccount = async (accountId: number) => {
|
||||
try {
|
||||
await disconnectSocialAccount(accountId);
|
||||
setSocialAccounts(prev => prev.filter(acc => acc.id !== accountId));
|
||||
} catch (error) {
|
||||
console.error('Failed to disconnect:', error);
|
||||
}
|
||||
};
|
||||
|
||||
// 플랫폼별 연결된 모든 계정 가져오기
|
||||
const getConnectedAccounts = (platform: string) => {
|
||||
return socialAccounts.filter(acc => acc.platform === platform && acc.is_active);
|
||||
};
|
||||
|
||||
const youtubeAccounts = getConnectedAccounts('youtube');
|
||||
const instagramAccounts = getConnectedAccounts('instagram');
|
||||
const hasConnectedAccounts = youtubeAccounts.length > 0 || instagramAccounts.length > 0;
|
||||
|
||||
const tabs = [
|
||||
{ id: 'basic' as TabType, label: '기본 정보' },
|
||||
{ id: 'payment' as TabType, label: '결제 정보' },
|
||||
{ id: 'business' as TabType, label: '내 비즈니스 & 소셜 채널 관리' },
|
||||
];
|
||||
|
||||
return (
|
||||
<main className="myinfo-page">
|
||||
<h1 className="myinfo-title">내 정보</h1>
|
||||
|
||||
{/* 탭 네비게이션 */}
|
||||
<div className="myinfo-tabs">
|
||||
{tabs.map(tab => (
|
||||
<button
|
||||
key={tab.id}
|
||||
onClick={() => setActiveTab(tab.id)}
|
||||
className={`myinfo-tab ${activeTab === tab.id ? 'active' : ''}`}
|
||||
>
|
||||
{tab.label}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{/* 탭 컨텐츠 */}
|
||||
<div className="myinfo-content">
|
||||
{activeTab === 'basic' && (
|
||||
<div className="myinfo-section">
|
||||
<p className="myinfo-placeholder">기본 정보 설정 기능이 준비 중입니다.</p>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{activeTab === 'payment' && (
|
||||
<div className="myinfo-section">
|
||||
<p className="myinfo-placeholder">결제 정보 설정 기능이 준비 중입니다.</p>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{activeTab === 'business' && (
|
||||
<>
|
||||
{/* 내 비즈니스 섹션 */}
|
||||
<div className="myinfo-section">
|
||||
<h2 className="myinfo-section-title">내 비즈니스</h2>
|
||||
<div className="myinfo-business-card">
|
||||
<h3 className="myinfo-business-empty-title">아직 등록된 비즈니스가 없어요</h3>
|
||||
<p className="myinfo-business-empty-desc">
|
||||
네이버 지도 URL을 입력하면, 영상 제작에 필요한 정보를 자동으로 불러와요
|
||||
</p>
|
||||
<div className="myinfo-business-input-row">
|
||||
<input
|
||||
type="text"
|
||||
value={businessUrl}
|
||||
onChange={(e) => setBusinessUrl(e.target.value)}
|
||||
placeholder="네이버 지도 URL 입력"
|
||||
className="myinfo-business-input"
|
||||
/>
|
||||
<button className="myinfo-business-submit">
|
||||
비즈니스 등록
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 소셜 채널 섹션 */}
|
||||
<div className="myinfo-section">
|
||||
<h2 className="myinfo-section-title">소셜 채널</h2>
|
||||
|
||||
{/* 연결 버튼들 (가로 배치) */}
|
||||
<div className="myinfo-social-buttons">
|
||||
<button
|
||||
onClick={handleYoutubeConnect}
|
||||
disabled={isConnecting === 'youtube'}
|
||||
className={`myinfo-social-btn ${youtubeAccounts.length > 0 ? 'connected' : ''}`}
|
||||
>
|
||||
<img src="/assets/images/social-youtube.png" alt="YouTube" className="myinfo-social-btn-icon" />
|
||||
<span>{isConnecting === 'youtube' ? '연결 중...' : 'YouTube 연결'}</span>
|
||||
</button>
|
||||
|
||||
<button
|
||||
disabled
|
||||
className="myinfo-social-btn disabled"
|
||||
>
|
||||
<img src="/assets/images/social-instagram.png" alt="Instagram" className="myinfo-social-btn-icon" />
|
||||
<span>Instagram 연결</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* 연결된 계정 목록 */}
|
||||
{hasConnectedAccounts && (
|
||||
<div className="myinfo-connected-accounts">
|
||||
{/* YouTube 계정들 */}
|
||||
{youtubeAccounts.map(account => (
|
||||
<div key={account.id} className="myinfo-connected-card">
|
||||
<div className="myinfo-connected-info">
|
||||
{account.profile_image ? (
|
||||
<img
|
||||
src={account.profile_image}
|
||||
alt={account.display_name}
|
||||
className="myinfo-connected-avatar"
|
||||
/>
|
||||
) : (
|
||||
<div className="myinfo-connected-icon">
|
||||
<img src="/assets/images/social-youtube.png" alt="YouTube" />
|
||||
</div>
|
||||
)}
|
||||
<div className="myinfo-connected-text">
|
||||
<span className="myinfo-connected-channel">{account.display_name}</span>
|
||||
<span className="myinfo-connected-platform">YouTube</span>
|
||||
</div>
|
||||
</div>
|
||||
<div className="myinfo-connected-actions">
|
||||
<span className="myinfo-connected-badge">
|
||||
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5">
|
||||
<polyline points="20 6 9 17 4 12" />
|
||||
</svg>
|
||||
연결됨
|
||||
</span>
|
||||
<button
|
||||
onClick={() => handleDisconnectAccount(account.id)}
|
||||
className="myinfo-connected-disconnect"
|
||||
>
|
||||
연결 해제
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
|
||||
{/* Instagram 계정들 */}
|
||||
{instagramAccounts.map(account => (
|
||||
<div key={account.id} className="myinfo-connected-card">
|
||||
<div className="myinfo-connected-info">
|
||||
{account.profile_image ? (
|
||||
<img
|
||||
src={account.profile_image}
|
||||
alt={account.display_name}
|
||||
className="myinfo-connected-avatar"
|
||||
/>
|
||||
) : (
|
||||
<div className="myinfo-connected-icon">
|
||||
<img src="/assets/images/social-instagram.png" alt="Instagram" />
|
||||
</div>
|
||||
)}
|
||||
<div className="myinfo-connected-text">
|
||||
<span className="myinfo-connected-channel">{account.display_name}</span>
|
||||
<span className="myinfo-connected-platform">Instagram</span>
|
||||
</div>
|
||||
</div>
|
||||
<div className="myinfo-connected-actions">
|
||||
<span className="myinfo-connected-badge">
|
||||
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5">
|
||||
<polyline points="20 6 9 17 4 12" />
|
||||
</svg>
|
||||
연결됨
|
||||
</span>
|
||||
<button
|
||||
onClick={() => handleDisconnectAccount(account.id)}
|
||||
className="myinfo-connected-disconnect"
|
||||
>
|
||||
연결 해제
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{isLoadingAccounts && (
|
||||
<p className="myinfo-loading">계정 정보를 불러오는 중...</p>
|
||||
)}
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</main>
|
||||
);
|
||||
};
|
||||
|
||||
export default MyInfoContent;
|
||||
Reference in new issue
Block a user