feat: [stocks] 재고 관리 페이지 신규 + 회계 모듈 타입/코드 정리
- 재고 관리 페이지 및 컴포넌트 신규 추가 - 회계 6개 모듈 중복 타입 제거, 코드 간소화 (-212줄) - AccountSubjectSelect 마이너 수정 - Popover 외부 클릭 다이얼로그 이슈 가이드 문서
This commit is contained in:
75
src/app/[locale]/(protected)/sales/stocks/[id]/page.tsx
Normal file
75
src/app/[locale]/(protected)/sales/stocks/[id]/page.tsx
Normal file
@@ -0,0 +1,75 @@
|
||||
'use client';
|
||||
|
||||
/**
|
||||
* 재고생산 상세/수정 페이지
|
||||
*
|
||||
* - 기본: 상세 보기 (StockProductionDetail)
|
||||
* - ?mode=edit: 수정 (StockProductionForm)
|
||||
*/
|
||||
|
||||
import { useState, useEffect } from 'react';
|
||||
import { useParams, useSearchParams } from 'next/navigation';
|
||||
import { Loader2 } from 'lucide-react';
|
||||
import { toast } from 'sonner';
|
||||
import { StockProductionDetail } from '@/components/stocks/StockProductionDetail';
|
||||
import { StockProductionForm } from '@/components/stocks/StockProductionForm';
|
||||
import { getStockOrderById, type StockOrder } from '@/components/stocks/actions';
|
||||
|
||||
function EditStockContent({ id }: { id: string }) {
|
||||
const [order, setOrder] = useState<StockOrder | null>(null);
|
||||
const [loading, setLoading] = useState(true);
|
||||
|
||||
useEffect(() => {
|
||||
async function load() {
|
||||
try {
|
||||
const result = await getStockOrderById(id);
|
||||
if (result.__authError) {
|
||||
toast.error('인증이 만료되었습니다.');
|
||||
return;
|
||||
}
|
||||
if (result.success && result.data) {
|
||||
setOrder(result.data);
|
||||
} else {
|
||||
toast.error(result.error || '데이터를 불러오는데 실패했습니다.');
|
||||
}
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
}
|
||||
load();
|
||||
}, [id]);
|
||||
|
||||
if (loading) {
|
||||
return (
|
||||
<div className="flex items-center justify-center min-h-[400px]">
|
||||
<div className="flex flex-col items-center gap-4">
|
||||
<Loader2 className="h-8 w-8 animate-spin text-blue-600" />
|
||||
<p className="text-muted-foreground">데이터를 불러오는 중...</p>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (!order) {
|
||||
return (
|
||||
<div className="flex items-center justify-center min-h-[400px]">
|
||||
<p className="text-muted-foreground">데이터를 찾을 수 없습니다.</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return <StockProductionForm initialData={order} isEditMode />;
|
||||
}
|
||||
|
||||
export default function StockDetailPage() {
|
||||
const params = useParams();
|
||||
const searchParams = useSearchParams();
|
||||
const id = params.id as string;
|
||||
const mode = searchParams.get('mode');
|
||||
|
||||
if (mode === 'edit') {
|
||||
return <EditStockContent id={id} />;
|
||||
}
|
||||
|
||||
return <StockProductionDetail orderId={id} />;
|
||||
}
|
||||
27
src/app/[locale]/(protected)/sales/stocks/page.tsx
Normal file
27
src/app/[locale]/(protected)/sales/stocks/page.tsx
Normal file
@@ -0,0 +1,27 @@
|
||||
'use client';
|
||||
|
||||
/**
|
||||
* 재고생산관리 페이지
|
||||
*
|
||||
* - 기본: 목록 (StockProductionList)
|
||||
* - ?mode=new: 등록 (StockProductionForm)
|
||||
*/
|
||||
|
||||
import { useSearchParams } from 'next/navigation';
|
||||
import { StockProductionList } from '@/components/stocks/StockProductionList';
|
||||
import { StockProductionForm } from '@/components/stocks/StockProductionForm';
|
||||
|
||||
function CreateStockContent() {
|
||||
return <StockProductionForm />;
|
||||
}
|
||||
|
||||
export default function StocksPage() {
|
||||
const searchParams = useSearchParams();
|
||||
const mode = searchParams.get('mode');
|
||||
|
||||
if (mode === 'new') {
|
||||
return <CreateStockContent />;
|
||||
}
|
||||
|
||||
return <StockProductionList />;
|
||||
}
|
||||
Reference in New Issue
Block a user