import { CopyButton } from "@/components/dashboard/copy-button";
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
import { Code } from "@/components/ui/code";
// import { getTenantId } from "@/lib/auth";
// import { db } from "@/lib/db";
import { redirect } from "next/navigation";
// import { UpdateWorkspaceImage } from "./update-workspace-image";
import { UpdateWorkspaceName } from "./update-workspace-name";
import Link from "next/link";
import { ArrowLeft, UploadCloud } from "lucide-react";
import { UpdateWorkspace } from "./update-workspace";
import { Textarea } from "@/components/ui/textarea";
import { Button } from "@/components/ui/button";
import Loading from "../../apis/loading";
export const dynamic = "force-dynamic";

export default async function SettingsPage() {
  // const tenantId = getTenantId();

  // const workspace = await db.query.workspaces.findFirst({
  //   where: (table, { and, eq, isNull }) =>
  //     and(eq(table.tenantId, tenantId), isNull(table.deletedAt)),
  // });
  // if (!workspace) {
  //   return redirect("/new");
  // }

  const workspace = {
    id: "string",
    tenantId: "string",
    name: "string",
  }

  // const dragActive = true

  return (
    <div className="mb-20 flex flex-col gap-8 ">
      {/* <UpdateWorkspaceName workspace={workspace} /> */}
      {/* <UpdateWorkspaceImage /> */}

      <Link
        // href="/manage"
        href="javascript:history.back()"
        className="flex items-center gap-1 text-sm duration-200 text-content-subtle hover:text-foreground"
      >
        <ArrowLeft className="w-4 h-4" /> Manage
      </Link>

      {/* <Card>
        <CardHeader>
          <CardTitle>Workspace Avatar</CardTitle>
        </CardHeader>
        <CardContent>
          <p className="text-sm text-content-subtle">
            This is a personal workspace. Change your personal avatar{" "}
            <Link href="/app/settings/user" className="underline hover:text-content">
              here
            </Link>
            .
          </p>
        </CardContent>
      </Card> */}
      <Card>
        <CardHeader>
          <CardTitle>Workspace ID</CardTitle>
          <CardDescription>xxxxxxxx</CardDescription>
        </CardHeader>
        <CardContent>
          <Code className="flex h-8 w-full max-w-sm items-center justify-between gap-4">
            <pre>{workspace.id}</pre>
            <div className="flex items-start justify-between gap-4">
              <CopyButton value={workspace.id} />
            </div>
          </Code>
        </CardContent>
      </Card>



      <UpdateWorkspace />


    </div>
  );
}
