import { env } from "next-runtime-env"; import { HiMiniArrowTopRightOnSquare } from "react-icons/hi2"; import Button from "~/components/Button"; import Modal from "~/components/modal"; import { NewWorkspaceForm } from "~/components/NewWorkspaceForm"; import { PageHead } from "~/components/PageHead"; import { useModal } from "~/providers/modal"; import { useWorkspace } from "~/providers/workspace"; import { api } from "~/utils/api"; import Avatar from "./components/Avatar"; import CreateAPIKeyForm from "./components/CreateAPIKeyForm"; import { CustomURLConfirmation } from "./components/CustomURLConfirmation"; import { DeleteAccountConfirmation } from "./components/DeleteAccountConfirmation"; import { DeleteWorkspaceConfirmation } from "./components/DeleteWorkspaceConfirmation"; import UpdateDisplayNameForm from "./components/UpdateDisplayNameForm"; import UpdateWorkspaceDescriptionForm from "./components/UpdateWorkspaceDescriptionForm"; import UpdateWorkspaceNameForm from "./components/UpdateWorkspaceNameForm"; import UpdateWorkspaceUrlForm from "./components/UpdateWorkspaceUrlForm"; export default function SettingsPage() { const { modalContentType, openModal } = useModal(); const { workspace } = useWorkspace(); const utils = api.useUtils(); const { data } = api.user.getUser.useQuery(); const refetchUser = () => utils.user.getUser.refetch(); const handleOpenBillingPortal = async () => { try { const response = await fetch("/api/stripe/create_billing_session", { method: "POST", headers: { "Content-Type": "application/json", }, }); const { url } = (await response.json()) as { url: string }; if (url) { window.location.href = url; } } catch (error) { console.error("Error creating billing session:", error); } }; return ( <>

Settings

Profile picture

Display name

Workspace name

Workspace URL

Workspace description

{env("NEXT_PUBLIC_KAN_ENV") === "cloud" && (

Billing

View and manage your billing and subscription.

)}

API keys

View and manage your API keys.

Delete workspace

Once you delete your workspace, there is no going back. This action cannot be undone.

Delete account

Once you delete your account, there is no going back. This action cannot be undone.

{modalContentType === "NEW_WORKSPACE" && } {modalContentType === "DELETE_WORKSPACE" && ( )} {modalContentType === "UPDATE_WORKSPACE_URL" && ( )} {modalContentType === "DELETE_ACCOUNT" && ( )}
); }