From f17eedadcca392f1483f76a11835ca3b035369c9 Mon Sep 17 00:00:00 2001 From: 6-keem <6ukeem@gmail.com> Date: Wed, 20 Aug 2025 01:33:07 +0900 Subject: [PATCH] feat: connect APIs --- .../connection-wizard/wizard-modal.tsx | 19 +- .../components/erd/table-detail-sidebar.tsx | 18 +- .../src/components/layout/side-bar.tsx | 7 +- .../erd/db-schema-panel/annotation-item.tsx | 38 +++ .../db-schema-panel/annotation-sidebar.tsx | 71 ++++ .../erd/db-schema-panel/annotation.types.ts | 15 + src/renderer/src/erd/erd-page.tsx | 135 +++++++- src/renderer/src/erd/erd.type.ts | 318 ++++++++++++++++++ 8 files changed, 602 insertions(+), 19 deletions(-) create mode 100644 src/renderer/src/erd/db-schema-panel/annotation-item.tsx create mode 100644 src/renderer/src/erd/db-schema-panel/annotation-sidebar.tsx create mode 100644 src/renderer/src/erd/db-schema-panel/annotation.types.ts diff --git a/src/renderer/src/components/connection-wizard/wizard-modal.tsx b/src/renderer/src/components/connection-wizard/wizard-modal.tsx index cccfec0..7b4215f 100644 --- a/src/renderer/src/components/connection-wizard/wizard-modal.tsx +++ b/src/renderer/src/components/connection-wizard/wizard-modal.tsx @@ -151,17 +151,32 @@ export function ConnectionWizard(): JSX.Element { api .post('/api/user/db/create/profile', filteredPayload) .then((response) => { - const id = response.data.id as number + const id = response.data.id as string setConnectionDetail((prev) => ({ ...prev, id: id })) + createAnnotation(id) }) .catch(() => { toast.error('데이터베이스 연결 생성 중 오류가 발생했습니다.') }) + .finally(() => { + // NOTE: 페이지 새로고침 -> 저장된거 불러오도록 + window.location.reload() + onClose() + }) + } - onClose() + const createAnnotation = (db_profile_id: string): void => { + api + .post('/api/annotations/create', { + db_profile_id: db_profile_id + }) + .then(() => {}) + .catch(() => { + toast.error('어노테이션 생성 중 오류가 발생했습니다.') + }) } return ( diff --git a/src/renderer/src/components/erd/table-detail-sidebar.tsx b/src/renderer/src/components/erd/table-detail-sidebar.tsx index 4dc5f55..6ae0916 100644 --- a/src/renderer/src/components/erd/table-detail-sidebar.tsx +++ b/src/renderer/src/components/erd/table-detail-sidebar.tsx @@ -3,14 +3,13 @@ import { Table2, KeyRound, Link, - Square, - SquareDashedBottomIcon as SquareDashed, Database, Calendar, Hash, Type, Check, - LucideProps + LucideProps, + Diamond } from 'lucide-react' import { Button } from '@/components/ui/button' import { Badge } from '@/components/ui/badge' @@ -29,20 +28,20 @@ interface TableDetailSidebarProps { const constraintIcons = { primary: KeyRound, foreign: Link, - 'not-null': Square, - nullable: SquareDashed, + 'not-null': Diamond, + nullable: Diamond, unique: Hash, index: Database } as const // 제약 조건들 색상 const constraintColors = { - primary: 'text-yellow-400 bg-yellow-400/10', + primary: 'text-purple-400 bg-purple-400/10', foreign: 'text-blue-400 bg-blue-400/10', 'not-null': 'text-gray-400 bg-gray-400/10', nullable: 'text-gray-500 bg-gray-500/10', unique: 'text-green-400 bg-green-400/10', - index: 'text-purple-400 bg-purple-400/10' + index: 'text-yellow-400 bg-yellow-400/10' } as const // 제약 조건 표시 @@ -194,7 +193,10 @@ export function TableDetailSidebar({ className={`flex items-center gap-1 px-2 py-1 rounded text-xs ${colorClass}`} title={label} > - + {label} ) diff --git a/src/renderer/src/components/layout/side-bar.tsx b/src/renderer/src/components/layout/side-bar.tsx index 6b9016f..6753bfb 100644 --- a/src/renderer/src/components/layout/side-bar.tsx +++ b/src/renderer/src/components/layout/side-bar.tsx @@ -3,7 +3,7 @@ import AppIcon from '@renderer/assets/icon.svg' import { Database, Plus, Settings, Tag } from 'lucide-react' import { cn } from '@/lib/utils' import type { NavItem } from '../workspace/types' -import { useNavigate } from 'react-router-dom' +import { useLocation, useNavigate } from 'react-router-dom' const bottomNavItems: NavItem[] = [ { @@ -59,21 +59,24 @@ function NavButton({ item }: { item: NavItem }): React.JSX.Element { export function Sidebar(): React.JSX.Element { const navigate = useNavigate() + const location = useLocation() const topNavItems: NavItem[] = [ { id: 'database', icon: Database, - active: true, + active: location.pathname === '/', onClick: (): void | Promise => navigate('/') }, { id: 'tags', icon: Tag, + active: location.pathname === '/erd', disabled: false, onClick: (): void | Promise => navigate('/erd') } // TODO: DB 연결 후에 disabled: false ] + return (