feat(WEB): 거래처 상세 - 알람에서 신용분석 모달 자동 오픈

- page.tsx: modal 쿼리 파라미터 읽어서 VendorDetail에 전달
- VendorDetail: openModal prop 추가 및 useEffect로 모달 자동 오픈
- 사용: /accounting/vendors/{id}?modal=credit
This commit is contained in:
2026-01-23 11:22:57 +09:00
parent 1934126a18
commit c34bab591a
2 changed files with 12 additions and 2 deletions

View File

@@ -8,6 +8,7 @@ export default function VendorDetailPage() {
const searchParams = useSearchParams();
const vendorId = params.id as string;
const mode = searchParams.get('mode') === 'edit' ? 'edit' : 'view';
const openModal = searchParams.get('modal');
return <VendorDetail mode={mode} vendorId={vendorId} />;
return <VendorDetail mode={mode} vendorId={vendorId} openModal={openModal} />;
}

View File

@@ -51,6 +51,8 @@ import {
interface VendorDetailProps {
mode: 'view' | 'edit' | 'new';
vendorId?: string;
/** URL 쿼리 파라미터로 전달된 모달 타입 (예: 'credit') */
openModal?: string | null;
}
// 빈 Vendor 데이터 (신규 등록용)
@@ -92,7 +94,7 @@ const getEmptyVendor = (): Omit<Vendor, 'id' | 'createdAt' | 'updatedAt'> => ({
memos: [],
});
export function VendorDetail({ mode, vendorId }: VendorDetailProps) {
export function VendorDetail({ mode, vendorId, openModal }: VendorDetailProps) {
const router = useRouter();
const isViewMode = mode === 'view';
const isNewMode = mode === 'new';
@@ -149,6 +151,13 @@ export function VendorDetail({ mode, vendorId }: VendorDetailProps) {
// 신용분석 모달
const [isCreditModalOpen, setIsCreditModalOpen] = useState(false);
// URL 쿼리 파라미터로 모달 자동 오픈 (알람에서 접근 시)
useEffect(() => {
if (openModal === 'credit' && !isLoading) {
setIsCreditModalOpen(true);
}
}, [openModal, isLoading]);
// Validation 함수
const validateForm = useCallback(() => {
const errors: Record<string, string> = {};