import { FC, useEffect } from "react"; import { useRouter } from "next/router"; import useSWR from "swr"; // react-hook-form import { UseFormSetValue } from "react-hook-form"; // services import { GithubIntegrationService } from "services/integrations"; // ui import { Button, Loader } from "@plane/ui"; // types import { IUserDetails, TFormValues, TIntegrationSteps } from "components/integration"; // fetch-keys import { GITHUB_REPOSITORY_INFO } from "constants/fetch-keys"; type Props = { selectedRepo: any; handleStepChange: (value: TIntegrationSteps) => void; setUsers: React.Dispatch>; setValue: UseFormSetValue; }; // services const githubIntegrationService = new GithubIntegrationService(); export const GithubRepoDetails: FC = ({ selectedRepo, handleStepChange, setUsers, setValue }) => { const router = useRouter(); const { workspaceSlug } = router.query; const { data: repoInfo } = useSWR( workspaceSlug && selectedRepo ? GITHUB_REPOSITORY_INFO(workspaceSlug as string, selectedRepo.name) : null, workspaceSlug && selectedRepo ? () => githubIntegrationService.getGithubRepoInfo(workspaceSlug as string, { owner: selectedRepo.owner.login, repo: selectedRepo.name, }) : null ); useEffect(() => { if (!repoInfo) return; setValue("collaborators", repoInfo.collaborators); const fetchedUsers = repoInfo.collaborators.map((collaborator) => ({ username: collaborator.login, import: "map", email: "", })); setUsers(fetchedUsers); }, [repoInfo, setUsers, setValue]); return (
{repoInfo ? ( repoInfo.issue_count > 0 ? (
Repository Details
Import completed. We have found:

{repoInfo.issue_count}

Issues

{repoInfo.labels}

Labels

{repoInfo.collaborators.length}

Users
) : (
We didn{"'"}t find any issue in this repository.
) ) : ( )}
); };