Skip to content

Commit f7c4c84

Browse files
authored
Merge pull request #62 from cortex-reply/fix/files
fix: applies fix on files
2 parents 252a3f9 + d82ad71 commit f7c4c84

7 files changed

Lines changed: 233 additions & 84 deletions

File tree

src/components/DigitalColleagues/Pages/dashboardpage.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,14 @@ import { mockProjectSummary } from '../test-data'
1414
import type {
1515
App,
1616
ProjectSummary,
17-
FileType,
17+
// FileType,
1818
BusinessUnit,
1919
Project,
2020
SidebarItem,
2121
Colleague,
2222
User,
2323
} from '../types'
24+
import type { File as FileType } from '../../Foundary/types'
2425
// import { ColleaguesManagement } from "../colleagues-management"
2526
import ColleaguesView from './../Views/ColleaguesView'
2627
import KnowledgeView from '../Views/KnowledgeView'

src/components/Foundary/Pages/dashboardpage.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ import { mockProjectSummary } from '../test-data'
1414
import type {
1515
App,
1616
ProjectSummary,
17-
FileType,
17+
// FileType,
18+
File as FileType,
1819
BusinessUnit,
1920
Project,
2021
SidebarItem,
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
import React, { useState } from 'react'
2+
import { Dialog, DialogContent, DialogHeader, DialogTitle } from '@/components/ui/dialog'
3+
import { Button } from '@/components/ui/button'
4+
interface AddFileModalProps {
5+
isOpen: boolean
6+
onClose: () => void
7+
onAddFile?: (file: FormData) => void
8+
}
9+
10+
export const AddFileModal: React.FC<AddFileModalProps> = ({ isOpen, onClose, onAddFile }) => {
11+
const [selectedFile, setSelectedFile] = useState<File | null>(null)
12+
const [fileName, setFileName] = useState('')
13+
const [description, setDescription] = useState('')
14+
const [tags, setTags] = useState('')
15+
16+
const handleFileChange = (e: React.ChangeEvent<HTMLInputElement>) => {
17+
const file = e.target.files?.[0]
18+
if (file) {
19+
setSelectedFile(file)
20+
// Auto-populate filename if not already set
21+
if (!fileName) {
22+
setFileName(file.name)
23+
}
24+
}
25+
}
26+
27+
const handleSubmit = async (e: React.FormEvent) => {
28+
e.preventDefault()
29+
30+
if (!selectedFile) {
31+
return
32+
}
33+
34+
const formData = new FormData()
35+
formData.append('file', selectedFile as File)
36+
formData.append('name', fileName)
37+
38+
if (description) {
39+
formData.append('description', description)
40+
}
41+
42+
if (tags) {
43+
formData.append('tags', tags)
44+
}
45+
46+
onAddFile?.(formData)
47+
48+
onClose()
49+
setSelectedFile(null)
50+
setFileName('')
51+
setDescription('')
52+
setTags('')
53+
}
54+
55+
return (
56+
<Dialog open={isOpen} onOpenChange={onClose}>
57+
<DialogContent className="sm:max-w-md">
58+
<DialogHeader>
59+
<DialogTitle>Add New File</DialogTitle>
60+
</DialogHeader>
61+
62+
<form onSubmit={handleSubmit} className="grid gap-4">
63+
<div className="flex items-center justify-center w-full">
64+
<label
65+
htmlFor="dropzone-file"
66+
className="flex flex-col items-center justify-center w-full h-64 border-2 border-gray-300 border-dashed rounded-lg cursor-pointer bg-gray-50 dark:hover:bg-bray-800 dark:bg-gray-700 hover:bg-gray-100 dark:border-gray-600 dark:hover:border-gray-500 dark:hover:bg-gray-600"
67+
>
68+
<div className="flex flex-col items-center justify-center pt-5 pb-6">
69+
<UploadIcon className="w-10 h-10 text-gray-400" />
70+
<p className="mb-2 text-sm text-gray-500 dark:text-gray-400">
71+
<span className="font-semibold">Click to upload</span> or drag and drop
72+
</p>
73+
<p className="text-xs text-gray-500 dark:text-gray-400">
74+
SVG, PNG, JPG or GIF (MAX. 800x400px)
75+
</p>
76+
</div>
77+
<input
78+
id="dropzone-file"
79+
type="file"
80+
className="hidden"
81+
onChange={handleFileChange}
82+
/>
83+
</label>
84+
</div>
85+
{selectedFile && (
86+
<div className="flex items-center justify-between">
87+
<div>
88+
<p className="font-medium">{selectedFile.name}</p>
89+
<p className="text-sm text-muted-foreground">
90+
{((selectedFile.size || 0) / 1024).toFixed(2)} KB
91+
</p>
92+
</div>
93+
<Button type="submit" onClick={handleSubmit}>
94+
Upload
95+
</Button>
96+
</div>
97+
)}
98+
</form>
99+
</DialogContent>
100+
</Dialog>
101+
)
102+
}
103+
104+
function UploadIcon(props: React.SVGProps<SVGSVGElement>) {
105+
return (
106+
<svg
107+
{...props}
108+
xmlns="http://www.w3.org/2000/svg"
109+
width="24"
110+
height="24"
111+
viewBox="0 0 24 24"
112+
fill="none"
113+
stroke="currentColor"
114+
strokeWidth="2"
115+
strokeLinecap="round"
116+
strokeLinejoin="round"
117+
>
118+
<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" />
119+
<polyline points="17 8 12 3 7 8" />
120+
<line x1="12" x2="12" y1="3" y2="15" />
121+
</svg>
122+
)
123+
}

src/components/Projects/FileView.tsx

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,21 @@
11
'use client'
22

33
import { useEffect, useState } from 'react'
4-
import { Plus, Search, File, Filter, Download, Upload } from 'lucide-react'
4+
import { Plus, Search, File, Filter } from 'lucide-react'
55
import { Button } from '@/components/ui/button'
6-
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'
6+
import { Card, CardContent } from '@/components/ui/card'
77
import { Input } from '@/components/ui/input'
8-
import {
9-
Select,
10-
SelectContent,
11-
SelectItem,
12-
SelectTrigger,
13-
SelectValue,
14-
} from '@/components/ui/select'
8+
159
import { NavigationTabs } from '../AdvancedComponents/navigation-tabs'
1610
import { FileList } from './file-list'
1711
import { DashboardHero } from '../Heros/DashboardHero/DashboardHero'
18-
import { FileType, type RecentFile } from '../DigitalColleagues/types'
12+
import { File as FileType } from '../Foundary/types'
1913
import { motion, AnimatePresence } from 'motion/react'
14+
import { AddFileModal } from './AddFileModal'
2015

2116
interface FileViewProps {
2217
initialFiles?: FileType[]
23-
onFileAdd?: () => void
18+
onFileAdd?: (file: FormData) => void
2419
onFileEdit?: (file: FileType) => void
2520
onFileDelete?: (fileId: string) => void
2621
onFileClick?: (file: FileType) => void
@@ -41,26 +36,26 @@ export default function FileView({
4136
const [searchTerm, setSearchTerm] = useState('')
4237
const [appFilter, setAppFilter] = useState<string>('all')
4338
const [activeTab, setActiveTab] = useState('all')
44-
39+
const [isAddFileModalOpen, setIsAddFileModalOpen] = useState(false)
4540
useEffect(() => {
4641
setFiles(initialFiles)
4742
}, [initialFiles])
4843

4944
// Get unique apps for filter
50-
const uniqueApps = Array.from(new Set(files.map((file) => file.mimeType)))
45+
// const uniqueApps = Array.from(new Set(files.map((file) => file.mimeType)))
5146

5247
const filteredFiles = files.filter((file) => {
5348
const matchesSearch = file.name.toLowerCase().includes(searchTerm.toLowerCase())
54-
const matchesApp = appFilter === 'all' || file.mimeType === appFilter
55-
return matchesSearch && matchesApp
49+
// const matchesApp = appFilter === 'all' || file.mimeType === appFilter || file.app === appFilter
50+
return matchesSearch
5651
})
5752

5853
const recentFiles = filteredFiles.slice(0, 10) // Show 10 most recent
5954
const sharedFiles = filteredFiles.filter(Boolean)
6055

6156
const handleAddFile = () => {
6257
// This would typically open a file upload dialog
63-
onFileAdd?.()
58+
setIsAddFileModalOpen(true)
6459
}
6560

6661
const handleEditFile = (file: FileType) => {
@@ -70,7 +65,7 @@ export default function FileView({
7065
const handleDeleteFile = (file: FileType) => {
7166
console.log('deleting file', file)
7267
setFiles((prev) => prev.filter((f) => f.name !== file.name))
73-
onFileDelete?.(file.id)
68+
onFileDelete?.(file.id.toString())
7469
}
7570

7671
const handleFileClick = (file: FileType) => {
@@ -248,6 +243,11 @@ export default function FileView({
248243
</div>
249244
</motion.div>
250245
</AnimatePresence>
246+
<AddFileModal
247+
isOpen={isAddFileModalOpen}
248+
onClose={() => setIsAddFileModalOpen(false)}
249+
onAddFile={onFileAdd}
250+
/>
251251
</div>
252252
)
253253
}

src/components/Projects/ProjectView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { TaskDetailsModal } from './TaskDetailsModal'
1515
import type {
1616
Reminder,
1717
DigitalColleague,
18-
FileType,
18+
File as FileType,
1919
User,
2020
Task,
2121
Epic,

src/components/Projects/file-list.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import { motion } from 'motion/react'
44
import { MoreHorizontal, Trash2, Edit } from 'lucide-react'
55
import { Button } from '@/components/ui/button'
6-
import { FileType } from '../DigitalColleagues/types'
6+
import { File as FileType } from '../Foundary/types'
77

88
interface FileListProps {
99
files: FileType[]

0 commit comments

Comments
 (0)