import React, { useState } from "react"; import { useRouter } from "next/router"; import useSWR from "swr"; // layouts import { AppLayout } from "layouts/app-layout"; import { WorkspaceSettingLayout } from "layouts/settings-layout"; // component import { WorkspaceSettingHeader } from "components/headers"; import { ApiTokenEmptyState, ApiTokenListItem, CreateApiTokenModal } from "components/api-token"; // ui import { Button, Spinner } from "@plane/ui"; // services import { APITokenService } from "services/api_token.service"; // types import { NextPageWithLayout } from "types/app"; // constants import { API_TOKENS_LIST } from "constants/fetch-keys"; import { observer } from "mobx-react-lite"; import { useMobxStore } from "lib/mobx/store-provider"; const apiTokenService = new APITokenService(); const ApiTokensPage: NextPageWithLayout = observer(() => { // states const [isCreateTokenModalOpen, setIsCreateTokenModalOpen] = useState(false); // router const router = useRouter(); const { workspaceSlug } = router.query; // mobx store const { user: { currentWorkspaceRole }, } = useMobxStore(); const isAdmin = currentWorkspaceRole === 20; const { data: tokens } = useSWR(workspaceSlug && isAdmin ? API_TOKENS_LIST(workspaceSlug.toString()) : null, () => workspaceSlug && isAdmin ? apiTokenService.getApiTokens(workspaceSlug.toString()) : null ); if (!isAdmin) return (
You are not authorized to access this page.