diff options
| -rw-r--r-- | lib/docu-list-rule/document-class/service.ts | 25 | ||||
| -rw-r--r-- | lib/docu-list-rule/document-class/table/document-class-option-add-dialog.tsx | 36 | ||||
| -rw-r--r-- | lib/projects/service.ts | 15 |
3 files changed, 40 insertions, 36 deletions
diff --git a/lib/docu-list-rule/document-class/service.ts b/lib/docu-list-rule/document-class/service.ts index 378c3215..29ed2642 100644 --- a/lib/docu-list-rule/document-class/service.ts +++ b/lib/docu-list-rule/document-class/service.ts @@ -593,4 +593,29 @@ export async function deleteDocumentClassOption(id: number) { error: "Failed to delete document class option" } } +} + +// 프로젝트 일정 설정을 가져오는 함수 +export async function getProjectKindScheduleSetting(projectCode: string): Promise<ScheduleSetting[]> { + try { + const response = await fetch( + `http://60.100.99.217/DDP/Services/VNDRService.svc/GetProjectKindScheduleSetting?PROJ_NO=${projectCode}`, + { + method: 'GET', + headers: { + 'Content-Type': 'application/json', + }, + } + ) + + if (!response.ok) { + throw new Error('Failed to fetch schedule settings') + } + + const data = await response.json() + return data.GetProjectKindScheduleSettingResult || [] + } catch (error) { + console.error('Error fetching schedule settings:', error) + return [] + } }
\ No newline at end of file diff --git a/lib/docu-list-rule/document-class/table/document-class-option-add-dialog.tsx b/lib/docu-list-rule/document-class/table/document-class-option-add-dialog.tsx index 31337675..ac943ceb 100644 --- a/lib/docu-list-rule/document-class/table/document-class-option-add-dialog.tsx +++ b/lib/docu-list-rule/document-class/table/document-class-option-add-dialog.tsx @@ -40,7 +40,7 @@ import { import { cn } from "@/lib/utils" import { useParams } from "next/navigation" -import { createDocumentClassOptionItem } from "@/lib/docu-list-rule/document-class/service" +import { createDocumentClassOptionItem, getProjectKindScheduleSetting } from "@/lib/docu-list-rule/document-class/service" import { getProjectCode } from "@/lib/projects/service" // API 응답 타입 @@ -54,31 +54,6 @@ interface ScheduleSetting { USE_YN2: string } -// 프로젝트 일정 설정을 가져오는 함수 -async function getProjectKindScheduleSetting(projectCode: string): Promise<ScheduleSetting[]> { - try { - const response = await fetch( - `http://60.100.99.217/DDP/Services/VNDRService.svc/GetProjectKindScheduleSetting?PROJ_NO=${projectCode}`, - { - method: 'GET', - headers: { - 'Content-Type': 'application/json', - }, - } - ) - - if (!response.ok) { - throw new Error('Failed to fetch schedule settings') - } - - const data = await response.json() - return data.GetProjectKindScheduleSettingResult || [] - } catch (error) { - console.error('Error fetching schedule settings:', error) - return [] - } -} - const createOptionSchema = z.object({ optionCode: z.string().min(1, "옵션을 선택해주세요."), }) @@ -218,7 +193,14 @@ export function DocumentClassOptionAddDialog({ documentClassId, onSuccess }: Doc <CommandEmpty> {isLoading ? "로딩 중..." : "검색 결과가 없습니다."} </CommandEmpty> - <CommandGroup className="max-h-[200px] overflow-auto"> + <CommandGroup + className="max-h-[200px] overflow-auto" + onWheel={(e) => { + e.stopPropagation(); + const target = e.currentTarget; + target.scrollTop += e.deltaY; + }} + > {scheduleSettings.map((setting) => ( <CommandItem key={setting.COL_NM} diff --git a/lib/projects/service.ts b/lib/projects/service.ts index 4685fce4..aad1856e 100644 --- a/lib/projects/service.ts +++ b/lib/projects/service.ts @@ -121,16 +121,13 @@ export async function getAllProjectInfoByProjectCode(projectCode: string) { */ export async function getProjectCode(projectId: number): Promise<string | null> { try { - const project = await db.project.findUnique({ - where: { - id: projectId, - }, - select: { - code: true, - }, - }) + const project = await db + .select({ code: projects.code }) + .from(projects) + .where(eq(projects.id, projectId)) + .limit(1); - return project?.code || null + return project[0]?.code || null; } catch (error) { console.error("Error fetching project code:", error) return null |
