import { useState } from "react"; import { TApiKeys } from "@calcom/ee/api-keys/components/ApiKeyListItem"; import LicenseRequired from "@calcom/ee/common/components/v2/LicenseRequired"; import ApiKeyDialogForm from "@calcom/features/ee/api-keys/components/v2/ApiKeyDialogForm"; import ApiKeyListItem from "@calcom/features/ee/api-keys/components/v2/ApiKeyListItem"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import { trpc } from "@calcom/trpc/react"; import { Icon } from "@calcom/ui"; import SkeletonLoader from "@calcom/ui/apps/SkeletonLoader"; import { EmptyScreen, Button } from "@calcom/ui/v2"; import { Dialog, DialogContent } from "@calcom/ui/v2/core/Dialog"; import Meta from "@calcom/ui/v2/core/Meta"; import { getLayout } from "@calcom/ui/v2/core/layouts/SettingsLayout"; const ApiKeysView = () => { const { t } = useLocale(); const { data, isLoading } = trpc.useQuery(["viewer.apiKeys.list"]); const [apiKeyModal, setApiKeyModal] = useState(false); const [apiKeyToEdit, setApiKeyToEdit] = useState<(TApiKeys & { neverExpires?: boolean }) | undefined>( undefined ); const NewApiKeyButton = () => { return ( { setApiKeyToEdit(undefined); setApiKeyModal(true); }}> {t("new_api_key")} ); }; return ( <> <> {isLoading && } {data?.length ? ( <> {data?.map((apiKey, index) => ( { setApiKeyToEdit(apiKey); setApiKeyModal(true); }} /> ))} > ) : ( } /> )} > setApiKeyModal(false)} defaultValues={apiKeyToEdit} /> > ); }; ApiKeysView.getLayout = getLayout; export default ApiKeysView;