"use client"; import { useEffect, useState } from "react"; import type { TApiKeys } from "@calcom/ee/api-keys/components/ApiKeyListItem"; import LicenseRequired from "@calcom/ee/common/components/LicenseRequired"; import ApiKeyDialogForm from "@calcom/features/ee/api-keys/components/ApiKeyDialogForm"; import ApiKeyListItem from "@calcom/features/ee/api-keys/components/ApiKeyListItem"; import { APP_NAME } from "@calcom/lib/constants"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import { trpc } from "@calcom/trpc/react"; import { Button, Dialog, DialogContent, EmptyScreen, SkeletonContainer, SkeletonText } from "@calcom/ui"; const SkeletonLoader = ({ title, description }: { title: string; description: string }) => { return ( ); }; export const apiKeyModalRef = { current: null as null | ((show: boolean) => void), }; export const apiKeyToEditRef = { current: null as null | ((apiKey: (TApiKeys & { neverExpires?: boolean }) | undefined) => void), }; export const NewApiKeyButton = () => { const { t } = useLocale(); return ( { apiKeyModalRef.current?.(true); apiKeyToEditRef.current?.(undefined); }}> {t("add")} ); }; const ApiKeysView = () => { const { t } = useLocale(); const { data, isPending } = trpc.viewer.apiKeys.list.useQuery(); const [apiKeyModal, setApiKeyModal] = useState(false); const [apiKeyToEdit, setApiKeyToEdit] = useState<(TApiKeys & { neverExpires?: boolean }) | undefined>( undefined ); useEffect(() => { apiKeyModalRef.current = setApiKeyModal; apiKeyToEditRef.current = setApiKeyToEdit; return () => { apiKeyModalRef.current = null; apiKeyToEditRef.current = null; }; }, []); if (isPending || !data) { return ( ); } return ( <> {data?.length ? ( <> {data.map((apiKey, index) => ( { setApiKeyToEdit(apiKey); setApiKeyModal(true); }} /> ))} > ) : ( } /> )} setApiKeyModal(false)} defaultValues={apiKeyToEdit} /> > ); }; export default ApiKeysView;