castad front 작업
This commit is contained in:
1 parent
aa39cde4c6
commit
a42562279e
30 files changed
+4332
No files matched your search
Executable
+161
@@ -0,0 +1,161 @@
|
||||
|
||||
import React, { useRef, useEffect, useState } from 'react';
|
||||
import Sidebar from '../../components/Sidebar';
|
||||
import AssetManagementContent from './AssetManagementContent';
|
||||
import SoundStudioContent from './SoundStudioContent';
|
||||
import CompletionContent from './CompletionContent';
|
||||
import DashboardContent from './DashboardContent';
|
||||
import BusinessSettingsContent from './BusinessSettingsContent';
|
||||
import { ImageItem } from '../../types/api';
|
||||
|
||||
interface BusinessInfo {
|
||||
customer_name: string;
|
||||
region: string;
|
||||
detail_region_info: string;
|
||||
}
|
||||
|
||||
interface GenerationFlowProps {
|
||||
onHome: () => void;
|
||||
initialActiveItem?: string;
|
||||
initialImageList?: string[];
|
||||
businessInfo?: BusinessInfo;
|
||||
}
|
||||
|
||||
const GenerationFlow: React.FC<GenerationFlowProps> = ({ onHome, initialActiveItem = '대시보드', initialImageList = [], businessInfo }) => {
|
||||
const scrollContainerRef = useRef<HTMLDivElement>(null);
|
||||
const [activeItem, setActiveItem] = useState(initialActiveItem);
|
||||
const [maxWizardIndex, setMaxWizardIndex] = useState(0);
|
||||
|
||||
// URL 이미지를 ImageItem 형태로 변환하여 초기화
|
||||
const [imageList, setImageList] = useState<ImageItem[]>(
|
||||
initialImageList.map(url => ({ type: 'url', url }))
|
||||
);
|
||||
|
||||
const handleRemoveImage = (index: number) => {
|
||||
setImageList(prev => {
|
||||
const item = prev[index];
|
||||
// 파일 이미지인 경우 메모리 해제
|
||||
if (item.type === 'file') {
|
||||
URL.revokeObjectURL(item.preview);
|
||||
}
|
||||
return prev.filter((_, i) => i !== index);
|
||||
});
|
||||
};
|
||||
|
||||
const handleAddImages = (files: File[]) => {
|
||||
const newImages: ImageItem[] = files.map(file => ({
|
||||
type: 'file',
|
||||
file,
|
||||
preview: URL.createObjectURL(file),
|
||||
}));
|
||||
setImageList(prev => [...prev, ...newImages]);
|
||||
};
|
||||
|
||||
const scrollToWizardSection = (index: number) => {
|
||||
if (scrollContainerRef.current) {
|
||||
const sections = scrollContainerRef.current.querySelectorAll('.flow-section');
|
||||
if (sections[index]) {
|
||||
setMaxWizardIndex(prev => Math.max(prev, index));
|
||||
sections[index].scrollIntoView({ behavior: 'smooth', block: 'start' });
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
const container = scrollContainerRef.current;
|
||||
if (!container || activeItem !== '새 프로젝트 만들기') return;
|
||||
|
||||
const handleWheel = (e: WheelEvent) => {
|
||||
// 스크롤 가능한 자식 요소 내부에서 발생한 이벤트인지 확인
|
||||
const target = e.target as HTMLElement;
|
||||
|
||||
// custom-scrollbar 클래스를 가진 요소 또는 그 자식에서 발생한 이벤트인지 확인
|
||||
const scrollableParent = target.closest('.custom-scrollbar') as HTMLElement;
|
||||
if (scrollableParent) {
|
||||
const { scrollTop, scrollHeight, clientHeight } = scrollableParent;
|
||||
const hasScrollableContent = scrollHeight > clientHeight;
|
||||
const atTop = scrollTop <= 0;
|
||||
const atBottom = scrollTop + clientHeight >= scrollHeight - 1;
|
||||
|
||||
// 스크롤 가능한 콘텐츠가 있는 경우
|
||||
if (hasScrollableContent) {
|
||||
// 위로 스크롤하고 맨 위가 아니거나, 아래로 스크롤하고 맨 아래가 아니면 허용
|
||||
if ((e.deltaY < 0 && !atTop) || (e.deltaY > 0 && !atBottom)) {
|
||||
return; // 이미지 리스트 스크롤 허용 (preventDefault 하지 않음)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const h = container.clientHeight;
|
||||
const currentIdx = Math.round(container.scrollTop / h);
|
||||
|
||||
if (e.deltaY > 0) { // Down
|
||||
if (currentIdx >= maxWizardIndex) {
|
||||
e.preventDefault();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
container.addEventListener('wheel', handleWheel, { passive: false });
|
||||
return () => container.removeEventListener('wheel', handleWheel);
|
||||
}, [maxWizardIndex, activeItem]);
|
||||
|
||||
const renderContent = () => {
|
||||
switch (activeItem) {
|
||||
case '대시보드':
|
||||
return <DashboardContent />;
|
||||
case '비즈니스 설정':
|
||||
return <BusinessSettingsContent />;
|
||||
case '새 프로젝트 만들기':
|
||||
return (
|
||||
<div
|
||||
ref={scrollContainerRef}
|
||||
className="flex-1 h-full overflow-y-auto snap-y snap-mandatory scroll-smooth no-scrollbar"
|
||||
style={{ scrollbarWidth: 'none', msOverflowStyle: 'none' }}
|
||||
>
|
||||
{/* Step 0: Asset Management (AnalysisResultSection removed) */}
|
||||
<div className="flow-section snap-start h-full w-full flex flex-col overflow-hidden">
|
||||
<AssetManagementContent
|
||||
onBack={() => setActiveItem('대시보드')}
|
||||
onNext={() => scrollToWizardSection(1)}
|
||||
imageList={imageList}
|
||||
onRemoveImage={handleRemoveImage}
|
||||
onAddImages={handleAddImages}
|
||||
/>
|
||||
</div>
|
||||
{/* Step 1: Sound Studio */}
|
||||
<div className="flow-section snap-start h-full w-full flex flex-col">
|
||||
<SoundStudioContent
|
||||
onBack={() => scrollToWizardSection(0)}
|
||||
onNext={() => scrollToWizardSection(2)}
|
||||
businessInfo={businessInfo}
|
||||
/>
|
||||
</div>
|
||||
{/* Step 2: Completion */}
|
||||
<div className="flow-section snap-start h-full w-full flex flex-col overflow-hidden">
|
||||
<CompletionContent
|
||||
onBack={() => scrollToWizardSection(1)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
default:
|
||||
return (
|
||||
<div className="flex-1 flex items-center justify-center text-gray-500 font-light">
|
||||
{activeItem} 페이지 준비 중입니다.
|
||||
</div>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="flex w-full h-[100dvh] bg-[#0d1416] text-white overflow-hidden">
|
||||
<Sidebar activeItem={activeItem} onNavigate={setActiveItem} />
|
||||
<div className="flex-1 h-full relative overflow-hidden pl-0 md:pl-0">
|
||||
{renderContent()}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default GenerationFlow;
|
||||
Reference in new issue
Block a user