From b9a2081a76e669688d5884f20482b37cc8acca22 Mon Sep 17 00:00:00 2001
From: dujinkim <dujin.kim@dtsolution.co.kr>
Date: Mon, 13 Oct 2025 08:56:27 +0000
Subject: (최겸, 임수민) 구매 입찰, 견적(그룹코드, tbe에러) 수정, data-room
 수정
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 components/file-manager/FileManager.tsx | 100 +++++++++++++++++++++++---------
 1 file changed, 73 insertions(+), 27 deletions(-)

(limited to 'components/file-manager/FileManager.tsx')

diff --git a/components/file-manager/FileManager.tsx b/components/file-manager/FileManager.tsx
index 587beb22..fa2d8c38 100644
--- a/components/file-manager/FileManager.tsx
+++ b/components/file-manager/FileManager.tsx
@@ -335,7 +335,7 @@ export function FileManager({ projectId }: FileManagerProps) {
   const [searchQuery, setSearchQuery] = useState('');
   const [loading, setLoading] = useState(false);
 
-  console.log(items,"items")
+  console.log(items, "items")
 
   // Upload states
   const [uploadDialogOpen, setUploadDialogOpen] = useState(false);
@@ -754,9 +754,9 @@ export function FileManager({ projectId }: FileManagerProps) {
   // View file with PDFTron
   const viewFile = async (file: FileItem) => {
     try {
- 
 
-      
+
+
       setViewerFileUrl(file.filePath);
       setSelectedFile(file);
       setViewerDialogOpen(true);
@@ -991,7 +991,16 @@ export function FileManager({ projectId }: FileManagerProps) {
                 <Button
                   size="sm"
                   variant="outline"
-                  onClick={() => setUploadDialogOpen(true)}
+                  onClick={() => {
+                    // 현재 폴더의 카테고리를 기본값으로 설정
+                    if (currentParentId) {
+                      const currentFolder = items.find(item => item.parentId === currentParentId);
+                      if (currentFolder) {
+                        setUploadCategory(currentFolder.category);
+                      }
+                    }
+                    setUploadDialogOpen(true);
+                  }}
                 >
                   <Upload className="h-4 w-4 mr-1" />
                   Upload
@@ -1005,7 +1014,7 @@ export function FileManager({ projectId }: FileManagerProps) {
                 {items.filter(item =>
                   selectedItems.has(item.id) &&
                   item.type === 'file' &&
-                  item.permissions?.canDownload ==='true'
+                  item.permissions?.canDownload === 'true'
                 ).length > 0 && (
                     <Button
                       size="sm"
@@ -1296,16 +1305,42 @@ export function FileManager({ projectId }: FileManagerProps) {
                   <SelectValue />
                 </SelectTrigger>
                 <SelectContent>
-                  {Object.entries(categoryConfig).map(([key, config]) => (
-                    <SelectItem key={key} value={key}>
-                      <div className="flex items-center">
-                        <config.icon className={cn("h-4 w-4 mr-2", config.color)} />
-                        <span>{config.label}</span>
-                      </div>
-                    </SelectItem>
-                  ))}
+                  {Object.entries(categoryConfig)
+                    .filter(([key]) => {
+                      // 현재 폴더가 있는 경우
+                      if (currentParentId) {
+                        const currentFolder = items.find(item => item.parentId === currentParentId);
+                        // 현재 폴더가 public이 아니면 public 옵션 제외
+                        if (currentFolder && currentFolder.category !== 'public') {
+                          return key !== 'public';
+                        }
+                      }
+                      // 루트 폴더이거나 현재 폴더가 public인 경우 모든 옵션 표시
+                      return true;
+                    })
+                    .map(([key, config]) => (
+                      <SelectItem key={key} value={key}>
+                        <div className="flex items-center">
+                          <config.icon className={cn("h-4 w-4 mr-2", config.color)} />
+                          <span>{config.label}</span>
+                        </div>
+                      </SelectItem>
+                    ))}
                 </SelectContent>
               </Select>
+              {/* 현재 폴더 정보 표시 (선택사항) */}
+              {currentParentId && (() => {
+                const currentFolder = items.find(item => item.parentId === currentParentId);
+                if (currentFolder && currentFolder.category !== 'public') {
+                  return (
+                    <p className="text-xs text-muted-foreground mt-1 flex items-center">
+                      <AlertCircle className="h-3 w-3 mr-1" />
+                      Current folder is {categoryConfig[currentFolder.category].label}.
+                      Public uploads are not allowed.
+                    </p>
+                  );
+                }
+              })()}
             </div>
 
             {/* Dropzone */}
@@ -1644,13 +1679,13 @@ export function FileManager({ projectId }: FileManagerProps) {
               Changing category for {selectedFile?.name} folder.
             </DialogDescription>
           </DialogHeader>
-          
+
           <div className="space-y-4">
             <div>
               <Label>New Category</Label>
               <div className="mt-2 space-y-2">
                 {Object.entries(categoryConfig).map(([key, config]) => (
-                  <div 
+                  <div
                     key={key}
                     className={cn(
                       "flex items-center p-3 rounded-lg border cursor-pointer transition-colors",
@@ -1672,24 +1707,35 @@ export function FileManager({ projectId }: FileManagerProps) {
                 ))}
               </div>
             </div>
-            
             {selectedFile?.type === 'folder' && (
               <div className="flex items-center space-x-2">
                 <Switch
                   id="apply-to-children"
-                  checked={applyToChildren}
-                  onCheckedChange={setApplyToChildren}
+                  checked={newCategory !== 'public' ? true : applyToChildren}
+                  onCheckedChange={(checked) => {
+                    if (newCategory === 'public') {
+                      setApplyToChildren(checked);
+                    }
+                  }}
+                  disabled={newCategory !== 'public'}
                 />
-                <Label htmlFor="apply-to-children">
+                <Label htmlFor="apply-to-children" className={cn(
+                  newCategory !== 'public' && "text-muted-foreground"
+                )}>
                   Apply to all files and subfolders
+                  {newCategory !== 'public' && (
+                    <span className="text-xs block mt-1">
+                      (Required for security categories)
+                    </span>
+                  )}
                 </Label>
               </div>
             )}
           </div>
-          
+
           <DialogFooter>
-            <Button 
-              variant="outline" 
+            <Button
+              variant="outline"
               onClick={() => {
                 setCategoryDialogOpen(false);
                 setSelectedFile(null);
@@ -1698,7 +1744,7 @@ export function FileManager({ projectId }: FileManagerProps) {
             >
               Cancel
             </Button>
-            <Button 
+            <Button
               onClick={() => {
                 if (selectedFile) {
                   changeCategory(selectedFile.id, newCategory, applyToChildren);
@@ -1715,8 +1761,8 @@ export function FileManager({ projectId }: FileManagerProps) {
       </Dialog>
 
       {/* Secure Document Viewer Dialog */}
-      <Dialog 
-        open={viewerDialogOpen} 
+      <Dialog
+        open={viewerDialogOpen}
         onOpenChange={(open) => {
           if (!open) {
             setViewerDialogOpen(false);
@@ -1747,7 +1793,7 @@ export function FileManager({ projectId }: FileManagerProps) {
               </div>
             </DialogDescription>
           </DialogHeader>
-          
+
           <div className="relative flex-1 h-[calc(90vh-120px)]">
             {viewerFileUrl && selectedFile && (
               <SecurePDFViewer
@@ -1761,7 +1807,7 @@ export function FileManager({ projectId }: FileManagerProps) {
               />
             )}
           </div>
-          
+
           <div className="px-6 py-3 border-t bg-muted/50">
             <div className="flex items-center justify-between text-xs text-muted-foreground">
               <div className="flex items-center gap-4">
-- 
cgit v1.2.3

