diff --git a/src/ui/components/project-dialog.tsx b/src/ui/components/project-dialog.tsx index ee9ca759..b7a2728e 100644 --- a/src/ui/components/project-dialog.tsx +++ b/src/ui/components/project-dialog.tsx @@ -1,7 +1,5 @@ -import { client } from '@/ui/api/client' -import { useMutation, useQueryClient } from '@tanstack/react-query' -import type { InferResponseType, InferRequestType } from 'hono/client' import type { ProjectInfo } from '@/dtos/project' +import { client } from '@/ui/api/client' import { Button } from '@/ui/components/ui/button' import { Dialog, @@ -13,8 +11,11 @@ import { } from '@/ui/components/ui/dialog' import { Input } from '@/ui/components/ui/input' import { Label } from '@/ui/components/ui/label' +import { Switch } from '@/ui/components/ui/switch' +import { useMutation, useQueryClient } from '@tanstack/react-query' import { useNavigate } from '@tanstack/react-router' -import { Loader2, Upload } from 'lucide-react' +import type { InferRequestType, InferResponseType } from 'hono/client' +import { Bell, Check, Loader2, Sliders, Sparkles, Upload, X } from 'lucide-react' import { useEffect, useRef, useState } from 'react' interface ProjectDialogProps { @@ -29,6 +30,7 @@ export function ProjectDialog({ open, onOpenChange, mode, teamId, project }: Pro const queryClient = useQueryClient() const navigate = useNavigate() const [name, setName] = useState('') + const [enableNotification, setEnableNotification] = useState(true) // Cover Image State const [coverImageKey, setCoverImageKey] = useState(undefined) @@ -42,10 +44,12 @@ export function ProjectDialog({ open, onOpenChange, mode, teamId, project }: Pro setName(project.name || '') setCoverImageKey(project.coverImageKey) setCoverImagePreview(project.coverImage) + setEnableNotification(project.enableNotification !== false) } else { setName('') setCoverImageKey(undefined) setCoverImagePreview(undefined) + setEnableNotification(true) } } }, [open, mode, project]) @@ -66,10 +70,13 @@ export function ProjectDialog({ open, onOpenChange, mode, teamId, project }: Pro queryKey: ['teams', teamId, 'projects'], }) onOpenChange(false) - navigate({ - to: '/projects/$projectId', - params: { projectId: data.id! }, - }) + const dataObj = data as Record + if (dataObj && typeof dataObj.id === 'string') { + navigate({ + to: '/projects/$projectId', + params: { projectId: dataObj.id }, + }) + } }, }) @@ -112,8 +119,9 @@ export function ProjectDialog({ open, onOpenChange, mode, teamId, project }: Pro return await res.json() }, onSuccess: (data) => { - if (typeof data === 'object' && 'key' in data) { - setCoverImageKey(data.key) + const obj = data as Record + if (obj && typeof obj.key === 'string') { + setCoverImageKey(obj.key) } setIsUploading(false) }, @@ -141,6 +149,12 @@ export function ProjectDialog({ open, onOpenChange, mode, teamId, project }: Pro fileInputRef.current?.click() } + const handleRemoveCover = (e: React.MouseEvent) => { + e.stopPropagation() + setCoverImageKey(undefined) + setCoverImagePreview(undefined) + } + const handleSubmit = () => { if (!name.trim()) return @@ -148,32 +162,87 @@ export function ProjectDialog({ open, onOpenChange, mode, teamId, project }: Pro createProject({ name: name.trim(), coverImageKey: coverImageKey, + enableNotification: enableNotification, }) } else if (mode === 'edit' && project?.id) { updateProject({ name: name.trim(), coverImageKey: coverImageKey, + enableNotification: enableNotification, }) } } return ( - - - {mode === 'create' ? 'Create Project' : 'Project Settings'} - - {mode === 'create' - ? 'Configure your new project.' - : 'Update your project configuration.'} - + + {/* Beautiful Glowing Header */} + +
+
+ +
+
+ + {mode === 'create' ? 'Create New Project' : 'Project Settings'} + + + {mode === 'create' + ? 'Configure your new project workspace and appearance.' + : 'Manage and update your project workspace configurations.'} + +
+
-
- {/* Cover Image Upload Section */} -
- + + {/* Scrollable Form Content */} +
+ {/* Project Name Field */} +
+ +
+ setName(e.target.value)} + placeholder="e.g. Acme Marketing, Q3 Product Launch..." + className="h-11 px-4 rounded-xl border-border/80 focus-visible:ring-ring/25 focus-visible:border-primary transition-all shadow-xs pr-10" + /> + {name.trim() && ( +
+ +
+ )} +
+

+ A clear, concise name to identify your project space. +

+
+ + {/* Cover Image & Branding Section */} +
+
+ + {coverImagePreview && ( + + )} +
+ + {/* Centered Square 1:1 Preview Area */}
- {isUploading ? ( -
- + + {/* Uploading Spinner */} + {isUploading && ( +
+
+ + Uploading... +
- ) : null} + )} {coverImagePreview ? ( - Cover Preview + <> + Cover Preview + {/* Hover Overlay */} +
+ + Upload Image +
+ ) : ( -
- - Upload Image +
+
+ +
+
+

Upload cover

+

+ Drag and drop, or browse. Recommended 1:1 (400×400px). +

+
)}
-
-
- - +