import { Breadcrumb, BreadcrumbItem, Text, type TextProps, VStack, HStack, Input, Button, Divider, Icon, useDisclosure, } from "@chakra-ui/react"; import { useEffect, useState } from "react"; import { BsTrash } from "react-icons/bs"; import AppShell from "~/components/nav/AppShell"; import PageHeaderContainer from "~/components/nav/PageHeaderContainer"; import { api } from "~/utils/api"; import { useHandledAsyncCallback, useSelectedOrg } from "~/utils/hooks"; import ProjectBreadcrumbContents from "~/components/nav/ProjectBreadcrumbContents"; import CopiableCode from "~/components/CopiableCode"; import { DeleteProjectDialog } from "~/components/projectSettings/DeleteProjectDialog"; export default function Settings() { const utils = api.useContext(); const { data: selectedOrg } = useSelectedOrg(); const apiKey = selectedOrg?.apiKeys?.length && selectedOrg?.apiKeys[0] ? selectedOrg?.apiKeys[0].apiKey : ""; const updateMutation = api.organizations.update.useMutation(); const [onSaveName] = useHandledAsyncCallback(async () => { if (name && name !== selectedOrg?.name && selectedOrg?.id) { await updateMutation.mutateAsync({ id: selectedOrg.id, updates: { name }, }); await Promise.all([utils.organizations.get.invalidate({ id: selectedOrg.id })]); } }, [updateMutation, selectedOrg]); const [name, setName] = useState(selectedOrg?.name); useEffect(() => { setName(selectedOrg?.name); }, [selectedOrg?.name]); const deleteProjectOpen = useDisclosure(); return ( <> Project Settings Project Settings Configure your project settings. These settings only apply to {selectedOrg?.name}. Display Name setName(e.target.value)} borderColor="gray.300" /> Project API Key Use your project API key to authenticate your requests when sending data to OpenPipe. You can set this key in your environment variables, or use it directly in your code. {selectedOrg?.personalOrgUserId ? ( Personal Project This project is {selectedOrg?.personalOrgUser?.name}'s personal project. It cannot be deleted. ) : ( Danger Zone Permanently delete your project and all of its data. This action cannot be undone. Delete {selectedOrg?.name} )} ); } const Subtitle = (props: TextProps) => ;