diff --git a/app/[workspace]/project/[projectId]/settings/page.tsx b/app/[workspace]/project/[projectId]/(home)/settings/page.tsx similarity index 100% rename from app/[workspace]/project/[projectId]/settings/page.tsx rename to app/[workspace]/project/[projectId]/(home)/settings/page.tsx diff --git a/app/[workspace]/project/[projectId]/(workspace)/settings/page.tsx b/app/[workspace]/project/[projectId]/(workspace)/settings/page.tsx deleted file mode 100644 index 1876fe7c..00000000 --- a/app/[workspace]/project/[projectId]/(workspace)/settings/page.tsx +++ /dev/null @@ -1,258 +0,0 @@ -"use client"; - -import { useEffect, useState } from "react"; -import { useParams, useRouter } from "next/navigation"; -import { useSession } from "next-auth/react"; -import { toast } from "sonner"; -import { Loader2 } from "lucide-react"; - -interface Project { - id: string; - productName: string; - productVision?: string; - giteaRepo?: string; - giteaRepoUrl?: string; - status?: string; -} - -function SectionLabel({ children }: { children: React.ReactNode }) { - return ( -
- {children} -
- ); -} - -function FieldLabel({ children }: { children: React.ReactNode }) { - return ( -
- {children} -
- ); -} - -function InfoCard({ children, style = {} }: { children: React.ReactNode; style?: React.CSSProperties }) { - return ( -
- {children} -
- ); -} - -export default function ProjectSettingsPage() { - const params = useParams(); - const router = useRouter(); - const { data: session } = useSession(); - const projectId = params.projectId as string; - const workspace = params.workspace as string; - - const [project, setProject] = useState(null); - const [loading, setLoading] = useState(true); - const [saving, setSaving] = useState(false); - const [deleting, setDeleting] = useState(false); - const [confirmDelete, setConfirmDelete] = useState(false); - - const [productName, setProductName] = useState(""); - const [productVision, setProductVision] = useState(""); - - const userInitial = session?.user?.name?.[0]?.toUpperCase() ?? session?.user?.email?.[0]?.toUpperCase() ?? "?"; - const userName = session?.user?.name ?? session?.user?.email?.split("@")[0] ?? "You"; - - useEffect(() => { - fetch(`/api/projects/${projectId}`) - .then((r) => r.json()) - .then((d) => { - const p = d.project; - setProject(p); - setProductName(p?.productName ?? ""); - setProductVision(p?.productVision ?? ""); - }) - .catch(() => toast.error("Failed to load project")) - .finally(() => setLoading(false)); - }, [projectId]); - - const handleSave = async () => { - setSaving(true); - try { - const res = await fetch(`/api/projects/${projectId}`, { - method: "PATCH", - headers: { "Content-Type": "application/json" }, - body: JSON.stringify({ productName, productVision }), - }); - if (res.ok) { - toast.success("Saved"); - setProject((p) => p ? { ...p, productName, productVision } : p); - } else { - toast.error("Failed to save"); - } - } catch { - toast.error("An error occurred"); - } finally { - setSaving(false); - } - }; - - const handleDelete = async () => { - if (!confirmDelete) { setConfirmDelete(true); return; } - setDeleting(true); - try { - const res = await fetch("/api/projects/delete", { - method: "POST", - headers: { "Content-Type": "application/json" }, - body: JSON.stringify({ projectId }), - }); - if (res.ok) { - toast.success("Project deleted"); - router.push(`/${workspace}/projects`); - } else { - toast.error("Failed to delete project"); - } - } catch { - toast.error("An error occurred"); - } finally { - setDeleting(false); - } - }; - - if (loading) { - return ( -
- -
- ); - } - - return ( -
-
-

- Project Settings -

-

- Configure {project?.productName ?? "this project"} -

- - {/* General */} - - General - Project name - setProductName(e.target.value)} - style={{ width: "100%", padding: "9px 13px", borderRadius: 7, border: "1px solid #e0dcd4", background: "#faf8f5", fontSize: "0.84rem", color: "#1a1a1a", marginBottom: 16, boxSizing: "border-box" }} - /> - Description -