From f839e58817340f09720e477ad610d41994a2cd8c Mon Sep 17 00:00:00 2001
From: joonhoekim <26rote@gmail.com>
Date: Thu, 27 Mar 2025 19:04:46 +0900
Subject: fix: unresolved merge
---
components/documents/view-document-dialog.tsx | 244 +-------------------------
1 file changed, 9 insertions(+), 235 deletions(-)
diff --git a/components/documents/view-document-dialog.tsx b/components/documents/view-document-dialog.tsx
index 7603fdc0..6daa806b 100644
--- a/components/documents/view-document-dialog.tsx
+++ b/components/documents/view-document-dialog.tsx
@@ -1,80 +1,3 @@
-<<<<<<< HEAD
-"use client";
-
-import * as React from "react";
-import { WebViewerInstance } from "@pdftron/webviewer";
-import {
- Dialog,
- DialogTrigger,
- DialogContent,
- DialogHeader,
- DialogTitle,
- DialogDescription,
- DialogFooter,
-} from "@/components/ui/dialog";
-import { Building2, FileIcon, Loader2 } from "lucide-react";
-import { Button } from "@/components/ui/button";
-import fs from "fs";
-
-// 인터페이스
-interface Attachment {
- id: number;
- fileName: string;
- filePath: string;
- fileType?: string;
-}
-
-interface Version {
- id: number;
- stage: string;
- revision: string;
- uploaderType: string;
- uploaderName: string | null;
- comment: string | null;
- status: string | null;
- planDate: string | null;
- actualDate: string | null;
- approvedDate: string | null;
- DocumentSubmitDate: Date;
- attachments: Attachment[];
- selected: boolean;
-}
-
-type ViewDocumentDialogProps = {
- versions: Version[];
-};
-
-export function ViewDocumentDialog({ versions }: ViewDocumentDialogProps) {
- const [open, setOpen] = React.useState(false);
-
- return (
- <>
-
- {open && (
-
- )}
- >
- );
-}
-
-const DocumentViewer: React.FC<{
- open: boolean;
- setOpen: React.Dispatch>;
- versions: Version[];
-}> = ({ open, setOpen, versions }) => {
- const [instance, setInstance] = React.useState(
- null
- );
- const [viwerLoading, setViewerLoading] = React.useState(true);
- const [fileSetLoading, setFileSetLoading] = React.useState(true);
-=======
"use client"
import * as React from "react"
@@ -85,7 +8,14 @@ import {
} from "@/components/ui/dialog"
import { Building2, FileIcon, Loader2 } from "lucide-react"
import { Button } from "@/components/ui/button"
-import fs from "fs"
+
+interface Attachment {
+ id: number;
+ fileName: string;
+ filePath: string;
+ fileType?: string;
+}
+
interface Version {
id: number
@@ -135,34 +65,22 @@ function DocumentViewer({open, setOpen, versions}){
const [instance, setInstance] = React.useState(null)
const [viwerLoading, setViewerLoading] = React.useState(true)
const [fileSetLoading, setFileSetLoading] = React.useState(true)
->>>>>>> cac978d5c77e9b30165e4fbe6930eeac9862204d
const viewer = React.useRef(null);
const initialized = React.useRef(false);
const isCancelled = React.useRef(false); // 초기화 중단용 flag
const cleanupHtmlStyle = () => {
const htmlElement = document.documentElement;
-<<<<<<< HEAD
-
- // 기존 style 속성 가져오기
- const originalStyle = htmlElement.getAttribute("style") || "";
-
-=======
// 기존 style 속성 가져오기
const originalStyle = htmlElement.getAttribute("style") || "";
->>>>>>> cac978d5c77e9b30165e4fbe6930eeac9862204d
// "color-scheme: light" 또는 "color-scheme: dark" 찾기
const colorSchemeStyle = originalStyle
.split(";")
.map((s) => s.trim())
.find((s) => s.startsWith("color-scheme:"));
-<<<<<<< HEAD
-
-=======
->>>>>>> cac978d5c77e9b30165e4fbe6930eeac9862204d
// 새로운 스타일 적용 (color-scheme만 유지)
if (colorSchemeStyle) {
htmlElement.setAttribute("style", colorSchemeStyle + ";");
@@ -170,46 +88,13 @@ function DocumentViewer({open, setOpen, versions}){
htmlElement.removeAttribute("style"); // color-scheme도 없으면 style 속성 자체 삭제
}
-<<<<<<< HEAD
- console.log("html style 삭제");
-=======
console.log("html style 삭제")
->>>>>>> cac978d5c77e9b30165e4fbe6930eeac9862204d
};
React.useEffect(() => {
if (open && !initialized.current) {
initialized.current = true;
isCancelled.current = false; // 다시 열릴 때는 false로 리셋
-<<<<<<< HEAD
-
- requestAnimationFrame(() => {
- if (viewer.current) {
- import("@pdftron/webviewer").then(({ default: WebViewer }) => {
- console.log(isCancelled.current);
- if (isCancelled.current) {
- console.log("📛 WebViewer 초기화 취소됨 (Dialog 닫힘)");
-
- return;
- }
-
- WebViewer(
- {
- path: "/pdftronWeb",
- licenseKey: process.env.NEXT_PUBLIC_PDFTRON_WEBVIEW_KEY,
- fullAPI: true,
- css: "/globals.css",
- },
- viewer.current as HTMLDivElement
- ).then(async (instance: WebViewerInstance) => {
- setInstance(instance);
- instance.UI.enableFeatures([instance.UI.Feature.MultiTab]);
- instance.UI.disableElements([
- "addTabButton",
- "multiTabsEmptyPage",
- ]);
- setViewerLoading(false);
-=======
requestAnimationFrame(() => {
if (viewer.current) {
@@ -237,21 +122,11 @@ function DocumentViewer({open, setOpen, versions}){
instance.UI.disableElements(["addTabButton", "multiTabsEmptyPage"]);
setViewerLoading(false);
->>>>>>> cac978d5c77e9b30165e4fbe6930eeac9862204d
});
});
}
});
}
-<<<<<<< HEAD
-
- return () => {
- // cleanup 시에는 중단 flag 세움
- if (instance) {
- instance.UI.dispose();
- }
- setTimeout(() => cleanupHtmlStyle(), 500);
-=======
return async () => {
// cleanup 시에는 중단 flag 세움
@@ -259,78 +134,10 @@ function DocumentViewer({open, setOpen, versions}){
await instance.UI.dispose()
}
await setTimeout(() => cleanupHtmlStyle(), 500)
->>>>>>> cac978d5c77e9b30165e4fbe6930eeac9862204d
};
}, [open]);
React.useEffect(() => {
-<<<<<<< HEAD
- const loadDocument = async () => {
- if (instance && versions.length > 0) {
- const { UI } = instance;
-
- const optionsArray: any[] = [];
-
- versions.forEach((c) => {
- const { attachments } = c;
- attachments.forEach((c2) => {
- const { fileName, filePath, fileType } = c2;
-
- const fileTypeCur = fileType ?? "";
-
- const options = {
- filename: fileName,
- ...(fileTypeCur.includes("xlsx") && {
- officeOptions: {
- formatOptions: {
- applyPageBreaksToSheet: true,
- },
- },
- }),
- };
-
- optionsArray.push({
- filePath,
- options,
- });
- });
- });
-
- const tabIds = [];
-
- for (const option of optionsArray) {
- const { filePath, options } = option;
- const response = await fetch(filePath);
- const blob = await response.blob();
-
- const tab = await UI.TabManager.addTab(blob, options);
- tabIds.push(tab); // 탭 ID 저장
- }
-
- if (tabIds.length > 0) {
- await UI.TabManager.setActiveTab(tabIds[0]);
- }
-
- setFileSetLoading(false);
- }
- };
- loadDocument();
- }, [instance, versions]);
-
- return (
-
- );
-};
-=======
// cleanupHtmlStyle()
setViewerLoading(false);
@@ -455,5 +230,4 @@ function DocumentViewer({open, setOpen, versions}){
);
-}
->>>>>>> cac978d5c77e9b30165e4fbe6930eeac9862204d
+}
\ No newline at end of file
--
cgit v1.2.3